wicked-studio 0.16.13 → 0.16.15

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.
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="wicked-editor" content="wicked-doc">
6
- <meta name="wicked-editor-version" content="0.16.13">
6
+ <meta name="wicked-editor-version" content="0.16.15">
7
7
  <title>Document</title>
8
8
  <style>
9
9
  /* The plugin's own chrome takes the host's tokens (`host.hello.theme` / `host.theme`), with plain
@@ -45,7 +45,7 @@
45
45
  </style>
46
46
  </head>
47
47
  <body data-size="pane">
48
- <script>var kn=Object.defineProperty;var xn=(X,P,J)=>P in X?kn(X,P,{enumerable:!0,configurable:!0,writable:!0,value:J}):X[P]=J;var vt=(X,P,J)=>xn(X,typeof P!="symbol"?P+"":P,J);(function(){"use strict";const X=/^slide-(\d+)-([a-z-]+)-(\d+)$/,P=/^section-(\d+)$/,J={heading:"heading",paragraph:"paragraph","list-item":"list item",quote:"quote",caption:"caption",cell:"table cell",link:"link",button:"button",image:"image",block:"block",text:"line"},bt=/^[A-Za-z]{2,}(?:[-_ ][A-Za-z]{2,})*$/;function ne(e,n){const r=X.exec(e);if(r!==null){const i=Number(r[1]),l=J[r[2]??""]??(r[2]??"").replace(/-+/g," "),a=Number(r[3]);return n==="deck"?`slide ${i+1}’s ${l==="heading"&&a===1?"title":`${l} ${a}`}`:i===0?`${l} ${a}`:`${l} ${a} in section ${i+1}`}const s=P.exec(e);return s!==null?n==="deck"?`slide ${Number(s[1])+1}`:`section ${Number(s[1])+1}`:bt.test(e)?`the ${e.replace(/[-_]+/g," ").toLowerCase()}`:"this part"}function wt(e,n){const r=Object.entries(n).filter(([,s])=>!s.composite&&s.text!=="");return e.map(s=>{const i=s.reqId.trim();if(i==="")return{...s,wid:null};const l=r.find(([,a])=>kt(a.text,i));return{...s,wid:l===void 0?null:l[0]}})}const Xe=/[A-Za-z0-9_-]/,Ye=/[A-Za-z0-9]/;function kt(e,n){const r=e.toLowerCase(),s=n.toLowerCase();if(s==="")return!1;for(let i=r.indexOf(s);i!==-1;i=r.indexOf(s,i+1)){const l=r.charAt(i-1),a=r.charAt(i+s.length),u=Xe.test(l)||l==="."&&Ye.test(r.charAt(i-2)),w=Xe.test(a)||a==="."&&Ye.test(r.charAt(i+s.length+1));if(!u&&!w)return!0}return!1}function xt(e,n){const r=e.filter(i=>i.wid!==null).length,s=n>e.length?` (the first ${e.length} of ${n})`:"";return`${r} of ${e.length} named in this document${s}`}const At={"Alt+J":{verb:"navigate",what:"next card or row"},"Alt+K":{verb:"navigate",what:"previous card or row"},"Alt+/":{verb:"navigate",what:"the keyboard shortcuts overlay"},"Alt+P":{verb:"navigate",what:"peek at the top item that needs you"},"Alt+G":{verb:"navigate",what:"jump to the top item that needs you"},"Alt+B":{verb:"navigate",what:"back to where you were"},"Alt+T":{verb:"navigate",what:"the run’s evidence timeline"},"Alt+U":{verb:"navigate",what:"the run’s unit list"},"Alt+A":{verb:"approve",what:"approve the open gate"},"Alt+R":{verb:"decide",what:"reject the open gate"},"Alt+X":{verb:"decide",what:"select a gate for batch resolution"},"Alt+N":{verb:"compose",what:"compose a steer note"}},Et=new Set(["Escape","Mod+K","Tab","Shift+Tab"]);function He(e){if(Et.has(e))return!0;const n=At[Ct(e)];return n!==void 0&&n.verb==="navigate"}function Ct(e){const n=/^alt\+(.)$/i.exec(e);return n===null?e:`Alt+${n[1].toUpperCase()}`}function $t(e,n,r){return{left:e.left-(r.scrollX-n.scrollX),top:e.top-(r.scrollY-n.scrollY),width:e.width,height:e.height}}const St=/^[A-Za-z0-9_.:-]{1,100}$/;function _(e){return typeof e=="number"&&isFinite(e)}function Tt(e){if(typeof e!="object"||e===null)return!1;const n=e;return n.section!==void 0&&(typeof n.section!="string"||!St.test(n.section))?!1:typeof n.text=="string"&&typeof n.composite=="boolean"}function Ot(e){if(typeof e!="object"||e===null)return!1;const n=e;return _(n.x)&&_(n.y)&&_(n.width)&&_(n.height)&&_(n.top)&&_(n.left)&&_(n.right)&&_(n.bottom)}function Lt(e){if(typeof e!="object"||e===null)return null;const n=e;if(n.v!==1)return null;const r=n.type;if(r==="wid-inventory"){const s=n.widMap,i=n.scrollX,l=n.scrollY;if(typeof s!="object"||s===null||!_(i)||!_(l))return null;const a={};for(const[C,v]of Object.entries(s)){if(!Ot(v))return null;a[C]=v}const u=n.blocks;if(u===void 0)return{v:1,type:"wid-inventory",widMap:a,scrollX:i,scrollY:l};if(typeof u!="object"||u===null)return null;const w={};for(const[C,v]of Object.entries(u)){if(!Tt(v))return null;w[C]={text:v.text,composite:v.composite,...v.cut===!0?{cut:!0}:{},...v.section!==void 0?{section:v.section}:{}}}return{v:1,type:"wid-inventory",widMap:a,scrollX:i,scrollY:l,blocks:w}}if(r==="scroll-state"){const s=n.scrollX,i=n.scrollY;return!_(s)||!_(i)?null:{v:1,type:"scroll-state",scrollX:s,scrollY:i}}if(r==="scroll-ack"){const s=n.wid;if(typeof s!="string"||s==="")return null;const i=n.scrollX,l=n.scrollY,a=n.seq;return{v:1,type:"scroll-ack",wid:s,..._(i)&&_(l)?{scrollX:i,scrollY:l}:{},...typeof a=="number"&&Number.isInteger(a)&&a>0?{seq:a}:{}}}if(r==="wid-click"){const s=n.wid;return typeof s!="string"||s===""?null:{v:1,type:"wid-click",wid:s}}if(r==="wid-hover"){const s=n.wid;return s!==null&&(typeof s!="string"||s==="")?null:{v:1,type:"wid-hover",wid:s}}return null}const Rt=Object.freeze({v:1,type:"request-inventory"});function Mt(e,n){return n===void 0?{v:1,type:"scroll-to-wid",wid:e}:{v:1,type:"scroll-to-wid",wid:e,seq:n}}const Ft="request-inventory";function _t(e){return e.includes(Ft)}const jt=`
48
+ <script>var En=Object.defineProperty;var Cn=(X,K,J)=>K in X?En(X,K,{enumerable:!0,configurable:!0,writable:!0,value:J}):X[K]=J;var vt=(X,K,J)=>Cn(X,typeof K!="symbol"?K+"":K,J);(function(){"use strict";const X=/^slide-(\d+)-([a-z-]+)-(\d+)$/,K=/^section-(\d+)$/,J={heading:"heading",paragraph:"paragraph","list-item":"list item",quote:"quote",caption:"caption",cell:"table cell",link:"link",button:"button",image:"image",block:"block",text:"line"},wt=/^[A-Za-z]{2,}(?:[-_ ][A-Za-z]{2,})*$/;function ne(e,n){const r=X.exec(e);if(r!==null){const i=Number(r[1]),l=J[r[2]??""]??(r[2]??"").replace(/-+/g," "),a=Number(r[3]);return n==="deck"?`slide ${i+1}’s ${l==="heading"&&a===1?"title":`${l} ${a}`}`:i===0?`${l} ${a}`:`${l} ${a} in section ${i+1}`}const s=K.exec(e);return s!==null?n==="deck"?`slide ${Number(s[1])+1}`:`section ${Number(s[1])+1}`:wt.test(e)?`the ${e.replace(/[-_]+/g," ").toLowerCase()}`:"this part"}function kt(e,n){const r=Object.entries(n).filter(([,s])=>!s.composite&&s.text!=="");return e.map(s=>{const i=s.reqId.trim();if(i==="")return{...s,wid:null};const l=r.find(([,a])=>xt(a.text,i));return{...s,wid:l===void 0?null:l[0]}})}const Xe=/[A-Za-z0-9_-]/,Ye=/[A-Za-z0-9]/;function xt(e,n){const r=e.toLowerCase(),s=n.toLowerCase();if(s==="")return!1;for(let i=r.indexOf(s);i!==-1;i=r.indexOf(s,i+1)){const l=r.charAt(i-1),a=r.charAt(i+s.length),u=Xe.test(l)||l==="."&&Ye.test(r.charAt(i-2)),w=Xe.test(a)||a==="."&&Ye.test(r.charAt(i+s.length+1));if(!u&&!w)return!0}return!1}function At(e,n){const r=e.filter(i=>i.wid!==null).length,s=n>e.length?` (the first ${e.length} of ${n})`:"";return`${r} of ${e.length} named in this document${s}`}const Et={"Alt+J":{verb:"navigate",what:"next card or row"},"Alt+K":{verb:"navigate",what:"previous card or row"},"Alt+/":{verb:"navigate",what:"the keyboard shortcuts overlay"},"Alt+P":{verb:"navigate",what:"peek at the top item that needs you"},"Alt+G":{verb:"navigate",what:"jump to the top item that needs you"},"Alt+B":{verb:"navigate",what:"back to where you were"},"Alt+T":{verb:"navigate",what:"the run’s evidence timeline"},"Alt+U":{verb:"navigate",what:"the run’s unit list"},"Alt+A":{verb:"approve",what:"approve the open gate"},"Alt+R":{verb:"decide",what:"reject the open gate"},"Alt+X":{verb:"decide",what:"select a gate for batch resolution"},"Alt+N":{verb:"compose",what:"compose a steer note"}},Ct=new Set(["Escape","Mod+K","Tab","Shift+Tab"]);function He(e){if(Ct.has(e))return!0;const n=Et[St(e)];return n!==void 0&&n.verb==="navigate"}function St(e){const n=/^alt\+(.)$/i.exec(e);return n===null?e:`Alt+${n[1].toUpperCase()}`}function $t(e){if(e===""||/[\u0000-\u001f\u007f]/.test(e))return!1;const n=Intl.Segmenter;return n!==void 0?Array.from(new n(void 0,{granularity:"grapheme"}).segment(e)).length===1:Array.from(e).length===1}function Tt(e,n,r){return{left:e.left-(r.scrollX-n.scrollX),top:e.top-(r.scrollY-n.scrollY),width:e.width,height:e.height}}const Ot=/^[A-Za-z0-9_.:-]{1,100}$/;function _(e){return typeof e=="number"&&isFinite(e)}function Lt(e){if(typeof e!="object"||e===null)return!1;const n=e;return n.section!==void 0&&(typeof n.section!="string"||!Ot.test(n.section))?!1:typeof n.text=="string"&&typeof n.composite=="boolean"}function Rt(e){if(typeof e!="object"||e===null)return!1;const n=e;return _(n.x)&&_(n.y)&&_(n.width)&&_(n.height)&&_(n.top)&&_(n.left)&&_(n.right)&&_(n.bottom)}function Mt(e){if(typeof e!="object"||e===null)return null;const n=e;if(n.v!==1)return null;const r=n.type;if(r==="wid-inventory"){const s=n.widMap,i=n.scrollX,l=n.scrollY;if(typeof s!="object"||s===null||!_(i)||!_(l))return null;const a={};for(const[C,b]of Object.entries(s)){if(!Rt(b))return null;a[C]=b}const u=n.blocks;if(u===void 0)return{v:1,type:"wid-inventory",widMap:a,scrollX:i,scrollY:l};if(typeof u!="object"||u===null)return null;const w={};for(const[C,b]of Object.entries(u)){if(!Lt(b))return null;w[C]={text:b.text,composite:b.composite,...b.cut===!0?{cut:!0}:{},...b.section!==void 0?{section:b.section}:{}}}return{v:1,type:"wid-inventory",widMap:a,scrollX:i,scrollY:l,blocks:w}}if(r==="scroll-state"){const s=n.scrollX,i=n.scrollY;return!_(s)||!_(i)?null:{v:1,type:"scroll-state",scrollX:s,scrollY:i}}if(r==="scroll-ack"){const s=n.wid;if(typeof s!="string"||s==="")return null;const i=n.scrollX,l=n.scrollY,a=n.seq;return{v:1,type:"scroll-ack",wid:s,..._(i)&&_(l)?{scrollX:i,scrollY:l}:{},...typeof a=="number"&&Number.isInteger(a)&&a>0?{seq:a}:{}}}if(r==="wid-click"){const s=n.wid;return typeof s!="string"||s===""?null:{v:1,type:"wid-click",wid:s}}if(r==="wid-hover"){const s=n.wid;return s!==null&&(typeof s!="string"||s==="")?null:{v:1,type:"wid-hover",wid:s}}return null}const Ft=Object.freeze({v:1,type:"request-inventory"});function _t(e,n){return n===void 0?{v:1,type:"scroll-to-wid",wid:e}:{v:1,type:"scroll-to-wid",wid:e,seq:n}}const jt="request-inventory";function Dt(e){return e.includes(jt)}const Bt=`
49
49
  (function () {
50
50
  if (window.__wickedInstrumentBridge) return;
51
51
  window.__wickedInstrumentBridge = 1;
@@ -123,22 +123,22 @@
123
123
  post(inventory());
124
124
  }
125
125
  })();
126
- `;function Bt(e){const n=`<script>${jt}<\/script>`;return/<\/body>/i.test(e)?e.replace(/<\/body>/i,()=>`${n}</body>`):`${e}${n}`}const V=String.raw`\s*-?(?:\d+(?:\.\d+)?|\.\d+)%?\s*`,Dt=new RegExp(`^(?:#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\\((?:${V},){2}${V}(?:,${V})?\\)|hsla?\\(\\s*-?\\d+(?:\\.\\d+)?(?:deg)?\\s*,${V},${V}(?:,${V})?\\)|var\\(--wi-[a-z0-9-]{1,40}\\)|revert-layer)$`,"i");function Nt(e,n=new Set){if(!Dt.test(e))return!1;const r=/^var\((--wi-[a-z0-9-]+)\)$/i.exec(e);return r===null||n.has(r[1].toLowerCase())}const qt=[["--wi-bg","Background"],["--wi-surface","Surface"],["--wi-card-bg","Card"],["--wi-primary","Primary"],["--wi-secondary","Secondary"],["--wi-accent","Accent"],["--wi-text","Text"],["--wi-text-secondary","Secondary text"],["--wi-muted","Muted"],["--wi-border","Border"]],Ce="revert-layer";function It(e){const n=new Map;for(const i of e.matchAll(/(--wi-[a-z-]{1,40})\s*:\s*([^;}{]{1,80})/gi))n.set(i[1].toLowerCase(),i[2].trim());const r=new Set,s=[];for(const[i,l]of qt){const a=n.get(i);if(a===void 0)continue;const u=a.startsWith("#")?a.toLowerCase():a;!Nt(u)||r.has(u.toLowerCase())||(r.add(u.toLowerCase()),s.push({token:i,value:u,label:l}))}return s}const oe="wicked.editor",re=1,Je=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),zt=["card","options","full"];function Pt(e){return e==="inline"?"card":e==="pane"?"options":"full"}function Kt(e){return e==="card"?"inline":e==="options"?"pane":"full"}function Ut(e){const n=Je(e)?e:{},r=n.size==="inline"||n.size==="full"?n.size:"pane",s=n.protocol===2?2:1,i=s===2&&typeof n.tab=="string"?n.tab:null,l=s===2&&zt.includes(n.surface)?n.surface:Pt(r),a=l==="options"&&i===null?"full":l,u=s===2&&(n.mode==="simple"||n.mode==="advanced")?n.mode:null;return{protocol:s,surface:a,tab:i,mode:u,size:r}}function Wt(e,n,r){return{editor:e,version:n,protocol:[1,2],surfaces:r}}function Xt(e,n){const r=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:oe,v:re,type:"plugin.ready",payload:Wt(e,r,n)},"*")}function Yt(e,n,r){const s=e.metaKey||e.ctrlKey;let i=null;if(e.key==="Escape")i="Escape";else if(s&&!e.altKey&&e.key.toLowerCase()==="k")i="Mod+K";else if(e.altKey&&!s&&/^Key[A-Z]$/.test(e.code)&&He(`Alt+${e.code.slice(3)}`))i=`Alt+${e.code.slice(3)}`;else if(e.key==="Tab"){const l=Array.from(n.querySelectorAll("button, input, select, textarea, [tabindex]")).filter(u=>u.tabIndex>=0&&!u.matches(":disabled")&&u.closest("[hidden]")===null),a=l.indexOf(e.target);(e.shiftKey?a<=0:a===-1||a===l.length-1)&&(i=e.shiftKey?"Shift+Tab":"Tab")}return i===null?!1:(e.preventDefault(),e.stopPropagation(),r(i),!0)}class Ht{constructor(n,r){vt(this,"revs",new Map);this.port=n,this.h=r}reply(n,r){this.port.postMessage({p:oe,v:re,re:n,ok:!0,payload:r})}refuse(n,r,s){this.port.postMessage({p:oe,v:re,re:n,ok:!1,error:{code:r,message:s}})}bump(n){const r=(this.revs.get(n)??0)+1;return this.revs.set(n,r),r}values(n,r){this.port.postMessage({p:oe,v:re,type:"options.values",payload:{tab:n,rev:this.bump(n),values:r}})}height(n){this.port.postMessage({p:oe,v:re,type:"ui.height",payload:{px:Math.round(n)}})}dispatch(n){const r=Je(n.payload)?n.payload:{},s=typeof n.id=="string"?n.id:null;switch(n.type){case"host.surface":{const i=r.surface;return(i==="card"||i==="options"||i==="full")&&this.h.surface?.(i,r.mode==="simple"||r.mode==="advanced"?r.mode:null),!0}case"host.mode":{if(s===null)return!0;const i=r.mode;return i!=="simple"&&i!=="advanced"?(this.refuse(s,"bad_request","mode is simple or advanced"),!0):(this.reply(s,{mode:this.h.mode?.(i)??i}),!0)}case"host.action":{if(s===null)return!0;const i=r.id;return typeof i!="string"||this.h.action===void 0?(this.reply(s,{handled:!1}),!0):(Promise.resolve(this.h.action(i)).then(l=>this.reply(s,{handled:l.handled===!0,...typeof l.status=="string"?{status:l.status.slice(0,120)}:{}}),()=>this.reply(s,{handled:!1})),!0)}case"host.tab":return typeof r.tab=="string"&&this.h.tab?.(r.tab),!0;case"host.selection":return Array.isArray(r.anchors)&&this.h.selection?.(r.anchors),!0;case"options.changed":{if(s===null)return!0;const i=r.tab,l=r.id;return typeof i!="string"||typeof l!="string"||this.h.optionsChanged===void 0?(this.refuse(s,"unsupported","no controls here"),!0):(Promise.resolve(this.h.optionsChanged(i,l,r.value)).then(a=>this.reply(s,{applied:a.applied,rev:this.bump(i),values:a.values,...a.reason!==void 0?{reason:a.reason.slice(0,120)}:{}}),a=>this.refuse(s,"unavailable",a instanceof Error?a.message.slice(0,120):"failed")),!0)}default:return!1}}}const ue=[{name:"corporate-light",display_name:"Corporate Light",colors:{background:"#FFFFFF",surface:"#F8FAFC",primary:"#1E3A5F",secondary:"#2563EB",accent:"#0891B2",text_primary:"#1E293B",text_secondary:"#64748B",text_muted:"#94A3B8",border:"#E2E8F0"},fonts:{heading:"Calibri",body:"Calibri",mono:"Consolas"}},{name:"midnight-purple",display_name:"Midnight Purple",colors:{background:"#0A0A0F",surface:"#13091D",primary:"#A100FF",secondary:"#6B2FA0",accent:"#F59E0B",text_primary:"#FFFFFF",text_secondary:"#A0A0B0",text_muted:"#6B6B80",border:"#2A2A3D"},fonts:{heading:"Calibri",body:"Calibri",mono:"Consolas"}},{name:"warm-dark",display_name:"Warm Dark",colors:{background:"#1A1A2E",surface:"#16213E",primary:"#FF6B6B",secondary:"#C44569",accent:"#FFD93D",text_primary:"#F8F8F2",text_secondary:"#B0B0C0",text_muted:"#6B6B80",border:"#2D2D44"},fonts:{heading:"Calibri",body:"Calibri",mono:"Consolas"}}],Ve=["Inter","Roboto","Source Sans 3","IBM Plex Sans","Calibri","Georgia","system-ui"],Jt=[["background","Background"],["surface","Surface"],["primary","Primary"],["accent","Accent"],["text_primary","Text"]],$e=e=>({name:e.name,colors:{...e.colors},fonts:{...e.fonts}});function Vt(e,n){e.replaceChildren(),e.classList.add("plugin-style"),e.onkeydown=g=>{n.key!==void 0&&Yt(g,e,n.key)};const r=document.createElement("style");r.textContent=`.plugin-style{padding:16px;box-sizing:border-box;color:var(--ink-high);background:var(--surface-base);font:13px var(--font-sans,system-ui)}
126
+ `;function Nt(e){const n=`<script>${Bt}<\/script>`;return/<\/body>/i.test(e)?e.replace(/<\/body>/i,()=>`${n}</body>`):`${e}${n}`}const V=String.raw`\s*-?(?:\d+(?:\.\d+)?|\.\d+)%?\s*`,qt=new RegExp(`^(?:#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\\((?:${V},){2}${V}(?:,${V})?\\)|hsla?\\(\\s*-?\\d+(?:\\.\\d+)?(?:deg)?\\s*,${V},${V}(?:,${V})?\\)|var\\(--wi-[a-z0-9-]{1,40}\\)|revert-layer)$`,"i");function It(e,n=new Set){if(!qt.test(e))return!1;const r=/^var\((--wi-[a-z0-9-]+)\)$/i.exec(e);return r===null||n.has(r[1].toLowerCase())}const Pt=[["--wi-bg","Background"],["--wi-surface","Surface"],["--wi-card-bg","Card"],["--wi-primary","Primary"],["--wi-secondary","Secondary"],["--wi-accent","Accent"],["--wi-text","Text"],["--wi-text-secondary","Secondary text"],["--wi-muted","Muted"],["--wi-border","Border"]],Ce="revert-layer";function zt(e){const n=new Map;for(const i of e.matchAll(/(--wi-[a-z-]{1,40})\s*:\s*([^;}{]{1,80})/gi))n.set(i[1].toLowerCase(),i[2].trim());const r=new Set,s=[];for(const[i,l]of Pt){const a=n.get(i);if(a===void 0)continue;const u=a.startsWith("#")?a.toLowerCase():a;!It(u)||r.has(u.toLowerCase())||(r.add(u.toLowerCase()),s.push({token:i,value:u,label:l}))}return s}const oe="wicked.editor",re=1,Je=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Kt=["card","options","full"];function Ut(e){return e==="inline"?"card":e==="pane"?"options":"full"}function Wt(e){return e==="card"?"inline":e==="options"?"pane":"full"}function Xt(e){const n=Je(e)?e:{},r=n.size==="inline"||n.size==="full"?n.size:"pane",s=n.protocol===2?2:1,i=s===2&&typeof n.tab=="string"?n.tab:null,l=s===2&&Kt.includes(n.surface)?n.surface:Ut(r),a=l==="options"&&i===null?"full":l,u=s===2&&(n.mode==="simple"||n.mode==="advanced")?n.mode:null;return{protocol:s,surface:a,tab:i,mode:u,size:r}}function Yt(e,n,r){return{editor:e,version:n,protocol:[1,2],surfaces:r}}function Ht(e,n){const r=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:oe,v:re,type:"plugin.ready",payload:Yt(e,r,n)},"*")}function Ve(e){return Array.from(e.querySelectorAll("button, a[href], input, select, textarea, summary, [tabindex]")).filter(n=>n.tabIndex>=0&&!n.matches(":disabled")&&n.closest("[hidden]")===null)}function Jt(e,n,r){const s=e.metaKey||e.ctrlKey;let i=null;if(e.key==="Escape")i="Escape";else if(s&&!e.altKey&&e.key.toLowerCase()==="k")i="Mod+K";else if(e.altKey&&!s&&/^Key[A-Z]$/.test(e.code)&&He(`Alt+${e.code.slice(3)}`))i=`Alt+${e.code.slice(3)}`;else if(e.key==="Tab"){const l=Ve(n),a=l.indexOf(e.target);(e.shiftKey?a<=0:a===-1||a===l.length-1)&&(i=e.shiftKey?"Shift+Tab":"Tab")}return i===null?!1:(e.preventDefault(),e.stopPropagation(),r(i),!0)}function Vt(e,n,r){if(e.defaultPrevented)return!1;const s=e.target;if(e.key==="Tab"&&!(s instanceof HTMLElement&&Ve(n).includes(s)))return!1;if(Jt(e,n,l=>r("ui.key",{key:l})))return!0;if(e.metaKey||e.ctrlKey||e.altKey||!$t(e.key))return!1;const i=s?.closest("[contenteditable]");return s?.closest("input,textarea,select")||i&&i.getAttribute("contenteditable")!=="false"||e.key===" "&&s?.closest('button,summary,a[href],[role="button"],[tabindex]:not([tabindex="-1"])')?!1:(e.preventDefault(),e.stopPropagation(),r("ui.typed",{grapheme:e.key}),!0)}class Zt{constructor(n,r){vt(this,"revs",new Map);this.port=n,this.h=r}reply(n,r){this.port.postMessage({p:oe,v:re,re:n,ok:!0,payload:r})}refuse(n,r,s){this.port.postMessage({p:oe,v:re,re:n,ok:!1,error:{code:r,message:s}})}bump(n){const r=(this.revs.get(n)??0)+1;return this.revs.set(n,r),r}values(n,r){this.port.postMessage({p:oe,v:re,type:"options.values",payload:{tab:n,rev:this.bump(n),values:r}})}height(n){this.port.postMessage({p:oe,v:re,type:"ui.height",payload:{px:Math.round(n)}})}dispatch(n){const r=Je(n.payload)?n.payload:{},s=typeof n.id=="string"?n.id:null;switch(n.type){case"host.surface":{const i=r.surface;return(i==="card"||i==="options"||i==="full")&&this.h.surface?.(i,r.mode==="simple"||r.mode==="advanced"?r.mode:null),!0}case"host.mode":{if(s===null)return!0;const i=r.mode;return i!=="simple"&&i!=="advanced"?(this.refuse(s,"bad_request","mode is simple or advanced"),!0):(this.reply(s,{mode:this.h.mode?.(i)??i}),!0)}case"host.action":{if(s===null)return!0;const i=r.id;return typeof i!="string"||this.h.action===void 0?(this.reply(s,{handled:!1}),!0):(Promise.resolve(this.h.action(i)).then(l=>this.reply(s,{handled:l.handled===!0,...typeof l.status=="string"?{status:l.status.slice(0,120)}:{}}),()=>this.reply(s,{handled:!1})),!0)}case"host.tab":return typeof r.tab=="string"&&this.h.tab?.(r.tab),!0;case"host.selection":return Array.isArray(r.anchors)&&this.h.selection?.(r.anchors),!0;case"options.changed":{if(s===null)return!0;const i=r.tab,l=r.id;return typeof i!="string"||typeof l!="string"||this.h.optionsChanged===void 0?(this.refuse(s,"unsupported","no controls here"),!0):(Promise.resolve(this.h.optionsChanged(i,l,r.value)).then(a=>this.reply(s,{applied:a.applied,rev:this.bump(i),values:a.values,...a.reason!==void 0?{reason:a.reason.slice(0,120)}:{}}),a=>this.refuse(s,"unavailable",a instanceof Error?a.message.slice(0,120):"failed")),!0)}default:return!1}}}const ue=[{name:"corporate-light",display_name:"Corporate Light",colors:{background:"#FFFFFF",surface:"#F8FAFC",primary:"#1E3A5F",secondary:"#2563EB",accent:"#0891B2",text_primary:"#1E293B",text_secondary:"#64748B",text_muted:"#94A3B8",border:"#E2E8F0"},fonts:{heading:"Calibri",body:"Calibri",mono:"Consolas"}},{name:"midnight-purple",display_name:"Midnight Purple",colors:{background:"#0A0A0F",surface:"#13091D",primary:"#A100FF",secondary:"#6B2FA0",accent:"#F59E0B",text_primary:"#FFFFFF",text_secondary:"#A0A0B0",text_muted:"#6B6B80",border:"#2A2A3D"},fonts:{heading:"Calibri",body:"Calibri",mono:"Consolas"}},{name:"warm-dark",display_name:"Warm Dark",colors:{background:"#1A1A2E",surface:"#16213E",primary:"#FF6B6B",secondary:"#C44569",accent:"#FFD93D",text_primary:"#F8F8F2",text_secondary:"#B0B0C0",text_muted:"#6B6B80",border:"#2D2D44"},fonts:{heading:"Calibri",body:"Calibri",mono:"Consolas"}}],Ze=["Inter","Roboto","Source Sans 3","IBM Plex Sans","Calibri","Georgia","system-ui"],Gt=[["background","Background"],["surface","Surface"],["primary","Primary"],["accent","Accent"],["text_primary","Text"]],Se=e=>({name:e.name,colors:{...e.colors},fonts:{...e.fonts}});function Qt(e,n){e.replaceChildren(),e.classList.add("plugin-style"),e.tabIndex=-1,e.onkeydown=g=>{Vt(g,e,(m,k)=>{"key"in k?n.key?.(k.key):n.typed?.(k.grapheme)})};const r=document.createElement("style");r.textContent=`.plugin-style{padding:16px;box-sizing:border-box;color:var(--ink-high);background:var(--surface-base);font:13px var(--font-sans,system-ui)}
127
127
  .plugin-style h2{font-size:16px;margin:0 0 12px}.plugin-style .theme-cards{display:grid;gap:8px;margin-bottom:18px}
128
128
  .plugin-style button,.plugin-style input,.plugin-style select{font:inherit;color:var(--ink-high);background:var(--surface-card);border:1px solid var(--border);border-radius:4px}
129
129
  .plugin-style button{padding:8px;text-align:left;cursor:pointer}.plugin-style button:focus-visible,.plugin-style input:focus-visible,.plugin-style select:focus-visible{outline:2px solid var(--accent)}
130
130
  .plugin-style .ps-swatches{display:flex;width:100%;height:16px;margin-bottom:6px;border:1px solid var(--border)}.plugin-style .ps-swatches span{flex:1}
131
131
  .plugin-style label{display:flex;align-items:center;gap:8px;margin:10px 0}.plugin-style label>span:first-child{flex:1}.plugin-style input[type=color]{width:36px;height:30px;padding:2px}.plugin-style input[type=text]{width:80px;padding:5px}.plugin-style select{max-width:170px;padding:5px}
132
- .plugin-style p{line-height:1.5;color:var(--ink-body)}.plugin-style [role=status]{min-height:1.5em}.plugin-style :disabled{opacity:.6;cursor:default}`,e.append(r);const s=document.createElement("h2");s.textContent="Style",e.append(s);const i=document.createElement("div");i.className="theme-cards",e.append(i);const l=document.createElement("p");l.setAttribute("role","status"),l.setAttribute("aria-live","polite");let a=!1;const u=[],w=()=>$e(n.tokens()??ue[0]),C=[],v=[],A=()=>{const g=w();for(const{key:m,picker:x,hex:$}of C)$.value=g.colors[m],x.value=/^#[0-9a-f]{6}$/i.test(g.colors[m])?g.colors[m]:"";for(const{key:m,select:x}of v)x.value=Ve.includes(g.fonts[m])?g.fonts[m]:"system-ui";for(const m of Array.from(i.querySelectorAll("button")))m.setAttribute("aria-pressed",String(m.dataset.theme===g.name))},F=async g=>{if(!a){a=!0,u.forEach(m=>{m.disabled=!0}),l.textContent="Applying theme…";try{const m=await n.apply(g);l.textContent=m.ok?"Theme applied.":`Theme was not applied: ${m.reason}`}catch(m){l.textContent=`Theme was not applied: ${m instanceof Error?m.message:"unavailable"}`}finally{a=!1,u.forEach(m=>{m.disabled=!1}),A()}}};for(const g of ue){const m=document.createElement("button");m.type="button",m.dataset.theme=g.name;const x=document.createElement("span");x.className="ps-swatches",x.setAttribute("aria-hidden","true");for(const y of["background","surface","primary","secondary","accent"]){const k=document.createElement("span");k.style.backgroundColor=g.colors[y],x.append(k)}const $=document.createElement("span");$.textContent=g.display_name,m.append(x,$),m.addEventListener("click",()=>{F($e(g))}),i.append(m),u.push(m)}for(const[g,m]of Jt){const x=document.createElement("label"),$=document.createElement("span");$.textContent=m;const y=document.createElement("input");y.type="color",y.setAttribute("aria-label",m);const k=document.createElement("input");k.type="text",k.maxLength=7,k.setAttribute("aria-label",`${m} hex`);const L=Z=>{if(!/^#[0-9a-f]{6}$/i.test(Z)){l.textContent="Enter a six-digit hex colour: a # and six digits or letters a to f.",A();return}const D=w();D.name="custom",D.colors[g]=Z,F(D)};y.addEventListener("change",()=>L(y.value)),k.addEventListener("change",()=>L(k.value)),x.append($,y,k),e.append(x),u.push(y,k),C.push({key:g,picker:y,hex:k})}for(const g of["heading","body"]){const m=document.createElement("label"),x=document.createElement("span");x.textContent=g==="heading"?"Heading font":"Body font";const $=document.createElement("select");$.setAttribute("aria-label",x.textContent);for(const y of Ve){const k=document.createElement("option");k.value=y,k.textContent=y,$.append(k)}$.addEventListener("change",()=>{const y=w();y.name="custom",y.fonts[g]=$.value,F(y)}),m.append(x,$),e.append(m),u.push($),v.push({key:g,select:$})}const B=document.createElement("p");return B.textContent="Match a website or a PDF: the host's Match button under this tab",e.append(B,l),A(),{refresh:A}}function Zt(e){const n=new DOMParser().parseFromString(e,"text/html"),r=Array.from(n.querySelectorAll("style")).map(u=>u.textContent??"").join(`
133
- `),s=new Map;for(const u of r.matchAll(/(--wi-[a-z-]+)\s*:\s*([^;}{]+)/gi))s.set(u[1].toLowerCase(),u[2].trim());if(s.size===0)return null;const i=$e(ue[0]),l={background:"--wi-bg",surface:"--wi-surface",primary:"--wi-primary",secondary:"--wi-secondary",accent:"--wi-accent",text_primary:"--wi-text",text_secondary:"--wi-text-secondary",text_muted:"--wi-muted",border:"--wi-border"};for(const u of Object.keys(l)){const w=s.get(l[u]);w!==void 0&&/^(#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgb|hsl)a?\([0-9.,%\s]+\))$/i.test(w)&&(i.colors[u]=w)}for(const u of["heading","body","mono"]){const w=s.get(`--wi-font-${u}`);w!==void 0&&(i.fonts[u]=w.split(",")[0].trim().replace(/^['"]|['"]$/g,""))}const a=ue.find(u=>JSON.stringify(u.colors)===JSON.stringify(i.colors)&&JSON.stringify(u.fonts)===JSON.stringify(i.fonts));return i.name=a?.name??"custom",i}const Gt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),I=(e,n)=>e>>>n|e<<32-n;function Ze(e){const n=new TextEncoder().encode(e),r=n.length*8,s=new Uint8Array(Math.ceil((n.length+9)/64)*64);s.set(n),s[n.length]=128;const i=new DataView(s.buffer);i.setUint32(s.length-8,Math.floor(r/4294967296)),i.setUint32(s.length-4,r>>>0);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let C=0;C<s.length;C+=64){for(let y=0;y<16;y++)a[y]=i.getUint32(C+y*4);for(let y=16;y<64;y++){const k=I(a[y-15],7)^I(a[y-15],18)^a[y-15]>>>3,L=I(a[y-2],17)^I(a[y-2],19)^a[y-2]>>>10;a[y]=a[y-16]+k+a[y-7]+L>>>0}let[v,A,F,B,g,m,x,$]=[l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7]];for(let y=0;y<64;y++){const k=$+(I(g,6)^I(g,11)^I(g,25))+(g&m^~g&x)+Gt[y]+a[y]>>>0,L=(I(v,2)^I(v,13)^I(v,22))+(v&A^v&F^A&F)>>>0;$=x,x=m,m=g,g=B+k>>>0,B=F,F=A,A=v,v=k+L>>>0}l[0]=l[0]+v>>>0,l[1]=l[1]+A>>>0,l[2]=l[2]+F>>>0,l[3]=l[3]+B>>>0,l[4]=l[4]+g>>>0,l[5]=l[5]+m>>>0,l[6]=l[6]+x>>>0,l[7]=l[7]+$>>>0}const u=new DataView(new ArrayBuffer(32));l.forEach((C,v)=>u.setUint32(v*4,C));let w="";for(let C=0;C<32;C++)w+=String.fromCharCode(u.getUint8(C));return btoa(w)}const Ge="WebRTC is not available in an editor frame",Qt=["RTCPeerConnection","webkitRTCPeerConnection","mozRTCPeerConnection","RTCDataChannel","RTCIceTransport","RTCDtlsTransport","RTCSctpTransport","RTCRtpSender","RTCRtpReceiver","RTCRtpTransceiver","RTCIceCandidate","RTCSessionDescription","RTCCertificate"],Se='(function(w,o){if(typeof w!=="object"||w===null||w.window!==w)throw '+JSON.stringify(Ge)+";var n="+JSON.stringify(Qt)+",k=o.getOwnPropertyNames(w),i,d;for(i=0;i!==k.length;i++)if(/^(webkit|moz)?RTC/.test(k[i])&&(d=o.getOwnPropertyDescriptor(w,k[i]))&&d.configurable)n.push(k[i]);for(i=0;i!==n.length;i++){o.defineProperty(w,n[i],{value:void 0,writable:false,configurable:false});if(w[n[i]]!==void 0)throw "+JSON.stringify(Ge)+`}})(window,({}).constructor);
134
- `,se=/[\n\r\u2028\u2029]/,Qe=/\s/,et=/[\w$\\\u0080-\uFFFF]/;function en(e,n){if(n>=e.length)return!0;const r=e[n];if(r==='"'||r==="'"||r==="{"||r==="~"||/[0-9]/.test(r))return!0;if(r==="!")return e[n+1]!=="=";if(r===".")return/[0-9]/.test(e[n+1]??"");if(r==="\\")return!0;if(r==="+"||r==="-")return e[n+1]===r;if(!et.test(r))return!1;let s=n;for(;s<e.length&&et.test(e[s])&&!Qe.test(e[s]);)s++;const i=e.slice(n,s);return i!=="in"&&i!=="instanceof"}function tn(e){const n=e.length;let r=0,s=0,i=!1,l=!1;if(e.startsWith("#!")){for(;r<n&&!se.test(e[r]);)r++;s=r,i=!0}let a=!1,u=!0,w=!0;const C=()=>{for(;;){for(;r<n&&Qe.test(e[r]);)se.test(e[r])&&(a=!0,u=!0),r++;if(w&&u&&e.startsWith("-->",r)){for(;r<n&&!se.test(e[r]);)r++;continue}if(e.startsWith("/*",r)){const v=e.indexOf("*/",r+2);if(v<0)return!1;se.test(e.slice(r,v))&&(a=!0,u=!0),r=v+2}else if(e.startsWith("//",r)||w&&e.startsWith("<!--",r))for(;r<n&&!se.test(e[r]);)r++;else return!0}};for(;C();){const v=e[r];if(v!=='"'&&v!=="'")break;w=!1;let A=r+1,F=!1;for(;A<n;){const g=e[A];if(g==="\\"){A+=2;continue}if(g===v){F=!0,A+=1;break}if(g===`
135
- `||g==="\r")break;A+=1}if(!F)break;u=!1;const B=A;if(r=A,a=!1,!C())break;if(e[r]===";")r+=1,u=!1,s=r,l=!1;else if(e.startsWith("<!--",r)){s=B,l=!0,i=!1;break}else if((a||r>=n)&&en(e,r))s=B,l=!0;else break;i=!1}return{at:s,afterHashbang:i,semicolon:l}}function nn(e){const{at:n,afterHashbang:r,semicolon:s}=tn(e);return e.slice(0,n)+(s?";":"")+(r?`
136
- `:"")+Se+e.slice(n)}const on=new Set(["application/ecmascript","application/javascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript"]),tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml";function rn(e){if(e.namespaceURI===tt?e.hasAttribute("href")||e.hasAttribute("xlink:href"):e.hasAttribute("src"))return!1;const n=e.namespaceURI===tt?null:e.getAttribute("language"),r=e.hasAttribute("type")?e.getAttribute("type"):n!==null&&n!==""?`text/${n}`:"";return r===""||r.toLowerCase()==="module"?!0:on.has(r.replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g,"").toLowerCase())}function ot(e){const n=Array.from(e.querySelectorAll("script"));for(const r of Array.from(e.querySelectorAll("template")))r.namespaceURI===nt&&n.push(...ot(r.content));return n}function rt(e){const n=Array.from(e.querySelectorAll("meta[http-equiv]")).filter(r=>r.getAttribute("http-equiv").trim().toLowerCase()==="content-security-policy");for(const r of Array.from(e.querySelectorAll("template")))r.namespaceURI===nt&&n.push(...rt(r.content));return n}function sn(e){return e.doctype===null?"":new XMLSerializer().serializeToString(e.doctype)}function an(e){const n=new DOMParser().parseFromString(e,"text/html"),r=new Set([Ze(Se)]);for(const a of ot(n)){if(!rn(a))continue;const u=nn((a.textContent??"").replace(/\r\n?/g,`
137
- `));a.textContent=u,r.add(Ze(u))}for(const a of rt(n)){const u=(a.getAttribute("content")??"").split(";").map(w=>w.trim()).filter(w=>w!==""&&!/^script-src(-elem|-attr)?(\s|$)/i.test(w));a.setAttribute("content",[...u,"script-src 'unsafe-inline'"].join("; "))}const s=n.createElement("meta");s.setAttribute("http-equiv","Content-Security-Policy"),s.setAttribute("content",`script-src ${[...r].map(a=>`'sha256-${a}'`).join(" ")}; frame-src 'none'; child-src 'none'; worker-src 'none'; object-src 'none'`);const i=n.createElement("meta");i.setAttribute("http-equiv","Content-Security-Policy"),i.setAttribute("content","script-src 'unsafe-inline'");const l=n.createElement("script");return l.textContent=Se,n.head.prepend(s,i,l),`${sn(n)}${n.documentElement.outerHTML}`}const ie="wicked.editor",pe=1,ln=[[390,"Phone"],[820,"Tablet"],[1280,"Desktop"]],Te=34,cn=[0,250,750,1500],dn=`
132
+ .plugin-style p{line-height:1.5;color:var(--ink-body)}.plugin-style [role=status]{min-height:1.5em}.plugin-style :disabled{opacity:.6;cursor:default}`,e.append(r);const s=document.createElement("h2");s.textContent="Style",e.append(s);const i=document.createElement("div");i.className="theme-cards",e.append(i);const l=document.createElement("p");l.setAttribute("role","status"),l.setAttribute("aria-live","polite");let a=!1;const u=[],w=()=>Se(n.tokens()??ue[0]),C=[],b=[],A=()=>{const g=w();for(const{key:m,picker:k,hex:S}of C)S.value=g.colors[m],k.value=/^#[0-9a-f]{6}$/i.test(g.colors[m])?g.colors[m]:"";for(const{key:m,select:k}of b)k.value=Ze.includes(g.fonts[m])?g.fonts[m]:"system-ui";for(const m of Array.from(i.querySelectorAll("button")))m.setAttribute("aria-pressed",String(m.dataset.theme===g.name))},F=async g=>{if(!a){a=!0,u.forEach(m=>{m.disabled=!0}),l.textContent="Applying theme…";try{const m=await n.apply(g);l.textContent=m.ok?"Theme applied.":`Theme was not applied: ${m.reason}`}catch(m){l.textContent=`Theme was not applied: ${m instanceof Error?m.message:"unavailable"}`}finally{a=!1,u.forEach(m=>{m.disabled=!1}),A()}}};for(const g of ue){const m=document.createElement("button");m.type="button",m.dataset.theme=g.name;const k=document.createElement("span");k.className="ps-swatches",k.setAttribute("aria-hidden","true");for(const y of["background","surface","primary","secondary","accent"]){const x=document.createElement("span");x.style.backgroundColor=g.colors[y],k.append(x)}const S=document.createElement("span");S.textContent=g.display_name,m.append(k,S),m.addEventListener("click",()=>{F(Se(g))}),i.append(m),u.push(m)}for(const[g,m]of Gt){const k=document.createElement("label"),S=document.createElement("span");S.textContent=m;const y=document.createElement("input");y.type="color",y.setAttribute("aria-label",m);const x=document.createElement("input");x.type="text",x.maxLength=7,x.setAttribute("aria-label",`${m} hex`);const L=Z=>{if(!/^#[0-9a-f]{6}$/i.test(Z)){l.textContent="Enter a six-digit hex colour: a # and six digits or letters a to f.",A();return}const B=w();B.name="custom",B.colors[g]=Z,F(B)};y.addEventListener("change",()=>L(y.value)),x.addEventListener("change",()=>L(x.value)),k.append(S,y,x),e.append(k),u.push(y,x),C.push({key:g,picker:y,hex:x})}for(const g of["heading","body"]){const m=document.createElement("label"),k=document.createElement("span");k.textContent=g==="heading"?"Heading font":"Body font";const S=document.createElement("select");S.setAttribute("aria-label",k.textContent);for(const y of Ze){const x=document.createElement("option");x.value=y,x.textContent=y,S.append(x)}S.addEventListener("change",()=>{const y=w();y.name="custom",y.fonts[g]=S.value,F(y)}),m.append(k,S),e.append(m),u.push(S),b.push({key:g,select:S})}const D=document.createElement("p");return D.textContent="Match a website or a PDF: the host's Match button under this tab",e.append(D,l),A(),{refresh:A}}function en(e){const n=new DOMParser().parseFromString(e,"text/html"),r=Array.from(n.querySelectorAll("style")).map(u=>u.textContent??"").join(`
133
+ `),s=new Map;for(const u of r.matchAll(/(--wi-[a-z-]+)\s*:\s*([^;}{]+)/gi))s.set(u[1].toLowerCase(),u[2].trim());if(s.size===0)return null;const i=Se(ue[0]),l={background:"--wi-bg",surface:"--wi-surface",primary:"--wi-primary",secondary:"--wi-secondary",accent:"--wi-accent",text_primary:"--wi-text",text_secondary:"--wi-text-secondary",text_muted:"--wi-muted",border:"--wi-border"};for(const u of Object.keys(l)){const w=s.get(l[u]);w!==void 0&&/^(#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgb|hsl)a?\([0-9.,%\s]+\))$/i.test(w)&&(i.colors[u]=w)}for(const u of["heading","body","mono"]){const w=s.get(`--wi-font-${u}`);w!==void 0&&(i.fonts[u]=w.split(",")[0].trim().replace(/^['"]|['"]$/g,""))}const a=ue.find(u=>JSON.stringify(u.colors)===JSON.stringify(i.colors)&&JSON.stringify(u.fonts)===JSON.stringify(i.fonts));return i.name=a?.name??"custom",i}const tn=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),I=(e,n)=>e>>>n|e<<32-n;function Ge(e){const n=new TextEncoder().encode(e),r=n.length*8,s=new Uint8Array(Math.ceil((n.length+9)/64)*64);s.set(n),s[n.length]=128;const i=new DataView(s.buffer);i.setUint32(s.length-8,Math.floor(r/4294967296)),i.setUint32(s.length-4,r>>>0);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let C=0;C<s.length;C+=64){for(let y=0;y<16;y++)a[y]=i.getUint32(C+y*4);for(let y=16;y<64;y++){const x=I(a[y-15],7)^I(a[y-15],18)^a[y-15]>>>3,L=I(a[y-2],17)^I(a[y-2],19)^a[y-2]>>>10;a[y]=a[y-16]+x+a[y-7]+L>>>0}let[b,A,F,D,g,m,k,S]=[l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7]];for(let y=0;y<64;y++){const x=S+(I(g,6)^I(g,11)^I(g,25))+(g&m^~g&k)+tn[y]+a[y]>>>0,L=(I(b,2)^I(b,13)^I(b,22))+(b&A^b&F^A&F)>>>0;S=k,k=m,m=g,g=D+x>>>0,D=F,F=A,A=b,b=x+L>>>0}l[0]=l[0]+b>>>0,l[1]=l[1]+A>>>0,l[2]=l[2]+F>>>0,l[3]=l[3]+D>>>0,l[4]=l[4]+g>>>0,l[5]=l[5]+m>>>0,l[6]=l[6]+k>>>0,l[7]=l[7]+S>>>0}const u=new DataView(new ArrayBuffer(32));l.forEach((C,b)=>u.setUint32(b*4,C));let w="";for(let C=0;C<32;C++)w+=String.fromCharCode(u.getUint8(C));return btoa(w)}const Qe="WebRTC is not available in an editor frame",nn=["RTCPeerConnection","webkitRTCPeerConnection","mozRTCPeerConnection","RTCDataChannel","RTCIceTransport","RTCDtlsTransport","RTCSctpTransport","RTCRtpSender","RTCRtpReceiver","RTCRtpTransceiver","RTCIceCandidate","RTCSessionDescription","RTCCertificate"],$e='(function(w,o){if(typeof w!=="object"||w===null||w.window!==w)throw '+JSON.stringify(Qe)+";var n="+JSON.stringify(nn)+",k=o.getOwnPropertyNames(w),i,d;for(i=0;i!==k.length;i++)if(/^(webkit|moz)?RTC/.test(k[i])&&(d=o.getOwnPropertyDescriptor(w,k[i]))&&d.configurable)n.push(k[i]);for(i=0;i!==n.length;i++){o.defineProperty(w,n[i],{value:void 0,writable:false,configurable:false});if(w[n[i]]!==void 0)throw "+JSON.stringify(Qe)+`}})(window,({}).constructor);
134
+ `,se=/[\n\r\u2028\u2029]/,et=/\s/,tt=/[\w$\\\u0080-\uFFFF]/;function on(e,n){if(n>=e.length)return!0;const r=e[n];if(r==='"'||r==="'"||r==="{"||r==="~"||/[0-9]/.test(r))return!0;if(r==="!")return e[n+1]!=="=";if(r===".")return/[0-9]/.test(e[n+1]??"");if(r==="\\")return!0;if(r==="+"||r==="-")return e[n+1]===r;if(!tt.test(r))return!1;let s=n;for(;s<e.length&&tt.test(e[s])&&!et.test(e[s]);)s++;const i=e.slice(n,s);return i!=="in"&&i!=="instanceof"}function rn(e){const n=e.length;let r=0,s=0,i=!1,l=!1;if(e.startsWith("#!")){for(;r<n&&!se.test(e[r]);)r++;s=r,i=!0}let a=!1,u=!0,w=!0;const C=()=>{for(;;){for(;r<n&&et.test(e[r]);)se.test(e[r])&&(a=!0,u=!0),r++;if(w&&u&&e.startsWith("-->",r)){for(;r<n&&!se.test(e[r]);)r++;continue}if(e.startsWith("/*",r)){const b=e.indexOf("*/",r+2);if(b<0)return!1;se.test(e.slice(r,b))&&(a=!0,u=!0),r=b+2}else if(e.startsWith("//",r)||w&&e.startsWith("<!--",r))for(;r<n&&!se.test(e[r]);)r++;else return!0}};for(;C();){const b=e[r];if(b!=='"'&&b!=="'")break;w=!1;let A=r+1,F=!1;for(;A<n;){const g=e[A];if(g==="\\"){A+=2;continue}if(g===b){F=!0,A+=1;break}if(g===`
135
+ `||g==="\r")break;A+=1}if(!F)break;u=!1;const D=A;if(r=A,a=!1,!C())break;if(e[r]===";")r+=1,u=!1,s=r,l=!1;else if(e.startsWith("<!--",r)){s=D,l=!0,i=!1;break}else if((a||r>=n)&&on(e,r))s=D,l=!0;else break;i=!1}return{at:s,afterHashbang:i,semicolon:l}}function sn(e){const{at:n,afterHashbang:r,semicolon:s}=rn(e);return e.slice(0,n)+(s?";":"")+(r?`
136
+ `:"")+$e+e.slice(n)}const an=new Set(["application/ecmascript","application/javascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript"]),nt="http://www.w3.org/2000/svg",ot="http://www.w3.org/1999/xhtml";function ln(e){if(e.namespaceURI===nt?e.hasAttribute("href")||e.hasAttribute("xlink:href"):e.hasAttribute("src"))return!1;const n=e.namespaceURI===nt?null:e.getAttribute("language"),r=e.hasAttribute("type")?e.getAttribute("type"):n!==null&&n!==""?`text/${n}`:"";return r===""||r.toLowerCase()==="module"?!0:an.has(r.replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g,"").toLowerCase())}function rt(e){const n=Array.from(e.querySelectorAll("script"));for(const r of Array.from(e.querySelectorAll("template")))r.namespaceURI===ot&&n.push(...rt(r.content));return n}function st(e){const n=Array.from(e.querySelectorAll("meta[http-equiv]")).filter(r=>r.getAttribute("http-equiv").trim().toLowerCase()==="content-security-policy");for(const r of Array.from(e.querySelectorAll("template")))r.namespaceURI===ot&&n.push(...st(r.content));return n}function cn(e){return e.doctype===null?"":new XMLSerializer().serializeToString(e.doctype)}function dn(e){const n=new DOMParser().parseFromString(e,"text/html"),r=new Set([Ge($e)]);for(const a of rt(n)){if(!ln(a))continue;const u=sn((a.textContent??"").replace(/\r\n?/g,`
137
+ `));a.textContent=u,r.add(Ge(u))}for(const a of st(n)){const u=(a.getAttribute("content")??"").split(";").map(w=>w.trim()).filter(w=>w!==""&&!/^script-src(-elem|-attr)?(\s|$)/i.test(w));a.setAttribute("content",[...u,"script-src 'unsafe-inline'"].join("; "))}const s=n.createElement("meta");s.setAttribute("http-equiv","Content-Security-Policy"),s.setAttribute("content",`script-src ${[...r].map(a=>`'sha256-${a}'`).join(" ")}; frame-src 'none'; child-src 'none'; worker-src 'none'; object-src 'none'`);const i=n.createElement("meta");i.setAttribute("http-equiv","Content-Security-Policy"),i.setAttribute("content","script-src 'unsafe-inline'");const l=n.createElement("script");return l.textContent=$e,n.head.prepend(s,i,l),`${cn(n)}${n.documentElement.outerHTML}`}const ie="wicked.editor",pe=1,un=[[390,"Phone"],[820,"Tablet"],[1280,"Desktop"]],Te=34,pn=[0,250,750,1500],fn=`
138
138
  <div data-testid="page-style" id="style" class="style-pane" hidden></div>
139
139
  <div data-testid="page-editor" id="editor" class="editor" data-kind="page" data-head="" data-pickable="false" data-selected="" data-size="pane" data-width="" tabindex="0" role="application" aria-label="The page">
140
140
  <div data-testid="page-tools" id="tools" class="tools" role="toolbar" aria-label="Page width">
141
- ${ln.map(([e,n])=>`<button type="button" data-testid="page-width" data-width="${e}" aria-pressed="false" title="${n} · ${e} px wide">${n} ${e}</button>`).join("")}
141
+ ${un.map(([e,n])=>`<button type="button" data-testid="page-width" data-width="${e}" aria-pressed="false" title="${n} · ${e} px wide">${n} ${e}</button>`).join("")}
142
142
  </div>
143
143
  <div id="stage" class="stage"></div>
144
144
  <div data-testid="page-hover-box" id="hover" class="box box--hover" hidden></div>
@@ -153,13 +153,13 @@
153
153
  <span class="swatches" data-testid="page-swatches" data-prop="background" id="fills"><span class="word">Fill</span></span>
154
154
  <span class="swatches" data-testid="page-swatches" data-prop="color" id="inks"><span class="word">Text</span></span>
155
155
  </div>
156
- </div>`;function M(e){const n=document.getElementById(e);if(n===null)throw new Error(`wicked-page: no #${e}`);return n}function st(e,n){const r=e?.blocks[n];return e===null||e.widMap[n]===void 0||r===void 0?"unmeasured":r.composite?"container":r.cut===!0?"cut":"yes"}function Oe(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function un(e){document.body.insertAdjacentHTML("afterbegin",dn);const n=M("editor");n.dataset.kind=e.kind,n.setAttribute("aria-label",e.kind==="document"?"The document":"The page");const r=M("stage");let s=null;const i=M("hover"),l=M("selected"),a=M("input"),u=M("handle"),w=M("hint"),C=M("note"),v=M("tools"),A=M("peek"),F=M("to-section"),B=M("remove"),g=M("fills"),m=M("inks");let x=null,$=[],y="pane",k=1,L="options",Z="style",D="simple",Le=null;const ae=()=>k===1?y!=="inline":L==="full",G=()=>ae()&&(k===1||D==="advanced");let fe=null,pn=0;const Re=new Map,K=(t,o)=>{x?.postMessage({p:ie,v:pe,type:t,payload:o})},le=(t,o)=>new Promise(c=>{if(x===null){c({ok:!1,error:{code:"unavailable",message:"no host yet"}});return}const d=`wp-${++pn}`;Re.set(d,c),x.postMessage({p:ie,v:pe,type:t,id:d,payload:o})}),he=t=>K("ui.status",{line:t.slice(0,120)});let O=null,Me=Object.create(null),Q=null,Fe=0,ce=!1,_e=!1,Y=null;const E=e.coverage?document.createElement("aside"):null;if(E!==null){E.id="coverage",E.dataset.testid="doc-coverage",E.setAttribute("aria-label","Requirements"),E.hidden=!0,document.body.append(E);const t=document.createElement("style");t.textContent=`#coverage{box-sizing:border-box;height:100%;overflow:auto;padding:16px;color:var(--ink-high);background:var(--surface-base);font:13px var(--font-sans,system-ui)}
156
+ </div>`;function M(e){const n=document.getElementById(e);if(n===null)throw new Error(`wicked-page: no #${e}`);return n}function it(e,n){const r=e?.blocks[n];return e===null||e.widMap[n]===void 0||r===void 0?"unmeasured":r.composite?"container":r.cut===!0?"cut":"yes"}function Oe(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function hn(e){document.body.insertAdjacentHTML("afterbegin",fn);const n=M("editor");n.dataset.kind=e.kind,n.setAttribute("aria-label",e.kind==="document"?"The document":"The page");const r=M("stage");let s=null;const i=M("hover"),l=M("selected"),a=M("input"),u=M("handle"),w=M("hint"),C=M("note"),b=M("tools"),A=M("peek"),F=M("to-section"),D=M("remove"),g=M("fills"),m=M("inks");let k=null,S=[],y="pane",x=1,L="options",Z="style",B="simple",Le=null;const ae=()=>x===1?y!=="inline":L==="full",G=()=>ae()&&(x===1||B==="advanced");let fe=null,yn=0;const Re=new Map,P=(t,o)=>{k?.postMessage({p:ie,v:pe,type:t,payload:o})},le=(t,o)=>new Promise(c=>{if(k===null){c({ok:!1,error:{code:"unavailable",message:"no host yet"}});return}const d=`wp-${++yn}`;Re.set(d,c),k.postMessage({p:ie,v:pe,type:t,id:d,payload:o})}),he=t=>P("ui.status",{line:t.slice(0,120)});let O=null,Me=Object.create(null),Q=null,Fe=0,ce=!1,_e=!1,Y=null;const E=e.coverage?document.createElement("aside"):null;if(E!==null){E.id="coverage",E.dataset.testid="doc-coverage",E.setAttribute("aria-label","Requirements"),E.hidden=!0,document.body.append(E);const t=document.createElement("style");t.textContent=`#coverage{box-sizing:border-box;height:100%;overflow:auto;padding:16px;color:var(--ink-high);background:var(--surface-base);font:13px var(--font-sans,system-ui)}
157
157
  #coverage h2{font-size:16px;margin:0 0 12px}#coverage p{color:var(--ink-muted);line-height:1.5}
158
158
  #coverage button{display:block;width:100%;padding:10px 8px;text-align:left;font:inherit;color:var(--ink-high);background:var(--surface-card);border:1px solid var(--border);border-radius:4px;margin:6px 0;cursor:pointer}
159
159
  #coverage button:disabled{cursor:default}#coverage button:focus-visible{outline:2px solid var(--accent)}
160
160
  #coverage p button{display:inline;width:auto;padding:0;margin:0;border:0;background:transparent;color:var(--accent);text-decoration:underline}
161
161
  body[data-coverage="side"] .editor{width:calc(100% - min(300px,38%))}
162
- body[data-coverage="side"] #coverage{position:absolute;right:0;top:0;width:min(300px,38%);border-left:1px solid var(--border)}`,document.body.append(t)}const ye=()=>{if(E===null)return;if(E.replaceChildren(),delete E.dataset.total,delete E.dataset.rows,delete E.dataset.named,ce){const h=document.createElement("p");h.textContent="Couldn't read the requirements · ";const T=document.createElement("button");T.type="button",T.textContent="Try again",T.addEventListener("click",()=>{je()}),h.append(T),E.append(h);return}if(Q===null){const h=document.createElement("p");h.textContent="Reading requirements…",E.append(h);return}if(Q.length===0){const h=document.createElement("p");h.textContent="No requirements for this document's repository",E.append(h);return}const t=wt(Q.map(h=>({key:h.id,reqId:h.id,title:h.text,risk:!1})),Me),o=t.filter(h=>h.wid!==null),c=t.filter(h=>h.wid===null);E.dataset.total=String(Fe),E.dataset.rows=String(t.length),E.dataset.named=String(o.length);const d=document.createElement("h2");d.textContent="Requirements",E.append(d);const p=document.createElement("p");p.dataset.testid="doc-coverage-line",p.textContent=xt(t,Fe),E.append(p);const f=(h,T)=>{if(T.length===0)return;const de=document.createElement("p");de.textContent=`${h} (${T.length})`,E.append(de);for(const q of T){const W=document.createElement("button");W.type="button",W.dataset.testid="doc-coverage-row",W.dataset.req=q.reqId,W.dataset.named=String(q.wid!==null),W.disabled=q.wid===null,W.textContent=`${q.reqId} · ${q.title}${q.wid===null?"":` · ${ne(q.wid,e.kind)}`}`,W.addEventListener("click",()=>{if(q.wid!==null){if(L==="options"){$.includes("selection.chip")&&K("selection.set",{anchors:[{kind:"element",id:q.wid}]});return}te(q.wid,!0),Ae(q.wid)}}),E.append(W)}};f("Not named",c),f("Named",o)},je=async()=>{if(!(!e.coverage||Q!==null||_e)){_e=!0,ce=!1,ye();try{const t=await le("checks.read",{}),o=t.ok?t.payload.checks:null;if(!t.ok||!Array.isArray(o)){ce=!0;return}Q=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.id=="string"&&typeof c.text=="string"),Fe=typeof t.payload.total=="number"?t.payload.total:Q.length}catch{ce=!0}finally{_e=!1,ye()}}},fn=t=>{const o=new DOMParser().parseFromString(t,"text/html");Me=Object.create(null);const c=Array.from(o.querySelectorAll("[data-wid]")),d=new Map;for(const p of c){const f=p.getAttribute("data-wid")??"";d.set(f,(d.get(f)??0)+1)}for(const p of c){const f=p.getAttribute("data-wid")??"";!/^[A-Za-z0-9_.:-]{1,100}$/.test(f)||d.get(f)!==1||(Me[f]={text:(p.textContent??"").replace(/\s+/g," ").trim(),composite:p.querySelector("[data-wid]")!==null})}ye()};let S=null,me={scrollX:0,scrollY:0},ge=null,b=null,j=null,ve=null,N=!1,it=[],z=null,Be=0,at=-1,ee=null,De=null,lt=0,be=[],Ne=!1,qe=null,we=null;const ct=t=>{s?.contentWindow?.postMessage(t,"*")},hn=t=>{if(t===s){at=Be;for(const o of be)clearTimeout(o);be=cn.map(o=>setTimeout(()=>ct(Rt),o))}},yn=t=>{const o=document.createElement("iframe");for(const[d,p]of Object.entries({"data-testid":"page-frame",sandbox:"allow-scripts",title:e.kind==="document"?"The document":"The page",class:"frame"}))o.setAttribute(d,p);o.addEventListener("load",()=>hn(o));const c=s;s=o;for(const d of be)clearTimeout(d);o.srcdoc=an(t),r.appendChild(o),c?.remove(),ke()},dt=()=>{const t=y==="inline"?0:Te;if(z===null)return{x:0,y:t,s:1};const o=r.clientWidth,c=o>0?Math.min(1,o/z):1;return{x:Math.max(0,(o-z*c)/2),y:t,s:c}},ke=()=>{r.style.top=`${y==="inline"?0:Te}px`,n.dataset.width=z===null?"":String(z);for(const c of Array.from(v.querySelectorAll("[data-width]")))c.setAttribute("aria-pressed",String(Number(c.dataset.width)===z));if(s===null)return;if(z===null){s.style.cssText="";return}const t=dt(),o=r.clientHeight>0?r.clientHeight/t.s:0;s.style.cssText=`position:absolute;left:${t.x}px;top:0;width:${z}px;${o>0?`height:${o}px;`:""}transform:scale(${t.s});transform-origin:0 0`},xe=t=>{if(t===null||S===null)return null;const o=S.widMap[t];if(o===void 0)return null;const c=$t(o,S.measured,me),d=dt();return{left:d.x+c.left*d.s,top:d.y+c.top*d.s,width:c.width*d.s,height:c.height*d.s}},Ie=(t,o,c=0,d=0)=>{if(o===null){t.hidden=!0;return}t.hidden=!1,t.style.left=`${o.left}px`,t.style.top=`${o.top}px`,t.style.width=`${Math.max(o.width,c)}px`,t.style.height=`${Math.max(o.height,d)}px`},ze=()=>(y!=="inline"||k>=2&&L==="card")&&S!==null,R=()=>{if(n.dataset.head=O===null?"":String(O),n.dataset.pickable=String(ze()),n.dataset.selected=b??"",n.dataset.size=y,Ie(i,ge!==b&&j===null?xe(ge):null),l.dataset.wid=b??"",Ie(l,j===null?xe(b):null),j!==null?Ie(a,xe(j.wid),160,30):a.hidden=!0,v.hidden=y==="inline",n.dataset.mode=k>=2?D:"",B.hidden=!G(),g.hidden=!G(),m.hidden=!G(),mn(),!ae()||!ze()||j!==null){w.hidden=!0;return}if(w.hidden=!1,b===null){w.removeAttribute("data-editable"),w.textContent="Click an element to make it the subject · type on it to change it";return}const t=ne(b,e.kind),o=st(S,b);w.dataset.editable=String(o==="yes"),w.textContent=o==="yes"?`Type to change ${t} · Enter to edit its text · Esc to let go`:o==="container"?`${Oe(t)} holds other parts — click a line of text inside it to change the words · Esc to let go`:o==="cut"?`${Oe(t)} is too long to change by typing — say what to change in the message box · Esc to let go`:`${Oe(t)} can’t be changed by typing — say what to change in the message box · Esc to let go`},mn=()=>{const t=G()&&ze()&&j===null&&!N?xe(b):null;if(t===null||b===null){A.hidden=!0;return}A.hidden=!1,F.hidden=S?.blocks[b]?.section===void 0;const o=A.offsetHeight||30,c=t.top+t.height+6,d=n.clientHeight===0||c+o<=n.clientHeight-4,p=A.offsetWidth,f=n.clientWidth>0?n.clientWidth-p-4:1/0;A.style.left=`${Math.max(4,Math.min(t.left,f))}px`,A.style.top=`${d?c:Math.max(Te+2,t.top-o-6)}px`},ut=(t,o)=>{for(const d of Array.from(t.querySelectorAll("button")))d.remove();const c=(d,p)=>{const f=document.createElement("button");f.type="button",f.className=d===Ce?"swatch swatch--default":"swatch";for(const[h,T]of Object.entries({"data-testid":"page-swatch"}))f.setAttribute(h,T);f.dataset.prop=o,f.dataset.value=d,f.title=`${o==="background"?"Fill":"Text"}: ${p}`,f.setAttribute("aria-label",f.title),d===Ce?f.textContent="Default":f.style.setProperty("--swatch",d),f.addEventListener("click",()=>{b!==null&&vn(b,o,d,p)}),t.appendChild(f)};for(const d of it)c(d.value,d.label);c(Ce,"Default")},U=()=>{if(j===null)return;j=null,a.hidden=!0,a.value="";const t=ve;ve=null,t!==null&&Pe(t),R()},te=(t,o=!1)=>{Y=null,b=t,U(),R(),t!==null&&($.includes("selection.chip")&&K("selection.set",{anchors:[{kind:"element",id:t}]}),o||u.focus())},Ae=t=>{lt+=1,ct(Mt(t,lt))},Pe=t=>{const o=t.version;if(typeof o=="number"&&O!==null&&o<O)return;if(j!==null){const p=ve?.version;typeof o=="number"&&o>j.base&&(typeof p!="number"||o>=p)&&(ve=t);return}C.hidden=!0;const c=t.content,d=typeof c?.html=="string"?c.html:"";e.coverage&&fn(d),O=typeof o=="number"?o:O,it=It(d),fe=Zt(d)??fe,We?.refresh(),ut(g,"background"),ut(m,"color"),Be+=1,De=ee,ee=null,S=null,ge=null,b=null,U(),R(),yn(_t(d)?d:Bt(d))},H=async t=>{if(Ne){if(t!==void 0&&t===qe)return;we=t===void 0?{}:{version:t};return}Ne=!0,qe=t??null;try{const o=await le("artifact.read",t===void 0?{}:{version:t});if(!o.ok){C.hidden=!1,C.textContent=o.error.code==="not_granted"?`This editor may not read the ${e.kind} here.`:`The ${e.kind} could not be read (${o.error.code}).`;return}Pe(o.payload)}finally{if(Ne=!1,qe=null,we!==null){const o=we;we=null,(o.version===void 0||o.version!==O)&&H(o.version)}}};window.addEventListener("message",t=>{if(s===null||s.contentWindow===null||t.source!==s.contentWindow||at!==Be)return;const o=Lt(t.data);if(o!==null){if(o.type==="wid-inventory"){for(const d of be)clearTimeout(d);S={widMap:o.widMap,blocks:o.blocks??{},measured:{scrollX:o.scrollX,scrollY:o.scrollY}},me={scrollX:o.scrollX,scrollY:o.scrollY};const c=De;De=null,c!==null&&o.widMap[c]!==void 0&&Ae(c),Y!==null&&o.widMap[Y]!==void 0&&(b=Y,e.coverage&&Ae(Y)),R()}else if(o.type==="scroll-state")me={scrollX:o.scrollX,scrollY:o.scrollY},R();else if(o.type==="scroll-ack")o.scrollX!==void 0&&o.scrollY!==void 0&&(me={scrollX:o.scrollX,scrollY:o.scrollY},R());else if(o.type==="wid-hover")ge=o.wid,R();else if(o.type==="wid-click"){if(k===1&&y==="inline")return;if(k===2&&L==="card"){te(o.wid);return}const c=o.wid===b?S?.blocks[o.wid]?.section:void 0;te(c!==void 0&&S?.widMap[c]!==void 0?c:o.wid)}}});const pt=(t,o)=>{if(!ae()||N||O===null||S===null||st(S,t)!=="yes")return;const c=S.blocks[t]?.text??"";j={wid:t,before:c,base:O},a.value=o??c,R(),a.focus(),o===null?a.select():a.setSelectionRange(a.value.length,a.value.length)},Ke=async(t,o,c,d,p=O)=>{if(O===null||N)return;N=!0,R(),he(c);const f=d;try{const h=await le("version.write",{base:p,ops:t,summary:o});if(h.ok)ee=f,await H(typeof h.payload.version=="number"?h.payload.version:void 0);else if(h.error.code==="stale"||h.error.code==="head_moved"){he(h.error.code==="stale"&&h.error.message?h.error.message:"Not changed: it moved while you typed"),ee=f;const T=h.payload?.head;h.error.code==="head_moved"?await H(typeof T=="number"?T:void 0):typeof T=="number"&&T!==O&&await H(T)}else h.error.code==="timeout"||(h.error.code==="refused"?he(h.error.message||"Nothing changed"):he(`Not changed: ${h.error.message||h.error.code}`))}finally{N=!1,R()}},gn=async()=>{if(j===null||O===null||N)return;const{wid:t,before:o,base:c}=j,d=a.value.replace(/\s*\n\s*/g," ");if(U(),u.focus(),d===o)return;const p=ne(t,e.kind);await Ke([{op:"text",anchor:t,value:d,before:o}],p,`Changing ${p}…`,t,c)},ft=async t=>{if(!G()||N||S?.widMap[t]===void 0)return;const o=ne(t,e.kind),c=S.blocks[t]?.section??null;u.focus(),await Ke([{op:"remove",anchor:t}],o,`Removing ${o}…`,c)},vn=async(t,o,c,d)=>{if(!G()||N||S?.widMap[t]===void 0)return;const p=ne(t,e.kind);u.focus(),await Ke([{op:"style",anchor:t,style:{[o]:c}}],p,`${o==="background"?"Filling":"Colouring the text of"} ${p}: ${d.toLowerCase()}…`,t)},ht=t=>{const o=S?.blocks[t]?.section;return o===void 0||S?.widMap[o]===void 0?!1:(te(o),!0)};F.addEventListener("click",()=>{b!==null&&ht(b)}),B.addEventListener("click",()=>{b!==null&&ft(b)});for(const t of Array.from(v.querySelectorAll("[data-width]")))t.addEventListener("click",()=>{const o=Number(t.dataset.width);z=z===o?null:o,ke(),R()});window.addEventListener("resize",()=>{ke(),R()}),a.addEventListener("keydown",t=>{t.stopPropagation(),t.key==="Enter"?(t.preventDefault(),gn()):t.key==="Escape"&&(t.preventDefault(),U(),u.focus())}),a.addEventListener("blur",()=>{U()});const bn=()=>[...Array.from(v.querySelectorAll("button")),u,...Array.from(A.querySelectorAll("button")),...Array.from(E?.querySelectorAll("button")??[])].filter(t=>t.closest("[hidden]")===null&&!(t instanceof HTMLButtonElement&&t.disabled)),yt=(t,o)=>{if(t.target===a)return;const c=t.target?.tagName==="BUTTON";if(!(c&&(t.key==="Enter"||t.key===" "))){if(t.key==="Escape"){if(!o&&b!==null){t.preventDefault(),te(null);return}t.preventDefault(),K("ui.key",{key:"Escape"});return}if((t.metaKey||t.ctrlKey)&&!t.altKey&&t.key.toLowerCase()==="k"){t.preventDefault(),K("ui.key",{key:"Mod+K"});return}if(!o&&(t.metaKey||t.ctrlKey)&&!t.altKey&&(t.key==="Backspace"||t.key==="Delete")){t.preventDefault(),b!==null&&!N&&ft(b);return}if(!o&&t.altKey&&!t.metaKey&&!t.ctrlKey&&t.key==="ArrowUp"){t.preventDefault(),b!==null&&ht(b);return}if(t.altKey&&!t.metaKey&&!t.ctrlKey&&/^Key[A-Z]$/.test(t.code)&&He(`Alt+${t.code.slice(3)}`)){t.preventDefault(),K("ui.key",{key:`Alt+${t.code.slice(3)}`});return}if(t.key==="Tab"){t.preventDefault();const d=bn(),p=d.indexOf(document.activeElement),f=p===-1&&document.activeElement===n&&!t.shiftKey?0:p+(t.shiftKey?-1:1);if(p===-1&&f!==0||f<0||f>=d.length){K("ui.key",{key:t.shiftKey?"Shift+Tab":"Tab"});return}d[f].focus();return}if(!(t.metaKey||t.ctrlKey||t.altKey)&&!(c&&t.key.length!==1)){if(t.key==="Enter"){!o&&b!==null&&!N&&ae()&&(t.preventDefault(),pt(b,null));return}if(t.key.length===1){if(t.preventDefault(),!o&&b!==null&&!N&&ae()){pt(b,t.key);return}K("ui.typed",{grapheme:t.key})}}}};n.addEventListener("keydown",t=>yt(t,!1)),E?.addEventListener("keydown",t=>yt(t,!0));const Ue=t=>{y=t,document.body.dataset.size=t,t==="inline"&&(U(),k<2&&te(null),document.activeElement?.blur?.()),ke(),R()},mt=t=>{if(!(typeof t!="object"||t===null))for(const[o,c]of Object.entries(t))/^--[a-z0-9-]+$/.test(o)&&typeof c=="string"&&c.length<=200&&!/url\(/i.test(c)&&document.documentElement.style.setProperty(o,c)},wn=t=>{const o=t.data;try{if(o===null||typeof o!="object"||o.p!==ie||o.v!==pe)return;if(typeof o.re=="string"){const d=Re.get(o.re);if(d===void 0)return;Re.delete(o.re);const p=typeof o.payload=="object"&&o.payload!==null?o.payload:{};o.ok===!0?d({ok:!0,payload:p}):d({ok:!1,error:o.error??{code:"unavailable",message:"no answer"},payload:p});return}if(Le!==null&&Le.dispatch(o))return;const c=typeof o.payload=="object"&&o.payload!==null?o.payload:{};switch(o.type){case"host.ping":typeof o.id=="string"&&x?.postMessage({p:ie,v:pe,re:o.id,ok:!0,payload:{}});return;case"host.size":(c.size==="inline"||c.size==="pane"||c.size==="full")&&Ue(c.size);return;case"host.theme":mt(c.theme);return;case"artifact.changed":{ce&&je();const d=c.version;typeof d=="number"&&d!==O&&(ee=ee??b,H(d));return}case"selection.cleared":Y=null,b!==null&&(b=null,U(),R());return;default:return}}catch{}};window.addEventListener("message",t=>{const o=t.data;if(x!==null||o===null||typeof o!="object"||o.p!==ie||o.type!=="host.hello"||t.ports[0]===void 0)return;x=t.ports[0],x.onmessage=wn;const c=typeof o.payload=="object"&&o.payload!==null?o.payload:{};$=Array.isArray(c.grants)?c.grants.filter(p=>typeof p=="string"):[],mt(c.theme);const d=Ut(c);k=d.protocol,k>=2?(L=c.surface==="options"?"options":d.surface,Z=d.tab??"style",D=d.mode??"simple",Le=new Ht(x,{surface:(p,f)=>{L=p,f!==null&&(D=f),Ee()},mode:p=>(D=p,e.coverage?Ee():R(),D),tab:p=>{e.coverage&&(Z=p,Ee())},selection:p=>{const f=p.find(h=>typeof h=="object"&&h!==null&&h.kind==="element"&&typeof h.id=="string");L==="options"&&f!==void 0||(Y=f?.id??null,b=f!==void 0&&S?.widMap[f.id]!==void 0?f.id:null,b!==null&&e.coverage&&Ae(b),U(),R())}}),Ee()):Ue(d.size),H()});const gt=M("style");let We=null;const Ee=()=>{const t=L==="options",o=e.coverage&&t&&Z==="coverage",c=e.coverage&&L==="full"&&D==="advanced";e.coverage&&(document.body.dataset.coverage=c?"side":"",E!==null&&(E.hidden=!o&&!c),(o||c)&&(ye(),je())),gt.hidden=!t||o,n.hidden=t,t&&!o&&We===null&&(We=Vt(gt,{tokens:()=>fe,key:d=>K("ui.key",{key:d}),apply:async d=>{for(let p=0;p<2;p+=1){if(O===null)return{ok:!1,reason:`The ${e.kind} is not loaded yet`};const f=await le("theme.set",{base:O,tokens:d});if(f.ok){const de=f.payload.version;return fe={name:d.name,colors:{...d.colors},fonts:{...d.fonts}},typeof de=="number"&&await H(de),{ok:!0}}if(f.error.code!=="head_moved")return{ok:!1,reason:f.error.message};const h=await le("artifact.read",{});if(!h.ok)return{ok:!1,reason:h.error.message||h.error.code};const T=h.payload.version;if(typeof T!="number"||O!==null&&T<O)return{ok:!1,reason:`The current ${e.kind} version could not be read.`};if(Pe(h.payload),p===1)return{ok:!1,reason:f.error.message||f.error.code}}return{ok:!1,reason:`The ${e.kind} changed again: try once more`}}})),Ue(Kt(L))};Xt(e.editor,e.surfaces)}un({editor:"wicked-doc",surfaces:{card:{interactive:!0,aspect:"16:9",actions:[{id:"ask",label:"Ask about this",verb:"host:ask"},{id:"export",label:"Export",verb:"host:export"}]},options:{tabs:[{id:"style",label:"Style",render:"plugin"},{id:"coverage",label:"Coverage",render:"plugin"}]},full:{modes:["simple","advanced"],default:"simple"}},kind:"document",coverage:!0})})();
162
+ body[data-coverage="side"] #coverage{position:absolute;right:0;top:0;width:min(300px,38%);border-left:1px solid var(--border)}`,document.body.append(t)}const ye=()=>{if(E===null)return;if(E.replaceChildren(),delete E.dataset.total,delete E.dataset.rows,delete E.dataset.named,ce){const h=document.createElement("p");h.textContent="Couldn't read the requirements · ";const T=document.createElement("button");T.type="button",T.textContent="Try again",T.addEventListener("click",()=>{je()}),h.append(T),E.append(h);return}if(Q===null){const h=document.createElement("p");h.textContent="Reading requirements…",E.append(h);return}if(Q.length===0){const h=document.createElement("p");h.textContent="No requirements for this document's repository",E.append(h);return}const t=kt(Q.map(h=>({key:h.id,reqId:h.id,title:h.text,risk:!1})),Me),o=t.filter(h=>h.wid!==null),c=t.filter(h=>h.wid===null);E.dataset.total=String(Fe),E.dataset.rows=String(t.length),E.dataset.named=String(o.length);const d=document.createElement("h2");d.textContent="Requirements",E.append(d);const p=document.createElement("p");p.dataset.testid="doc-coverage-line",p.textContent=At(t,Fe),E.append(p);const f=(h,T)=>{if(T.length===0)return;const de=document.createElement("p");de.textContent=`${h} (${T.length})`,E.append(de);for(const q of T){const W=document.createElement("button");W.type="button",W.dataset.testid="doc-coverage-row",W.dataset.req=q.reqId,W.dataset.named=String(q.wid!==null),W.disabled=q.wid===null,W.textContent=`${q.reqId} · ${q.title}${q.wid===null?"":` · ${ne(q.wid,e.kind)}`}`,W.addEventListener("click",()=>{if(q.wid!==null){if(L==="options"){S.includes("selection.chip")&&P("selection.set",{anchors:[{kind:"element",id:q.wid}]});return}te(q.wid,!0),Ae(q.wid)}}),E.append(W)}};f("Not named",c),f("Named",o)},je=async()=>{if(!(!e.coverage||Q!==null||_e)){_e=!0,ce=!1,ye();try{const t=await le("checks.read",{}),o=t.ok?t.payload.checks:null;if(!t.ok||!Array.isArray(o)){ce=!0;return}Q=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.id=="string"&&typeof c.text=="string"),Fe=typeof t.payload.total=="number"?t.payload.total:Q.length}catch{ce=!0}finally{_e=!1,ye()}}},mn=t=>{const o=new DOMParser().parseFromString(t,"text/html");Me=Object.create(null);const c=Array.from(o.querySelectorAll("[data-wid]")),d=new Map;for(const p of c){const f=p.getAttribute("data-wid")??"";d.set(f,(d.get(f)??0)+1)}for(const p of c){const f=p.getAttribute("data-wid")??"";!/^[A-Za-z0-9_.:-]{1,100}$/.test(f)||d.get(f)!==1||(Me[f]={text:(p.textContent??"").replace(/\s+/g," ").trim(),composite:p.querySelector("[data-wid]")!==null})}ye()};let $=null,me={scrollX:0,scrollY:0},ge=null,v=null,j=null,be=null,N=!1,at=[],z=null,De=0,lt=-1,ee=null,Be=null,ct=0,ve=[],Ne=!1,qe=null,we=null;const dt=t=>{s?.contentWindow?.postMessage(t,"*")},gn=t=>{if(t===s){lt=De;for(const o of ve)clearTimeout(o);ve=pn.map(o=>setTimeout(()=>dt(Ft),o))}},bn=t=>{const o=document.createElement("iframe");for(const[d,p]of Object.entries({"data-testid":"page-frame",sandbox:"allow-scripts",title:e.kind==="document"?"The document":"The page",class:"frame"}))o.setAttribute(d,p);o.addEventListener("load",()=>gn(o));const c=s;s=o;for(const d of ve)clearTimeout(d);o.srcdoc=dn(t),r.appendChild(o),c?.remove(),ke()},ut=()=>{const t=y==="inline"?0:Te;if(z===null)return{x:0,y:t,s:1};const o=r.clientWidth,c=o>0?Math.min(1,o/z):1;return{x:Math.max(0,(o-z*c)/2),y:t,s:c}},ke=()=>{r.style.top=`${y==="inline"?0:Te}px`,n.dataset.width=z===null?"":String(z);for(const c of Array.from(b.querySelectorAll("[data-width]")))c.setAttribute("aria-pressed",String(Number(c.dataset.width)===z));if(s===null)return;if(z===null){s.style.cssText="";return}const t=ut(),o=r.clientHeight>0?r.clientHeight/t.s:0;s.style.cssText=`position:absolute;left:${t.x}px;top:0;width:${z}px;${o>0?`height:${o}px;`:""}transform:scale(${t.s});transform-origin:0 0`},xe=t=>{if(t===null||$===null)return null;const o=$.widMap[t];if(o===void 0)return null;const c=Tt(o,$.measured,me),d=ut();return{left:d.x+c.left*d.s,top:d.y+c.top*d.s,width:c.width*d.s,height:c.height*d.s}},Ie=(t,o,c=0,d=0)=>{if(o===null){t.hidden=!0;return}t.hidden=!1,t.style.left=`${o.left}px`,t.style.top=`${o.top}px`,t.style.width=`${Math.max(o.width,c)}px`,t.style.height=`${Math.max(o.height,d)}px`},Pe=()=>(y!=="inline"||x>=2&&L==="card")&&$!==null,R=()=>{if(n.dataset.head=O===null?"":String(O),n.dataset.pickable=String(Pe()),n.dataset.selected=v??"",n.dataset.size=y,Ie(i,ge!==v&&j===null?xe(ge):null),l.dataset.wid=v??"",Ie(l,j===null?xe(v):null),j!==null?Ie(a,xe(j.wid),160,30):a.hidden=!0,b.hidden=y==="inline",n.dataset.mode=x>=2?B:"",D.hidden=!G(),g.hidden=!G(),m.hidden=!G(),vn(),!ae()||!Pe()||j!==null){w.hidden=!0;return}if(w.hidden=!1,v===null){w.removeAttribute("data-editable"),w.textContent="Click an element to make it the subject · type on it to change it";return}const t=ne(v,e.kind),o=it($,v);w.dataset.editable=String(o==="yes"),w.textContent=o==="yes"?`Type to change ${t} · Enter to edit its text · Esc to let go`:o==="container"?`${Oe(t)} holds other parts — click a line of text inside it to change the words · Esc to let go`:o==="cut"?`${Oe(t)} is too long to change by typing — say what to change in the message box · Esc to let go`:`${Oe(t)} can’t be changed by typing — say what to change in the message box · Esc to let go`},vn=()=>{const t=G()&&Pe()&&j===null&&!N?xe(v):null;if(t===null||v===null){A.hidden=!0;return}A.hidden=!1,F.hidden=$?.blocks[v]?.section===void 0;const o=A.offsetHeight||30,c=t.top+t.height+6,d=n.clientHeight===0||c+o<=n.clientHeight-4,p=A.offsetWidth,f=n.clientWidth>0?n.clientWidth-p-4:1/0;A.style.left=`${Math.max(4,Math.min(t.left,f))}px`,A.style.top=`${d?c:Math.max(Te+2,t.top-o-6)}px`},pt=(t,o)=>{for(const d of Array.from(t.querySelectorAll("button")))d.remove();const c=(d,p)=>{const f=document.createElement("button");f.type="button",f.className=d===Ce?"swatch swatch--default":"swatch";for(const[h,T]of Object.entries({"data-testid":"page-swatch"}))f.setAttribute(h,T);f.dataset.prop=o,f.dataset.value=d,f.title=`${o==="background"?"Fill":"Text"}: ${p}`,f.setAttribute("aria-label",f.title),d===Ce?f.textContent="Default":f.style.setProperty("--swatch",d),f.addEventListener("click",()=>{v!==null&&kn(v,o,d,p)}),t.appendChild(f)};for(const d of at)c(d.value,d.label);c(Ce,"Default")},U=()=>{if(j===null)return;j=null,a.hidden=!0,a.value="";const t=be;be=null,t!==null&&ze(t),R()},te=(t,o=!1)=>{Y=null,v=t,U(),R(),t!==null&&(S.includes("selection.chip")&&P("selection.set",{anchors:[{kind:"element",id:t}]}),o||u.focus())},Ae=t=>{ct+=1,dt(_t(t,ct))},ze=t=>{const o=t.version;if(typeof o=="number"&&O!==null&&o<O)return;if(j!==null){const p=be?.version;typeof o=="number"&&o>j.base&&(typeof p!="number"||o>=p)&&(be=t);return}C.hidden=!0;const c=t.content,d=typeof c?.html=="string"?c.html:"";e.coverage&&mn(d),O=typeof o=="number"?o:O,at=zt(d),fe=en(d)??fe,We?.refresh(),pt(g,"background"),pt(m,"color"),De+=1,Be=ee,ee=null,$=null,ge=null,v=null,U(),R(),bn(Dt(d)?d:Nt(d))},H=async t=>{if(Ne){if(t!==void 0&&t===qe)return;we=t===void 0?{}:{version:t};return}Ne=!0,qe=t??null;try{const o=await le("artifact.read",t===void 0?{}:{version:t});if(!o.ok){C.hidden=!1,C.textContent=o.error.code==="not_granted"?`This editor may not read the ${e.kind} here.`:`The ${e.kind} could not be read (${o.error.code}).`;return}ze(o.payload)}finally{if(Ne=!1,qe=null,we!==null){const o=we;we=null,(o.version===void 0||o.version!==O)&&H(o.version)}}};window.addEventListener("message",t=>{if(s===null||s.contentWindow===null||t.source!==s.contentWindow||lt!==De)return;const o=Mt(t.data);if(o!==null){if(o.type==="wid-inventory"){for(const d of ve)clearTimeout(d);$={widMap:o.widMap,blocks:o.blocks??{},measured:{scrollX:o.scrollX,scrollY:o.scrollY}},me={scrollX:o.scrollX,scrollY:o.scrollY};const c=Be;Be=null,c!==null&&o.widMap[c]!==void 0&&Ae(c),Y!==null&&o.widMap[Y]!==void 0&&(v=Y,e.coverage&&Ae(Y)),R()}else if(o.type==="scroll-state")me={scrollX:o.scrollX,scrollY:o.scrollY},R();else if(o.type==="scroll-ack")o.scrollX!==void 0&&o.scrollY!==void 0&&(me={scrollX:o.scrollX,scrollY:o.scrollY},R());else if(o.type==="wid-hover")ge=o.wid,R();else if(o.type==="wid-click"){if(x===1&&y==="inline")return;if(x===2&&L==="card"){te(o.wid);return}const c=o.wid===v?$?.blocks[o.wid]?.section:void 0;te(c!==void 0&&$?.widMap[c]!==void 0?c:o.wid)}}});const ft=(t,o)=>{if(!ae()||N||O===null||$===null||it($,t)!=="yes")return;const c=$.blocks[t]?.text??"";j={wid:t,before:c,base:O},a.value=o??c,R(),a.focus(),o===null?a.select():a.setSelectionRange(a.value.length,a.value.length)},Ke=async(t,o,c,d,p=O)=>{if(O===null||N)return;N=!0,R(),he(c);const f=d;try{const h=await le("version.write",{base:p,ops:t,summary:o});if(h.ok)ee=f,await H(typeof h.payload.version=="number"?h.payload.version:void 0);else if(h.error.code==="stale"||h.error.code==="head_moved"){he(h.error.code==="stale"&&h.error.message?h.error.message:"Not changed: it moved while you typed"),ee=f;const T=h.payload?.head;h.error.code==="head_moved"?await H(typeof T=="number"?T:void 0):typeof T=="number"&&T!==O&&await H(T)}else h.error.code==="timeout"||(h.error.code==="refused"?he(h.error.message||"Nothing changed"):he(`Not changed: ${h.error.message||h.error.code}`))}finally{N=!1,R()}},wn=async()=>{if(j===null||O===null||N)return;const{wid:t,before:o,base:c}=j,d=a.value.replace(/\s*\n\s*/g," ");if(U(),u.focus(),d===o)return;const p=ne(t,e.kind);await Ke([{op:"text",anchor:t,value:d,before:o}],p,`Changing ${p}…`,t,c)},ht=async t=>{if(!G()||N||$?.widMap[t]===void 0)return;const o=ne(t,e.kind),c=$.blocks[t]?.section??null;u.focus(),await Ke([{op:"remove",anchor:t}],o,`Removing ${o}…`,c)},kn=async(t,o,c,d)=>{if(!G()||N||$?.widMap[t]===void 0)return;const p=ne(t,e.kind);u.focus(),await Ke([{op:"style",anchor:t,style:{[o]:c}}],p,`${o==="background"?"Filling":"Colouring the text of"} ${p}: ${d.toLowerCase()}…`,t)},yt=t=>{const o=$?.blocks[t]?.section;return o===void 0||$?.widMap[o]===void 0?!1:(te(o),!0)};F.addEventListener("click",()=>{v!==null&&yt(v)}),D.addEventListener("click",()=>{v!==null&&ht(v)});for(const t of Array.from(b.querySelectorAll("[data-width]")))t.addEventListener("click",()=>{const o=Number(t.dataset.width);z=z===o?null:o,ke(),R()});window.addEventListener("resize",()=>{ke(),R()}),a.addEventListener("keydown",t=>{t.stopPropagation(),t.key==="Enter"?(t.preventDefault(),wn()):t.key==="Escape"&&(t.preventDefault(),U(),u.focus())}),a.addEventListener("blur",()=>{U()});const xn=()=>[...Array.from(b.querySelectorAll("button")),u,...Array.from(A.querySelectorAll("button")),...Array.from(E?.querySelectorAll("button")??[])].filter(t=>t.closest("[hidden]")===null&&!(t instanceof HTMLButtonElement&&t.disabled)),mt=(t,o)=>{if(t.target===a)return;const c=t.target?.tagName==="BUTTON";if(!(c&&(t.key==="Enter"||t.key===" "))){if(t.key==="Escape"){if(!o&&v!==null){t.preventDefault(),te(null);return}t.preventDefault(),P("ui.key",{key:"Escape"});return}if((t.metaKey||t.ctrlKey)&&!t.altKey&&t.key.toLowerCase()==="k"){t.preventDefault(),P("ui.key",{key:"Mod+K"});return}if(!o&&(t.metaKey||t.ctrlKey)&&!t.altKey&&(t.key==="Backspace"||t.key==="Delete")){t.preventDefault(),v!==null&&!N&&ht(v);return}if(!o&&t.altKey&&!t.metaKey&&!t.ctrlKey&&t.key==="ArrowUp"){t.preventDefault(),v!==null&&yt(v);return}if(t.altKey&&!t.metaKey&&!t.ctrlKey&&/^Key[A-Z]$/.test(t.code)&&He(`Alt+${t.code.slice(3)}`)){t.preventDefault(),P("ui.key",{key:`Alt+${t.code.slice(3)}`});return}if(t.key==="Tab"){t.preventDefault();const d=xn(),p=d.indexOf(document.activeElement),f=p===-1&&document.activeElement===n&&!t.shiftKey?0:p+(t.shiftKey?-1:1);if(p===-1&&f!==0||f<0||f>=d.length){P("ui.key",{key:t.shiftKey?"Shift+Tab":"Tab"});return}d[f].focus();return}if(!(t.metaKey||t.ctrlKey||t.altKey)&&!(c&&t.key.length!==1)){if(t.key==="Enter"){!o&&v!==null&&!N&&ae()&&(t.preventDefault(),ft(v,null));return}if(t.key.length===1){if(t.preventDefault(),!o&&v!==null&&!N&&ae()){ft(v,t.key);return}P("ui.typed",{grapheme:t.key})}}}};n.addEventListener("keydown",t=>mt(t,!1)),E?.addEventListener("keydown",t=>mt(t,!0));const Ue=t=>{y=t,document.body.dataset.size=t,t==="inline"&&(U(),x<2&&te(null),document.activeElement?.blur?.()),ke(),R()},gt=t=>{if(!(typeof t!="object"||t===null))for(const[o,c]of Object.entries(t))/^--[a-z0-9-]+$/.test(o)&&typeof c=="string"&&c.length<=200&&!/url\(/i.test(c)&&document.documentElement.style.setProperty(o,c)},An=t=>{const o=t.data;try{if(o===null||typeof o!="object"||o.p!==ie||o.v!==pe)return;if(typeof o.re=="string"){const d=Re.get(o.re);if(d===void 0)return;Re.delete(o.re);const p=typeof o.payload=="object"&&o.payload!==null?o.payload:{};o.ok===!0?d({ok:!0,payload:p}):d({ok:!1,error:o.error??{code:"unavailable",message:"no answer"},payload:p});return}if(Le!==null&&Le.dispatch(o))return;const c=typeof o.payload=="object"&&o.payload!==null?o.payload:{};switch(o.type){case"host.ping":typeof o.id=="string"&&k?.postMessage({p:ie,v:pe,re:o.id,ok:!0,payload:{}});return;case"host.size":(c.size==="inline"||c.size==="pane"||c.size==="full")&&Ue(c.size);return;case"host.theme":gt(c.theme);return;case"artifact.changed":{ce&&je();const d=c.version;typeof d=="number"&&d!==O&&(ee=ee??v,H(d));return}case"selection.cleared":Y=null,v!==null&&(v=null,U(),R());return;default:return}}catch{}};window.addEventListener("message",t=>{const o=t.data;if(k!==null||o===null||typeof o!="object"||o.p!==ie||o.type!=="host.hello"||t.ports[0]===void 0)return;k=t.ports[0],k.onmessage=An;const c=typeof o.payload=="object"&&o.payload!==null?o.payload:{};S=Array.isArray(c.grants)?c.grants.filter(p=>typeof p=="string"):[],gt(c.theme);const d=Xt(c);x=d.protocol,x>=2?(L=c.surface==="options"?"options":d.surface,Z=d.tab??"style",B=d.mode??"simple",Le=new Zt(k,{surface:(p,f)=>{L=p,f!==null&&(B=f),Ee()},mode:p=>(B=p,e.coverage?Ee():R(),B),tab:p=>{e.coverage&&(Z=p,Ee())},selection:p=>{const f=p.find(h=>typeof h=="object"&&h!==null&&h.kind==="element"&&typeof h.id=="string");L==="options"&&f!==void 0||(Y=f?.id??null,v=f!==void 0&&$?.widMap[f.id]!==void 0?f.id:null,v!==null&&e.coverage&&Ae(v),U(),R())}}),Ee()):Ue(d.size),H()});const bt=M("style");let We=null;const Ee=()=>{const t=L==="options",o=e.coverage&&t&&Z==="coverage",c=e.coverage&&L==="full"&&B==="advanced";e.coverage&&(document.body.dataset.coverage=c?"side":"",E!==null&&(E.hidden=!o&&!c),(o||c)&&(ye(),je())),bt.hidden=!t||o,n.hidden=t,t&&!o&&We===null&&(We=Qt(bt,{tokens:()=>fe,key:d=>P("ui.key",{key:d}),typed:d=>P("ui.typed",{grapheme:d}),apply:async d=>{for(let p=0;p<2;p+=1){if(O===null)return{ok:!1,reason:`The ${e.kind} is not loaded yet`};const f=await le("theme.set",{base:O,tokens:d});if(f.ok){const de=f.payload.version;return fe={name:d.name,colors:{...d.colors},fonts:{...d.fonts}},typeof de=="number"&&await H(de),{ok:!0}}if(f.error.code!=="head_moved")return{ok:!1,reason:f.error.message};const h=await le("artifact.read",{});if(!h.ok)return{ok:!1,reason:h.error.message||h.error.code};const T=h.payload.version;if(typeof T!="number"||O!==null&&T<O)return{ok:!1,reason:`The current ${e.kind} version could not be read.`};if(ze(h.payload),p===1)return{ok:!1,reason:f.error.message||f.error.code}}return{ok:!1,reason:`The ${e.kind} changed again: try once more`}}})),Ue(Wt(L))};Ht(e.editor,e.surfaces)}hn({editor:"wicked-doc",surfaces:{card:{interactive:!0,aspect:"16:9",actions:[{id:"ask",label:"Ask about this",verb:"host:ask"},{id:"export",label:"Export",verb:"host:export"}]},options:{tabs:[{id:"style",label:"Style",render:"plugin"},{id:"coverage",label:"Coverage",render:"plugin"}]},full:{modes:["simple","advanced"],default:"simple"}},kind:"document",coverage:!0})})();
163
163
  </script>
164
164
  </body>
165
165
  </html>
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "wicked-insights",
3
3
  "title": "Run insights",
4
- "version": "0.16.13",
4
+ "version": "0.16.15",
5
5
  "protocol": [
6
6
  1,
7
7
  2
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="wicked-editor" content="wicked-insights">
6
- <meta name="wicked-editor-version" content="0.16.13">
6
+ <meta name="wicked-editor-version" content="0.16.15">
7
7
  <title>Run insights</title>
8
8
  <style>
9
9
  /* The host's tokens arrive in host.hello / host.theme; these are plain fallbacks. */
@@ -65,7 +65,7 @@
65
65
  </style>
66
66
  </head>
67
67
  <body>
68
- <script>var wickedEditor=(function($){"use strict";var te=Object.defineProperty;var ne=($,y,A)=>y in $?te($,y,{enumerable:!0,configurable:!0,writable:!0,value:A}):$[y]=A;var U=($,y,A)=>ne($,typeof y!="symbol"?y+"":y,A);const y="wicked.editor",F=s=>typeof s=="object"&&s!==null&&!Array.isArray(s),G=["card","options","full"];function J(s){return s==="inline"?"card":s==="pane"?"options":"full"}function K(s){const e=F(s)?s:{},a=e.size==="inline"||e.size==="full"?e.size:"pane",c=e.protocol===2?2:1,p=c===2&&typeof e.tab=="string"?e.tab:null,u=c===2&&G.includes(e.surface)?e.surface:J(a),g=u==="options"&&p===null?"full":u,S=c===2&&(e.mode==="simple"||e.mode==="advanced")?e.mode:null;return{protocol:c,surface:g,tab:p,mode:S,size:a}}function Q(s,e,a){return{editor:s,version:e,protocol:[1,2],surfaces:a}}function X(s,e){const a=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:y,v:1,type:"plugin.ready",payload:Q(s,a,e)},"*")}class Y{constructor(e,a){U(this,"revs",new Map);this.port=e,this.h=a}reply(e,a){this.port.postMessage({p:y,v:1,re:e,ok:!0,payload:a})}refuse(e,a,c){this.port.postMessage({p:y,v:1,re:e,ok:!1,error:{code:a,message:c}})}bump(e){const a=(this.revs.get(e)??0)+1;return this.revs.set(e,a),a}values(e,a){this.port.postMessage({p:y,v:1,type:"options.values",payload:{tab:e,rev:this.bump(e),values:a}})}height(e){this.port.postMessage({p:y,v:1,type:"ui.height",payload:{px:Math.round(e)}})}dispatch(e){const a=F(e.payload)?e.payload:{},c=typeof e.id=="string"?e.id:null;switch(e.type){case"host.surface":{const p=a.surface;return(p==="card"||p==="options"||p==="full")&&this.h.surface?.(p,a.mode==="simple"||a.mode==="advanced"?a.mode:null),!0}case"host.mode":{if(c===null)return!0;const p=a.mode;return p!=="simple"&&p!=="advanced"?(this.refuse(c,"bad_request","mode is simple or advanced"),!0):(this.reply(c,{mode:this.h.mode?.(p)??p}),!0)}case"host.action":{if(c===null)return!0;const p=a.id;return typeof p!="string"||this.h.action===void 0?(this.reply(c,{handled:!1}),!0):(Promise.resolve(this.h.action(p)).then(u=>this.reply(c,{handled:u.handled===!0,...typeof u.status=="string"?{status:u.status.slice(0,120)}:{}}),()=>this.reply(c,{handled:!1})),!0)}case"host.tab":return typeof a.tab=="string"&&this.h.tab?.(a.tab),!0;case"host.selection":return Array.isArray(a.anchors)&&this.h.selection?.(a.anchors),!0;case"options.changed":{if(c===null)return!0;const p=a.tab,u=a.id;return typeof p!="string"||typeof u!="string"||this.h.optionsChanged===void 0?(this.refuse(c,"unsupported","no controls here"),!0):(Promise.resolve(this.h.optionsChanged(p,u,a.value)).then(g=>this.reply(c,{applied:g.applied,rev:this.bump(p),values:g.values,...g.reason!==void 0?{reason:g.reason.slice(0,120)}:{}}),g=>this.refuse(c,"unavailable",g instanceof Error?g.message.slice(0,120):"failed")),!0)}default:return!1}}}const Z={card:{interactive:!0,aspect:"auto",actions:[]},full:{}},ee={spend:"What a typical run cost, review by review",pass_rate:"Share of finished runs that passed",override_rate:"Share of runs where a person overrode a stop",wait_on_people:"How long a typical run waited on a person",unresolved_rate:"Share of runs nobody closed"},W=["spend","pass_rate","override_rate","wait_on_people","unresolved_rate"];function _(s,e){return e===null||!Number.isFinite(e)?"none":s==="ratio"?`${Math.round(e*100)}%`:s==="minutes"?e>=120?`${(e/60).toFixed(1)} h`:`${Math.round(e)} min`:s==="usd"?`$${e.toFixed(2)}`:e.toFixed(e%1===0?0:1)}const x=s=>new Date(s).toLocaleDateString(void 0,{month:"short",day:"numeric"});function t(s,e={},a){const c=document.createElement(s);for(const[p,u]of Object.entries(e))c.setAttribute(p,u);return a!==void 0&&(c.textContent=a),c}function M(s,e){const a=document.createElementNS("http://www.w3.org/2000/svg",s);for(const[c,p]of Object.entries(e))a.setAttribute(c,p);return a}function H(s,e){const g=M("svg",{viewBox:"0 0 300 96",role:"img"}),S=s.flatMap(o=>[o.value,o.lo,o.hi]).filter(o=>o!==null&&Number.isFinite(o));if(s.length===0||S.length===0)return g;const k=e==="ratio"?0:Math.min(...S),V=e==="ratio"?1:Math.max(...S),j=V-k||1,P=o=>s.length===1?344/2:44+o*246/(s.length-1),N=o=>86-(o-k)/j*64;for(const[o,b]of[[V,12],[k,94]]){const w=M("text",{class:"axis",x:"0",y:String(b)});w.textContent=_(e,o),g.append(w)}const C=s.map((o,b)=>({p:o,i:b})).filter(({p:o})=>o.lo!==null&&o.hi!==null);if(C.length>1){const o=C.map(({p:w,i:T})=>`${P(T)},${N(w.hi)}`),b=[...C].reverse().map(({p:w,i:T})=>`${P(T)},${N(w.lo)}`);g.append(M("polygon",{class:"band",points:[...o,...b].join(" ")}))}const O=s.map((o,b)=>({p:o,i:b})).filter(({p:o})=>o.value!==null);O.length>1&&g.append(M("polyline",{class:"line",points:O.map(({p:o,i:b})=>`${P(b)},${N(o.value)}`).join(" ")}));for(const{p:o,i:b}of O){const w=M("circle",{class:o.small?"pt small":"pt",cx:String(P(b)),cy:String(N(o.value)),r:"3.5","data-small":String(o.small)}),T=M("title",{});T.textContent=`${x(o.at)}: ${_(e,o.value)} from ${o.n} run${o.n===1?"":"s"}${o.small?", too few to tell":""}`,w.append(T),g.append(w)}return g}function q(){const s=t("main",{"data-testid":"insights-plugin"});document.body.prepend(s);let e=null,a=null,c=1,p=[],u=null,g=0,S=0,k=null,V=0,j=!1;const P=new Map,N=(n,l)=>e?.postMessage({p:y,v:1,type:n,payload:l}),C=(n,l)=>new Promise(h=>{if(e===null||j){h({ok:!1,error:{code:"unavailable",message:"No host here."}});return}const d=`wi-${++V}`,f=setTimeout(()=>{P.delete(d),h({ok:!1,error:{code:"timeout",message:"The host has not answered."}})},1e4);P.set(d,{resolve:h,timer:f}),e.postMessage({p:y,v:1,type:n,id:d,payload:l})}),O=n=>{k=n,p.includes("selection.chip")&&N("selection.set",{anchors:n===null?[]:[{kind:"element",id:n}]}),w()};function o(n){const l=t("details",{class:"why","data-testid":"insights-why"});l.append(t("summary",{},"Why we think this"));const h=t("ul");for(const d of n.why)h.append(t("li",{},d));if(n.runs.length>0){const d=[...new Set(n.runs)].slice(0,5);h.append(t("li",{},`Runs behind it: ${d.join("; ")}${n.runs.length>d.length?`; and ${n.runs.length-d.length} more`:""}.`))}return h.append(t("li",{},`What would change our mind: ${n.changeMind}`)),l.append(h),l}function b(n){const l=t("section",{"data-testid":"insights-review","aria-label":"Review"}),h=t("div");if(h.append(t("h1",{},"Run insights")),h.append(t("p",{class:"lede","data-testid":"insights-summary"},n.status==="completed"||n.status==="running"?n.sentence:`${n.sentence} ${n.error??""}`.trim())),n.summary!==null){const r=t("details",{class:"why"});r.append(t("summary",{},"The reviewer’s reading")),r.append(t("p",{},n.summary)),h.append(r)}l.append(h);const d=t("div",{class:"cols"}),f=t("section",{"data-testid":"insights-better","aria-label":"What got better"});f.append(t("h2",{},"What got better"));const i=t("ul",{class:"plain"});n.improvements.length===0&&i.append(t("li",{class:"muted"},n.status==="completed"?"Nothing changed enough to call it better.":"—"));for(const r of n.improvements)i.append(t("li",{class:"good"},r));f.append(i),d.append(f);const m=t("section",{"data-testid":"insights-recommendations","aria-label":"Could improve"});m.append(t("h2",{},"Could improve"));const v=t("ul",{class:"plain"});n.recommendations.length===0&&v.append(t("li",{class:"muted"},n.status==="completed"?"Nothing to change.":"—"));for(const r of n.recommendations){const E=t("li"),L=t("article",{class:"rec","data-testid":"insights-rec","data-anchor":r.anchor,"data-state":r.state,"aria-current":String(k===r.anchor)}),R=t("button",{type:"button",class:"pick","data-testid":"insights-rec-pick","aria-pressed":String(k===r.anchor)});R.append(t("span",{class:"t"},r.title)),R.append(t("span",{class:"say"},r.say)),R.append(t("span",{class:"effect"},`If done: ${r.effect}`)),R.addEventListener("click",()=>O(k===r.anchor?null:r.anchor)),L.append(R);const D=t("div",{class:"row"});D.append(t("span",{class:"chip","data-confidence":r.confidence.toLowerCase(),"data-testid":"insights-confidence"},r.confidence)),D.append(t("span",{class:"verb"},r.verb)),r.state!=="new"&&D.append(t("span",{class:"pill","data-state":r.state},r.state==="dismissed"?`Dismissed${r.reason!==null?`: ${r.reason}`:""}`:"Accepted")),L.append(D),L.append(o(r)),E.append(L),v.append(E)}if(m.append(v),n.recommendations.some(r=>r.state==="new")&&m.append(t("p",{class:"note"},"Pick one to accept or dismiss it.")),d.append(m),l.append(d),n.watching.length>0||n.regressions.length>0){const r=t("details",{class:"why watching","data-testid":"insights-watching"});r.append(t("summary",{},`Also watching (${n.watching.length+n.regressions.length})`));const E=t("ul",{class:"plain"});for(const L of n.watching)E.append(t("li",{},L.title));for(const L of n.regressions)E.append(t("li",{class:"muted"},L));r.append(E),l.append(r)}return l}function w(){if(s.replaceChildren(),u===null){s.append(t("p",{class:"muted"},"Reading the reviews…"));return}if(u.reviews.length===0){const d=t("div",{class:"empty","data-testid":"insights-empty"});d.append(t("h1",{},"Run insights")),d.append(t("p",{class:"lede"},u.running?"The first review is running now.":"No review has run yet. The first one runs on its schedule, or start it from Build & settings.")),s.append(d);return}const n=u.reviews[Math.min(S,u.reviews.length-1)];s.append(b(n));const l=t("section",{"data-testid":"insights-trends","aria-label":"Trends"});l.append(t("h2",{},"Trends")),l.append(t("p",{class:"note"},"One dot per review. The shaded band is the likely range; grey dots had too few runs to tell."));const h=t("div",{class:"trends"});for(const d of W){const f=u.metrics.find(E=>E.id===d),i=u.trends.find(E=>E.metric===d);if(f===void 0||i===void 0)continue;const m=i.points[i.points.length-1],v=t("div",{class:"chart","data-testid":"insights-trend","data-metric":d});v.append(t("div",{class:"t"},f.label)),v.append(t("div",{class:"v"},ee[d]??f.label));const r=H(i.points,f.unit);r.setAttribute("aria-label",`${f.label} across ${i.points.length} reviews`),v.append(r),v.append(t("div",{class:"v"},m===void 0?"No reviews yet":m.small?`Latest: too few runs to tell (${m.n})`:`Latest: ${_(f.unit,m.value)}, from ${m.n} runs`)),h.append(v)}if(l.append(h),s.append(l),u.reviews.length>1){const d=t("section",{class:"history","data-testid":"insights-history","aria-label":"Earlier reviews"});d.append(t("h2",{},"Earlier reviews"));const f=t("ul",{class:"plain"});u.reviews.forEach((i,m)=>{const v=t("button",{type:"button","data-testid":"insights-history-row","aria-current":String(m===S)});v.append(t("span",{},`${x(i.launchedAt)} · ${i.status==="completed"?`${i.totals?.runs??0} runs`:i.status}`));const r=i.recommendations.filter(L=>L.state!=="new").length;v.append(t("span",{class:"muted"},`${i.recommendations.length} to improve, ${r} decided`)),v.addEventListener("click",()=>{S=m,k=null,O(null)});const E=t("li");E.append(v),f.append(E)}),d.append(f),s.append(d)}n.footnote!==null&&s.append(t("p",{class:"note footnote","data-testid":"insights-footnote"},n.footnote))}async function T(){const n=await C("artifact.read",{});if(!n.ok||n.payload===void 0){s.replaceChildren(t("p",{class:"muted"},`The reviews could not be read: ${n.error?.message??"no answer"}.`));return}const l=n.payload.content;l?.type==="run-insights"&&(u=l,g=typeof n.payload.version=="number"?n.payload.version:g,w())}const z=n=>{if(!(typeof n!="object"||n===null))for(const[l,h]of Object.entries(n))/^--[a-z0-9-]+$/.test(l)&&typeof h=="string"&&h.length<=200&&!/url\(/i.test(h)&&document.documentElement.style.setProperty(l,h)};function I(){j=!0;for(const{timer:n,resolve:l}of P.values())clearTimeout(n),l({ok:!1,error:{code:"unavailable",message:"Closed."}});P.clear(),e?.close(),window.removeEventListener("message",B)}function B(n){const l=n.data;if(e!==null||l?.p!==y||l.v!==1||l.type!=="host.hello"||!n.ports[0])return;const h=K(l.payload),d=l.payload;c=h.protocol,p=Array.isArray(d.grants)?d.grants.filter(f=>typeof f=="string"):[],z(d.theme),e=n.ports[0],a=new Y(e,{selection(f){const i=f.find(m=>typeof m=="object"&&m!==null&&m.kind==="element");k=typeof i?.id=="string"?i.id:null,w()}}),e.onmessage=f=>{const i=f.data;if(i?.p!==y||i.v!==1)return;if(typeof i.re=="string"){const v=P.get(i.re);if(v===void 0)return;clearTimeout(v.timer),P.delete(i.re),v.resolve({ok:i.ok===!0,...i.payload!==void 0?{payload:i.payload}:{},...i.error===void 0?{}:{error:i.error}});return}if(c===2&&a?.dispatch(i))return;const m=i.payload??{};switch(i.type){case"host.ping":i.id&&e?.postMessage({p:y,v:1,re:i.id,ok:!0,payload:{}});break;case"host.theme":z(m.theme);break;case"artifact.changed":(typeof m.head!="number"||m.head>g)&&T();break;case"selection.cleared":k=null,w();break;case"host.teardown":I();break}},e.start(),w(),T()}window.addEventListener("message",B),window.addEventListener("pagehide",I,{once:!0}),w(),X("wicked-insights",Z)}return typeof window<"u"&&document.querySelector('meta[name="wicked-editor"][content="wicked-insights"]')!==null&&q(),$.TREND_METRICS=W,$.formatMetric=_,$.start=q,$.trendSvg=H,Object.defineProperty($,Symbol.toStringTag,{value:"Module"}),$})({});
68
+ <script>var wickedEditor=(function(b){"use strict";var ge=Object.defineProperty;var me=(b,M,O)=>M in b?ge(b,M,{enumerable:!0,configurable:!0,writable:!0,value:O}):b[M]=O;var ee=(b,M,O)=>me(b,typeof M!="symbol"?M+"":M,O);const M={"Alt+J":{verb:"navigate",what:"next card or row"},"Alt+K":{verb:"navigate",what:"previous card or row"},"Alt+/":{verb:"navigate",what:"the keyboard shortcuts overlay"},"Alt+P":{verb:"navigate",what:"peek at the top item that needs you"},"Alt+G":{verb:"navigate",what:"jump to the top item that needs you"},"Alt+B":{verb:"navigate",what:"back to where you were"},"Alt+T":{verb:"navigate",what:"the run’s evidence timeline"},"Alt+U":{verb:"navigate",what:"the run’s unit list"},"Alt+A":{verb:"approve",what:"approve the open gate"},"Alt+R":{verb:"decide",what:"reject the open gate"},"Alt+X":{verb:"decide",what:"select a gate for batch resolution"},"Alt+N":{verb:"compose",what:"compose a steer note"}},O=new Set(["Escape","Mod+K","Tab","Shift+Tab"]);function te(e){if(O.has(e))return!0;const t=M[ne(e)];return t!==void 0&&t.verb==="navigate"}function ne(e){const t=/^alt\+(.)$/i.exec(e);return t===null?e:`Alt+${t[1].toUpperCase()}`}function se(e){if(e===""||/[\u0000-\u001f\u007f]/.test(e))return!1;const t=Intl.Segmenter;return t!==void 0?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e)).length===1:Array.from(e).length===1}const $="wicked.editor",E=1,H=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ae=["card","options","full"];function oe(e){return e==="inline"?"card":e==="pane"?"options":"full"}function ie(e){const t=H(e)?e:{},a=t.size==="inline"||t.size==="full"?t.size:"pane",o=t.protocol===2?2:1,i=o===2&&typeof t.tab=="string"?t.tab:null,m=o===2&&ae.includes(t.surface)?t.surface:oe(a),d=m==="options"&&i===null?"full":m,L=o===2&&(t.mode==="simple"||t.mode==="advanced")?t.mode:null;return{protocol:o,surface:d,tab:i,mode:L,size:a}}function re(e,t,a){return{editor:e,version:t,protocol:[1,2],surfaces:a}}function le(e,t){const a=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:$,v:E,type:"plugin.ready",payload:re(e,a,t)},"*")}function z(e){return Array.from(e.querySelectorAll("button, a[href], input, select, textarea, summary, [tabindex]")).filter(t=>t.tabIndex>=0&&!t.matches(":disabled")&&t.closest("[hidden]")===null)}function ce(e,t,a){const o=e.metaKey||e.ctrlKey;let i=null;if(e.key==="Escape")i="Escape";else if(o&&!e.altKey&&e.key.toLowerCase()==="k")i="Mod+K";else if(e.altKey&&!o&&/^Key[A-Z]$/.test(e.code)&&te(`Alt+${e.code.slice(3)}`))i=`Alt+${e.code.slice(3)}`;else if(e.key==="Tab"){const m=z(t),d=m.indexOf(e.target);(e.shiftKey?d<=0:d===-1||d===m.length-1)&&(i=e.shiftKey?"Shift+Tab":"Tab")}return i===null?!1:(e.preventDefault(),e.stopPropagation(),a(i),!0)}function de(e,t,a){if(e.defaultPrevented)return!1;const o=e.target;if(e.key==="Tab"&&!(o instanceof HTMLElement&&z(t).includes(o)))return!1;if(ce(e,t,m=>a("ui.key",{key:m})))return!0;if(e.metaKey||e.ctrlKey||e.altKey||!se(e.key))return!1;const i=o?.closest("[contenteditable]");return o?.closest("input,textarea,select")||i&&i.getAttribute("contenteditable")!=="false"||e.key===" "&&o?.closest('button,summary,a[href],[role="button"],[tabindex]:not([tabindex="-1"])')?!1:(e.preventDefault(),e.stopPropagation(),a("ui.typed",{grapheme:e.key}),!0)}class pe{constructor(t,a){ee(this,"revs",new Map);this.port=t,this.h=a}reply(t,a){this.port.postMessage({p:$,v:E,re:t,ok:!0,payload:a})}refuse(t,a,o){this.port.postMessage({p:$,v:E,re:t,ok:!1,error:{code:a,message:o}})}bump(t){const a=(this.revs.get(t)??0)+1;return this.revs.set(t,a),a}values(t,a){this.port.postMessage({p:$,v:E,type:"options.values",payload:{tab:t,rev:this.bump(t),values:a}})}height(t){this.port.postMessage({p:$,v:E,type:"ui.height",payload:{px:Math.round(t)}})}dispatch(t){const a=H(t.payload)?t.payload:{},o=typeof t.id=="string"?t.id:null;switch(t.type){case"host.surface":{const i=a.surface;return(i==="card"||i==="options"||i==="full")&&this.h.surface?.(i,a.mode==="simple"||a.mode==="advanced"?a.mode:null),!0}case"host.mode":{if(o===null)return!0;const i=a.mode;return i!=="simple"&&i!=="advanced"?(this.refuse(o,"bad_request","mode is simple or advanced"),!0):(this.reply(o,{mode:this.h.mode?.(i)??i}),!0)}case"host.action":{if(o===null)return!0;const i=a.id;return typeof i!="string"||this.h.action===void 0?(this.reply(o,{handled:!1}),!0):(Promise.resolve(this.h.action(i)).then(m=>this.reply(o,{handled:m.handled===!0,...typeof m.status=="string"?{status:m.status.slice(0,120)}:{}}),()=>this.reply(o,{handled:!1})),!0)}case"host.tab":return typeof a.tab=="string"&&this.h.tab?.(a.tab),!0;case"host.selection":return Array.isArray(a.anchors)&&this.h.selection?.(a.anchors),!0;case"options.changed":{if(o===null)return!0;const i=a.tab,m=a.id;return typeof i!="string"||typeof m!="string"||this.h.optionsChanged===void 0?(this.refuse(o,"unsupported","no controls here"),!0):(Promise.resolve(this.h.optionsChanged(i,m,a.value)).then(d=>this.reply(o,{applied:d.applied,rev:this.bump(i),values:d.values,...d.reason!==void 0?{reason:d.reason.slice(0,120)}:{}}),d=>this.refuse(o,"unavailable",d instanceof Error?d.message.slice(0,120):"failed")),!0)}default:return!1}}}const ue={card:{interactive:!0,aspect:"auto",actions:[]},full:{}},he={spend:"What a typical run cost, review by review",pass_rate:"Share of finished runs that passed",override_rate:"Share of runs where a person overrode a stop",wait_on_people:"How long a typical run waited on a person",unresolved_rate:"Share of runs nobody closed"},I=["spend","pass_rate","override_rate","wait_on_people","unresolved_rate"];function F(e,t){return t===null||!Number.isFinite(t)?"none":e==="ratio"?`${Math.round(t*100)}%`:e==="minutes"?t>=120?`${(t/60).toFixed(1)} h`:`${Math.round(t)} min`:e==="usd"?`$${t.toFixed(2)}`:t.toFixed(t%1===0?0:1)}const q=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});function s(e,t={},a){const o=document.createElement(e);for(const[i,m]of Object.entries(t))o.setAttribute(i,m);return a!==void 0&&(o.textContent=a),o}function x(e,t){const a=document.createElementNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,i);return a}function B(e,t){const d=x("svg",{viewBox:"0 0 300 96",role:"img"}),L=e.flatMap(r=>[r.value,r.lo,r.hi]).filter(r=>r!==null&&Number.isFinite(r));if(e.length===0||L.length===0)return d;const C=t==="ratio"?0:Math.min(...L),T=t==="ratio"?1:Math.max(...L),W=T-C||1,P=r=>e.length===1?344/2:44+r*246/(e.length-1),k=r=>86-(r-C)/W*64;for(const[r,v]of[[T,12],[C,94]]){const A=x("text",{class:"axis",x:"0",y:String(v)});A.textContent=F(t,r),d.append(A)}const K=e.map((r,v)=>({p:r,i:v})).filter(({p:r})=>r.lo!==null&&r.hi!==null);if(K.length>1){const r=K.map(({p:A,i:R})=>`${P(R)},${k(A.hi)}`),v=[...K].reverse().map(({p:A,i:R})=>`${P(R)},${k(A.lo)}`);d.append(x("polygon",{class:"band",points:[...r,...v].join(" ")}))}const _=e.map((r,v)=>({p:r,i:v})).filter(({p:r})=>r.value!==null);_.length>1&&d.append(x("polyline",{class:"line",points:_.map(({p:r,i:v})=>`${P(v)},${k(r.value)}`).join(" ")}));for(const{p:r,i:v}of _){const A=x("circle",{class:r.small?"pt small":"pt",cx:String(P(v)),cy:String(k(r.value)),r:"3.5","data-small":String(r.small)}),R=x("title",{});R.textContent=`${q(r.at)}: ${F(t,r.value)} from ${r.n} run${r.n===1?"":"s"}${r.small?", too few to tell":""}`,A.append(R),d.append(A)}return d}function U(){const e=s("main",{"data-testid":"insights-plugin"});document.body.prepend(e);let t=null,a=null,o=1,i=0,m=[],d=null,L=0,C=0,T=null,W=0,P=!1;const k=new Map,K=(n,p)=>t?.postMessage({p:$,v:E,type:n,payload:p}),_=n=>{de(n,e,K)};document.addEventListener("keydown",_);const r=(n,p)=>new Promise(h=>{if(t===null||P){h({ok:!1,error:{code:"unavailable",message:"No host here."}});return}const u=`wi-${++W}`,f=setTimeout(()=>{k.delete(u),h({ok:!1,error:{code:"timeout",message:"The host has not answered."}})},1e4);k.set(u,{resolve:h,timer:f}),t.postMessage({p:$,v:E,type:n,id:u,payload:p})}),v=n=>{T=n,m.includes("selection.chip")&&K("selection.set",{anchors:n===null?[]:[{kind:"element",id:n}]}),D()};function A(n){const p=s("details",{class:"why","data-testid":"insights-why"});p.append(s("summary",{},"Why we think this"));const h=s("ul");for(const u of n.why)h.append(s("li",{},u));if(n.runs.length>0){const u=[...new Set(n.runs)].slice(0,5);h.append(s("li",{},`Runs behind it: ${u.join("; ")}${n.runs.length>u.length?`; and ${n.runs.length-u.length} more`:""}.`))}return h.append(s("li",{},`What would change our mind: ${n.changeMind}`)),p.append(h),p}function R(n){const p=s("section",{"data-testid":"insights-review","aria-label":"Review"}),h=s("div");if(h.append(s("h1",{},"Run insights")),h.append(s("p",{class:"lede","data-testid":"insights-summary"},n.status==="completed"||n.status==="running"?n.sentence:`${n.sentence} ${n.error??""}`.trim())),n.summary!==null){const c=s("details",{class:"why"});c.append(s("summary",{},"The reviewer’s reading")),c.append(s("p",{},n.summary)),h.append(c)}p.append(h);const u=s("div",{class:"cols"}),f=s("section",{"data-testid":"insights-better","aria-label":"What got better"});f.append(s("h2",{},"What got better"));const l=s("ul",{class:"plain"});n.improvements.length===0&&l.append(s("li",{class:"muted"},n.status==="completed"?"Nothing changed enough to call it better.":"—"));for(const c of n.improvements)l.append(s("li",{class:"good"},c));f.append(l),u.append(f);const g=s("section",{"data-testid":"insights-recommendations","aria-label":"Could improve"});g.append(s("h2",{},"Could improve"));const y=s("ul",{class:"plain"});n.recommendations.length===0&&y.append(s("li",{class:"muted"},n.status==="completed"?"Nothing to change.":"—"));for(const c of n.recommendations){const w=s("li"),S=s("article",{class:"rec","data-testid":"insights-rec","data-anchor":c.anchor,"data-state":c.state,"aria-current":String(T===c.anchor)}),N=s("button",{type:"button",class:"pick","data-testid":"insights-rec-pick","aria-pressed":String(T===c.anchor)});N.append(s("span",{class:"t"},c.title)),N.append(s("span",{class:"say"},c.say)),N.append(s("span",{class:"effect"},`If done: ${c.effect}`)),N.addEventListener("click",()=>v(T===c.anchor?null:c.anchor)),S.append(N);const j=s("div",{class:"row"});j.append(s("span",{class:"chip","data-confidence":c.confidence.toLowerCase(),"data-testid":"insights-confidence"},c.confidence)),j.append(s("span",{class:"verb"},c.verb)),c.state!=="new"&&j.append(s("span",{class:"pill","data-state":c.state},c.state==="dismissed"?`Dismissed${c.reason!==null?`: ${c.reason}`:""}`:"Accepted")),S.append(j),S.append(A(c)),w.append(S),y.append(w)}if(g.append(y),n.recommendations.some(c=>c.state==="new")&&g.append(s("p",{class:"note"},"Pick one to accept or dismiss it.")),u.append(g),p.append(u),n.watching.length>0||n.regressions.length>0){const c=s("details",{class:"why watching","data-testid":"insights-watching"});c.append(s("summary",{},`Also watching (${n.watching.length+n.regressions.length})`));const w=s("ul",{class:"plain"});for(const S of n.watching)w.append(s("li",{},S.title));for(const S of n.regressions)w.append(s("li",{class:"muted"},S));c.append(w),p.append(c)}return p}function D(){if(e.replaceChildren(),d===null){e.append(s("p",{class:"muted"},"Reading the reviews…"));return}if(d.reviews.length===0){const u=s("div",{class:"empty","data-testid":"insights-empty"});u.append(s("h1",{},"Run insights")),u.append(s("p",{class:"lede"},d.running?"The first review is running now.":"No review has run yet. The first one runs on its schedule, or start it from Build & settings.")),e.append(u);return}const n=d.reviews[Math.min(C,d.reviews.length-1)];e.append(R(n));const p=s("section",{"data-testid":"insights-trends","aria-label":"Trends"});p.append(s("h2",{},"Trends")),p.append(s("p",{class:"note"},"One dot per review. The shaded band is the likely range; grey dots had too few runs to tell."));const h=s("div",{class:"trends"});for(const u of I){const f=d.metrics.find(w=>w.id===u),l=d.trends.find(w=>w.metric===u);if(f===void 0||l===void 0)continue;const g=l.points[l.points.length-1],y=s("div",{class:"chart","data-testid":"insights-trend","data-metric":u});y.append(s("div",{class:"t"},f.label)),y.append(s("div",{class:"v"},he[u]??f.label));const c=B(l.points,f.unit);c.setAttribute("aria-label",`${f.label} across ${l.points.length} reviews`),y.append(c),y.append(s("div",{class:"v"},g===void 0?"No reviews yet":g.small?`Latest: too few runs to tell (${g.n})`:`Latest: ${F(f.unit,g.value)}, from ${g.n} runs`)),h.append(y)}if(p.append(h),e.append(p),d.reviews.length>1){const u=s("section",{class:"history","data-testid":"insights-history","aria-label":"Earlier reviews"});u.append(s("h2",{},"Earlier reviews"));const f=s("ul",{class:"plain"});d.reviews.forEach((l,g)=>{const y=s("button",{type:"button","data-testid":"insights-history-row","aria-current":String(g===C)});y.append(s("span",{},`${q(l.launchedAt)} · ${l.status==="completed"?`${l.totals?.runs??0} runs`:l.status}`));const c=l.recommendations.filter(S=>S.state!=="new").length;y.append(s("span",{class:"muted"},`${l.recommendations.length} to improve, ${c} decided`)),y.addEventListener("click",()=>{C=g,T=null,v(null)});const w=s("li");w.append(y),f.append(w)}),u.append(f),e.append(u)}n.footnote!==null&&e.append(s("p",{class:"note footnote","data-testid":"insights-footnote"},n.footnote))}async function V(){try{await fe()}finally{Z=!0,Q()}}async function fe(){const n=await r("artifact.read",{});if(!n.ok||n.payload===void 0){e.replaceChildren(s("p",{class:"muted"},`The reviews could not be read: ${n.error?.message??"no answer"}.`));return}const p=n.payload.content;p?.type==="run-insights"&&(d=p,L=typeof n.payload.version=="number"?n.payload.version:L,D())}const G=n=>{if(!(typeof n!="object"||n===null))for(const[p,h]of Object.entries(n))/^--[a-z0-9-]+$/.test(p)&&typeof h=="string"&&h.length<=200&&!/url\(/i.test(h)&&document.documentElement.style.setProperty(p,h)};function J(){P=!0;for(const{timer:n,resolve:p}of k.values())clearTimeout(n),p({ok:!1,error:{code:"unavailable",message:"Closed."}});k.clear(),t?.close(),Y?.disconnect(),document.removeEventListener("keydown",_),window.removeEventListener("message",X)}function X(n){const p=n.data;if(t!==null||p?.p!==$||p.v!==E||p.type!=="host.hello"||!n.ports[0])return;const h=ie(p.payload),u=p.payload;o=h.protocol,m=Array.isArray(u.grants)?u.grants.filter(f=>typeof f=="string"):[],G(u.theme),t=n.ports[0],a=new pe(t,{selection(f){const l=f.find(g=>typeof g=="object"&&g!==null&&g.kind==="element");T=typeof l?.id=="string"?l.id:null,D()}}),t.onmessage=f=>{const l=f.data;if(l?.p!==$||l.v!==E)return;if(typeof l.re=="string"){const y=k.get(l.re);if(y===void 0)return;clearTimeout(y.timer),k.delete(l.re),y.resolve({ok:l.ok===!0,...l.payload!==void 0?{payload:l.payload}:{},...l.error===void 0?{}:{error:l.error}});return}if(o===2&&a?.dispatch(l))return;const g=l.payload??{};switch(l.type){case"host.ping":l.id&&t?.postMessage({p:$,v:E,re:l.id,ok:!0,payload:{}});break;case"host.theme":G(g.theme);break;case"artifact.changed":(typeof g.head!="number"||g.head>L)&&V();break;case"selection.cleared":T=null,D();break;case"host.teardown":J();break}},t.start(),D(),V()}let Z=!1;function Q(){if(o!==2||a===null||!Z)return;const n=Math.round(e.getBoundingClientRect().height);n>0&&n!==i&&(i=n,a.height(n))}const Y=typeof ResizeObserver=="function"?new ResizeObserver(Q):null;Y?.observe(e),window.addEventListener("message",X),window.addEventListener("pagehide",J,{once:!0}),D(),le("wicked-insights",ue)}return typeof window<"u"&&document.querySelector('meta[name="wicked-editor"][content="wicked-insights"]')!==null&&U(),b.TREND_METRICS=I,b.formatMetric=F,b.start=U,b.trendSvg=B,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}),b})({});
69
69
  </script>
70
70
  </body>
71
71
  </html>
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "wicked-page",
3
3
  "title": "Page",
4
- "version": "0.16.13",
4
+ "version": "0.16.15",
5
5
  "protocol": [
6
6
  1,
7
7
  2