@pipeup/share 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pipeup+share.min.js +8 -8
- package/package.json +2 -2
package/dist/pipeup+share.min.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var Pipeup=(()=>{var gn=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var mr=Object.getOwnPropertyNames;var hr=Object.prototype.hasOwnProperty;var gr=(e,t)=>{for(var n in t)gn(e,n,{get:t[n],enumerable:!0})},vr=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of mr(t))!hr.call(e,r)&&r!==n&&gn(e,r,{get:()=>t[r],enumerable:!(o=fr(t,r))||o.enumerable});return e};var yr=e=>vr(gn({},"__esModule",{value:!0}),e);var ji={};gr(ji,{ADDON_API:()=>Et,ANIMALS:()=>Je,COLOURS:()=>zt,DEFAULT_PROFILE_NAME:()=>kn,IndexedDbStore:()=>pt,MemoryStore:()=>dt,PipeupDocument:()=>lt,UnsavedChangeError:()=>we,VERSION:()=>vt,addons:()=>Co,animalName:()=>me,copyAll:()=>jt,copyThread:()=>Yt,createIdentity:()=>Nt,describeElement:()=>_t,describeRange:()=>Ft,formatAgo:()=>Qe,labelOf:()=>Me,loadOrCreateProfile:()=>ct,locate:()=>qt,mount:()=>Yn,nameOf:()=>ce,newDocumentAttribute:()=>oo,onReveal:()=>Zo,parseDocumentAttribute:()=>Dt,resolveAnchor:()=>gt,setViewState:()=>Qo,use:()=>xt});function ve(e){let t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function He(e){let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}function jn(e=16){return ve(crypto.getRandomValues(new Uint8Array(e)))}function ye(e){return new TextEncoder().encode(e)}function Ge(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(Ge).join(",")+"]";let t=e;return"{"+Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>JSON.stringify(n)+":"+Ge(t[n])).join(",")+"}"}function De(e){return e.replace(/\s+/g," ").trim()}function Be(e){let t=De(e),n=2166136261;for(let o=0;o<t.length;o++)n^=t.charCodeAt(o),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}var wr=/^[A-Za-z0-9_-]{43}$/,br=512,Xe=new Map;async function Nt(){let e=await crypto.subtle.generateKey({name:"Ed25519"},!1,["sign","verify"]),t=new Uint8Array(await crypto.subtle.exportKey("raw",e.publicKey));return{publicKey:ve(t),privateKey:e.privateKey}}async function Rt(e,t){let n=await crypto.subtle.sign({name:"Ed25519"},e.privateKey,t);return ve(new Uint8Array(n))}async function Gn(e,t,n){if(!wr.test(e))return!1;try{if(ve(He(e))!==e)return!1;let o=Xe.get(e);if(!o){Xe.size>=br&&Xe.delete(Xe.keys().next().value),o=crypto.subtle.importKey("raw",He(e),{name:"Ed25519"},!0,["verify"]),Xe.set(e,o);let r=o;r.catch(()=>{Xe.get(e)===r&&Xe.delete(e)})}return await crypto.subtle.verify({name:"Ed25519"},await o,He(n),t)}catch{return!1}}var $t=1e4,xr=2**18,yn=2**40,wn=2**47,j={doc:64,path:2e3,snapshot:500,anchorId:200,quote:1e4,context:64,viewEntries:16,viewKey:64,viewValue:200},Er=/^[0-9a-f]{8}$/,vn=/^[A-Za-z0-9_-]{43}$/,kr=/^[A-Za-z0-9_-]{43}$/,Sr=new Set(["create","reply","edit","delete","resolve","reopen"]);async function Jn(e,t){if(e.author!==t.publicKey)throw new Error("pipeup: an op must be signed by its author");return{body:e,sig:await Rt(t,ye(Ge(e)))}}var Le=(e,t)=>typeof e=="string"&&e.length<=t,at=e=>!!e&&typeof e=="object",Xn=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1;function bn(e){if(!at(e))return!1;let{id:t,path:n,fingerprint:o,snapshot:r,quote:s,point:l,view:d}=e;if(!Le(n,j.path)||!Le(r,j.snapshot)||typeof o!="string"||!Er.test(o)||t!==void 0&&(!Le(t,j.anchorId)||t==="")||s!==void 0&&(!at(s)||!Le(s.exact,j.quote)||s.exact===""||!Le(s.prefix,j.context)||!Le(s.suffix,j.context))||l!==void 0&&(!at(l)||!Xn(l.x)||!Xn(l.y)))return!1;if(d!==void 0){if(!at(d)||Array.isArray(d))return!1;let m=Object.entries(d);if(m.length>j.viewEntries||!m.every(([u,v])=>u.length<=j.viewKey&&Le(v,j.viewValue)))return!1}return!0}function Qn(e){if(!at(e))return!1;let{body:t,sig:n}=e;if(typeof n!="string"||!at(t)||JSON.stringify({body:t,sig:n}).length>xr)return!1;let o=t;return!(o.v!==1||typeof o.id!="string"||!vn.test(o.id)||!Sr.has(o.kind)||!Le(o.doc,j.doc)||o.doc===""||typeof o.thread!="string"||!vn.test(o.thread)||typeof o.author!="string"||!kr.test(o.author)||typeof o.name!="string"||o.name.length>80||o.name!==o.name.trim()||typeof o.clock!="number"||!Number.isSafeInteger(o.clock)||o.clock<1||o.clock>yn||typeof o.at!="number"||!Number.isSafeInteger(o.at)||o.at<0||o.at>wn||o.text!==void 0&&(!Le(o.text,$t)||o.text!==o.text.trim())||o.target!==void 0&&(typeof o.target!="string"||!vn.test(o.target))||(o.kind==="create"||o.kind==="reply"||o.kind==="edit")&&!o.text||(o.kind==="reply"||o.kind==="edit"||o.kind==="delete")&&!o.target||o.kind==="create"&&(o.id!==o.thread||!bn(o.anchor)))}function Zn(e){return Gn(e.body.author,ye(Ge(e.body)),e.sig)}function eo(e,t){return e.body.clock!==t.body.clock?e.body.clock-t.body.clock:e.body.at!==t.body.at?e.body.at-t.body.at:e.body.author!==t.body.author?e.body.author<t.body.author?-1:1:e.body.id!==t.body.id?e.body.id<t.body.id?-1:1:0}function no(e){let t=new Map,n=new Map,o=new Map;for(let{body:r}of[...e].sort(eo)){if(r.name&&o.set(r.author,r.name),r.kind==="create"){if(t.has(r.id)||!r.anchor||r.text===void 0)continue;let d=to(r.id,r.author,r.name,r.text,r.at);t.set(r.id,{id:r.id,anchor:r.anchor,root:d,resolved:!1}),n.set(r.id,{comment:d,thread:r.id});continue}let s=t.get(r.thread);if(!s)continue;if(r.kind==="resolve"||r.kind==="reopen"){s.resolved=r.kind==="resolve";continue}let l=r.target?n.get(r.target):void 0;if(!(!l||l.thread!==r.thread)){if(r.kind==="reply"){if(n.has(r.id)||r.text===void 0)continue;let d=to(r.id,r.author,r.name,r.text,r.at);s.root.replies.push(d),n.set(r.id,{comment:d,thread:r.thread});continue}r.author!==l.comment.author||l.comment.deleted||(r.kind==="edit"&&r.text!==void 0&&(l.comment.text=r.text,l.comment.edited=!0),r.kind==="delete"&&(l.comment.text="",l.comment.deleted=!0))}}for(let{comment:r}of n.values())r.name||(r.unnamed=!0,r.name=o.get(r.author)??"");return[...t.values()]}function to(e,t,n,o,r){return{id:e,author:t,name:n,text:o,at:r,edited:!1,deleted:!1,replies:[]}}async function xn(e){let t={...e,id:void 0,thread:e.kind==="create"?void 0:e.thread},n=await crypto.subtle.digest("SHA-256",ye(Ge(t)));return ve(new Uint8Array(n))}var Ht=class{constructor(t){this.doc=t}ops=new Map;clock=0;createAt=new Map;threadAt=new Map;get size(){return this.ops.size}all(){return[...this.ops.values()]}threads(){return no(this.ops.values())}async add(t){let n=[];for(let o of t){if(!Qn(o)||o.body.doc!==this.doc||this.ops.has(o.body.id)||o.body.id!==await xn(o.body)||!await Zn(o))continue;let r={body:o.body,sig:o.sig};this.ops.set(r.body.id,r),this.clock=Math.max(this.clock,r.body.clock),r.body.kind==="create"&&this.createAt.set(r.body.author,Math.max(this.createAt.get(r.body.author)??0,r.body.at)),this.threadAt.set(r.body.thread,Math.max(this.threadAt.get(r.body.thread)??0,r.body.at)),n.push(r)}return n}async append(t,n,o){let r={v:1,...o,id:"",thread:o.kind==="create"?"":o.thread,doc:this.doc,author:t.publicKey,name:n,clock:Math.min(this.clock+1,yn),at:Math.min(Math.max(Date.now(),o.kind==="create"?(this.createAt.get(t.publicKey)??0)+1:(this.threadAt.get(o.thread)??0)+1),wn)};r.id=await xn(r);let s=this.ops.get(r.id);if(s)return s;r.kind==="create"&&(r.thread=r.id);let[l]=await this.add([await Jn(r,t)]);if(!l)throw new Error("pipeup: could not record this change");return l}};var Tr=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;function oo(){return`${jn(12)}:${ve(crypto.getRandomValues(new Uint8Array(32)))}`}async function Dt(e){let t=Tr.exec(e.trim()),n=t?.[1],o=t?.[2];if(!n||!o)throw new Error('pipeup: data-pipeup-doc must look like "<id>:<key>", as made by newDocumentAttribute()');let r=await crypto.subtle.importKey("raw",He(o),{name:"AES-GCM"},!1,["encrypt","decrypt"]);return{id:n,key:r}}async function ro(e,t,n){let o=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:o,additionalData:ye(n)},e,ye(t));return{iv:ve(o),data:ve(new Uint8Array(r))}}async function io(e,t,n){try{let o=await crypto.subtle.decrypt({name:"AES-GCM",iv:He(t.iv),additionalData:ye(n)},e,He(t.data));return new TextDecoder().decode(o)}catch{throw new Error("pipeup: this feedback could not be opened with this document")}}var Ar=5e6,so=e=>`pipeup-file:${e}`;async function ao(e,t,n){let o=n?{pipeup:1,doc:e,sealed:!0,...await ro(n,JSON.stringify(t),so(e))}:{pipeup:1,doc:e,sealed:!1,ops:t};return JSON.stringify(o,null,2)}async function lo(e,t,n){if(e.length>Ar)throw new Error("pipeup: this feedback file is too large");let o;try{o=JSON.parse(e)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}if(!o||typeof o!="object"||o.pipeup!==1||typeof o.doc!="string")throw new Error("pipeup: this is not an Pipeup feedback file");if(o.doc!==t)throw new Error("pipeup: this feedback is for a different document");if(!o.sealed)return Array.isArray(o.ops)?o.ops:[];if(!n)throw new Error("pipeup: this feedback is sealed, and this page has no document key");if(typeof o.iv!="string"||typeof o.data!="string")throw new Error("pipeup: this is not an Pipeup feedback file");let r;try{r=await io(n,{iv:o.iv,data:o.data},so(t))}catch{throw new Error("pipeup: this feedback could not be opened with this document's key")}let s;try{s=JSON.parse(r)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}return Array.isArray(s)?s:[]}var Lr=5e3,Mr=/^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/,co=80,we=class extends Error{constructor(n,o,r=1){super("pipeup: shown here, but not saved yet");this.id=n;this.cause=o;this.count=r;this.name="UnsavedChangeError"}},lt=class e{constructor(t,n){this.log=t;this.options=n;this.displayName=n.name.trim()?po(n.name):""}listeners=new Set;cache=[];comments=new Map;displayName;de=Promise.resolve();unsaved=[];static async open(t){if(typeof t.doc!="string"||t.doc===""||t.doc.length>j.doc)throw new Error(`pipeup: the document id must be 1 to ${j.doc} characters`);let n=new Ht(t.doc),o=await t.store.load(t.doc),r=o.length-(await n.add(o)).length;r&&console.warn(`pipeup: ${r} saved change${r===1?"":"s"} on this page couldn't be read; kept as saved`);let s=new e(n,t);return s.refresh(!1),s}get id(){return this.options.doc}get me(){return this.options.identity.publicKey}get name(){return this.displayName}set name(t){this.displayName=po(t),this.refresh(!0,[],"")}threads(){return this.cache}ops(){return this.log.all()}onChange(t){return this.listeners.add(t),()=>this.listeners.delete(t)}comment(t,n){return this.enqueue(()=>this.write({kind:"create",anchor:t,text:En(n)}))}reply(t,n){return this.enqueue(()=>this.write({kind:"reply",thread:this.find(t).thread,target:t,text:En(n)}))}edit(t,n){return this.enqueue(async()=>{let{thread:o}=this.mine(t);await this.write({kind:"edit",thread:o,target:t,text:En(n)})})}remove(t){return this.enqueue(async()=>{let{thread:n}=this.mine(t);await this.write({kind:"delete",thread:n,target:t})})}resolve(t){return this.enqueue(async()=>{await this.write({kind:"resolve",thread:this.thread(t)})})}reopen(t){return this.enqueue(async()=>{await this.write({kind:"reopen",thread:this.thread(t)})})}sign(t,n){if(!Mr.test(t))throw new Error('pipeup: a signing purpose looks like "<add-on id>/<name>"');return Rt(this.options.identity,ye(`pipeup:${t}
|
|
2
|
-
${n}`))}flush(){return this.enqueue(()=>this.persist())}exportFile(){return ao(this.options.doc,this.log.all(),this.options.key)}async importFile(t){return this.merge(await lo(t,this.options.doc,this.options.key),"file")}merge(t,n){return t.length>Lr?Promise.reject(new RangeError("pipeup: too many changes to merge at once")):this.enqueue(async()=>{let o=await this.log.add([...t]);this.unsaved.push(...o),o.length>0&&this.refresh(!0,o,n);try{await this.persist()}catch(r){throw o.length>0?new we(o[0].body.id,r,o.length):r}return o.length})}enqueue(t){let n=this.de.then(t);return this.de=n.catch(()=>{}),n}async write(t){let n=await this.log.append(this.options.identity,this.displayName,t);this.unsaved.push(n),this.refresh(!0,[n],"local");try{await this.persist()}catch(o){throw new we(n.body.id,o)}return n.body.id}async persist(){if(this.unsaved.length===0)return;let t=[...this.unsaved];await this.options.store.append(this.options.doc,t),this.unsaved=this.unsaved.filter(n=>!t.includes(n))}refresh(t,n=[],o=""){this.cache=this.log.threads(),this.comments.clear();let r=(s,l)=>{s.unnamed&&s.author===this.me&&this.displayName&&(s.name=this.displayName),this.comments.set(s.id,{comment:s,thread:l});for(let d of s.replies)r(d,l)};for(let s of this.cache)r(s.root,s.id);if(t)for(let s of this.listeners)try{s(this.cache,n,o)}catch(l){globalThis.reportError?.(l)}}find(t){let n=this.comments.get(t);if(!n)throw new Error("pipeup: there is no comment with that id");return n}mine(t){let n=this.find(t);if(n.comment.author!==this.me)throw new Error("pipeup: only the writer can change a comment");return n}thread(t){if(!this.cache.some(n=>n.id===t))throw new Error("pipeup: there is no thread with that id");return t}};function En(e){let t=e.trim();if(!t)throw new Error("pipeup: a comment needs some words");if(t.length>$t)throw new Error(`pipeup: comments are limited to ${$t} characters`);return t}function po(e){let t=e.replace(/\s+/g," ").trim();if(!t||t.length>co)throw new Error(`pipeup: choose a name of 1 to ${co} characters`);return t}var dt=class{docs=new Map;profile=null;async load(t){return[...this.docs.get(t)?.values()??[]]}async append(t,n){let o=this.docs.get(t);o||this.docs.set(t,o=new Map);for(let r of n)o.set(r.body.id,r)}async loadProfile(){return this.profile}async saveProfile(t){this.profile=t}async saveProfileIfAbsent(t){return this.profile||(this.profile=t),this.profile}},kn="",Cr="Reviewer";async function ct(e,t=kn){let n=await e.loadProfile();if(n)return n.name===Cr?{...n,name:""}:n;let o={identity:await Nt(),name:t};return e.saveProfileIfAbsent(o)}var pt=class e{constructor(t){this.db=t}static open(t="pipeup"){return new Promise((n,o)=>{let r=indexedDB.open(t,1);r.onupgradeneeded=()=>{let s=r.result;s.createObjectStore("ops",{keyPath:["doc","id"]}).createIndex("doc","doc"),s.createObjectStore("meta")},r.onsuccess=()=>{let s=r.result;s.onversionchange=()=>s.close(),n(new e(s))},r.onerror=()=>o(r.error??new Error("pipeup: could not open local storage"))})}close(){this.db.close()}async load(t){return(await this.request("ops","readonly",o=>o.index("doc").getAll(t))).map(o=>o.op)}async append(t,n){if(n.length===0)return;let o=this.db.transaction("ops","readwrite"),r=o.objectStore("ops"),s=uo(o);try{for(let l of n)r.put({doc:t,id:l.body.id,op:l})}catch(l){throw o.abort(),s.catch(()=>{}),l}await s}async loadProfile(){return await this.request("meta","readonly",t=>t.get("profile"))??null}async saveProfile(t){await this.request("meta","readwrite",n=>n.put(t,"profile"))}async saveProfileIfAbsent(t){let n=this.db.transaction("meta","readwrite"),o=n.objectStore("meta"),r=uo(n),s=t,l=o.get("profile");return l.onsuccess=()=>{l.result?s=l.result:o.put(t,"profile")},await r,s}request(t,n,o){return new Promise((r,s)=>{let l=o(this.db.transaction(t,n).objectStore(t));l.onsuccess=()=>r(l.result),l.onerror=()=>s(l.error??new Error("pipeup: local storage request failed"))})}};function uo(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??new Error("pipeup: local storage write failed")),e.onabort=()=>n(e.error??new Error("pipeup: local storage write aborted"))})}function mt(e){let n=(e.ownerDocument??e).createTreeWalker(e,NodeFilter.SHOW_TEXT),o=[],r="";for(let s=n.nextNode();s;s=n.nextNode())o.push({node:s,start:r.length}),r+=s.data;return{text:r,nodes:o}}function Sn(e,t,n){let r=(e.ownerDocument??e).createRange();return r.setStart(e,0),r.setEnd(t,n),r.toString().length}function Tn(e,t,n){let o=fo(e,t,!1),r=fo(e,n,!0);if(!o||!r||n<t)return null;let s=o.node.ownerDocument.createRange();return s.setStart(o.node,o.offset),s.setEnd(r.node,r.offset),s}function fo(e,t,n){let o=e.nodes.find(r=>t>=r.start&&t<r.start+r.node.data.length+Number(n));return o&&{node:o.node,offset:t-o.start}}var mo=32,go=200,Pr="p,li,h1,h2,h3,h4,h5,h6,td,th,blockquote,pre,figcaption,dt,dd,summary,caption";function vo(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function yo(e,t){for(let n=vo(e)?.closest("[data-pipeup-id]")??null;n;){if(!t.contains(n))return null;let o=n.getAttribute("data-pipeup-id")??"";if(o!==""&&o.length<=j.anchorId)return n;n=n.parentElement?.closest("[data-pipeup-id]")??null}return null}function Bt(e,t,n){return e.slice(t,n).replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"")}function Or(e,t){let n=Ir(e,t);if(n.length>j.path)throw new Error("pipeup: this element is nested too deeply to comment on \u2014 give a nearby container a data-pipeup-id");return n}function wo(e){if(!bn(e))throw new Error("pipeup: could not describe this place on the page");return e}function Vt(e,t){let n=vo(e),o=n?.closest(Pr)??null;return o&&t.contains(o)?o:n&&t.contains(n)?n:t}function Ir(e,t){if(e===t)return"";let n=[];for(let o=t;o&&o!==e;o=o.parentElement){let r=1;for(let s=o.previousElementSibling;s;s=s.previousElementSibling)s.tagName===o.tagName&&r++;n.unshift(`${o.tagName.toLowerCase()}:nth-of-type(${r})`)}return":scope > "+n.join(" > ")}function Ft(e,t,n){if(!t.contains(e.commonAncestorContainer))throw new Error("pipeup: the selection is outside the commentable area");let o=yo(e.commonAncestorContainer,t),r=o??t,{text:s}=mt(r),l=Sn(r,e.startContainer,e.startOffset),d=Sn(r,e.endContainer,e.endOffset),m=s.slice(l,d);if(m==="")throw new Error("pipeup: select some text to comment on");if(m.length>j.quote)throw new Error(`pipeup: selections are limited to ${j.quote} characters`);let u=Bt(s,Math.max(0,l-mo),l),v=Bt(s,d,d+mo);return wo({...o?{id:o.getAttribute("data-pipeup-id")??""}:{},path:"",quote:{exact:m,prefix:u,suffix:v},...n?{view:n}:{},fingerprint:Be(Vt(e.startContainer,t).textContent??""),snapshot:Bt(De(u+m+v),0,go)})}function _t(e,t,n,o){let r=yo(e,t);return wo({...r?{id:r.getAttribute("data-pipeup-id")??""}:{},path:Or(r??t,e),...n?{point:{x:ho(n.x),y:ho(n.y)}}:{},...o?{view:o}:{},fingerprint:Be(e.textContent??""),snapshot:Bt(De(e.textContent??""),0,go)})}function ho(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function bo(e,t,n){let o=Array.from({length:t.length+1},(l,d)=>d),r=[...o],s=[t.length];for(let l=1;l<=e.length;l++){r[0]=n?0:l;for(let d=1;d<=t.length;d++){let m=e.charCodeAt(l-1)===t.charCodeAt(d-1)?0:1;r[d]=Math.min(o[d]+1,r[d-1]+1,o[d-1]+m)}s.push(r[t.length]),[o,r]=[r,o]}return s}var Nr=(e,t)=>bo(e,t,!1).pop();function xo(e,t,n){let o=t.length;if(o===0)return null;let r=-1,s=1/0;if(bo(e,t,!0).forEach((m,u)=>{u&&m<s&&(s=m,r=u)}),s>n)return null;let l=Math.max(0,r-o),d=1/0;for(let m=Math.max(0,r-o-n);m<=Math.min(r,r-o+n);m++){let u=Nr(e.slice(m,r),t);u<d&&(d=u,l=m)}return{start:l,end:r,distance:d}}var ht={state:"orphaned",element:null,range:null},Rr=5e4,$r=300,Hr=12,Dr=":scope > ";function Br(e,t){for(let n of e.querySelectorAll("[data-pipeup-id]"))if(n.getAttribute("data-pipeup-id")===t)return n;return null}function gt(e,t,n={}){let o=e.id?Br(t,e.id):t;return e.quote?Fr(e,e.quote,o,t,n.fuzzy!==!1):Vr(e,o)}function Vr(e,t){if(!t)return ht;let n=t;if(e.path){if(!e.path.startsWith(Dr))return ht;try{n=t.querySelector(e.path)}catch{return ht}}return n?{state:Be(n.textContent??"")===e.fingerprint?"attached":"moved",element:n,range:null}:ht}function Fr(e,t,n,o,r){let s=n??o,l=mt(s),d=_r(l.text,t);if(d>=0){let m=Tn(l,d,d+t.exact.length);if(m){let u=Vt(m.startContainer,o);return{state:n!==null&&Be(u.textContent??"")===e.fingerprint?"attached":"moved",element:u,range:m}}}if(r){let m=s===o?l:mt(o);if(m.text.length<=Rr&&t.exact.length>=Hr&&t.exact.length<=$r){let u=xo(m.text,t.exact,Math.floor(t.exact.length/4)),v=u?Tn(m,u.start,u.end):null;if(v)return{state:"moved",element:Vt(v.startContainer,o),range:v}}}return ht}function _r(e,t){if(!t.exact)return-1;let n=-1,o=-1;for(let r=e.indexOf(t.exact);r!==-1;r=e.indexOf(t.exact,r+1)){let s=e.slice(Math.max(0,r-t.prefix.length),r),l=e.slice(r+t.exact.length,r+t.exact.length+t.suffix.length),d=qr(s,t.prefix)+Ur(l,t.suffix);d>o&&(n=r,o=d)}return n}function Ur(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function qr(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return n}var Kr={A:"Link",BUTTON:"Button",P:"Paragraph",LI:"List item",IMG:"Image",TABLE:"Table",TD:"Cell",TH:"Cell",FIGURE:"Figure",SVG:"Graphic",CANVAS:"Graphic",LABEL:"Label",INPUT:"Field",SELECT:"Field",TEXTAREA:"Field",SUMMARY:"Question",BLOCKQUOTE:"Quote",SECTION:"Section",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading"},zr=40;function Ut(e){return e.getAttribute("data-pipeup-label")||Kr[e.tagName.toUpperCase()]||"Block"}function Ln(e){return An(De(e.getAttribute("aria-label")??e.getAttribute("alt")??e.innerText??e.textContent??""),zr)}function Me(e){let t=e.getAttribute("data-pipeup-label");if(t)return t;let n=Ln(e);return n?`${Ut(e)} \xB7 ${n}`:Ut(e)}function qt(e,t,n){let o=e.id??null,r=e.quote?.exact??null,s=e.point?`${Math.round(e.point.x*100)}% across, ${Math.round(e.point.y*100)}% down the element`:null,l=t.element;if(t.state==="orphaned"||!l)return{where:`No longer on the page (it read: "${e.snapshot}")`,element:null,id:o,quote:r,pin:s};let d=[],m=e.view?.slide;if(m){let v=l.closest("[data-pipeup-slide]")?.querySelector("h1,h2,h3")?.textContent;d.push(`Slide ${m}`+(v?` "${An(De(v))}"`:""))}else{let v=Kt(e.view);v&&d.push(v);let x=Wr(l,n);x&&d.push(`Section "${An(De(x.textContent??""))}"`)}let u=Me(l);return d.push(u),{where:d.join(" \u203A "),element:u,id:o,quote:r,pin:s}}function Kt(e){return e?e.label||Object.entries(e).filter(([t,n])=>n&&t!=="slide").map(([,t])=>t).join(" \xB7 "):""}function Wr(e,t){let n=null;for(let o of t.querySelectorAll("h1,h2,h3")){if(o===e||o.contains(e))break;if(o.compareDocumentPosition(e)&4)n=o;else break}return n}function An(e,t=60){return e.length>t?e.slice(0,t-1)+"\u2026":e}var Je=["Otter","Fox","Owl","Bear","Rabbit"],zt=["Red","Orange","Yellow","Green","Teal","Blue","Purple","Pink","Brown","Grey"];function Eo(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),(t^t>>>16)>>>0}var Mn=e=>Eo(e)%Je.length,Cn=e=>Math.floor(Eo(e)/Je.length)%zt.length,me=e=>`${zt[Cn(e)]} ${Je[Mn(e)]}`,ce=e=>e.name||me(e.author);var Yr="Each thread says where it is: the slide or section, the element (its data-pipeup-id attribute in the HTML), and the exact quoted text or pin position. Work through the open threads in order, and for each one say what you changed or why you did not.";function Qe(e,t){let n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return"just now";let o=Math.round(n/60);if(o<60)return`${o}m ago`;let r=Math.round(o/60);return r<48?`${r}h ago`:`${Math.round(r/24)}d ago`}function Yt(e,t,n,o){return t==="ai"?ko(e,"## Comment thread",o,n):So(e)}function jt(e,t,n){let o=e.filter(d=>!d.thread.resolved);if(t==="text")return o.map(So).join(`
|
|
3
|
-
`);let r=e.length-o.length,s=[`# Review comments: ${ie(n.title)}`,"",`- **Page:** ${ie(n.url)}`,`- **Exported:** ${n.exportedAt.toISOString()}`,`- **Open threads:** ${o.length}${r?` (${r} resolved, not included)`:""}`,"",
|
|
4
|
-
`),l=n.exportedAt.getTime();return s+o.map((
|
|
5
|
-
`)}function ie(e){return e.replace(/\s+/g," ").trim()}function
|
|
1
|
+
"use strict";var Pipeup=(()=>{var wn=Object.defineProperty;var gr=Object.getOwnPropertyDescriptor;var vr=Object.getOwnPropertyNames;var yr=Object.prototype.hasOwnProperty;var wr=(e,t)=>{for(var n in t)wn(e,n,{get:t[n],enumerable:!0})},br=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of vr(t))!yr.call(e,r)&&r!==n&&wn(e,r,{get:()=>t[r],enumerable:!(o=gr(t,r))||o.enumerable});return e};var xr=e=>br(wn({},"__esModule",{value:!0}),e);var Qi={};wr(Qi,{ADDON_API:()=>Et,ANIMALS:()=>Qe,COLOURS:()=>Wt,DEFAULT_PROFILE_NAME:()=>An,IndexedDbStore:()=>pt,MemoryStore:()=>ct,PipeupDocument:()=>lt,UnsavedChangeError:()=>we,VERSION:()=>vt,addons:()=>$o,animalName:()=>me,copyAll:()=>Gt,copyThread:()=>jt,createIdentity:()=>$t,describeElement:()=>Ut,describeRange:()=>_t,formatAgo:()=>Ze,labelOf:()=>Me,loadOrCreateProfile:()=>dt,locate:()=>Kt,mount:()=>Qn,nameOf:()=>de,newDocumentAttribute:()=>lo,onReveal:()=>rr,parseDocumentAttribute:()=>Bt,resolveAnchor:()=>gt,setViewState:()=>or,use:()=>xt});function ve(e){let t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function De(e){let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}function Zn(e=16){return ve(crypto.getRandomValues(new Uint8Array(e)))}function ye(e){return new TextEncoder().encode(e)}function Xe(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(Xe).join(",")+"]";let t=e;return"{"+Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>JSON.stringify(n)+":"+Xe(t[n])).join(",")+"}"}function Be(e){return e.replace(/\s+/g," ").trim()}function Fe(e){let t=Be(e),n=2166136261;for(let o=0;o<t.length;o++)n^=t.charCodeAt(o),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}var Er=/^[A-Za-z0-9_-]{43}$/,kr=512,Je=new Map;async function $t(){let e=await crypto.subtle.generateKey({name:"Ed25519"},!1,["sign","verify"]),t=new Uint8Array(await crypto.subtle.exportKey("raw",e.publicKey));return{publicKey:ve(t),privateKey:e.privateKey}}async function Rt(e,t){let n=await crypto.subtle.sign({name:"Ed25519"},e.privateKey,t);return ve(new Uint8Array(n))}async function eo(e,t,n){if(!Er.test(e))return!1;try{if(ve(De(e))!==e)return!1;let o=Je.get(e);if(!o){Je.size>=kr&&Je.delete(Je.keys().next().value),o=crypto.subtle.importKey("raw",De(e),{name:"Ed25519"},!0,["verify"]),Je.set(e,o);let r=o;r.catch(()=>{Je.get(e)===r&&Je.delete(e)})}return await crypto.subtle.verify({name:"Ed25519"},await o,De(n),t)}catch{return!1}}var Ht=1e4,Sr=2**18,xn=2**40,En=2**47,G={doc:64,path:2e3,snapshot:500,anchorId:200,quote:1e4,context:64,viewEntries:16,viewKey:64,viewValue:200},Tr=/^[0-9a-f]{8}$/,bn=/^[A-Za-z0-9_-]{43}$/,Ar=/^[A-Za-z0-9_-]{43}$/,Lr=new Set(["create","reply","edit","delete","resolve","reopen"]);async function no(e,t){if(e.author!==t.publicKey)throw new Error("pipeup: an op must be signed by its author");return{body:e,sig:await Rt(t,ye(Xe(e)))}}var Le=(e,t)=>typeof e=="string"&&e.length<=t,at=e=>!!e&&typeof e=="object",to=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1;function kn(e){if(!at(e))return!1;let{id:t,path:n,fingerprint:o,snapshot:r,quote:s,point:l,view:c}=e;if(!Le(n,G.path)||!Le(r,G.snapshot)||typeof o!="string"||!Tr.test(o)||t!==void 0&&(!Le(t,G.anchorId)||t==="")||s!==void 0&&(!at(s)||!Le(s.exact,G.quote)||s.exact===""||!Le(s.prefix,G.context)||!Le(s.suffix,G.context))||l!==void 0&&(!at(l)||!to(l.x)||!to(l.y)))return!1;if(c!==void 0){if(!at(c)||Array.isArray(c))return!1;let m=Object.entries(c);if(m.length>G.viewEntries||!m.every(([u,g])=>u.length<=G.viewKey&&Le(g,G.viewValue)))return!1}return!0}function oo(e){if(!at(e))return!1;let{body:t,sig:n}=e;if(typeof n!="string"||!at(t)||JSON.stringify({body:t,sig:n}).length>Sr)return!1;let o=t;return!(o.v!==1||typeof o.id!="string"||!bn.test(o.id)||!Lr.has(o.kind)||!Le(o.doc,G.doc)||o.doc===""||typeof o.thread!="string"||!bn.test(o.thread)||typeof o.author!="string"||!Ar.test(o.author)||typeof o.name!="string"||o.name.length>80||o.name!==o.name.trim()||typeof o.clock!="number"||!Number.isSafeInteger(o.clock)||o.clock<1||o.clock>xn||typeof o.at!="number"||!Number.isSafeInteger(o.at)||o.at<0||o.at>En||o.text!==void 0&&(!Le(o.text,Ht)||o.text!==o.text.trim())||o.target!==void 0&&(typeof o.target!="string"||!bn.test(o.target))||(o.kind==="create"||o.kind==="reply"||o.kind==="edit")&&!o.text||(o.kind==="reply"||o.kind==="edit"||o.kind==="delete")&&!o.target||o.kind==="create"&&(o.id!==o.thread||!kn(o.anchor)))}function ro(e){return eo(e.body.author,ye(Xe(e.body)),e.sig)}function io(e,t){return e.body.clock!==t.body.clock?e.body.clock-t.body.clock:e.body.at!==t.body.at?e.body.at-t.body.at:e.body.author!==t.body.author?e.body.author<t.body.author?-1:1:e.body.id!==t.body.id?e.body.id<t.body.id?-1:1:0}function ao(e){let t=new Map,n=new Map,o=new Map;for(let{body:r}of[...e].sort(io)){if(r.name&&o.set(r.author,r.name),r.kind==="create"){if(t.has(r.id)||!r.anchor||r.text===void 0)continue;let c=so(r.id,r.author,r.name,r.text,r.at);t.set(r.id,{id:r.id,anchor:r.anchor,root:c,resolved:!1}),n.set(r.id,{comment:c,thread:r.id});continue}let s=t.get(r.thread);if(!s)continue;if(r.kind==="resolve"||r.kind==="reopen"){s.resolved=r.kind==="resolve";continue}let l=r.target?n.get(r.target):void 0;if(!(!l||l.thread!==r.thread)){if(r.kind==="reply"){if(n.has(r.id)||r.text===void 0)continue;let c=so(r.id,r.author,r.name,r.text,r.at);s.root.replies.push(c),n.set(r.id,{comment:c,thread:r.thread});continue}r.author!==l.comment.author||l.comment.deleted||(r.kind==="edit"&&r.text!==void 0&&(l.comment.text=r.text,l.comment.edited=!0),r.kind==="delete"&&(l.comment.text="",l.comment.deleted=!0))}}for(let{comment:r}of n.values())r.name||(r.unnamed=!0,r.name=o.get(r.author)??"");return[...t.values()]}function so(e,t,n,o,r){return{id:e,author:t,name:n,text:o,at:r,edited:!1,deleted:!1,replies:[]}}async function Sn(e){let t={...e,id:void 0,thread:e.kind==="create"?void 0:e.thread},n=await crypto.subtle.digest("SHA-256",ye(Xe(t)));return ve(new Uint8Array(n))}var Dt=class{constructor(t){this.doc=t}ops=new Map;clock=0;createAt=new Map;threadAt=new Map;get size(){return this.ops.size}all(){return[...this.ops.values()]}threads(){return ao(this.ops.values())}async add(t){let n=[];for(let o of t){if(!oo(o)||o.body.doc!==this.doc||this.ops.has(o.body.id)||o.body.id!==await Sn(o.body)||!await ro(o))continue;let r={body:o.body,sig:o.sig};this.ops.set(r.body.id,r),this.clock=Math.max(this.clock,r.body.clock),r.body.kind==="create"&&this.createAt.set(r.body.author,Math.max(this.createAt.get(r.body.author)??0,r.body.at)),this.threadAt.set(r.body.thread,Math.max(this.threadAt.get(r.body.thread)??0,r.body.at)),n.push(r)}return n}async append(t,n,o){let r={v:1,...o,id:"",thread:o.kind==="create"?"":o.thread,doc:this.doc,author:t.publicKey,name:n,clock:Math.min(this.clock+1,xn),at:Math.min(Math.max(Date.now(),o.kind==="create"?(this.createAt.get(t.publicKey)??0)+1:(this.threadAt.get(o.thread)??0)+1),En)};r.id=await Sn(r);let s=this.ops.get(r.id);if(s)return s;r.kind==="create"&&(r.thread=r.id);let[l]=await this.add([await no(r,t)]);if(!l)throw new Error("pipeup: could not record this change");return l}};var Mr=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;function lo(){return`${Zn(12)}:${ve(crypto.getRandomValues(new Uint8Array(32)))}`}async function Bt(e){let t=Mr.exec(e.trim()),n=t?.[1],o=t?.[2];if(!n||!o)throw new Error('pipeup: data-pipeup-doc must look like "<id>:<key>", as made by newDocumentAttribute()');let r=await crypto.subtle.importKey("raw",De(o),{name:"AES-GCM"},!1,["encrypt","decrypt"]);return{id:n,key:r}}async function co(e,t,n){let o=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:o,additionalData:ye(n)},e,ye(t));return{iv:ve(o),data:ve(new Uint8Array(r))}}async function po(e,t,n){try{let o=await crypto.subtle.decrypt({name:"AES-GCM",iv:De(t.iv),additionalData:ye(n)},e,De(t.data));return new TextDecoder().decode(o)}catch{throw new Error("pipeup: this feedback could not be opened with this document")}}var Cr=5e6,uo=e=>`pipeup-file:${e}`;async function fo(e,t,n){let o=n?{pipeup:1,doc:e,sealed:!0,...await co(n,JSON.stringify(t),uo(e))}:{pipeup:1,doc:e,sealed:!1,ops:t};return JSON.stringify(o,null,2)}async function mo(e,t,n){if(e.length>Cr)throw new Error("pipeup: this feedback file is too large");let o;try{o=JSON.parse(e)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}if(!o||typeof o!="object"||o.pipeup!==1||typeof o.doc!="string")throw new Error("pipeup: this is not an Pipeup feedback file");if(o.doc!==t)throw new Error("pipeup: this feedback is for a different document");if(!o.sealed)return Array.isArray(o.ops)?o.ops:[];if(!n)throw new Error("pipeup: this feedback is sealed, and this page has no document key");if(typeof o.iv!="string"||typeof o.data!="string")throw new Error("pipeup: this is not an Pipeup feedback file");let r;try{r=await po(n,{iv:o.iv,data:o.data},uo(t))}catch{throw new Error("pipeup: this feedback could not be opened with this document's key")}let s;try{s=JSON.parse(r)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}return Array.isArray(s)?s:[]}var Pr=5e3,Or=/^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/,ho=80,we=class extends Error{constructor(n,o,r=1){super("pipeup: shown here, but not saved yet");this.id=n;this.cause=o;this.count=r;this.name="UnsavedChangeError"}},lt=class e{constructor(t,n){this.log=t;this.options=n;this.displayName=n.name.trim()?go(n.name):""}listeners=new Set;cache=[];comments=new Map;displayName;ce=Promise.resolve();unsaved=[];static async open(t){if(typeof t.doc!="string"||t.doc===""||t.doc.length>G.doc)throw new Error(`pipeup: the document id must be 1 to ${G.doc} characters`);let n=new Dt(t.doc),o=await t.store.load(t.doc),r=o.length-(await n.add(o)).length;r&&console.warn(`pipeup: ${r} saved change${r===1?"":"s"} on this page couldn't be read; kept as saved`);let s=new e(n,t);return s.refresh(!1),s}get id(){return this.options.doc}get me(){return this.options.identity.publicKey}get name(){return this.displayName}set name(t){this.displayName=go(t),this.refresh(!0,[],"")}threads(){return this.cache}ops(){return this.log.all()}onChange(t){return this.listeners.add(t),()=>this.listeners.delete(t)}comment(t,n){return this.enqueue(()=>this.write({kind:"create",anchor:t,text:Tn(n)}))}reply(t,n){return this.enqueue(()=>this.write({kind:"reply",thread:this.find(t).thread,target:t,text:Tn(n)}))}edit(t,n){return this.enqueue(async()=>{let{thread:o}=this.mine(t);await this.write({kind:"edit",thread:o,target:t,text:Tn(n)})})}remove(t){return this.enqueue(async()=>{let{thread:n}=this.mine(t);await this.write({kind:"delete",thread:n,target:t})})}resolve(t){return this.enqueue(async()=>{await this.write({kind:"resolve",thread:this.thread(t)})})}reopen(t){return this.enqueue(async()=>{await this.write({kind:"reopen",thread:this.thread(t)})})}sign(t,n){if(!Or.test(t))throw new Error('pipeup: a signing purpose looks like "<add-on id>/<name>"');return Rt(this.options.identity,ye(`pipeup:${t}
|
|
2
|
+
${n}`))}flush(){return this.enqueue(()=>this.persist())}exportFile(){return fo(this.options.doc,this.log.all(),this.options.key)}async importFile(t){return this.merge(await mo(t,this.options.doc,this.options.key),"file")}merge(t,n){return t.length>Pr?Promise.reject(new RangeError("pipeup: too many changes to merge at once")):this.enqueue(async()=>{let o=await this.log.add([...t]);this.unsaved.push(...o),o.length>0&&this.refresh(!0,o,n);try{await this.persist()}catch(r){throw o.length>0?new we(o[0].body.id,r,o.length):r}return o.length})}enqueue(t){let n=this.ce.then(t);return this.ce=n.catch(()=>{}),n}async write(t){let n=await this.log.append(this.options.identity,this.displayName,t);this.unsaved.push(n),this.refresh(!0,[n],"local");try{await this.persist()}catch(o){throw new we(n.body.id,o)}return n.body.id}async persist(){if(this.unsaved.length===0)return;let t=[...this.unsaved];await this.options.store.append(this.options.doc,t),this.unsaved=this.unsaved.filter(n=>!t.includes(n))}refresh(t,n=[],o=""){this.cache=this.log.threads(),this.comments.clear();let r=(s,l)=>{s.unnamed&&s.author===this.me&&this.displayName&&(s.name=this.displayName),this.comments.set(s.id,{comment:s,thread:l});for(let c of s.replies)r(c,l)};for(let s of this.cache)r(s.root,s.id);if(t)for(let s of this.listeners)try{s(this.cache,n,o)}catch(l){globalThis.reportError?.(l)}}find(t){let n=this.comments.get(t);if(!n)throw new Error("pipeup: there is no comment with that id");return n}mine(t){let n=this.find(t);if(n.comment.author!==this.me)throw new Error("pipeup: only the writer can change a comment");return n}thread(t){if(!this.cache.some(n=>n.id===t))throw new Error("pipeup: there is no thread with that id");return t}};function Tn(e){let t=e.trim();if(!t)throw new Error("pipeup: a comment needs some words");if(t.length>Ht)throw new Error(`pipeup: comments are limited to ${Ht} characters`);return t}function go(e){let t=e.replace(/\s+/g," ").trim();if(!t||t.length>ho)throw new Error(`pipeup: choose a name of 1 to ${ho} characters`);return t}var ct=class{docs=new Map;profile=null;async load(t){return[...this.docs.get(t)?.values()??[]]}async append(t,n){let o=this.docs.get(t);o||this.docs.set(t,o=new Map);for(let r of n)o.set(r.body.id,r)}async loadProfile(){return this.profile}async saveProfile(t){this.profile=t}async saveProfileIfAbsent(t){return this.profile||(this.profile=t),this.profile}},An="",Ir="Reviewer";async function dt(e,t=An){let n=await e.loadProfile();if(n)return n.name===Ir?{...n,name:""}:n;let o={identity:await $t(),name:t};return e.saveProfileIfAbsent(o)}var pt=class e{constructor(t){this.db=t}static open(t="pipeup"){return new Promise((n,o)=>{let r=indexedDB.open(t,1);r.onupgradeneeded=()=>{let s=r.result;s.createObjectStore("ops",{keyPath:["doc","id"]}).createIndex("doc","doc"),s.createObjectStore("meta")},r.onsuccess=()=>{let s=r.result;s.onversionchange=()=>s.close(),n(new e(s))},r.onerror=()=>o(r.error??new Error("pipeup: could not open local storage"))})}close(){this.db.close()}async load(t){return(await this.request("ops","readonly",o=>o.index("doc").getAll(t))).map(o=>o.op)}async append(t,n){if(n.length===0)return;let o=this.db.transaction("ops","readwrite"),r=o.objectStore("ops"),s=vo(o);try{for(let l of n)r.put({doc:t,id:l.body.id,op:l})}catch(l){throw o.abort(),s.catch(()=>{}),l}await s}async loadProfile(){return await this.request("meta","readonly",t=>t.get("profile"))??null}async saveProfile(t){await this.request("meta","readwrite",n=>n.put(t,"profile"))}async saveProfileIfAbsent(t){let n=this.db.transaction("meta","readwrite"),o=n.objectStore("meta"),r=vo(n),s=t,l=o.get("profile");return l.onsuccess=()=>{l.result?s=l.result:o.put(t,"profile")},await r,s}request(t,n,o){return new Promise((r,s)=>{let l=o(this.db.transaction(t,n).objectStore(t));l.onsuccess=()=>r(l.result),l.onerror=()=>s(l.error??new Error("pipeup: local storage request failed"))})}};function vo(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??new Error("pipeup: local storage write failed")),e.onabort=()=>n(e.error??new Error("pipeup: local storage write aborted"))})}function mt(e){let n=(e.ownerDocument??e).createTreeWalker(e,NodeFilter.SHOW_TEXT),o=[],r="";for(let s=n.nextNode();s;s=n.nextNode())o.push({node:s,start:r.length}),r+=s.data;return{text:r,nodes:o}}function Ln(e,t,n){let r=(e.ownerDocument??e).createRange();return r.setStart(e,0),r.setEnd(t,n),r.toString().length}function Mn(e,t,n){let o=yo(e,t,!1),r=yo(e,n,!0);if(!o||!r||n<t)return null;let s=o.node.ownerDocument.createRange();return s.setStart(o.node,o.offset),s.setEnd(r.node,r.offset),s}function yo(e,t,n){let o=e.nodes.find(r=>t>=r.start&&t<r.start+r.node.data.length+Number(n));return o&&{node:o.node,offset:t-o.start}}var wo=32,xo=200,Nr="p,li,h1,h2,h3,h4,h5,h6,td,th,blockquote,pre,figcaption,dt,dd,summary,caption";function Eo(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function ko(e,t){for(let n=Eo(e)?.closest("[data-pipeup-id]")??null;n;){if(!t.contains(n))return null;let o=n.getAttribute("data-pipeup-id")??"";if(o!==""&&o.length<=G.anchorId)return n;n=n.parentElement?.closest("[data-pipeup-id]")??null}return null}function Ft(e,t,n){return e.slice(t,n).replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"")}function $r(e,t){let n=Rr(e,t);if(n.length>G.path)throw new Error("pipeup: this element is nested too deeply to comment on \u2014 give a nearby container a data-pipeup-id");return n}function So(e){if(!kn(e))throw new Error("pipeup: could not describe this place on the page");return e}function Vt(e,t){let n=Eo(e),o=n?.closest(Nr)??null;return o&&t.contains(o)?o:n&&t.contains(n)?n:t}function Rr(e,t){if(e===t)return"";let n=[];for(let o=t;o&&o!==e;o=o.parentElement){let r=1;for(let s=o.previousElementSibling;s;s=s.previousElementSibling)s.tagName===o.tagName&&r++;n.unshift(`${o.tagName.toLowerCase()}:nth-of-type(${r})`)}return":scope > "+n.join(" > ")}function _t(e,t,n){if(!t.contains(e.commonAncestorContainer))throw new Error("pipeup: the selection is outside the commentable area");let o=ko(e.commonAncestorContainer,t),r=o??t,{text:s}=mt(r),l=Ln(r,e.startContainer,e.startOffset),c=Ln(r,e.endContainer,e.endOffset),m=s.slice(l,c);if(m==="")throw new Error("pipeup: select some text to comment on");if(m.length>G.quote)throw new Error(`pipeup: selections are limited to ${G.quote} characters`);let u=Ft(s,Math.max(0,l-wo),l),g=Ft(s,c,c+wo);return So({...o?{id:o.getAttribute("data-pipeup-id")??""}:{},path:"",quote:{exact:m,prefix:u,suffix:g},...n?{view:n}:{},fingerprint:Fe(Vt(e.startContainer,t).textContent??""),snapshot:Ft(Be(u+m+g),0,xo)})}function Ut(e,t,n,o){let r=ko(e,t);return So({...r?{id:r.getAttribute("data-pipeup-id")??""}:{},path:$r(r??t,e),...n?{point:{x:bo(n.x),y:bo(n.y)}}:{},...o?{view:o}:{},fingerprint:Fe(e.textContent??""),snapshot:Ft(Be(e.textContent??""),0,xo)})}function bo(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function To(e,t,n){let o=Array.from({length:t.length+1},(l,c)=>c),r=[...o],s=[t.length];for(let l=1;l<=e.length;l++){r[0]=n?0:l;for(let c=1;c<=t.length;c++){let m=e.charCodeAt(l-1)===t.charCodeAt(c-1)?0:1;r[c]=Math.min(o[c]+1,r[c-1]+1,o[c-1]+m)}s.push(r[t.length]),[o,r]=[r,o]}return s}var Hr=(e,t)=>To(e,t,!1).pop();function Ao(e,t,n){let o=t.length;if(o===0)return null;let r=-1,s=1/0;if(To(e,t,!0).forEach((m,u)=>{u&&m<s&&(s=m,r=u)}),s>n)return null;let l=Math.max(0,r-o),c=1/0;for(let m=Math.max(0,r-o-n);m<=Math.min(r,r-o+n);m++){let u=Hr(e.slice(m,r),t);u<c&&(c=u,l=m)}return{start:l,end:r,distance:c}}var ht={state:"orphaned",element:null,range:null},Dr=5e4,Br=300,Fr=12,Vr=":scope > ";function _r(e,t){for(let n of e.querySelectorAll("[data-pipeup-id]"))if(n.getAttribute("data-pipeup-id")===t)return n;return null}function gt(e,t,n={}){let o=e.id?_r(t,e.id):t;return e.quote?qr(e,e.quote,o,t,n.fuzzy!==!1):Ur(e,o)}function Ur(e,t){if(!t)return ht;let n=t;if(e.path){if(!e.path.startsWith(Vr))return ht;try{n=t.querySelector(e.path)}catch{return ht}}return n?{state:Fe(n.textContent??"")===e.fingerprint?"attached":"moved",element:n,range:null}:ht}function qr(e,t,n,o,r){let s=n??o,l=mt(s),c=Kr(l.text,t);if(c>=0){let m=Mn(l,c,c+t.exact.length);if(m){let u=Vt(m.startContainer,o);return{state:n!==null&&Fe(u.textContent??"")===e.fingerprint?"attached":"moved",element:u,range:m}}}if(r){let m=s===o?l:mt(o);if(m.text.length<=Dr&&t.exact.length>=Fr&&t.exact.length<=Br){let u=Ao(m.text,t.exact,Math.floor(t.exact.length/4)),g=u?Mn(m,u.start,u.end):null;if(g)return{state:"moved",element:Vt(g.startContainer,o),range:g}}}return ht}function Kr(e,t){if(!t.exact)return-1;let n=-1,o=-1;for(let r=e.indexOf(t.exact);r!==-1;r=e.indexOf(t.exact,r+1)){let s=e.slice(Math.max(0,r-t.prefix.length),r),l=e.slice(r+t.exact.length,r+t.exact.length+t.suffix.length),c=Wr(s,t.prefix)+zr(l,t.suffix);c>o&&(n=r,o=c)}return n}function zr(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Wr(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return n}var Yr={A:"Link",BUTTON:"Button",P:"Paragraph",LI:"List item",IMG:"Image",TABLE:"Table",TD:"Cell",TH:"Cell",FIGURE:"Figure",SVG:"Graphic",CANVAS:"Graphic",LABEL:"Label",INPUT:"Field",SELECT:"Field",TEXTAREA:"Field",SUMMARY:"Question",BLOCKQUOTE:"Quote",SECTION:"Section",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading"},jr=40;function qt(e){return e.getAttribute("data-pipeup-label")||Yr[e.tagName.toUpperCase()]||"Block"}function Pn(e){return Cn(Be(e.getAttribute("aria-label")??e.getAttribute("alt")??e.innerText??e.textContent??""),jr)}function Me(e){let t=e.getAttribute("data-pipeup-label");if(t)return t;let n=Pn(e);return n?`${qt(e)} \xB7 ${n}`:qt(e)}function Kt(e,t,n){let o=e.id??null,r=e.quote?.exact??null,s=e.point?`${Math.round(e.point.x*100)}% across, ${Math.round(e.point.y*100)}% down the element`:null,l=t.element;if(t.state==="orphaned"||!l)return{where:`No longer on the page (it read: "${e.snapshot}")`,element:null,id:o,quote:r,pin:s};let c=[],m=e.view?.slide;if(m){let g=l.closest("[data-pipeup-slide]")?.querySelector("h1,h2,h3")?.textContent;c.push(`Slide ${m}`+(g?` "${Cn(Be(g))}"`:""))}else{let g=zt(e.view);g&&c.push(g);let E=Gr(l,n);E&&c.push(`Section "${Cn(Be(E.textContent??""))}"`)}let u=Me(l);return c.push(u),{where:c.join(" \u203A "),element:u,id:o,quote:r,pin:s}}function zt(e){return e?e.label||Object.entries(e).filter(([t,n])=>n&&t!=="slide").map(([,t])=>t).join(" \xB7 "):""}function Gr(e,t){let n=null;for(let o of t.querySelectorAll("h1,h2,h3")){if(o===e||o.contains(e))break;if(o.compareDocumentPosition(e)&4)n=o;else break}return n}function Cn(e,t=60){return e.length>t?e.slice(0,t-1)+"\u2026":e}var Qe=["Otter","Fox","Owl","Bear","Rabbit"],Wt=["Red","Orange","Yellow","Green","Teal","Blue","Purple","Pink","Brown","Grey"];function Lo(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),(t^t>>>16)>>>0}var On=e=>Lo(e)%Qe.length,In=e=>Math.floor(Lo(e)/Qe.length)%Wt.length,me=e=>`${Wt[In(e)]} ${Qe[On(e)]}`,de=e=>e.name||me(e.author);var Xr="Each thread says where it is: the slide or section, the element (its data-pipeup-id attribute in the HTML), and the exact quoted text or pin position. Work through the open threads in order, and for each one say what you changed or why you did not.";function Ze(e,t){let n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return"just now";let o=Math.round(n/60);if(o<60)return`${o}m ago`;let r=Math.round(o/60);return r<48?`${r}h ago`:`${Math.round(r/24)}d ago`}function jt(e,t,n,o){return t==="ai"?Mo(e,"## Comment thread",o,n):Co(e)}function Gt(e,t,n){let o=e.filter(c=>!c.thread.resolved);if(t==="text")return o.map(Co).join(`
|
|
3
|
+
`);let r=e.length-o.length,s=[`# Review comments: ${ie(n.title)}`,"",`- **Page:** ${ie(n.url)}`,`- **Exported:** ${n.exportedAt.toISOString()}`,`- **Open threads:** ${o.length}${r?` (${r} resolved, not included)`:""}`,"",Xr,"",""].join(`
|
|
4
|
+
`),l=n.exportedAt.getTime();return s+o.map((c,m)=>Mo(c,`## Thread ${m+1}`,l)).join(`
|
|
5
|
+
`)}function ie(e){return e.replace(/\s+/g," ").trim()}function Mo(e,t,n,o){let{thread:r,location:s}=e,l=r.root.replies.length,c=[`${t} \xB7 ${r.resolved?"resolved":"open"}`];if(c.push(`- **Thread:** ${r.id}`),o&&c.push(`- **Page:** ${ie(o)}`),c.push(`- **Where:** ${ie(s.where)}`),s.id){let m=ie(s.id.replace(/`/g,""));c.push(`- **Element:** \`[data-pipeup-id="${m}"]\`${s.element?` (${ie(s.element)})`:""}`)}s.quote&&c.push(`- **Quoted text:** "${ie(s.quote)}"`),s.pin&&c.push(`- **Pin:** ${ie(s.pin)}`),c.push(`- **Started by:** ${ie(de(r.root))}, ${Ze(r.root.at,n)}${l?` \xB7 ${l} ${l===1?"reply":"replies"}`:""}`,"",`**${ie(de(r.root))}** (${Ze(r.root.at,n)}): ${Yt(r.root," ")}`);for(let m of r.root.replies)c.push(`- **${ie(de(m))}** (${Ze(m.at,n)}): ${Yt(m," ")} <!-- comment:${m.id} -->`);return c.join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`}function
|
|
7
|
+
`}function Co(e){let{thread:t,location:n}=e,o=[ie(n.where)+(n.quote?`, on the text "${ie(n.quote)}"`:""),`${ie(de(t.root))}: ${Yt(t.root," ")}`];for(let r of t.root.replies)o.push(` ${ie(de(r))}: ${Yt(r," ")}`);return o.join(`
|
|
8
8
|
`)+`
|
|
9
|
-
`}function
|
|
10
|
-
`+t)+(e.edited?" (edited)":"")}var vt="0.5.0";function y(e,t={},...n){let o=document.createElement(e);for(let[r,s]of Object.entries(t))s===void 0||s===!1||(r==="class"?o.className=String(s):o.setAttribute(r,s===!0?"":s));for(let r of n)r!=null&&r!==!1&&o.append(r);return o}function Q(e,t){let n=e.getRootNode().activeElement;t&&n instanceof HTMLElement&&e.contains(n)&&n.blur(),e.inert=t}function Gt(e,t,n=null){let o=e.getRootNode().activeElement,r=!1;for(let s=t.length;s--;n=t[s])t[s].nextSibling!==n&&(r=!!e.insertBefore(t[s],n));return r&&o&&t.some(s=>s.contains(o))&&o.focus({preventScroll:!0}),r}var ut=()=>{let e=window.getSelection();return e&&!e.isCollapsed&&e.toString().trim()?e:null};function be(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}function Ve(e,t,n=4){e.style.left=`${t.left-n}px`,e.style.top=`${t.top-n}px`,e.style.width=`${t.width+n*2}px`,e.style.height=`${t.height+n*2}px`}var jr=/\bhttps?:\/\/[^\s<>"'`]+/gi,Gr=`.,;:!?'"]}`,Xr=2048,Jr=/[\u202A-\u202E\u2066-\u2069]/;function Qr(e){let t=0,n=0;for(let r of e)r==="("?t++:r===")"&&n++;let o=e.length;for(;o>0;){let r=e[o-1];if(r===")"&&n>t)n--;else if(!Gr.includes(r))break;o--}return e.slice(0,o)}function Xt(e){let t=[],n=0;for(let o of e.matchAll(jr)){if(o[0].length>Xr||Jr.test(o[0]))continue;let r=Qr(o[0]),s=o.index??0,l;try{let m=new URL(r);if(m.protocol!=="http:"&&m.protocol!=="https:")continue;l=m.href}catch{continue}s>n&&t.push(e.slice(n,s));let d=y("a",{href:l,target:"_blank",rel:"noopener noreferrer"},r);d.addEventListener("click",m=>m.stopPropagation()),t.push(d),n=s+r.length}return n<e.length&&t.push(e.slice(n)),t}var To="http://www.w3.org/2000/svg",Zr={comment:["M20.5 11.5a8 8 0 0 1-11.7 7.1L4 19.8l1.2-4.4A8 8 0 1 1 20.5 11.5z","M12.3 8.2v6.6M9 11.5h6.6"],send:["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],copy:["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],resolve:["M5 12.5l4.5 4.5L19 7.5"],reopen:["M3 12a9 9 0 1 0 3-6.7","M3 4v5h5"],lines:["M4 7h16M4 12h10M4 17h7"],list:["M3 6.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M3 12a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M3 17.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M9 6.5h11M9 12h11M9 17.5h7"],expand:["M14 4h6v6M20 4l-6 6M10 20H4v-6M4 20l6-6M20 14v6h-6M20 20l-6-6M4 10V4h6M4 4l6 6"],pin:["M6 18v-6a6 6 0 1 1 6 6z"],shrink:["M20 10h-6V4M14 10l6-6M4 14h6v6M10 14l-6 6M14 20v-6h6M14 14l6 6M10 4v6H4M10 10L4 4"],bubble:["M20.5 11.5a8 8 0 0 1-11.7 7.1L4 19.8l1.2-4.4A8 8 0 1 1 20.5 11.5z"],close:["M6 6l12 12M18 6L6 18"],edit:["M4 20h4L19 9l-4-4L4 16z"]};function Z(e,t=15,n){let o=Ce(Zr[e],t);return n&&o.setAttribute("stroke-width",String(n)),o}function Ce(e,t){let n=document.createElementNS(To,"svg"),o={width:String(t),height:String(t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"};for(let[r,s]of Object.entries(o))n.setAttribute(r,s);for(let r of e){let s=document.createElementNS(To,"path");s.setAttribute("d",r),n.append(s)}return n}var Jt=(e,t,n)=>`M${e} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 -${2*n} 0`,ei={Otter:"M4 13.2C4 9.2 7.6 6.5 12 6.5s8 2.7 8 6.7-3.6 6.3-8 6.3-8-2.3-8-6.3zM5.6 9.6a1.8 1.8 0 1 1 2.7-2.3M18.4 9.6a1.8 1.8 0 1 0-2.7-2.3M9.2 11.6h.01M14.8 11.6h.01M11 14h2l-1 1zM9.8 15.8l-3.2.4M9.9 17l-2.7 1.1M14.2 15.8l3.2.4M14.1 17l2.7 1.1",Fox:"M3.5 4l5 3.5h7l5-3.5-1.5 8.5L12 20l-7-7.5zM9 12h.01M15 12h.01M12 17h.01",Owl:`M5 4.5l3 2.5h8l3-2.5V14a7 7 0 0 1-14 0z${Jt(7.4,11.5,1.9)}${Jt(12.8,11.5,1.9)}M11.3 14.6l.7 1 .7-1`,Bear:`${Jt(5,13.5,7)}M8.9 7.22A2.8 2.8 0 1 0 5.89 10.09M18.11 10.09A2.8 2.8 0 1 0 15.1 7.22M9.4 12.6h.01M14.6 12.6h.01M10.3 16.4c0-1 .8-1.6 1.7-1.6s1.7.6 1.7 1.6-.8 1.6-1.7 1.6-1.7-.6-1.7-1.6z`,Rabbit:`${Jt(6.5,15.5,5.5)}M9.6 10.5C8.2 6.5 8.4 2.5 9.8 2.5s2.4 3.5 1.6 7.5M14.4 10.5c1.4-4 1.2-8-.2-8s-2.4 3.5-1.6 7.5M10 15h.01M14 15h.01M11.3 17.3l.7.5.7-.5`};function Ao(e){let t=/[\p{L}\p{N}]/u.exec(e);if(!t)return"";let n=t[0].toUpperCase();return[...n].length===1?n:t[0]}var yt=(e,t)=>Ao(t)||me(e);function Pe(e,t){return y("span",{class:`av c${Cn(e)}`,"aria-hidden":"true","data-animal":me(e)},Ao(t)||Ce([ei[Je[Mn(e)]]],24))}var ti=320;function Qt(e,t){setTimeout(()=>{e.remove(),t?.()},ti)}function Zt(e){return requestAnimationFrame(()=>{e.offsetWidth,e.classList.add("in")}),e}var Pn=null,On=e=>{Pn=e},Lo=()=>Pn?.note()??null,wt="pu-source";function en(e){let t=y("textarea",{class:"input",rows:"1","aria-label":e.label}),n=y("button",{class:"send",type:"button","aria-label":"Send",title:"Send",inert:!0},Z("send")),o=y("span",{class:"tools"});o.hidden=!0;let r=y("div",{class:"row"},e.before,t,o,n),s=e.kind??"comment",l=!1,d=new Set,m=()=>{for(let c of[...d])c()},u=()=>{let c=t.value.trim()!=="";n.classList.toggle("show",c),n.inert=!c,t.style.height="auto",t.style.height=`${Math.max(27,t.scrollHeight)}px`},v=()=>{let c=-1,k=0,L=(p,w)=>{c<0&&(c=t.selectionStart,k=0);let M=t.value.slice(0,c),P=p&&M&&!/\s$/.test(M)&&!/^\s/.test(p)?" ":"";t.setRangeText(P+p,c,c+k,"end"),k=P.length+p.length,w&&(c=-1),u()};return{update:p=>L(p,!1),commit:p=>L(p,!0),cancel:()=>{c>=0&&k&&t.setRangeText("",c,c+k,"end"),c=-1,k=0,u()}}},x=new Map,T=()=>{let c=(Pn?.tools()??[]).filter(k=>k.available?.()!==!1);for(let[k,L]of x)c.some(p=>p.id===k)||(L.remove(),x.delete(k));for(let k of c){if(x.has(k.id))continue;let L=y("button",{class:"ib tool",type:"button","aria-label":k.label,title:k.label,"aria-pressed":"false"},Ce(k.icon,15));L.addEventListener("mousedown",p=>p.preventDefault()),L.addEventListener("click",p=>{p.stopPropagation();try{k.press({kind:s,thread:e.thread?.()??null,text:()=>t.value,focus:()=>t.focus({preventScroll:!0}),connected:()=>r.isConnected,setPressed:w=>L.setAttribute("aria-pressed",String(w)),dictate:v,onEnd:w=>(d.add(w),()=>d.delete(w))})}catch(w){globalThis.reportError?.(w)}}),x.set(k.id,L),o.append(L)}o.hidden=x.size===0};T(),r.addEventListener(wt,T);let C=async()=>{let c=t.value.trim();if(!(!c||l)){l=!0;try{await e.F(c),n.matches(":focus")&&t.focus(),t.value="",u(),m()}catch{}finally{l=!1}}};return r.addEventListener("mousedown",c=>{c.target===t||n.contains(c.target)||o.contains(c.target)||(c.preventDefault(),t.focus({preventScroll:!0}),t.setSelectionRange(t.value.length,t.value.length))}),t.addEventListener("input",u),t.addEventListener("keydown",c=>{c.stopPropagation(),c.key==="Enter"&&!c.shiftKey&&!c.isComposing?(c.preventDefault(),C()):c.key==="Escape"&&(c.preventDefault(),t.value="",u(),t.blur(),m(),e._?.())}),n.addEventListener("click",c=>{c.stopPropagation(),C()}),{element:r,input:t,focus:()=>t.focus({preventScroll:!0})}}var Et=1,Mo=["sync","menu","notify","note","composer","panel","styles","status","overlay","here","sign"],ni=/^[a-z][a-z0-9-]{1,23}$/,oi=new Set(["local","file","page","user","pipeup","presence","sync"]),ri=1e4,tn=class{constructor(t,n,o){this.ctx=t;this.shadow=n;this.after=o;On({tools:()=>this.U,note:()=>[...this.X.values()].at(-1)??null})}G=0;R=[];X=new Map;J=new Map;U=[];Q=new Set;$=new Set;q=new Set;K=new Map;k=new Map;z=new Map;remote={n:0,who:new Set};last=0;timer=0;ce="";subscribe(t){return this.q.add(t),()=>void this.q.delete(t)}changed(t){t&&this.G++;for(let n of[...this.q])n(t);for(let n of this.ctx.t.querySelectorAll(".row, .draft"))n.dispatchEvent(new Event(wt))}H(t,n){let o=this.z.get(t)??this.z.set(t,new Set).get(t),r=()=>void(o.delete(r)&&n());return o.add(r),r}pe(){return[...this.J.values()].map(t=>t.text).join(" \xB7 ")}Ae(t,n){return this.R.push(n),this.changed(!0),{update:()=>this.changed(!1),remove:this.H(t,()=>{this.R.splice(this.R.indexOf(n),1),this.changed(!0)})}}ue(t,n,o){o?t.set(n,o):t.delete(n),this.changed(!1)}Le(t,n){return this.U.push(n),this.changed(!1),this.H(t,()=>{this.U.splice(this.U.indexOf(n),1),this.changed(!1)})}closed(){return this.ctx.state.hidden&&!this.ctx.state.c}Me(t,n){this.closed()?this.k.set(t,n):this.ctx.Z(n)}flush(){if(this.closed()||this.k.size===0)return;let t=[...this.k.values()].at(-1);this.k.clear(),this.ctx.Z(t)}Ce(){return this.shadow.activeElement instanceof HTMLTextAreaElement||[...this.ctx.t.querySelectorAll("textarea")].some(t=>t.value.trim()!=="")}Pe(t){this.ctx.state.hidden||this.ctx.w(t)}Oe(t,n){if(!(n==="local"||n==="")){for(let{body:o}of t)o.author===this.ctx.doc.me||o.kind!=="create"&&o.kind!=="reply"||(this.remote.n++,this.remote.who.add(o.name||me(o.author)));this.fe()}}fe(t=Math.max(0,this.last+ri-Date.now())){this.timer||!this.remote.n||(this.timer=window.setTimeout(()=>{if(this.timer=0,this.ctx.state.hidden||this.Ce())return this.fe(1e3);let{n,who:o}=this.remote;this.remote={n:0,who:new Set},this.last=Date.now(),this.ctx.w(`${n} new comment${n===1?"":"s"} from ${o.size===1?[...o][0]:`${o.size} people`}`)},t))}Ie(t){let n=this.K.get(t);return n||(n=y("div",{class:"ov","aria-hidden":"true","data-addon":t}),this.ctx.t.insertBefore(n,this.after.nextSibling),this.K.set(t,n)),n}Ne(t,n){let o=this.ctx.host.ownerDocument.defaultView?.CSSStyleSheet,r=o&&"replaceSync"in o.prototype&&"adoptedStyleSheets"in this.shadow?new o:null;r&&(r.replaceSync(n),this.shadow.adoptedStyleSheets=[...this.shadow.adoptedStyleSheets,r]);let s=r??this.shadow.appendChild(y("style",{},n));return this.H(t,()=>r?this.shadow.adoptedStyleSheets=this.shadow.adoptedStyleSheets.filter(l=>l!==r):s.remove())}he(t,n,o){return n.add(o),this.H(t,()=>n.delete(o))}Re(t,n){return this.he(t,this.Q,n)}$e(t,n){let o=this.he(t,this.$,n);return this.call(this.$,n,this.ge()),o}ge(){let{state:t}=this.ctx,n=this.shadow.activeElement;return{shown:!t.hidden,commentMode:t.l,allOpen:t.d,dark:this.ctx.t.classList.contains("dark"),view:this.ctx.p.view(),writing:n instanceof HTMLTextAreaElement?n.closest("[data-thread]")?.dataset.thread??"":null}}S(){for(let o of[...this.Q])this.call(this.Q,o);if(this.$.size===0)return;let t=this.ge(),n=JSON.stringify(t);if(n!==this.ce){this.ce=n;for(let o of[...this.$])this.call(this.$,o,t)}}call(t,n,...o){try{n(...o)}catch(r){t.delete(n),globalThis.reportError?.(r)}}He(t,n,o){let r=this.ctx.t,s=this.shadow.activeElement,l=y("button",{class:"ib",type:"button","aria-label":"Close"},Ce(["M6 6l12 12M18 6L6 18"],15)),d=y("div",{class:"xp",role:"dialog","aria-label":o.label,"data-addon":t},y("div",{class:"hd"},y("span",{},o.label),l),y("div",{class:"xb"},n)),m=[...r.children].filter(x=>x instanceof HTMLElement&&!x.inert);for(let x of m)x.inert=!0;r.append(d),d.offsetWidth,d.classList.add("show");let u=x=>{x.key==="Escape"&&(x.stopPropagation(),x.preventDefault(),v())},v=this.H(t,()=>{window.removeEventListener("keydown",u,!0);for(let x of m)x.inert=!1;d.classList.remove("show"),d.inert=!0,window.setTimeout(()=>d.remove(),300),s?.focus?.({preventScroll:!0});try{o.onClose?.()}catch(x){globalThis.reportError?.(x)}});return l.addEventListener("click",v),window.addEventListener("keydown",u,!0),(d.querySelector("button, input, textarea, select, a[href]")??d).focus?.({preventScroll:!0}),{close:v}}clear(t){for(let n of[...this.z.get(t)??[]])n();this.z.delete(t),this.K.get(t)?.remove(),this.K.delete(t);for(let n of[this.X,this.J,this.k])n.delete(t);this.changed(!0)}destroy(){window.clearTimeout(this.timer),On(null),this.q.clear()}},kt=new Map,bt=null,xe=(()=>{let e=globalThis.Pipeup;return e?.VERSION?e:null})();function Co(){return xe?xe.addons():[...kt.values()].map(e=>({...e.info}))}function xt(e){if(xe)return xe.use(e);let t=l=>console.warn(`pipeup: ${l}`),n=e;if(!n||typeof n!="object"||typeof n.id!="string"||!ni.test(n.id)||oi.has(n.id)||typeof n.setup!="function"||typeof n.network?.says!="string")return t("an add-on needs an id of 2 to 24 lowercase letters, digits and dashes (not a reserved one), a setup function and a network statement");if(kt.has(n.id))return t(`the add-on "${n.id}" is already registered; the second is ignored`);let o={id:n.id,version:String(n.version??""),network:n.network,state:"waiting"},r=(n.needs??[]).find(l=>!Mo.includes(l));n.api!==Et?(o.state="off",o.reason=`needs add-on API ${String(n.api)}; this Pipeup has ${Et}`):r&&(o.state="off",o.reason=`this Pipeup has no ${r} slot`);let s={addon:e,info:o};kt.set(n.id,s),bt?.i&&o.state==="waiting"&&Po(s,bt)}function nn(){if(xe)return!0;let e=globalThis,t=e.pipeupAddons;if(Array.isArray(t))for(let n of t)xt(n);else if(t&&typeof t=="object"&&t.push!==xt)return!1;return e.pipeupAddons={push:xt},!0}function ii(e){return e instanceof Error?e.message:String(e)}async function Po(e,t){let{addon:n,info:o}=e,r=new AbortController,s=new Set,{surface:l,doc:d}=t,m=()=>!r.signal.aborted,u=Object.assign(()=>{},{update(){},remove(){},close(){}}),v=p=>(...w)=>m()?p(...w):u,x={id:d.id,me:d.me,get name(){return d.name},threads:()=>d.threads(),ops:()=>d.ops(),onChange:p=>{let w=d.onChange(p);return s.add(w),()=>{w(),s.delete(w)}}},T=n.id,C={api:Et,version:t.version,document:x,root:t.root,ephemeral:t.ephemeral,signal:r.signal,has:p=>Mo.includes(p),off:p=>{k=String(p)},merge:p=>m()?d.merge(p,T):Promise.resolve(0),addMenuItem:v(p=>l.Ae(T,p)),notify:v(p=>l.Me(T,p)),announce:v(p=>l.Pe(p)),setComposerNote:v(p=>l.ue(l.X,T,p)),addComposerTool:v(p=>l.Le(T,p)),openPanel:v((p,w)=>l.He(T,p,w)),addStyles:v(p=>l.Ne(T,p)),setStatus:v(p=>l.ue(l.J,T,p)),overlay:()=>l.Ie(T),onFrame:v(p=>l.Re(T,p)),where:p=>l.ctx.p.view(p),isHere:p=>l.ctx.p.u(p),go:p=>l.ctx.p.W(p),onUi:v(p=>l.$e(T,p)),avatar:(p,w)=>{let M=Pe(p,w);return M.classList.add("in"),M},sign:(p,w)=>d.sign(`${T}/${p}`,w)},c,k,L=()=>{if(m()){r.abort();for(let p of[...s])p();try{c?.()}catch(p){globalThis.reportError?.(p)}l.clear(T),o.state==="on"&&(o.state="waiting")}};e.stop=L;try{if(c=await n.setup(C),!m()){c?.();return}if(k!==void 0){L(),o.state="off",o.reason=k;return}o.state="on",delete o.reason}catch(p){o.state="failed",o.reason=ii(p),L(),o.state="failed",globalThis.reportError?.(p)}}function Oo(e){let t={...e,i:!0};bt=t;for(let n of kt.values())n.info.state==="waiting"&&Po(n,t);return()=>{t.i=!1,bt===t&&(bt=null);for(let n of[...kt.values()].reverse())n.stop?.(),delete n.stop;e.surface.destroy()}}var si={code:"KeyC"},St=typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform)?"\u21E7\u2325C":"Shift+Alt+C",In="Shift+Alt+C";function Io(e){return e.code===si.code&&e.shiftKey&&e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.repeat&&!e.getModifierState("AltGraph")}function ai(e){let t=y("button",{class:"me",type:"button",tabindex:"-1","aria-hidden":"true"});t.addEventListener("mousedown",p=>p.preventDefault());let n=en({label:"Comment",kind:"comment",before:t,F:e.F,_:e._}),o=y("div",{class:"note"}),r=()=>{let p=Lo();o.textContent=p??"",o.hidden=!p};r();let s=y("div",{class:"say"}),l=y("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"}),d=y("div",{class:"nf"},l),m=y("div",{class:"you"},s,d),u="",v=!1,x=()=>{let p=e.name(),w=p?"change":"add your name";if(t.title=p?"Change your name":"Add your name",!t.lastChild||u!==p){let P=Pe(e.me,p),b=t.lastChild;b?(Zt(P),Qt(b)):P.classList.add("in"),t.append(P),u=p}let M=y("button",{type:"button"},w);M.addEventListener("click",C),s.replaceChildren(y("span",{class:"nm"},p||`You're ${me(e.me)}`)," \xB7 ",M)},T=p=>{m.classList.toggle("naming",p),Q(s,p),Q(d,!p)};function C(p){p.stopPropagation(),l.value=e.name(),T(!0),l.focus({preventScroll:!0}),l.select()}let c=()=>{T(!1),n.focus()};t.addEventListener("click",C),l.addEventListener("keydown",p=>{if(p.stopPropagation(),p.key==="Escape")p.preventDefault(),c();else if(p.key==="Enter"){p.preventDefault();let w=l.value.trim();if(!w||w===e.name())return c();if(v)return;v=!0,e.rename(w).finally(()=>{v=!1,x(),c()})}}),x(),T(!1);let k=y("div",{class:"ctx"},e.label),L=y("div",{class:"draft"},k,o,n.element,m);return L.addEventListener(wt,r),{element:L,ve:()=>{let{selectionStart:p,selectionEnd:w}=n.input;return()=>{n.focus(),n.input.setSelectionRange(p,w)}},ee:p=>{k.hidden=p},ye:p=>{k.textContent=p},focus:()=>n.focus(),De:()=>n.input.value.trim()===""}}function on(e,t){let n=ai({label:t.label,me:e.doc.me,name:()=>e.c.name(),rename:o=>e.c.rename(o),F:o=>e.Be(o),_:()=>e.Ve()});return e.D(n),n}function rn(e,t){if(t.state==="orphaned"||!t.element||e.quote)return null;let n=t.element.getBoundingClientRect();if(!n.width&&!n.height)return null;if(e.point)return{x:n.left+e.point.x*n.width,y:n.top+e.point.y*n.height};let o=t.element.ownerDocument.createRange();o.selectNodeContents(t.element);let r=o.getBoundingClientRect();return{x:r.width?Math.min(n.right-8,r.right+6):n.right-8,y:(r.height?r.top:n.top)+8}}function Tt(e){return e.range?[...e.range.getClientRects()]:[]}function Nn(e,t){let n=Tt(t)[0];if(n)return n.top;if(t.state==="orphaned"||!t.element)return null;let o=t.element.getBoundingClientRect();return e.point?o.top+e.point.y*o.height:o.top}function At(e,t){let n=Tt(t).at(-1);if(n)return{x:n.left,y:n.bottom,below:!0};let o=rn(e,t);return o?{...o,below:!1}:null}function No(e,t,n){for(let o of n)if(e>=o.left&&e<=o.right&&t>=o.top&&t<=o.bottom)return!0;return!1}function Ro(e,t,n=10){let o=[...e].sort((d,m)=>d.T-m.T),r=new Array(o.length).fill(0),s=o.findIndex(d=>d.id===t),l=d=>o[d];if(s<0)o.forEach((d,m)=>{r[m]=m===0?d.T:Math.max(d.T,(r[m-1]??0)+l(m-1).height+n)});else{r[s]=l(s).T;for(let d=s+1;d<o.length;d++)r[d]=Math.max(l(d).T,(r[d-1]??0)+l(d-1).height+n);for(let d=s-1;d>=0;d--)r[d]=Math.min(l(d).T,(r[d+1]??0)-l(d).height-n)}return new Map(o.map((d,m)=>[d.id,r[m]??0]))}var Lt=320,Ze=300,li=480,et=()=>window.innerWidth<=li;function sn(e){let t=window.innerWidth;return{width:e&&!et()?t-Lt:t,height:window.innerHeight}}function an(e,t,n,o=12){let r,s;return e.below?(r=Math.min(e.x,n.width-t.width-o),s=e.y+8,s+t.height>n.height-o&&(s=e.y-t.height-40)):(r=e.x+14,r+t.width>n.width-o&&(r=e.x-t.width-28),s=Math.min(e.y-12,n.height-t.height-o)),{left:Math.max(o,r),top:Math.max(o,s)}}function $o(e,t,n,o=12,r=44){let s=e.top-r>=8,l=e.top+e.height+8+(s?0:r),d=e.top-8-(s?r:0)-t.height,m=l+t.height<=n.height-o||d<o,u=m?l:d;return{above:!m,left:Math.max(o,Math.min(e.left,n.width-t.width-o)),top:Math.max(o,u)}}function ln(e,t,n){let o=e.top-t.height-10;return o<8&&(o=e.top+e.height+10),{left:Math.max(8,Math.min(e.left+e.width/2-t.width/2,n.width-t.width-8)),top:o}}function dn(e,t){let n=e.resolved.get(t.id);return n?.range?.startContainer??n?.element??null}var Fe=e=>(t,n)=>{let o=dn(e,t),r=dn(e,n),s=l=>l.anchor.point??{x:0,y:-1};return o!==r?!r||o&&o.compareDocumentPosition(r)&4?-1:1:s(t).y-s(n).y||s(t).x-s(n).x};var cn=e=>`${e} ${e===1?"reply":"replies"}`;function ft(e,t,n){let o={...n},r=e.id,s=y("div",{class:"rbox always"},y("div",{},en({label:"Reply",kind:"reply",thread:()=>r,F:p=>t.reply(r,p),_:t.close}).element)),l=y("div",{}),d=y("span",{class:"note"},"This thread was resolved. Your words are kept until you send or clear them.");d.hidden=!0,s.prepend(d);let m=y("div",{}),u=null,v=y("div",{},m,y("div",{class:"more"},l)),x=new Map,T=new Map,C=new Map,c=p=>{let w=yt(p.author,p.name),M=x.get(p.id),P=M?.e;if((!P||M.key!==w)&&(P=Zt(Pe(p.author,p.name)),M)){let H=M.e;C.set(p.id,H),Qt(H,()=>C.get(p.id)===H&&C.delete(p.id))}P.title=ce(p),T.set(p.id,{key:w,e:P});let b=C.get(p.id);return b?[b,P]:[P]},k=(p,w,M)=>{let P=y("button",{class:"ib",type:"button","aria-label":w,title:w},Z(p));return P.addEventListener("click",b=>{b.stopPropagation(),M()}),P};function L(p,w={}){Object.assign(o,w),r=p.id;let M=(o.now??Date.now)(),P=p.root.replies.length,b=K=>y("span",{class:"who"},`${ce(K)} \xB7 ${Qe(K.at,M)}`),H=K=>y("div",{class:K.deleted?"tx del":"tx"},...K.deleted?["Deleted"]:[...Xt(K.text),K.edited?" (edited)":""]),_=p.resolved?"Resolved"+(P?` \xB7 ${cn(P)}`:""):P?cn(P):"",V=y("div",{class:o.Y==="column"&&_?"ft has-rest":"ft"},o.Y==="column"&&_?y("span",{class:"rest"},_):null,y("span",{class:"hover"},b(p.root),y("span",{class:"acts"},k("copy","Copy thread",()=>t.copy(p.id)),p.resolved?k("reopen","Reopen",()=>void t.reopen(p.id)):k("resolve","Resolve",()=>void t.resolve(p.id))))),q=o.lost?y("div",{class:"ctx"},`${o.place||"No longer on the page"} \u2014 it read \u201C${be(o.lost,120)}\u201D`):o.quote?y("div",{class:"ctx"},`\u201C${be(o.quote,80)}\u201D`):null;T=new Map;let J=y("div",{class:"root"},...c(p.root),q,H(p.root),V);m.replaceWith(J),m=J,u?.remove(),u=P?y("div",{class:"rps"},...p.root.replies.map(K=>y("div",{class:"it"},...c(K),H(K),y("div",{class:"rft"},b(K))))):null,u&&l.prepend(u),x=T;let D=s.querySelector("textarea").value.trim()!=="";d.hidden=!(p.resolved&&D),p.resolved&&!D?s.remove():s.parentNode!==l&&l.append(s),v.className=p.resolved?"thread resolved":"thread",v.setAttribute("data-thread",p.id)}return L(e),{element:v,update:L}}var di="a,button,input,select,textarea,label,summary,[role=button],[contenteditable]",ci=400;function Rn(e,t){let n=new Map,o=y("div",{class:"tip",role:"tooltip"}),r=y("div",{class:"mark"}),s=y("div",{class:"pop",role:"dialog","aria-label":"Comment thread"});o.inert=s.inert=!0,e.t.append(r,o,s);let l=y("div",{class:"bub pin ghost","aria-hidden":"true"}),d=[],m=null,u=null,v=null,x=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,T=0,C=null,c=null,k=null,L=0,p=A=>d.find(N=>N.id===A)??null,w=()=>t.te||e.state.d,M=!1,P=A=>{let N=e.resolved.get(A.id);return N?At(A.anchor,N):null};function b(A,N,$){let{left:B,top:z}=an(N,{width:A.offsetWidth||$,height:A.offsetHeight},sn(e.state.d));A.style.left=`${B}px`,A.style.top=`${z}px`}function H(A){let N=A&&w()&&e.state.i!==A?p(A):null,$=N?P(N):null;if(!N||!$){k=null,o.classList.remove("show"),Q(o,!0);return}if(k!==N.id){let B=N.root.replies.length;o.replaceChildren(y("div",{class:"tx clamp"},...N.root.deleted?["Deleted"]:Xt(N.root.text)),y("div",{class:"who"},`${ce(N.root)}${B?` \xB7 ${B} ${B===1?"reply":"replies"}`:""}`)),k=N.id}b(o,$,260),o.classList.contains("show")||o.offsetWidth,o.classList.add("show"),o.inert=!1}function _(A){C=A,H(A),e.L(A)}function V(A){if(window.clearTimeout(L),A!==null){_(A);return}L=window.setTimeout(()=>_(null),w()?ci:0)}o.addEventListener("mouseenter",()=>window.clearTimeout(L)),o.addEventListener("mouseleave",()=>V(null)),o.addEventListener("click",A=>{A.stopPropagation();let N=k;N&&(window.clearTimeout(L),_(null),e.open(N))});function q(A){let N=n.get(A.id);if(N)return N;let $=y("button",{class:"bub",type:"button","data-thread":A.id});return $.addEventListener("mouseenter",()=>V(A.id)),$.addEventListener("mouseleave",()=>V(null)),$.addEventListener("click",B=>{B.stopPropagation(),H(null),e.open(A.id)}),e.t.insertBefore($,r),n.set(A.id,$),$}let J=!1;function D(){let A=e.state.o,N=v&&A&&!A.anchor.quote&&!A.anchor.point?A.resolved.element:null;if(N){let{left:B,top:z,above:F}=$o(N.getBoundingClientRect(),{width:s.offsetWidth||Ze,height:s.offsetHeight},{width:window.innerWidth,height:window.innerHeight}),U=v?.above!==null&&v?.above!==F;if(v&&(v.above=F),U&&oe())return;s.style.left=`${B}px`,s.style.top=`${z}px`;return}let $=v&&A?At(A.anchor,A.resolved):m?P(m):null;$&&b(s,$,Ze)}let K=A=>e.state.l&&!A.anchor.quote&&!A.anchor.point;function oe(A=()=>{}){return window.clearTimeout(T),x?(s.classList.remove("show"),T=window.setTimeout(()=>{A(),D(),s.classList.add("show")},220),!0):(A(),s.classList.add("glide"),T=window.setTimeout(()=>s.classList.remove("glide"),450),!1)}function Se(){if(!w())return null;let A=e.state.o;return A?A.anchor.quote||A.anchor.point||e.state.l?null:A.resolved.element:!m||m.anchor.quote||m.anchor.point?null:e.resolved.get(m.id)?.element??null}function se(A){d=A;let N=new Set;for(let F of A){if(!e.B(F)||F.anchor.quote)continue;let U=e.resolved.get(F.id);if(!U||U.state==="orphaned")continue;N.add(F.id);let W=q(F);W.classList.toggle("done",F.resolved),W.classList.toggle("on",e.state.i===F.id),W.classList.toggle("pin",F.anchor.point!==void 0);let ee=`Comment on ${Me(U.element)}: ${be(F.root.text,60)}`;W.getAttribute("aria-label")!==ee&&W.setAttribute("aria-label",ee)}Gt(e.t,A.filter(F=>N.has(F.id)).sort(Fe(e)).map(F=>n.get(F.id)),r);for(let[F,U]of n)N.has(F)||(U.classList.remove("in"),n.delete(F),window.setTimeout(()=>U.remove(),300));H(C),M!==e.state.d&&s.classList.contains("show")&&!x&&oe(),M=e.state.d;let $=t.te?e.state.o:null;if($){let F=$.anchor.point??$.resolved.element;v?.of!==$?(window.clearTimeout(T),s.classList.remove("glide"),v={s:on(e,$),of:$,at:F,above:null},v.s.ee(K($)),s.replaceChildren(v.s.element),s.inert=!1,v.s.focus(),m=null,u=null,D(),s.classList.add("show")):v&&(v.at!==F&&(v.at=F,v.above=null,oe(()=>v?.s.ye($.label))),v.s.ee(K($)));let U=!e.p.u($.anchor.view);U!==J&&(J=U,s.classList.toggle("show",!U),s.inert=U,U||D());return}v&&(window.clearTimeout(T),s.classList.remove("glide"),v=null,J=!1,e.D(null));let B=w()&&e.state.i?p(e.state.i):null;if(!B||!e.B(B)){m=null,u=null,s.classList.remove("show"),Q(s,!0);return}let z=B.anchor.quote?.exact??null;!m||!u||m.id!==B.id?(u=ft(B,e.j,{Y:"popover",quote:z}),s.replaceChildren(u.element),m=B,D(),s.classList.add("show"),s.inert=!1):m!==B&&(u.update(B,{quote:z}),m=B)}function le(){for(let[B,z]of n){let F=p(B),U=e.resolved.get(B),W=F&&U?rn(F.anchor,U):null;if(!W||W.y<-40||W.y>window.innerHeight+40){z.style.visibility="hidden";continue}z.style.visibility="",z.style.left=`${W.x}px`,z.style.top=`${W.y}px`,z.classList.contains("in")||(z.offsetWidth,z.classList.add("in"))}let A=e.state.o,N=A?.anchor.point&&e.p.u(A.anchor.view)?rn(A.anchor,A.resolved):null;N?(l.style.left=`${N.x}px`,l.style.top=`${N.y}px`,l.classList.contains("in")||(e.t.insertBefore(l,r),l.offsetWidth,l.classList.add("in"))):l.classList.contains("in")&&(l.classList.remove("in"),window.setTimeout(()=>l.classList.contains("in")||l.remove(),300)),s.classList.contains("show")&&D();let $=Se();r.classList.toggle("show",$!==null),$&&Ve(r,$.getBoundingClientRect(),4)}let de=A=>{if(e.m(A)){let $=A.composedPath()[0];c!==null&&!($ instanceof Element&&$.closest(".tip,.bub"))&&V(null),c=null;return}let N=e.ne(A.clientX,A.clientY)?.id??null;N!==c&&(c=N,V(N))},Te=A=>{if(e.m(A))return;let N=window.getSelection();if(N&&!N.isCollapsed||(e.state.l?A.altKey:A.target instanceof Element&&A.target.closest(di)))return;let $=e.ne(A.clientX,A.clientY);$&&(e.we(A),H(null),e.open($.id))};return window.addEventListener("pointermove",de,{capture:!0,passive:!0}),window.addEventListener("click",Te,!0),{f:se,S:le,destroy(){window.clearTimeout(L),window.clearTimeout(T),window.removeEventListener("pointermove",de,!0),window.removeEventListener("click",Te,!0),e.D(null);for(let A of n.values())A.remove();l.remove(),o.remove(),r.remove(),s.remove()}}}var pi={display:"block",position:"static",clips:!1,off:!1},ui=48,fi="button link img figure region list listitem tab tabpanel article navigation complementary banner contentinfo form search group dialog menu menuitem checkbox switch radio slider textbox combobox option row cell heading table".split(" ").map(e=>`[role=${e}]`),mi=["button,a,input,select,textarea,label,summary,details,img,svg,canvas,video,picture,figure,figcaption,table,th,td","li,ul,ol,dl,dt,dd,p,h1,h2,h3,h4,h5,h6,blockquote,pre","section,article,aside,nav,header,footer,main,form,fieldset",...fi].join(","),$n="a,button,label,summary,[role=button],[role=link],[role=tab],[role=option],[role=menuitem]",hi=`${$n},input,select,textarea,img,svg,canvas,video,picture,[role=img]`,Ho=24,gi=.6,pn=2,Hn=(e,t)=>Math.abs(e.left-t.left)<=pn&&Math.abs(e.top-t.top)<=pn&&Math.abs(e.width-t.width)<=pn&&Math.abs(e.height-t.height)<=pn;function Do(e,t){let n=t.s(e);if(n.width<2||n.height<2)return!1;if(e.hasAttribute("data-pipeup-id"))return!0;let o=t.oe();return n.width*n.height<=gi*o.width*o.height&&(e.matches(mi)||t.Fe(e)||e.childElementCount>1&&!e.parentElement?.closest($n)&&t._e(e))}function Mt(e,t,n){if(e===t||!t.contains(e)||e.closest("[data-pipeup-ignore]"))return null;let o=null;for(let s=e;s&&s!==t&&!o;s=s.parentElement)Do(s,n)&&(o=s);if(!o||o.hasAttribute("data-pipeup-id"))return o;let r=n.s(o);for(let s=o.parentElement;s&&s!==t&&Hn(n.s(s),r);s=s.parentElement)if(s.hasAttribute("data-pipeup-id"))return s;return o}function Dn(e,t,n){let o=n.s(e);for(let r=e.parentElement;r&&r!==t;){let s=Mt(r,t,n);if(!s)return null;if(!Hn(n.s(s),o))return s;r=s.parentElement}return null}function Bo(){return{s:e=>e.getBoundingClientRect(),Fe:e=>{let t=getComputedStyle(e),n=t.backgroundColor!=="transparent"&&!/,\s*0\)$/.test(t.backgroundColor),o=["top","right","bottom","left"].some(r=>parseFloat(t.getPropertyValue(`border-${r}-width`))>0);return n||o||t.backgroundImage!=="none"||t.boxShadow!=="none"},_e:e=>/^(inline-)?(flex|grid)$/.test(getComputedStyle(e).display),flow:e=>{let t=getComputedStyle(e),n=[t.overflowX,t.overflowY];return{display:t.display,position:t.position,clips:n.some(o=>o==="hidden"||o==="clip")&&!n.some(o=>o==="auto"||o==="scroll")&&e!==document.documentElement&&e!==document.body,off:t.pointerEvents==="none"}},oe:()=>({width:innerWidth,height:innerHeight})}}var vi=(e,t)=>e.left<t.left+t.width&&t.left<e.left+e.width&&e.top<t.top+t.height&&t.top<e.top+e.height,yi=(e,t)=>{let n=Math.max(e.left,t.left),o=Math.max(e.top,t.top);return{left:n,top:o,width:Math.max(0,Math.min(e.left+e.width,t.left+t.width)-n),height:Math.max(0,Math.min(e.top+e.height,t.top+t.height)-o)}};function Bn(e,t,n=()=>!0){let o=[],r=(s,l,d,m,u,v)=>{for(let x of s.children){if(x.hasAttribute("data-pipeup-ignore")||x.getAttribute("aria-hidden")==="true"||!n(x))continue;let T=t.flow?.(x)??pi,C=x.offsetParent,c=T.position==="fixed"||T.position==="absolute"&&!!m&&!(C&&m.contains(C)),k=c?null:d,L=t.s(x),p=L.width>0&&L.height>0;if(k&&p&&!vi(L,k))continue;let w=x.matches($n),P=(T.display.startsWith("inline")||v)&&!x.matches(hi)&&(T.display==="inline"||L.height<=ui),b=L.width<=Ho&&L.height<=Ho,H=x.hasAttribute("data-pipeup-id")||!u&&!T.off&&!P&&!(b&&!w),_=l;H&&Do(x,t)&&(l&&Hn(t.s(l.e),L)?(x.hasAttribute("data-pipeup-id")||!l.e.hasAttribute("data-pipeup-id"))&&(l.e=x):o.push(_={e:x,I:l,E:0}));let V=T.clips&&p;r(x,_,V?k?yi(k,L):L:k,V?x:c?null:m,u||w,/^inline-(flex|grid)$/.test(T.display)||v&&/(flex|grid)$/.test(T.display))}};r(e,null,null,null,!1,!1);for(let s=o.length-1;s>=0;s--){let l=o[s];l.I&&(l.I.E=Math.max(l.I.E,l.E+1))}return o}var tt=(e,t)=>e.filter(n=>n.E<=t&&(!n.I||n.I.E>t)),Vo=(e,t)=>e.filter(n=>n.I===t);var un="a,button,summary,[role=button],[role=link],[role=switch],[role=tab],[role=checkbox],input[type=checkbox],input[type=radio],input[type=submit],input[type=button],input[type=reset]",wi=`${un},input,select,textarea,[contenteditable]:not([contenteditable=false]),[tabindex]:not([tabindex="-1"])`,Fo=["click","dblclick","auxclick","submit","contextmenu","dragstart"],_o=[...["over","out","enter","leave","down","up"].flatMap(e=>[`pointer${e}`,`mouse${e}`]),"mousemove","touchstart","touchmove","touchend","touchcancel"],bi=400,Vn="Tab moves between blocks \xB7 \u2191 \u2193 change level \xB7 Enter comments \xB7 Esc to finish \xB7 F7 selects text",xi=4,Ei=150;function Uo(e){let t=Bo(),n=y("span",{hidden:!0},Vn),o=y("div",{class:"pick"},n),r=[0,1].map(()=>{let i=y("div",{class:"km",tabindex:"-1",role:"button"},y("span",{hidden:!0}),y("span",{hidden:!0}));return i.inert=!0,i.addEventListener("keydown",st),i.addEventListener("click",f=>{f.stopPropagation(),je()}),i.addEventListener("focus",()=>o.classList.add("kf")),i.addEventListener("blur",()=>o.classList.remove("kf")),i}),s=y("span",{class:"lbl"}),l=(i,f,a,g)=>{let S=y("button",{class:"nb",type:"button","aria-label":i,title:f},Z(a,16));return S.addEventListener("click",O=>{O.stopPropagation(),g()}),S},d=l("Around it","Select the block around it","expand",ke),m=l("Inside it","Select a block inside it","shrink",Re),u=l("Pin","Pin its centre","pin",()=>e.be(()=>W(c??b,{x:.5,y:.5}))),v=y("div",{class:"namebar",role:"group","aria-label":"Chosen block"},s,d,m,u);v.inert=!0;let x=e.t.querySelector(".launch");for(let i of[o,...r,v])e.t.insertBefore(i,x);v.addEventListener("mousedown",i=>i.preventDefault());let T=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,C=null,c=null,k=null,L=null,p=0,w=()=>{},M=null,P=()=>{},b=null,H=0,_=0,V=!1,q=null,J=null,D=null,K=0,oe=-1,Se=!0,se=null,le=null,de=i=>!e.m(i)&&!(i.target instanceof Element&&i.target.closest("[data-pipeup-ignore]"));function Te(){L&&(o.classList.toggle("glide",performance.now()<p),Ve(o,L.getBoundingClientRect(),4))}function A(){if(!M)return;v.classList.toggle("glide",performance.now()<p&&v.classList.contains("show"));let{left:i,top:f}=ln(M.getBoundingClientRect(),{width:v.offsetWidth||200,height:v.offsetHeight||34},{width:window.innerWidth,height:window.innerHeight});v.style.left=`${i}px`,v.style.top=`${f}px`}function N(i,f){L=i,p=f?performance.now()+bi:0,Te(),o.classList.add("show")}function $(i,f){let a=getComputedStyle(i);if(a.opacity==="0")return f(),()=>{};let g=0,S=()=>{window.clearTimeout(g),i.removeEventListener("transitionend",R)},O=()=>{S(),f()},R=X=>{X.target===i&&X.propertyName==="opacity"&&O()},Y=Math.max(...a.transitionDuration.split(",").map(X=>parseFloat(X)*1e3||0));return g=window.setTimeout(O,Y+100),i.addEventListener("transitionend",R),S}function B(i){if(i!==C){if(C=i,w(),!i){o.classList.remove("show");return}getComputedStyle(o).opacity==="0"?N(i,!1):T?(o.classList.remove("show"),w=$(o,()=>N(i,!1))):N(i,!0)}}function z(i){c=i,o.classList.toggle("on",i!==null),B(i),F(i)}function F(i){P(),v.inert=!i,i?T?(v.classList.remove("show"),P=$(v,()=>U(i))):U(i):(v.classList.remove("show"),M=null)}function U(i){s.textContent=s.title=Me(i),d.hidden=Dn(i,e.root,t)===null,m.hidden=(b?We(i).length:Bn(i,t,he).length)===0;let f=v.classList.contains("show");M=i,A(),f||(v.offsetWidth,v.classList.add("show"))}function W(i,f){let a;try{a=_t(i,e.root,f,e.p.view(i))}catch(O){e.re(O);return}let g={anchor:a,label:f?`Pin on ${Me(i).replace(/^[A-Z](?=[a-z])/,O=>O.toLowerCase())}`:Me(i),ranges:[],resolved:{state:"attached",element:i,range:null}},S=e.state.o;b&&(b=i,oe=-1),z(f?null:i),k=S??g,e.Ue(g),e.w(f?g.label:`Commenting on ${g.label}`)}function ee(i){e.be(()=>W(i))}function _e(i){let f=(i.target instanceof Element?Mt(i.target,e.root,t):null)??e.root;f!==e.root&&(q=f);let a=f.getBoundingClientRect();a.width&&a.height&&W(f,{x:(i.clientX-a.left)/a.width,y:(i.clientY-a.top)/a.height})}function Ee(i){let f=window.getSelection();if(f&&!f.isCollapsed)return;if(e.state.o&&(i.altKey||!e.C())){e.N();return}if(!i.altKey&&e.ne(i.clientX,i.clientY))return;if(e.state.i&&e.open(null),b&&i.detail&&ge(),i.altKey){_e(i);return}let a=i.target instanceof Element?Mt(i.target,e.root,t):null;a&&(q=a),a?W(a):(e.N(),z(null))}let Ue=i=>{if(e.m(i))return;if(!de(i)){c||B(null);return}if(i.stopPropagation(),c||e.state.o)return;let f=!ut()&&i.target instanceof Element?Mt(i.target,e.root,t):null;if(b){if(!f||f===b||(K+=Math.abs(i.movementX)+Math.abs(i.movementY),K<=xi))return;ge()}f&&(q=f),B(f)},Oe=()=>{ut()&&(b&&ge(),c||B(null))},te=i=>{de(i)&&(i.stopPropagation(),(i.type==="pointerdown"||i.type==="mousedown")&&i.target instanceof Element&&i.target.closest(wi)&&i.preventDefault())},qe=i=>{if(!de(i))return;let f=i.target;if((f===le||f.form&&f.form===le?.form)&&(i.type==="submit"||i.type==="click"&&!i.detail)){le=i.type==="click"&&f.type==="submit"?f.form:null;return}i.preventDefault(),i.stopPropagation(),i.type==="click"&&!e.state.c&&!e.qe(i)&&Ee(i)},G=i=>{if(le=null,h="",i.key==="Tab"&&Ae(i))return i.preventDefault(),i.stopPropagation(),h=i.key,e.N(),e.state.i&&e.open(null),e.state.c&&(e.state.c=!1,e.f()),Ne(i.shiftKey?-1:1);if(!(!de(i)||!(i.target instanceof Element)))if((i.key==="Enter"||i.key===" ")&&i.target.closest(un)){if(!b){le=i.target;return}i.preventDefault(),i.stopPropagation()}else i.key==="Enter"&&!b&&i.target.form&&(le=i.target)},Ae=i=>{if(i.ctrlKey||i.metaKey||i.altKey||i.isComposing)return!1;let f=i.composedPath()[0];return!(f instanceof Element)||r.some(a=>a===f)?!1:e.m(i)?!!f.closest(".launch,.menu")&&!f.closest("input,textarea,select,[contenteditable]"):!i.composedPath().some(a=>a instanceof Element&&a.hasAttribute("data-pipeup-ignore"))},pe=()=>e.t.getRootNode().activeElement,ue=()=>r.some(i=>i===pe()),he=i=>(i.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0})!==!1||getComputedStyle(i).display==="contents")&&e.p.u(e.p.view(i)),re=()=>(se?.some(i=>!i.e.isConnected)&&(se=null),se??=Bn(e.root,t,he)),Ie=i=>re().find(f=>f.e===i),ae=(i,f=!1)=>{let a=i.getBoundingClientRect();return a.bottom>0&&a.top<window.innerHeight&&(!f||a.top>=0)},Ke=()=>{let i=tt(re(),0);return i.find(f=>ae(f.e,!0))??i.find(f=>ae(f.e))??i[0]},ze=i=>e.doc.threads().filter(f=>e.B(f)&&i.contains(dn(e,f))).sort(Fe(e));function rt(i,f){let[a,g]=i.children,S=tt(re(),H),O=ze(f).length;a.textContent=`${Ut(f)}, ${S.findIndex(X=>X.e===f)+1} of ${S.length}${O?`, has ${O} comment${O===1?"":"s"}`:""}`;let R=(f.innerText??f.textContent??"").length<=Ei;g.textContent=Ln(f);let Y=Se?[n]:[];Se=!1,i.ariaLabelledByElements!==void 0?(i.ariaLabelledByElements=R?[a,f]:[a,g],i.ariaDescribedByElements=R?Y:[...Y,f]):i.setAttribute("aria-label",`${a.textContent}, ${g.textContent}`)}function ne(i,f=!0){K=0;let a=re(),g=a.find(O=>O.e===i);if(g&&!tt(a,H).includes(g)&&(H=g.E),i!==b&&(oe=-1),i!==c&&(c=null),b=i,B(i),F(i),i.scrollIntoView({block:"nearest",inline:"nearest",behavior:T?"auto":"smooth"}),!f)return;e.Ke();let S=r[_^=1];rt(S,i),Ve(S,i.getBoundingClientRect(),4),S.inert=!1,S.focus({preventScroll:!0}),r[_^1].inert=!0}function fe(){se=null;let i=document.activeElement;J=pe()??i;let f=Ie(q),a=f??(i&&i!==document.body&&e.root.contains(i)&&!i.closest("[data-pipeup-ignore]")?re().filter(g=>g.e.contains(i)).pop():void 0)??Ke();return a?(f||(H=a.E),V=!0,ne(a.e),!0):!1}function ge(){let i=ue();q=b,b=null,B(null),F(null);for(let f of r)Q(f,!0);return i}function it(){let i=J;i&&i!==document.body&&i.isConnected&&i.focus?.({preventScroll:!0}),(!i||i===document.body||!i.matches?.(":focus"))&&e.t.querySelector(".launch .mode")?.focus({preventScroll:!0})}function We(i){let f=Ie(i);return f?Vo(re(),f):[]}function Ye(i){let f=tt(re(),H),a=f.findIndex(S=>S.e===b),g=f[a<0?i>0?0:f.length-1:(a+i+f.length)%f.length];g&&ne(g.e)}function Ne(i){if(b)return Ye(i);se=null;let f=document.activeElement;J=pe()??f;let a=q?.isConnected?q:null,g=a&&Ie(a),S;if(g){H=g.E;let O=tt(re(),H),R=O.indexOf(g);S=O[(R+i+O.length)%O.length]}else if(a){H=0;let O=tt(re(),0),R=X=>(a.compareDocumentPosition(X.e)&Node.DOCUMENT_POSITION_FOLLOWING)!==0,Y=X=>X.e.contains(a);i>0?S=O.find(X=>R(X)&&!Y(X))??O[0]:S=O.filter(X=>!R(X)&&!Y(X)).pop()??O[O.length-1]}else S=Ke(),S&&(H=S.E);if(!S)return e.w("Nothing here to comment on");V=!0,ne(S.e)}function ke(){let i=c??b,f=i&&Dn(i,e.root,t);if(!f)return e.w("Nothing around it");if((!D||!i.contains(D))&&(D=i),c)return ee(f);ne(f)}function Re(){let i=c??b,f=i?We(i):[],a=f.find(g=>D&&g.e.contains(D))??f.find(g=>ae(g.e))??f[0];if(!a)return e.w("Nothing inside it");c?ee(a.e):ne(a.e)}function je(i=!1){if(!b)return;if(e.state.o&&!e.C())return e.ze();if(!i)return W(b);let f=ze(b);if(!f.length)return e.w("No comments on this block");oe=(oe+1)%f.length,e.open(f[oe].id),f.length>1&&e.w(`Comment ${oe+1} of ${f.length} on this block`)}function st(i){if(["Tab","ArrowUp","ArrowDown","Enter"," ","Escape"].includes(i.key)&&!(i.key.startsWith("Arrow")&&(i.metaKey||i.ctrlKey||i.altKey))){if(i.preventDefault(),i.stopPropagation(),h=i.key,i.key==="Escape")return void e.ie();if(i.key==="Enter"||i.key===" ")return je(i.shiftKey&&i.key==="Enter");i.key==="Tab"&&e.N(),e.state.i&&e.open(null),i.key==="Tab"?Ye(i.shiftKey?-1:1):i.key==="ArrowUp"?ke():Re()}}let $e=()=>{let i=pe();return i?!!i.closest("[inert]"):!document.activeElement||document.activeElement===document.body},h="",E=!1,I=i=>{E&&window.removeEventListener("keyup",I,!0),i.key===h&&(h="",i.preventDefault(),i.stopPropagation())};window.addEventListener("keyup",I,!0),window.addEventListener("pointermove",Ue,!0),document.addEventListener("selectionchange",Oe);for(let i of _o)window.addEventListener(i,te,!0);for(let i of Fo)window.addEventListener(i,qe,!0);return window.addEventListener("keydown",G,!0),{ie(){return c?(z(null),!0):!1},se:()=>b!==null,We:()=>V&&!b,xe:fe,ae(){b&&!ue()&&ne(b)},f(){if(se=null,b&&!(b.isConnected&&he(b))){let a=Ke();a?ne(a.e,ue()||$e()):ge()}let i=e.t.querySelector(".launch");if(i&&v.nextElementSibling!==i&&!ue()&&!v.contains(pe()))for(let a of[o,...r,v])e.t.insertBefore(a,i);let f=e.state.o;k&&f!==k?(k=null,z(null),b&&ne(b,$e())):f&&!k&&(C||c)&&z(null)},S(){Te(),A(),b&&Ve(r[_],b.getBoundingClientRect(),4)},destroy(){ge()&&it();for(let i of r)i.remove();w(),P(),E=!0,h||window.removeEventListener("keyup",I,!0),window.removeEventListener("pointermove",Ue,!0),document.removeEventListener("selectionchange",Oe);for(let i of _o)window.removeEventListener(i,te,!0);for(let i of Fo)window.removeEventListener(i,qe,!0);window.removeEventListener("keydown",G,!0),o.classList.remove("show"),v.classList.remove("show"),Q(v,!0),$(o,()=>o.remove()),$(v,()=>v.remove())}}}var ki=300,Si=32,Ti=220,Ct=320,Ai=24,qo=24;function Fn(e,t=!1){let n=e.ownerDocument.documentElement,o=n.getAttribute("data-pipeup-layout");if(o==="bubbles"||e.querySelector("[data-pipeup-slide]"))return null;let r=e.querySelector("article, main, [role=main]")??(o==="column"?e:null);if(!r)return null;if(n.hasAttribute("data-pipeup-reserve")){let d=n.clientWidth,u=getComputedStyle(r).maxWidth,v;return u.endsWith("px")?v=parseFloat(u):u.endsWith("%")?v=parseFloat(u)/100*d:v=r.getBoundingClientRect().width,o!=="column"&&d<v+Ct-(t?Ai:0)?null:{x:d-Ct+qo,width:Ct-2*qo}}let s=r.getBoundingClientRect().right;if(window.innerWidth-s<ki&&o!=="column")return null;let l=s+Si;return{x:l,width:Math.max(220,Math.min(300,window.innerWidth-l-16))}}function _n(e,t){let n=e.resolved.get(t.id);return!n||n.state==="orphaned"&&!e.k.has(t.id)}function Ko(e){let t=y("div",{class:"col"});e.t.append(t);let n=new Map,o=null,r=new ResizeObserver(()=>d()),s=c=>_n(e,c);function l(c){let k=e.resolved.get(c.id),L=k?Nn(c.anchor,k):null;return L===null?Number.POSITIVE_INFINITY:L+window.scrollY-4}function d(){let c=[],k=[];for(let[P,b]of n){let H=l(b.thread);if(Number.isFinite(H))b.placed=H;else if(e.k.has(P)){if(b.placed===null){b.e.classList.add("wait");continue}H=b.placed}Number.isFinite(H)?c.push({id:P,T:H,height:b.e.offsetHeight}):k.push({id:P,height:b.e.offsetHeight})}let L=e.state.o,p=L?Nn(L.anchor,L.resolved):null;o&&p!==null&&c.push({id:"draft",T:p+window.scrollY-4,height:o.e.offsetHeight});let w=Ro(c,o?"draft":e.state.i),M=Math.max(0,...c.map(P=>(w.get(P.id)??0)+P.height))+24;for(let P of k)w.set(P.id,M),M+=P.height+10;for(let[P,b]of n){if(b.e.classList.contains("wait")){if(!w.has(P))continue;b.e.style.transition="none",b.e.style.transform=`translateY(${Math.round(w.get(P))}px)`,b.e.offsetWidth,b.e.style.transition="",b.e.classList.remove("wait");continue}b.e.style.transform=`translateY(${Math.round(w.get(P)??0)}px)`}o&&(o.e.style.transform=`translateY(${Math.round(w.get("draft")??0)}px)`)}function m(c,k){c.thread=k,c.lost=s(k),c.view.update(k,{lost:c.lost?k.anchor.snapshot:null})}function u(c){let k=s(c),L=ft(c,e.j,{Y:"column",lost:k?c.anchor.snapshot:null}),p=y("div",{class:"th","data-thread":c.id},y("button",{class:"opn sr",type:"button","data-thread":c.id}),L.element);return p.style.transition="none",p.addEventListener("mouseenter",()=>e.L(c.id)),p.addEventListener("mouseleave",()=>e.L(null)),p.addEventListener("click",()=>e.open(c.id)),t.append(p),r.observe(p),{e:p,thread:c,lost:k,placed:null,view:L}}function v(c){r.unobserve(c),c.classList.add("out"),window.setTimeout(()=>c.remove(),Ti)}function x(){let c=e.state.o;if(o&&o.of!==c&&(v(o.e),o=null,c||e.D(null)),!c)return;let k=!o;if(o)o.s.ye(c.label);else{let L=on(e,c),p=y("div",{class:"th on"},L.element);p.style.transition="none",t.append(p),r.observe(p),o={e:p,s:L,of:c}}o.s.ee(e.state.l&&!c.anchor.quote&&!c.anchor.point),k&&o.s.focus()}function T(c){Q(t,e.state.d);let k=new Set,L=[],p=e.state.i!==null||e.state.o!==null;for(let w of c){if(!e.B(w))continue;k.add(w.id);let M=n.get(w.id);M?(M.thread!==w||M.lost!==s(w))&&m(M,w):(M=u(w),n.set(w.id,M),L.push(M.e));let P=M.e,b=e.state.i===w.id;P.classList.toggle("on",b);let H=P.firstElementChild,_=w.root.replies.length;H.setAttribute("aria-label",`Open thread: ${be(w.root.text,60)}, ${cn(_)}`),H.setAttribute("aria-expanded",String(b)),Q(H,b);let V=P.querySelector(".more");V&&Q(V,!b),P.classList.toggle("dim",p&&!b),P.classList.toggle("hot",e.state.L===w.id&&!b),P.classList.toggle("resolved",w.resolved),P.classList.toggle("lost",M.lost)}for(let[w,M]of n)k.has(w)||(n.delete(w),v(M.e));x(),Gt(t,c.filter(w=>k.has(w.id)).sort(Fe(e)).map(w=>n.get(w.id).e),o?.e??null)&&t.offsetWidth,d(),o&&L.push(o.e);for(let w of L)w.offsetWidth,w.style.transition=""}function C(){let c=Fn(e.root,!0);c&&(t.style.width=`${c.width}px`,t.style.transform=`translate(${c.x}px, ${-window.scrollY}px)`)}return{f:T,S:C,destroy(){r.disconnect(),e.D(null),t.remove()}}}var zo="[data-pipeup-ignore],input,textarea,select,[contenteditable]:not([contenteditable=false])";function Wo(e){let t=y("button",{type:"button","aria-label":"Comment",title:"Comment"},Z("comment",17)),n=y("div",{class:"selbar"},t);n.inert=!0,e.t.append(n);let o=null,r=0,s=!1,l=C=>{let c=C&&(C.nodeType===Node.ELEMENT_NODE?C:C.parentElement);return!!c&&e.root.contains(c)&&!c.closest(zo)};function d(){if(!o)return;let{left:C,top:c}=ln(o.getBoundingClientRect(),{width:n.offsetWidth||36,height:n.offsetHeight||34},{width:window.innerWidth,height:window.innerHeight});n.style.left=`${C}px`,n.style.top=`${c}px`}function m(){o=null,n.inert=!0,n.classList.remove("show")}function u(C=!1){let c=ut();if(!e.state.l||!c||!l(c.anchorNode)||!l(c.focusNode)){m();return}!o&&!C&&e.w("Enter comments on the selected words"),o=c.getRangeAt(0).cloneRange(),d(),n.inert=!1,n.classList.add("show")}t.addEventListener("mousedown",C=>C.preventDefault()),t.addEventListener("click",C=>{if(C.stopPropagation(),e.state.o&&!e.C())return e.N();let c=o;if(!c)return;let k;try{k=Ft(c,e.root,e.p.view(c.commonAncestorContainer))}catch(p){e.re(p),m();return}let L=be(c.toString().replace(/\s+/g," ").trim(),60);window.getSelection()?.removeAllRanges(),m(),e.Ye({anchor:k,label:`\u201C${L}\u201D`,ranges:[c],resolved:{state:"attached",element:null,range:c}})});let v=()=>{window.clearTimeout(r),r=window.setTimeout(()=>s||u(),250),o&&(ut()||m())};document.addEventListener("selectionchange",v);let x=C=>{C.type!=="keyup"&&(s=C.type==="mousedown"),!(s||e.m(C))&&window.setTimeout(()=>u(C.type==="mouseup"),0)};window.addEventListener("mousedown",x,!0),window.addEventListener("mouseup",x,!0),window.addEventListener("keyup",x,!0);let T=C=>{C.key!=="Enter"||!o||e.m(C)||C.target instanceof Element&&C.target.closest(`${zo},${un}`)||(C.preventDefault(),C.stopPropagation(),t.click())};return window.addEventListener("keydown",T,!0),{f(){!e.state.l&&o&&m()},S(){o&&d()},destroy(){window.removeEventListener("mousedown",x,!0),window.removeEventListener("mouseup",x,!0),window.removeEventListener("keyup",x,!0),window.removeEventListener("keydown",T,!0),window.clearTimeout(r),document.removeEventListener("selectionchange",v),n.remove()}}}async function Un(e,t){try{await navigator.clipboard.writeText(e);return}catch{}let n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.cssText="position:fixed;opacity:0;pointer-events:none",t.append(n),n.select();let o=document.execCommand("copy");if(n.remove(),!o)throw new Error("pipeup: your browser blocked copying")}var Li=3e3,Yo="Hidden on the page";function jo(e){let t=[y("span",{class:"n"}),y("span",{class:"n"})],n=Z("comment",20,1.4);n.lastElementChild.setAttribute("stroke-width","1.6");let o=y("button",{class:"mode",type:"button","aria-label":"Comment","aria-keyshortcuts":In,"aria-haspopup":"menu","aria-expanded":"false"},y("span",{class:"plus"},n),y("span",{class:"cnt"},Z("bubble",34,1.4),...t),y("span",{class:"dot"})),r=document.createTextNode("Comment"),s=y("span",{class:"ttip","aria-hidden":"true"},r,y("small",{},St)),l=y("div",{class:"launch"},o,s),d=y("div",{class:"menu",role:"menu","aria-label":"Comments"}),m=y("div",{class:"list",role:"menu","aria-label":"All comments"}),u=y("span",{class:"pn"}),v=y("button",{class:"ib",type:"button","aria-label":"Close"},Z("close")),x=y("button",{class:"hs",type:"button",role:"switch","aria-checked":"false"},"Show resolved",y("span",{class:"sw","aria-hidden":"true"}));x.addEventListener("click",h=>{h.stopPropagation(),e.c.je()});let T=y("div",{class:"all",role:"dialog","aria-label":"All comments"},y("div",{class:"hd"},y("span",{},"All comments"),u,x,v),m),C=y("div",{class:"pop side",role:"dialog","aria-label":"Comment thread"});d.inert=T.inert=C.inert=!0,e.t.append(d,l,T);let c=!1,k=null,L=0,p=[],w=0,M=null,P=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,b=h=>{c=e.state.c=h,h&&e.addons.flush(),window.clearTimeout(L),L=0,h||k?.(!0),d.classList.toggle("show",h),Q(d,!h),o.setAttribute("aria-expanded",String(h))},H=(h,E=!1)=>{e.state.d!==h&&(e.state.d=h,e.f(),h?(_(m)[0]??v).focus({preventScroll:!0}):E&&o.focus({preventScroll:!0}))},_=(h=d)=>[...h.querySelectorAll(".mi")],V=()=>d.getRootNode().activeElement,q=()=>{b(!1),o.focus({preventScroll:!0})},J=h=>{let E=_(h.currentTarget);if(E.length===0)return;let I=V(),i=E.indexOf(I),f=a=>{h.preventDefault(),E[(a+E.length)%E.length]?.focus({preventScroll:!0})};h.key==="ArrowDown"?f(i+1):h.key==="ArrowUp"?f(i<0?E.length-1:i-1):h.key==="Home"?f(0):h.key==="End"&&f(E.length-1)};d.addEventListener("keydown",J),m.addEventListener("keydown",J),v.addEventListener("click",h=>{h.stopPropagation(),H(!1,!0)});let D=h=>_n(e,h),K=h=>p.filter(E=>!E.resolved&&(h===void 0||e.V(E)===h)).length,oe=()=>K(!1),Se=()=>K(!0),se=()=>K(),le=h=>{let E=h.anchor.view?.slide,I=e.p.u(h.anchor.view)?"":Kt(h.anchor.view);return E&&e.p.slide()!==null?`On slide ${E}`:I?`In ${I}`:Yo},de=(h,E,I="")=>y("div",{role:"group","aria-label":I?`${h} \xB7 ${I}`:h},y("div",{class:"sec","aria-hidden":"true"},h,I&&y("b",{},I)),...E);function Te(h,E){let I=e.p.slide(),i=new Map;for(let f of h){let a=f.thread,g=I!==null?a.anchor.view?.slide??I:e.V(a)?e.p.u(a.anchor.view)?"":Kt(a.anchor.view):null;i.set(g,[...i.get(g)??[],f])}if(I===null){let f=i.get(null)??[];return i.delete(null),[...f.map(E),...[...i].map(([a,g])=>de(a||Yo,g.map(E)))]}return[...i].sort(([f],[a])=>Number(f)-Number(a)||0).map(([f,a])=>de(`Slide ${f} \xB7 ${a.filter(g=>!g.thread.resolved).length} open`,a.map(E),f===I?"This slide":""))}function A(){let h=V()?.dataset.thread,E=e.c.all().filter(a=>!a.thread.resolved||e.state.M),I=a=>{let g=a.thread,S=Pe(g.root.author,g.root.name);S.classList.add("in");let O=y("button",{class:g.resolved?"mi done":"mi",type:"button",role:"menuitem","data-thread":g.id},S,y("span",{},y("span",{class:"clamp"},g.root.deleted?"Deleted":g.root.text),y("small",{},D(g)?`\u201C${be(g.anchor.snapshot,80)}\u201D`:a.location.where)));return O.addEventListener("click",R=>{R.stopPropagation(),N(g.id,O.getBoundingClientRect().top)}),O},i=E.filter(a=>D(a.thread));u.textContent=String(se()),x.setAttribute("aria-checked",String(e.state.M)),m.replaceChildren(E.length?"":y("div",{class:"sec",role:"presentation"},"No open comments"),...Te(E.filter(a=>!D(a.thread)),I),i.length?de("No longer on the page",i.map(I)):"");let f=_(m);h&&f.find(a=>a.dataset.thread===h)?.focus({preventScroll:!0})}function N(h,E){et()&&(e.state.O=!0,H(!1)),B(h,E)}let $="";function B(h,E){let I=p.find(i=>i.id===h);if(I){if($=h,!e.V(I))return z(I,E);if(e.state.o&&!e.C())return e.N();e.p.W(I.anchor.view??{}).then(()=>{e.Ee();let i=p.find(f=>f.id===h);i&&$===h&&(e.state.d||e.state.O)&&z(i,E)})}}function z(h,E){let I=h.id,i=e.resolved.get(I),f=i&&!D(h)&&!e.V(h)?i.element??i.range?.startContainer.parentElement??null:null;if(f?.scrollIntoView({block:"center",inline:"nearest",behavior:P?"auto":"smooth"}),f&&i&&At(h.anchor,i)&&f.checkVisibility?.({visibilityProperty:!0})!==!1){U(),e.open(I);return}e.open(null),et()&&(e.state.O=!0,e.f()),F(h,E)}function F(h,E){let I=!D(h)&&e.V(h),i={quote:h.anchor.quote?.exact??null,lost:D(h)||I?h.anchor.snapshot:null,place:I?le(h):null};if(M?.id===h.id?M.view.update(h,i):(M={id:h.id,view:ft(h,e.j,{Y:"popover",...i})},C.replaceChildren(M.view.element)),E===void 0)return;C.isConnected||(e.t.insertBefore(C,T),C.offsetWidth);let f=sn(e.state.d),{left:a,top:g}=an({x:f.width,y:E,below:!1},{width:Ze,height:C.offsetHeight},f);C.style.left=`${a}px`,C.style.top=`${g}px`,C.classList.add("show"),C.inert=!1,e.Ge(h.id)}function U(h=!1){M&&(M=null,C.classList.remove("show"),Q(C,!0),h&&e.state.O&&(e.state.O=!1,e.f()))}function W(h,E,I=!1,...i){let f=y("button",{class:"mi",type:"button",role:I?"menuitemcheckbox":"menuitem"},h,y("span",{class:"lb"}),...i,I&&y("span",{class:"sw","aria-hidden":"true"}),y("span",{class:"tt","aria-hidden":"true"}));return f.addEventListener("click",a=>{a.stopPropagation(),E(a)}),f}let ee=(h,E,I,i)=>{let f=h.querySelector(".lb");f.textContent!==E&&(f.textContent=E),h.querySelector(".tt").textContent=I,h.setAttribute("aria-description",I),i!==void 0&&h.setAttribute("aria-checked",String(i))},_e=()=>y("div",{class:"sep",role:"separator"}),Ee=y("span",{class:"ma"}),Ue=y("span",{class:"kc"}),Oe="",te=W(Ee,it,!1,Ue);te.dataset.item="name";let qe=W(Z("copy"),()=>{q(),e.c.copyAll("ai")}),G=W(Z("lines"),()=>{q(),e.c.copyAll("text")}),Ae=y("span",{class:"kc"}),pe=W(Z("list"),()=>{b(!1),H(!0)},!1,Ae),ue=W(Z("comment"),h=>{let E=!e.state.l&&h.detail===0;e.Xe(!e.state.l,E),E&&b(!1)},!0,y("span",{class:"kc","aria-hidden":"true"},St));ue.dataset.item="comment",ue.setAttribute("aria-keyshortcuts",In);let he=y("div",{class:"sec",role:"presentation"}),re=_e(),Ie=_e(),ae=new Map,Ke=h=>{let E=ae.get(h);return E||(E=W(Ce(h.icon,15),()=>{h.checked||q(),Promise.resolve().then(()=>h.select()).catch(I=>e.re(I)).finally(()=>c&&fe())},!!h.checked,y("span",{class:"kc"})),ae.set(h,E)),E},ze=()=>[te,re,qe,G,pe,...e.addons.R.map(Ke),Ie,ue],rt=-1,ne=h=>{try{return h()}catch(E){return globalThis.reportError?.(E),""}};function fe(){let h=se(),E=e.c.name(),I=E||me(e.doc.me);if(ee(te,I,E?"The name on your comments":"Add a name to show on your comments"),te.setAttribute("aria-label",`${I}, ${E?"edit":"add"} your name`),Ue.replaceChildren(E?Z("edit",13):"Add name"),yt(e.doc.me,E)!==Oe){Oe=yt(e.doc.me,E);let f=Pe(e.doc.me,E);f.classList.add("in"),Ee.replaceChildren(f)}ee(qe,"Copy as Markdown","Markdown, with where each thread is"),ee(G,"Copy as Text","Just the words"),ee(pe,"All comments","Every thread, and where it is"),Ae.textContent=h?String(h):"";let i=e.addons.pe();he.textContent=i,i?!he.isConnected&&d.contains(te)&&d.prepend(he):he.remove();for(let f of e.addons.R){let a=ae.get(f);if(!a)continue;let g;try{g=f.checked?.()}catch(S){globalThis.reportError?.(S)}ee(a,ne(f.label),ne(f.hint),g),a.querySelector(".kc").textContent=f.count?ne(f.count):""}ee(ue,"Start commenting",e.state.l?"Turn off to hide the comments again":"Shows the comments; choose any part of the page to comment on it",e.state.l)}function ge(){fe(),(rt!==e.addons.G||!d.contains(te))&&(d.replaceChildren(...ze()),rt=e.addons.G,fe())}function it(){let h=y("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"});h.value=e.c.name();let E=y("div",{class:"ed"},Ee.cloneNode(!0),h),I=(i,f=!1)=>{if(k!==I)return;k=null;let a=h.value.trim();i&&a&&a!==e.c.name()&&e.c.rename(a).then(fe),E.replaceWith(te),f&&te.focus({preventScroll:!0})};k=I,h.addEventListener("keydown",i=>{i.stopPropagation(),(i.key==="Enter"||i.key==="Escape")&&(i.preventDefault(),I(i.key==="Enter",!0))}),h.addEventListener("blur",()=>I(!0)),te.replaceWith(E),h.focus({preventScroll:!0})}o.addEventListener("click",h=>{if(h.stopPropagation(),c){b(!1);return}ge(),b(!0),h.detail===0&&_().at(-1)?.focus({preventScroll:!0})});let We=!1,Ye=()=>{We=T.contains(V())},Ne=h=>{let E=h.composedPath();c&&!E.includes(d)&&!E.includes(o)&&(b(!1),e.state.l&&!e.m(h)&&(e.we(h),h.preventDefault(),h.stopPropagation())),e.state.d&&!e.m(h)&&H(!1,We&&(!document.activeElement||document.activeElement===document.body)),!E.includes(C)&&!E.includes(T)&&U(!0)},ke=h=>{if(!c||h.pointerType==="touch"||h.type==="pointerout"&&h.relatedTarget)return;let E=h.composedPath();h.type==="pointerover"&&(E.includes(d)||E.includes(o))?(window.clearTimeout(L),L=0):L||(L=window.setTimeout(()=>{L=0,k||b(!1)},Li))},Re={n:0,label:""},je=()=>{let{n:h,label:E}=Re,I=e.addons.pe(),i=`Comment${e.state.l?", comment mode on":""}${E?`, ${E}`:h?`, ${h} open`:""}${I?`, ${I}`:""}`;o.getAttribute("aria-label")!==i&&o.setAttribute("aria-label",i);let f=(E||"Comment")+(I?` \xB7 ${I}`:"");r.data!==f&&(r.data=f)},st=e.addons.subscribe(h=>{je(),!(!c||k)&&(h?ge():fe())});window.addEventListener("pointerdown",Ye,!0),window.addEventListener("click",Ne,!0),window.addEventListener("pointerover",ke,!0),window.addEventListener("pointerout",ke,!0);let $e=h=>{if(h.key!=="Escape"||k)return;let E=h.composedPath()[0];if(c)q();else if(e.state.d&&!(E instanceof HTMLTextAreaElement&&!T.contains(E)))H(!1,!0);else if(M)U(!0),e.j.close();else return;h.stopPropagation()};return window.addEventListener("keydown",$e,!0),{f(h){p=h;let E=oe();if(E!==w){if(E){let[a,g]=t[0].classList.contains("on")?t:[t[1],t[0]];g.textContent=E>99?"99+":String(E),g.classList.toggle("s",E>99),a.classList.remove("on"),g.classList.add("on")}o.classList.toggle("has",E>0),w=E}let I=Se(),i=I?`${E} here \xB7 ${I} ${e.p.slide()!==null?"on other slides":"in other views"}`:"";o.classList.toggle("else",I>0),Re={n:E,label:i},je(),o.classList.toggle("on",e.state.l),c&&!e.state.c&&b(!1),c&&fe();let f=e.state.d;if(T.classList.toggle("full",et()),T.classList.contains("show")!==f&&(T.classList.toggle("show",f),Q(T,!f)),f&&A(),M){let a=h.find(g=>g.id===M?.id);!a||e.state.i||a.resolved&&!e.state.M?U():F(a)}},S(){},destroy(){st(),window.removeEventListener("pointerdown",Ye,!0),window.removeEventListener("click",Ne,!0),window.removeEventListener("pointerover",ke,!0),window.removeEventListener("pointerout",ke,!0),window.clearTimeout(L),window.removeEventListener("keydown",$e,!0),d.remove(),T.remove(),C.remove(),l.remove()}}}var Pt="[data-pipeup-slide]",Go=1e3,Xo=["scroll","resize","keyup","click","transitionend","slidechanged"],qn=null,It=null,fn=new Set,Kn=new Set,Ot=e=>{try{e()}catch(t){globalThis.reportError?.(t)}};function Qo(e){let t=null;if(e){t={};let n=0;for(let[o,r]of Object.entries(e))if(!(typeof r!="string"||o==="slide"||o.length>j.viewKey||r.length>j.viewValue)){if(++n>=j.viewEntries)break;t[o]=r}}qn=t;for(let n of Kn)n()}function Zo(e){return fn.add(e),()=>void fn.delete(e)}function mn(e){It=typeof e?.current=="function"&&typeof e.go=="function"?e:null}function Mi(e,t,n){let o=t.oe(),r=null,s=0,l=0;for(let d of e){if(!t.shown(d))continue;let m=t.s(d),u=Math.min(m.left+m.width,o.width)-Math.max(m.left,0),v=Math.min(m.top+m.height,o.height)-Math.max(m.top,0);if(u<=0||v<=0)continue;let x=Math.round(u*v),T=t.opacity(d);(x>s||x===s&&(T>l||T===l&&d===n))&&(r=d,s=x,l=T)}return r}function Ci(e,t,n){return t!==null?e?.slide===void 0||e.slide===t:!e||!n?!0:Object.entries(e).every(([o,r])=>o==="label"||o==="slide"||n[o]===r)}function Pi(){return{s:e=>e.getBoundingClientRect(),shown:e=>e.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0})!==!1,opacity:e=>parseFloat(getComputedStyle(e).opacity)||0,oe:()=>({width:window.innerWidth,height:window.innerHeight})}}var Jo=()=>{let e=window.Reveal;return typeof e?.getIndices=="function"&&typeof e.slide=="function"?e:null};function er(e,t,n=Pi()){let o=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,r=null,s=null,l=0,d=!1,m=()=>[...e.querySelectorAll(Pt)],u=()=>[...e.querySelectorAll(".slides > section")],v=w=>typeof w=="string"&&w.length>0&&w.length<=j.viewValue?w:null,x=w=>v(w?.getAttribute("data-pipeup-slide"));function T(){if(It){let M=null;if(Ot(()=>{let P=It.current();Number.isInteger(P)&&P>0&&(M=String(P))}),M!==null)return M}let w=Jo();if(w){let M=null;if(Ot(()=>{let P=w.getIndices().h,b=u()[P];M=x(b?.matches(Pt)?b:b?.querySelector(Pt))??v(String(P+1))}),M!==null)return M}return r&&!r.isConnected&&(r=null),r=Mi(m(),n,r)??r,x(r)}function C(){l=0,s=T(),t()}let c=()=>{!l&&!d&&(l=requestAnimationFrame(C))},k=w=>Ci(w,s,qn);function L(w){if(k(w))return Promise.resolve(!0);let M=w.slide,P=Jo(),b=m().find(V=>x(V)===M),H=/^[1-9]\d{0,5}$/.test(M??"");if(H&&It)Ot(()=>It.go(Number(M)));else if(H&&P){let V=b?u().findIndex(q=>q===b||q.contains(b)):-1;Ot(()=>P.slide(V>=0?V:Number(M)-1))}else if(fn.size)for(let V of fn)Ot(()=>V({...w}));else if(b)b.scrollIntoView({block:"start",behavior:o?"auto":"smooth"});else return Promise.resolve(!1);let _=performance.now();return new Promise(V=>{let q=K=>{clearTimeout(J),V(K)},J=setTimeout(()=>q(!1),Go),D=()=>{if(d)return q(!1);if(s=T(),k(w))return q(!0);if(performance.now()-_>=Go)return q(!1);requestAnimationFrame(D)};requestAnimationFrame(D)})}let p=new MutationObserver(w=>{w.some(M=>M.target instanceof Element&&M.target.matches(Pt))&&c()});p.observe(e,{subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]});for(let w of Xo)window.addEventListener(w,c,{capture:!0,passive:!0});return Kn.add(c),s=T(),{slide:()=>s,view(w){let M=w instanceof Element?w:w?.parentElement,P=x(M?.closest(Pt))??s,b={...P!==null?{slide:P}:{},...qn};return Object.keys(b).length?b:void 0},u:k,W:L,destroy(){d=!0,cancelAnimationFrame(l),p.disconnect();for(let w of Xo)window.removeEventListener(w,c,!0);Kn.delete(c)}}}var zn=["pipeup-quote","pipeup-on","pipeup-done"],Oi={"pipeup-quote":[[250,227,188,.75],[250,200,100,.28]],"pipeup-on":[[247,212,154,.95],[250,200,100,.42]],"pipeup-done":[[180,178,169,.22],[180,178,169,.2]]},Ii=(e,t)=>zn.map(n=>{let[o,r,s,l]=Oi[n][e?1:0];return`::highlight(${n}){background-color:rgba(${o},${r},${s},${+(l*t).toFixed(3)})}`}).join("");function nr(){return typeof CSS<"u"&&"highlights"in CSS&&typeof Highlight<"u"}var Ni="<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><rect x='7' y='7' width='23' height='23' rx='4' fill='none' stroke='#534AB7' stroke-width='2' stroke-dasharray='4 3'/><path d='M3 2v15l4-3.5 3 6.5 2.5-1.2-3-6.3H15z' fill='#fff' stroke='#2C2C2A' stroke-width='1.2' stroke-linejoin='round'/></svg>",Ri=`:not([data-pipeup-ignore],[data-pipeup-ignore] *){cursor:url("data:image/svg+xml,${encodeURIComponent(Ni)}") 3 2,crosshair!important}`;function or(e=document,t=!1){let n=e.defaultView?.CSSStyleSheet;if(!n||!("replaceSync"in n.prototype)||!("adoptedStyleSheets"in e))return{ke(){},Se(){},le(){},Te(){},remove:()=>tr()};let o=new n,r=null,s=!1,l=1,d=0,m="",u=0,v=()=>o.replaceSync(Ii(t,l)+(r===null?"":`:root{--pipeup-gutter:${r}px}`)+(s?Ri:"")+(d||m?`html{--pipeup-panel:${d}px;${d?`margin-right:${d}px!important;`:""}${m}}`:""));return v(),e.adoptedStyleSheets=[...e.adoptedStyleSheets,o],{ke(x){x!==r&&(r=x,v())},Se(x){x!==s&&(s=x,v())},le(x){l=x,v()},Te(x,T){x!==d&&(d=x,m=T?"":"transition:margin-right .34s cubic-bezier(.4,0,.2,1)!important",clearTimeout(u),!x&&m&&(u=window.setTimeout(()=>{m="",v()},400)),v())},remove(){clearTimeout(u),e.adoptedStyleSheets=e.adoptedStyleSheets.filter(x=>x!==o),tr()}}}function rr(e){if(nr())for(let t of zn)CSS.highlights.set(t,new Highlight(...e[t.slice(7)]))}function tr(){if(nr())for(let e of zn)CSS.highlights.delete(e)}var Wn=':host{all:initial}*{box-sizing:border-box}button{appearance:none;font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}svg{display:block}.layer{all:initial;display:block;position:fixed;inset:0;pointer-events:none;font:13px/1.5 var(--pu-font,system-ui,sans-serif);color:var(--k);--k:#2C2C2A;--mu:#5F5E5A;--fa:#888780;--ln:#E5E3DA;--ru:#ECEAE2;--so:#FAFAF7;--su:#FFFFFF;--ho:#F1EFE8;--as:color-mix(in srgb,var(--pu-accent,#534AB7) 12%,transparent);--sh:0 8px 28px rgba(44,44,42,.1);--in:.26s;--mv:.34s;--out:.2s;--pl:1.2s;--eo:cubic-bezier(.22,.61,.36,1);--eio:cubic-bezier(.4,0,.2,1);--ei:cubic-bezier(.4,0,1,1);--pu-text:var(--k);--pu-muted:var(--mu);--pu-faint:var(--fa);--pu-line:var(--ln);--pu-surface:var(--su);--pu-soft:var(--so);--pu-hover:var(--ho);--pu-shadow:var(--sh);--pu-ease:var(--eo)}.layer.dark{--k:#ECEBE6;--mu:#B4B2A9;--fa:#8D8B84;--ln:#3A3936;--ru:#34332F;--so:#22221F;--su:#1B1B19;--ho:#2C2C29;--sh:0 8px 28px rgba(0,0,0,.45)}.layer.hidden .bub,.layer.hidden .col,.layer.hidden .pop,.layer.hidden .tip,.layer.hidden .mark,.layer.hidden .selbar{opacity:0!important;pointer-events:none!important}.tx{font-size:14px;line-height:1.5;color:var(--k);white-space:pre-wrap;overflow-wrap:anywhere}.tx.del,.who,.rest,.ctx{color:var(--fa)}.who,.rest{font-size:12px}.who{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rft>.who{display:block}.ctx[hidden]{display:none}.ctx{font-size:12px;margin-bottom:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.clamp{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.tx a{color:var(--pu-accent);text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.ft,.rft{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--in) var(--eo),opacity var(--in) var(--eo)}.ft>*,.rft>*{overflow:hidden;min-height:0;display:flex;align-items:center}.root:hover>.ft,.root:focus-within>.ft,.it:hover>.rft,.it:focus-within>.rft{grid-template-rows:1fr;opacity:1}.ft.has-rest{grid-template-rows:1fr;opacity:1}.ft.has-rest>*{grid-area:1/1}.ft .hover{opacity:0;transition:opacity var(--in) var(--eo)}.ft .rest{transition:opacity var(--in) var(--eo)}.root:hover>.ft .hover,.root:focus-within>.ft .hover,.ft:not(.has-rest) .hover{opacity:1}.root:hover>.ft .rest,.root:focus-within>.ft .rest{opacity:0}.acts{margin-left:6px;display:flex;flex:none}.ib{width:24px;height:22px;display:grid;place-items:center;border-radius:6px;color:var(--mu);transition:background-color .2s var(--eo),color .2s var(--eo)}.ib:hover,.ib:focus-visible{background:var(--ho);color:var(--k);outline:none}.rps,.rbox{padding-left:14px}.rps .it{padding-top:6px}.more{display:grid;grid-template-rows:1fr;transition:grid-template-rows var(--mv) var(--eio)}.more>div{overflow:hidden;min-height:0}.th:not(.on) .more{grid-template-rows:0fr}.row{display:flex;align-items:center;gap:8px;padding:8px 0 2px;cursor:text}.input{flex:1;min-width:0;height:27px;display:block;border:0;border-bottom:1px solid var(--ln);outline:none;resize:none;overflow:hidden;font:inherit;font-size:14px;line-height:1.5;padding:3px 0;color:var(--k);background:transparent;transition:border-color var(--in) var(--eo)}.row:hover .input,.input:hover{border-bottom-color:var(--mu)}.input:focus{border-bottom-color:var(--pu-accent)}.ed{display:flex;gap:10px;align-items:center;min-height:34px;padding:6px 10px}.ed .input{font-size:13px;height:22px}.root,.it{position:relative;padding-right:30px}.av{display:grid;place-items:center;width:22px;height:22px;border-radius:32%;font-size:12px;font-weight:600;line-height:1;opacity:0;transform:scale(.85);transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.av.in{opacity:1;transform:none}.av svg{width:80%;height:80%}.root>.av,.it>.av{position:absolute;top:0;right:0}.it>.av{top:6px}.av{--av-l:92%;--av-d:30%;--s:60%;background:hsl(var(--h) var(--s) var(--av-l));color:hsl(var(--h) var(--s) var(--av-d))}.dark .av{--av-l:20%;--av-d:78%}.c0{--h:0}.c1{--h:25}.c2{--h:50}.c3{--h:130}.c4{--h:175}.c5{--h:215}.c6{--h:270}.c7{--h:330}.c8{--h:28;--s:35%}.c9{--h:220;--s:8%}.me{flex:none;display:grid}.me>.av{grid-area:1/1;width:26px;height:26px;font-size:13px}.you{display:grid;padding:0 34px;min-height:24px;font-size:12px;color:var(--fa)}.you>*{grid-area:1/1;display:flex;align-items:center;min-width:0;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.say{white-space:pre;overflow:hidden}.nm{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.say button{flex:none}.say button{color:var(--mu);text-decoration:underline;text-decoration-color:var(--ln);text-underline-offset:2px;transition:color .2s var(--eo)}.say button:hover,.say button:focus-visible{color:var(--pu-accent);outline:none}.nf{opacity:0;transform:translateY(-4px);pointer-events:none}.nf .input{font-size:13px;height:24px}.you.naming .nf{opacity:1;transform:none;pointer-events:auto}.you.naming .say{opacity:0;pointer-events:none}.send{width:26px;height:26px;border-radius:50%;display:grid;place-items:center;color:var(--pu-accent);flex:none;opacity:0;pointer-events:none;transition:opacity var(--in) var(--eo),background-color .2s var(--eo)}.send.show{opacity:1;pointer-events:auto}.send:hover{background:var(--as)}.bub{position:fixed;left:0;top:0;width:20px;height:20px;margin:-20px 0 0 -2px;border-radius:50% 50% 50% 0;background:var(--pu-accent);border:2px solid var(--su);box-shadow:0 1px 4px #0003;pointer-events:auto;opacity:0;transform:translateY(-6px) scale(.9);transform-origin:2px 20px;transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.bub.in{opacity:1;transform:none;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.bub.in:hover,.bub.on{transform:scale(1.18)}.bub.done{background:var(--fa)}.bub.ghost{pointer-events:none}.tip,.pop,.menu,.all,.xp,.toast,.selbar,.namebar,.ttip,.tt,.mode{background:var(--su);border:1px solid var(--ln);box-shadow:var(--sh)}.tip{position:fixed;max-width:260px;border-radius:10px;padding:7px 10px;opacity:0;transform:translateY(3px);transition:opacity .22s var(--eo),transform .26s var(--eo)}.tip.show{opacity:1;transform:none;pointer-events:auto;cursor:pointer;transition:opacity .22s var(--eo),transform .26s var(--eo),left var(--mv) var(--eio),top var(--mv) var(--eio)}.pop{position:fixed;width:var(--pu-pop);border-radius:12px;padding:10px 12px 8px;pointer-events:none;opacity:0;transform:translateY(6px) scale(.98);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.pop.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo)}.pop.show.glide{transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo),left var(--mv) var(--eio),top var(--mv) var(--eio)}.mark{position:fixed;border:2px solid color-mix(in srgb,var(--pu-accent) 50%,transparent);background:var(--as);border-radius:8px;opacity:0;transition:opacity .3s var(--eo)}.mark.show{opacity:1}.pulse{position:fixed;border:2px solid var(--pu-accent);border-radius:8px;background:var(--as);animation:pu-pulse var(--pl) var(--eio) forwards}@keyframes pu-pulse{0%{opacity:0;transform:scale(.985)}35%{opacity:.85;transform:scale(1)}to{opacity:0;transform:scale(1.02)}}.col{position:fixed;left:0;top:0;pointer-events:none;transition:opacity var(--in) var(--eo)}.th{position:absolute;left:0;right:0;top:0;padding:4px 4px 4px 12px;pointer-events:auto;cursor:pointer;box-shadow:inset 2px 0 0 transparent;transition:transform var(--mv) var(--eio),box-shadow var(--in) var(--eo),opacity var(--in) var(--eo)}.th.hot{box-shadow:inset 2px 0 0 var(--ln)}.th.on{box-shadow:inset 2px 0 0 var(--pu-accent);cursor:default}.th.dim{opacity:.45}.th.resolved:not(.on):not(.hot){opacity:.6}.th.lost .ctx{white-space:normal}.th.wait{opacity:0!important;pointer-events:none}.th.out{opacity:0!important;pointer-events:none;transition:opacity var(--out) var(--ei)}.th:has(.opn:focus-visible){box-shadow:inset 2px 0 0 var(--ln);outline:2px solid var(--pu-accent);outline-offset:2px;border-radius:4px}.selbar{position:fixed;display:flex;border-radius:10px;padding:2px;opacity:0;transform:translateY(4px);pointer-events:none;transition:opacity var(--in) var(--eo),transform .3s var(--eo)}.selbar.show{opacity:1;transform:none;pointer-events:auto}.selbar button{width:32px;height:30px;display:grid;place-items:center;border-radius:8px;color:var(--pu-accent);transition:background-color .2s var(--eo)}.selbar button:hover,.selbar button:focus-visible{background:var(--as);outline:none}.pick{position:fixed;left:0;top:0;border:2px solid color-mix(in srgb,var(--pu-accent) 70%,transparent);background:color-mix(in srgb,var(--pu-accent) 6%,transparent);border-radius:8px;pointer-events:none;opacity:0;transition:opacity var(--out) var(--ei),border-color var(--out) var(--ei),border-width var(--out) var(--ei),box-shadow var(--out) var(--ei)}.pick.show{opacity:1;transition-duration:var(--in);transition-timing-function:var(--eo)}.pick.show.glide{transition-property:all;transition-duration:var(--mv);transition-timing-function:var(--eio)}.pick.on{border-color:var(--pu-accent)}.pick.kf{border:3px solid var(--pu-accent);box-shadow:0 0 0 2px var(--su)}.km{position:fixed;left:0;top:0;pointer-events:none;outline:none}.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.namebar{position:fixed;left:0;top:0;display:flex;align-items:center;gap:2px;padding:2px 2px 2px 10px;border-radius:10px;font-size:12px;color:var(--mu);white-space:nowrap;pointer-events:none;opacity:0;transform:translateY(4px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.namebar.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform .3s var(--eo)}.namebar.show.glide{transition-property:all;transition-duration:var(--mv);transition-timing-function:var(--eio)}.namebar .lbl{margin-right:6px;max-width:260px;overflow:hidden;text-overflow:ellipsis}.namebar .nb{padding:4px;display:grid;place-items:center;border-radius:7px;transition:background-color .2s var(--eo),color .2s var(--eo)}.namebar .nb:hover,.namebar .nb:focus-visible{background:var(--ho);color:var(--k);outline:none}.namebar .nb[hidden]{display:none}.launch{position:fixed;right:20px;bottom:20px;pointer-events:auto}.launch .mode{position:relative;display:grid;place-items:center;width:46px;height:46px;border-radius:50%;transition:background-color .3s var(--eo),color .3s var(--eo)}.mode>*,.cnt>*{grid-area:1/1}.mode>*{display:grid;place-items:center;transition:opacity var(--in) var(--eo)}.cnt,.has>.plus{opacity:0}.has>.cnt{opacity:1}.n{font-size:12px;font-weight:500;line-height:1;margin:-1.4px 0 0 1.4px;font-variant-numeric:tabular-nums;opacity:0;transition:opacity var(--in) var(--eo)}.n.s{font-size:9.5px;letter-spacing:-.04em}.n.on{opacity:1}.launch .mode:hover,.launch .mode[aria-expanded=true]{background:var(--ho)}.launch .mode.on{background:var(--pu-accent);color:#fff}.mode>.dot{position:absolute;top:3px;right:3px;width:9px;height:9px;border-radius:50%;background:var(--pu-accent);border:2px solid var(--su);opacity:0}.mode.else>.dot{opacity:1}.ttip{position:absolute;right:0;bottom:54px;white-space:nowrap;border-radius:8px;padding:4px 9px;font-size:12px;pointer-events:none;opacity:0;transform:translateY(3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.ttip small{margin-left:8px}.ttip small,.mi .kc{font-size:12px;color:var(--fa)}.mode:hover+.ttip,.mode:focus-visible+.ttip{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .5s,transform var(--in) var(--eo) .5s}.launch .mode[aria-expanded=true]+.ttip{opacity:0;transition:opacity var(--out) var(--ei)}@media(hover:none){.ttip,.tt{display:none}}.menu{position:fixed;right:20px;bottom:76px;width:290px;border-radius:12px;padding:4px;pointer-events:none;opacity:0;transform:translateY(6px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.menu.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo)}.mi{position:relative;display:flex;gap:10px;align-items:center;width:100%;min-height:34px;text-align:left;padding:6px 10px;border-radius:8px;transition:background-color .2s var(--eo)}.mi:hover,.mi:focus-visible{background:var(--so);outline:none}.mi svg{color:var(--mu);flex:none}.mi small{display:block;color:var(--fa);font-size:12px}.lb{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ma{flex:none;display:grid;margin:-2px 0}.ma .av{width:20px;height:20px;font-size:11px}.mi .av svg{color:inherit}.sep{height:1px;margin:4px 10px;background:var(--ru)}.tt{position:absolute;right:calc(100% + 14px);top:50%;translate:0 -50%;width:max-content;max-width:220px;padding:4px 9px;border-radius:8px;font-size:12px;line-height:1.4;color:var(--mu);pointer-events:none;opacity:0;transform:translate(3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.mi:hover>.tt,.mi:focus-visible>.tt{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .5s,transform var(--in) var(--eo) .5s}@media(max-width:600px){.tt{right:8px;top:auto;bottom:100%;translate:none;transform:translateY(3px)}}.sw{position:relative;flex:none;width:26px;height:16px;border-radius:8px;background:var(--ln);transition:background-color var(--mv) var(--eio)}.sw:before,.sw:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #00000040;transition:transform var(--mv) var(--eio),opacity var(--mv) var(--eio)}.sw:before{opacity:0;transform:translate(10px)}[aria-checked=true]>.sw{background:var(--pu-accent)}[aria-checked=true]>.sw:after{transform:translate(10px)}.tools{display:flex;flex:none;gap:2px}.tools[hidden]{display:none}.tool[aria-pressed=true]{background:var(--as);color:var(--pu-accent)}.note{display:block;padding:0 0 4px;font-size:12px;color:var(--fa)}.note[hidden]{display:none}.ov{position:absolute;inset:0;pointer-events:none;overflow:hidden}.xb{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px 16px 16px;font-size:13px}.xb p{margin:0 0 10px}.all,.xp{position:fixed;top:0;right:0;bottom:0;width:var(--pu-panel);display:flex;flex-direction:column;border-width:0 0 0 1px;opacity:0;transform:translate(100%);transition:transform var(--out) var(--ei),opacity var(--out) var(--ei)}.all.show,.xp.show{opacity:1;transform:none;pointer-events:auto;transition:transform var(--mv) var(--eo),opacity var(--in) var(--eo)}.all.full{width:100%}.hd{display:flex;align-items:center;gap:8px;padding:12px 10px 8px 16px;font-weight:600}.pn{font-weight:400;color:var(--fa)}.hs{margin-left:auto;display:flex;align-items:center;gap:6px;padding:3px 4px 3px 6px;border-radius:6px;font-size:12px;font-weight:400;color:var(--mu);transition:background-color .2s var(--eo)}.hs:hover,.hs:focus-visible{background:var(--ho);outline:none}.list{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px}.all .mi{align-items:flex-start}.all .mi>.av{flex:none}.all .mi>span:last-child{flex:1;min-width:0}.all .mi small{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.all .mi.done{opacity:.6}.layer.listing .col{opacity:0;transition:opacity var(--out) var(--ei)}.sec{padding:8px 10px 2px;font-size:12px;color:var(--fa)}.sec b{margin-left:6px;font-weight:500;color:var(--pu-accent)}.toast{position:fixed;left:50%;bottom:28px;border-radius:10px;padding:8px 14px;font-size:13px;opacity:0;transform:translate(-50%,6px);transition:opacity .3s var(--eo),transform .36s var(--eo)}.toast.show{opacity:1;transform:translate(-50%)}@media(forced-colors:active){.pick.kf{border:3px solid Highlight}.layer :is(.ib,.mi,.nb,.hs,.selbar button,.say button,.xb button):focus-visible{outline:2px solid Highlight}}@media(prefers-reduced-motion:reduce){.bub,.bub.in,.bub.in:hover,.bub.on,.tip,.pop,.selbar,.menu,.all,.xp,.ttip,.tt,.toast{transform:none!important}.sw:after{transform:none!important;transition-property:opacity}[aria-checked=true]>.sw:after{opacity:0}[aria-checked=true]>.sw:before{opacity:1}.th{transition-property:opacity,box-shadow}.tip.show{transition-property:opacity}.pick,.pick.show{transition:opacity .16s ease-in-out}.all,.all.show,.xp,.xp.show{transition-property:opacity}.namebar,.namebar.show{transform:none!important;transition:opacity .16s ease-in-out}.av,.nf{transform:none!important}@keyframes pu-pulse{0%{opacity:0}35%{opacity:.85}to{opacity:0}}}';var ir="#534AB7",$i="rgb(0, 0, 238)";function sr(e){let t=/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)/.exec(e);if(!t||t[1]===void 0||t[2]===void 0||t[3]===void 0)return null;let n=t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]);return{r:Number(t[1]),g:Number(t[2]),b:Number(t[3]),a:n}}function Hi(e){let t=n=>{let o=n/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function ar(e){let t=e.ownerDocument,n=t.defaultView;if(!n)return{font:"system-ui, sans-serif",accent:ir,dark:!1};let o=t.documentElement,r=n.getComputedStyle(e).fontFamily||"system-ui, sans-serif",s=(n.getComputedStyle(o).getPropertyValue("--pipeup-accent")||o.style.getPropertyValue("--pipeup-accent")).trim(),l=e.querySelector("a[href]"),d=l?n.getComputedStyle(l).color:"",m=s||(d&&d!==$i?d:ir),u=sr(n.getComputedStyle(t.body).backgroundColor);(!u||u.a===0)&&(u=sr(n.getComputedStyle(o).backgroundColor));let v=u&&u.a>0?Hi(u)<.2:n.matchMedia?.("(prefers-color-scheme: dark)").matches===!0&&/dark/.test(n.getComputedStyle(o).colorScheme||"");return{font:r,accent:m,dark:!!v}}function lr(e,t){e.style.setProperty("--pu-font",t.font),e.style.setProperty("--pu-accent",t.accent),e.classList.toggle("dark",t.dark)}function dr(e,t=document){let n=t.createElement("pipeup-root");n.setAttribute("data-pipeup-ignore",""),n.style.cssText="position:fixed!important;inset:0!important;pointer-events:none!important;z-index:2147483000!important;display:block!important;margin:0!important;visibility:visible!important;opacity:1!important;transform:none!important;filter:none!important;";let o=n.attachShadow({mode:"open"}),r=t.defaultView?.CSSStyleSheet;if(r&&"replaceSync"in r.prototype&&"adoptedStyleSheets"in o){let l=new r;l.replaceSync(Wn),o.adoptedStyleSheets=[l]}else{let l=t.createElement("style");l.textContent=Wn,o.append(l)}let s=t.createElement("div");return s.className="layer",s.style.setProperty("--pu-panel",`${Lt}px`),s.style.setProperty("--pu-pop",`${Ze}px`),lr(s,e),o.append(s),t.documentElement.append(n),{element:n,shadow:o,t:s,destroy:()=>n.remove()}}var Di=40,Bi=250,Vi=120,Fi=2400,_i=4e3,Ui=1e4;function cr(e,t=!1){return Fn(e,t)?"column":"bubbles"}function qi(e){return[...e.state.mode==="column"?[Ko(e),Rn(e,{te:!1})]:[Rn(e,{te:!0})],Wo(e),jo(e)]}var Ki=1e3,hn="Shown here, but not saved yet \u2014 it will be saved with your next change",nt=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";function pr(e){let t=ar(e.root),n=dr(t),o=or(document,t.dark);o.le(0);let r=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,s=document.documentElement.hasAttribute("data-pipeup-reserve"),l=new Map,d=new Set,m=new WeakSet,u={i:null,L:null,M:!1,hidden:!0,mode:cr(e.root),o:null,l:!1,d:!1,O:!1,c:!1},v=y("div",{class:"toast",role:"status","aria-live":"polite"}),x=y("div",{class:"sr","aria-live":"polite"});n.t.append(v,x);let T=null,C=[],c=null,k=!1,L=0,p=0,w=0,M=0,P=0,b=new Set,H="",_=new Map,V=er(e.root,()=>{!k&&U()&&G()}),q=!1,J=0;function D(a,g=Fi,S=!1,O=!1){k||(q=S,v.textContent=a,O?v.setAttribute("aria-hidden","true"):v.removeAttribute("aria-hidden"),v.classList.add("show"),window.clearTimeout(L),L=window.setTimeout(()=>v.classList.remove("show"),g))}function K(){q&&(q=!1,window.clearTimeout(L),v.classList.remove("show"))}function oe(a){x.textContent="",cancelAnimationFrame(J),J=requestAnimationFrame(()=>x.textContent=a)}function Se(a){D(nt(a))}function se(a){throw Se(a),a}let le=a=>({thread:a,location:qt(a.anchor,l.get(a.id)??gt(a.anchor,e.root),e.root)}),de=a=>(n.t.querySelector(`[data-thread="${a}"] .rbox textarea`)?.value.trim()??"")!=="",Te=a=>u.i!==a||u.M?!1:(c?.se()?c.ae():n.t.querySelector(".launch .mode")?.focus({preventScroll:!0}),!0),A={reply:async(a,g)=>{try{await e.doc.reply(a,g)}catch(S){S instanceof we?D(hn):se(S)}},resolve:async a=>{try{await e.doc.resolve(a),D("Resolved \xB7 Show resolved brings it back")}catch(g){D(g instanceof we?`Resolved \xB7 ${hn}`:nt(g))}Te(a)&&(u.i=null)},reopen:async a=>{try{await e.doc.reopen(a),D("Reopened")}catch(g){D(g instanceof we?`Reopened \xB7 ${hn}`:nt(g))}},close:()=>{ae(null);let a=Ae&&n.t.querySelector(Ae);a?a.focus({preventScroll:!0}):c?.ae(),Ae=""},copy:a=>{try{let g=e.doc.threads().find(O=>O.id===a);if(!g)return;let S=Yt(le(g),"ai",location.href,Date.now());Un(S,n.t).then(()=>D("Thread copied as Markdown for AI"),O=>D(nt(O)))}catch(g){D(nt(g))}}},N={copyAll:async a=>{let g=N.all(),S=jt(g,a,{title:document.title,url:location.href,exportedAt:new Date});try{await Un(S,n.t);let O=g.filter(R=>!R.thread.resolved).length;D(`Copied ${O} thread${O===1?"":"s"}${a==="ai"?" as Markdown for AI":""}`)}catch(O){D(nt(O))}},je:()=>{u.M=!u.M,G()},rename:async a=>{let g=a.replace(/\s+/g," ").trim();try{await We(g)?D(`New comments will say ${g}, but this browser couldn't remember it`):D(`New comments will say ${g}`)}catch(S){D(nt(S))}},name:()=>e.doc.name,all:()=>[...e.doc.threads()].sort(Fe(B)).map(le)},$={},B={get addons(){return $.surface},doc:e.doc,root:e.root,t:n.t,host:n.element,state:u,resolved:l,k:d,j:A,c:N,p:V,V:a=>b.has(a.id),Ee:()=>{U()&&G()},B:a=>!u.hidden&&(!a.resolved||u.M||de(a.id))&&!b.has(a.id),Je:(a,g)=>{for(let S of e.doc.threads()){let O=l.get(S.id);if(S.anchor.quote&&B.B(S)&&O?.range&&No(a,g,Tt(O)))return S}return null},ne:(a,g)=>B.C()?B.Je(a,g):null,m:a=>a.composedPath().includes(n.element),we:a=>void m.add(a),qe:a=>m.has(a),open:ae,Ge:a=>re(a),L:Ke,Ye:ze,Ue:rt,C:()=>!T||T.De(),be:a=>{let g=T?.ve();a(),g?.()},ze:()=>{let a=u.o?.anchor.view,g=T?.ve();Promise.resolve(V.u(a)||V.W(a??{}).then(()=>B.Ee())).then(g)},Be:Ye,Ve:ne,Xe:fe,N:it,D:a=>{T=a},Z:D,w:oe,Ke:K,re:Se,Qe:Ne,f:G,ie:ge},z=$.surface=new tn(B,n.shadow,x);function F(a){let g=performance.now(),S=e.doc.threads();for(let O of S){if(a&&!a.has(O.id))continue;let R=performance.now()-g<Di,Y=gt(O.anchor,e.root,{fuzzy:R});l.set(O.id,Y),!R&&Y.state==="orphaned"?d.add(O.id):d.delete(O.id)}for(let O of[...l.keys()])S.some(R=>R.id===O)||l.delete(O);d.size===0?(window.clearTimeout(M),M=0):M===0&&(M=window.setTimeout(()=>{M=0,!k&&(F(new Set(d)),G())},Bi))}function U(){let a=new Set,g=V.slide()!==null,S=new Set;for(let R of e.doc.threads()){S.add(R.id);let Y=l.get(R.id)?.element;(!V.u(R.anchor.view)||!g&&Y?.checkVisibility?.({visibilityProperty:!0})===!1)&&a.add(R.id)}b=a;for(let R of _.keys())S.has(R)||_.delete(R);let O=`${V.slide()}|${[...a].join()}`;return O===H?!1:(H=O,!0)}function W(a){let g=[],S=[],O=[];for(let R of a){let Y=l.get(R.id);R.resolved&&!u.M||!Y?.range||b.has(R.id)||(R.id===u.i||R.id===u.L?S.push(Y.range):R.resolved?O.push(Y.range):g.push(Y.range))}u.o&&V.u(u.o.anchor.view)&&S.push(...u.o.ranges),rr({quote:g,on:S,done:O})}let ee=0,_e=0,Ee=0;function Ue(a){if(a===_e)return;_e=a,cancelAnimationFrame(Ee);let g=ee,S=performance.now(),O=a?260:200,R=Y=>{let X=Math.min(1,(Y-S)/O);ee=g+(a-g)*(a?1-(1-X)**3:X*X),o.le(ee),X<1&&(Ee=requestAnimationFrame(R))};Ee=requestAnimationFrame(R)}let Oe=0,te=0;function qe(a){a!==Oe&&(Oe=a,o.Te(a,r),window.clearTimeout(te),te=window.setTimeout(()=>{F(),G()},r?0:400))}function G(){if(k)return;let a=e.doc.threads();if(U(),u.i&&b.has(u.i)){let S=n.t.querySelector(`[data-thread="${u.i}"] .rbox textarea`)?.value;S&&_.set(u.i,S),u.i=null}u.hidden=!u.l&&!u.d&&!u.O&&!u.o,u.hidden&&(u.i=null),Ue(u.hidden?0:1),n.t.classList.toggle("hidden",u.hidden),n.t.classList.toggle("listing",u.d);let g=u.d&&!et();qe(g?Lt:0),o.ke(s?u.mode==="column"&&!u.hidden&&!g?Ct:0:null),W(a);for(let S of C)S.f(a);c?.f(a),u.hidden||z.flush()}let Ae="",pe=()=>n.t.getRootNode().activeElement,ue="input,textarea,select,[contenteditable]:not([contenteditable=false])",he=()=>{let a=pe();return a instanceof HTMLTextAreaElement&&a.value!==""||!!document.activeElement?.matches(ue)};function re(a,g=he(),S=pe()){let O=[...n.t.querySelectorAll(`[data-thread="${a}"] .rbox textarea`)].find(Y=>!Y.closest("[inert]")),R=S?.getAttribute("data-thread");Ae=R?`.${S.classList[0]}[data-thread="${R}"]`:"",!(g||!O)&&O.focus({preventScroll:!0})}function Ie(){let a=u.o;return!a||B.C()?!1:(V.u(a.anchor.view)||V.W(a.anchor.view??{}),!0)}function ae(a,g=!1){if(a&&Ie())return;if(u.i===a&&!u.o)return a?re(a):void 0;let S=!g&&he(),O=pe();if(a||(u.O=!1),u.i=a,a&&(u.o=null,Ne(a)),G(),a){let R=_.get(a),Y=R&&n.t.querySelector(`[data-thread="${a}"] .rbox textarea`);Y&&!Y.value&&(Y.value=R,Y.dispatchEvent(new Event("input",{bubbles:!0}))),_.delete(a),g&&c?.se()?c.ae():re(a,S,O)}}function Ke(a){u.L!==a&&(u.L=a,a&&a!==u.i&&Ne(a),G())}function ze(a){K(),u.d=!1,u.o=a,u.i=null,G()}function rt(a){if(!u.o)return ze(a);Object.assign(u.o,a),G()}function ne(){u.o&&(u.o=null,G())}function fe(a,g=!1){u.l!==a&&(u.l=a,o.Se(a),a?(u.i=null,u.d=!1,c=Uo(B)):(K(),c?.destroy(),c=null,oe("Comment mode off")),G(),c&&(g&&c.xe(),g?c.se()?D(Vn,Ui,!0,!0):D("Nothing here to comment on"):D(`Click anything to comment, or Tab between blocks \xB7 Option-click (Alt-click) to pin \xB7 ${St} or Esc to finish`,_i,!0)))}function ge(){u.o&&(V.u(u.o.anchor.view)||B.C())?ne():u.i?ae(null):c&&!c.ie()&&fe(!1)}function it(){if(u.o){Ie()||ne();return}u.i&&ae(null)}async function We(a){try{return await e.onName(a),!1}catch(g){if(e.doc.name!==a)throw g;return!0}}async function Ye(a){let g=u.o;if(g)try{let S=await e.doc.comment(g.anchor,a);u.o=null,F(new Set([S])),ae(S,!0)}catch(S){if(S instanceof we){u.o=null,F(new Set([S.id])),ae(S.id,!0),D(hn);return}se(S)}}function Ne(a){let g=l.get(a);if(!g||g.state==="orphaned")return;let S=g.range?Tt(g):g.element?[g.element.getBoundingClientRect()]:[];for(let O of S.slice(0,6)){let R=y("div",{class:"pulse"});Ve(R,O,4),n.t.prepend(R),window.setTimeout(()=>R.remove(),1300)}}function ke(){for(let a of C)a.destroy();C=qi(B),G()}let Re=()=>{if(!k){for(let a of C)a.S();c?.S(),z.S(),P=requestAnimationFrame(Re)}},je=a=>{let g=a.composedPath()[0];return g instanceof Element&&g.closest(ue)!==null},st=a=>{if(a.key==="Escape")return ge();if(Io(a)&&!a.isComposing&&!a.defaultPrevented&&!je(a)){if(a.preventDefault(),c?.We()&&c.xe())return;fe(!u.l,!0)}},$e=a=>{if(B.m(a)||m.has(a))return;let g=window.getSelection();g&&!g.isCollapsed||it()},h=()=>{let a=cr(e.root,u.mode==="column");a!==u.mode?(u.mode=a,ke()):G()};function E(){let a=performance.now();p===0&&(w=a),window.clearTimeout(p);let g=Math.min(Vi,Math.max(0,w+Ki-a));p=window.setTimeout(()=>{p=0,F(),G()},g)}let I=new MutationObserver(a=>{a.every(g=>n.element.contains(g.target))||E()});window.addEventListener("keydown",st),window.addEventListener("click",$e),window.addEventListener("resize",h),I.observe(e.root,{subtree:!0,childList:!0,characterData:!0});let i=new ResizeObserver(E);i.observe(e.root);let f=e.doc.onChange((a,g,S)=>{z.Oe(g,S),F(),G()});return F(),ke(),P=requestAnimationFrame(Re),{ctx:B,destroy(){k=!0,cancelAnimationFrame(P),cancelAnimationFrame(Ee),cancelAnimationFrame(J),V.destroy(),window.clearTimeout(te),window.clearTimeout(L),window.clearTimeout(p),window.clearTimeout(M),I.disconnect(),i.disconnect(),f(),window.removeEventListener("keydown",st),window.removeEventListener("click",$e),window.removeEventListener("resize",h),c?.destroy();for(let a of C)a.destroy();z.destroy(),o.remove(),n.destroy()}}}var ot=null,zi=4e3;function Yn(e={}){if(xe)return xe.mount(e);if(!nn())return Promise.reject(new Error("pipeup: another copy of Pipeup owns the add-on queue. Remove one script."));if(ot)return ot;let t=Yi(e,()=>t).catch(n=>{throw ot===t&&(ot=null),n});return ot=t,t}function Wi(e,t){return new Promise((n,o)=>{let r=setTimeout(()=>o(new Error("timed out")),t);e.then(n,o).finally(()=>clearTimeout(r))})}async function Yi(e,t){let n=document.documentElement.getAttribute("data-pipeup-doc"),{id:o,key:r}=n?await Dt(n):{id:`page-${Be(location.origin+location.pathname)}`,key:null},s,l=!1,d;if(e.store)s=e.store,d=await ct(s);else try{let c=pt.open();s=await Wi(c,zi).catch(k=>{throw c.then(L=>L.close(),()=>{}),k}),d=await ct(s)}catch{s=new dt,l=!0,d=await ct(s)}let m=e.name?.trim();m&&m!==d.name&&(d={...d,name:m},await s.saveProfile(d));let u=await lt.open({doc:o,key:r,store:s,identity:d.identity,name:d.name});mn(e.slides??null);let v;try{v=pr({doc:u,root:e.root??document.body,onName:async c=>{u.name=c,d={...d,name:c},await s.saveProfile(d)}})}catch(c){throw mn(null),c}l&&v.ctx.Z("This browser can't keep comments for this page \u2014 copy the comments (Copy as Markdown) to keep them");let x=()=>void u.flush().catch(c=>globalThis.reportError?.(c)),T=Oo({surface:v.ctx.addons,doc:u,root:e.root??document.body,ephemeral:l,version:vt}),C=!1;return window.addEventListener("pagehide",x),{document:u,flush:()=>u.flush(),unmount:()=>{C||(C=!0,window.removeEventListener("pagehide",x),T(),v.destroy(),mn(null),ot===t()&&(ot=null))}}}function ur(){let e=document.documentElement;if(!e.hasAttribute("data-pipeup-doc")||e.getAttribute("data-pipeup-auto")==="off")return;let t=()=>void Yn().catch(n=>console.error(n));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}typeof document<"u"&&(xe?console.warn(`pipeup: Pipeup is on this page twice (${xe.VERSION} and ${vt}); the first one is used. Remove one script.`):(nn(),ur()));return yr(ji);})();
|
|
9
|
+
`}function Yt(e,t){return e.deleted?"(deleted)":e.text.replace(/\r\n|\r|\n/g,`
|
|
10
|
+
`+t)+(e.edited?" (edited)":"")}var vt="0.5.1";function v(e,t={},...n){let o=document.createElement(e);for(let[r,s]of Object.entries(t))s===void 0||s===!1||(r==="class"?o.className=String(s):o.setAttribute(r,s===!0?"":s));for(let r of n)r!=null&&r!==!1&&o.append(r);return o}function Q(e,t){let n=e.getRootNode().activeElement;t&&n instanceof HTMLElement&&e.contains(n)&&n.blur(),e.inert=t}function Xt(e,t,n=null){let o=e.getRootNode().activeElement,r=!1;for(let s=t.length;s--;n=t[s])t[s].nextSibling!==n&&(r=!!e.insertBefore(t[s],n));return r&&o&&t.some(s=>s.contains(o))&&o.focus({preventScroll:!0}),r}var ut=()=>{let e=window.getSelection();return e&&!e.isCollapsed&&e.toString().trim()?e:null};function be(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}function Ve(e,t,n=4){e.style.left=`${t.left-n}px`,e.style.top=`${t.top-n}px`,e.style.width=`${t.width+n*2}px`,e.style.height=`${t.height+n*2}px`}var Jr=/\bhttps?:\/\/[^\s<>"'`]+/gi,Qr=`.,;:!?'"]}`,Zr=2048,ei=/[\u202A-\u202E\u2066-\u2069]/;function ti(e){let t=0,n=0;for(let r of e)r==="("?t++:r===")"&&n++;let o=e.length;for(;o>0;){let r=e[o-1];if(r===")"&&n>t)n--;else if(!Qr.includes(r))break;o--}return e.slice(0,o)}function Jt(e){let t=[],n=0;for(let o of e.matchAll(Jr)){if(o[0].length>Zr||ei.test(o[0]))continue;let r=ti(o[0]),s=o.index??0,l;try{let m=new URL(r);if(m.protocol!=="http:"&&m.protocol!=="https:")continue;l=m.href}catch{continue}s>n&&t.push(e.slice(n,s));let c=v("a",{href:l,target:"_blank",rel:"noopener noreferrer"},r);c.addEventListener("click",m=>m.stopPropagation()),t.push(c),n=s+r.length}return n<e.length&&t.push(e.slice(n)),t}var Po="http://www.w3.org/2000/svg",ni={comment:["M20.5 11.5a8 8 0 0 1-11.7 7.1L4 19.8l1.2-4.4A8 8 0 1 1 20.5 11.5z","M12.3 8.2v6.6M9 11.5h6.6"],send:["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],copy:["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],resolve:["M5 12.5l4.5 4.5L19 7.5"],reopen:["M3 12a9 9 0 1 0 3-6.7","M3 4v5h5"],lines:["M4 7h16M4 12h10M4 17h7"],list:["M3 6.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M3 12a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M3 17.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M9 6.5h11M9 12h11M9 17.5h7"],expand:["M14 4h6v6M20 4l-6 6M10 20H4v-6M4 20l6-6M20 14v6h-6M20 20l-6-6M4 10V4h6M4 4l6 6"],pin:["M6 18v-6a6 6 0 1 1 6 6z"],shrink:["M20 10h-6V4M14 10l6-6M4 14h6v6M10 14l-6 6M14 20v-6h6M14 14l6 6M10 4v6H4M10 10L4 4"],bubble:["M20.5 11.5a8 8 0 0 1-11.7 7.1L4 19.8l1.2-4.4A8 8 0 1 1 20.5 11.5z"],close:["M6 6l12 12M18 6L6 18"],edit:["M4 20h4L19 9l-4-4L4 16z"]};function Z(e,t=15,n){let o=Ce(ni[e],t);return n&&o.setAttribute("stroke-width",String(n)),o}function Ce(e,t){let n=document.createElementNS(Po,"svg"),o={width:String(t),height:String(t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"};for(let[r,s]of Object.entries(o))n.setAttribute(r,s);for(let r of e){let s=document.createElementNS(Po,"path");s.setAttribute("d",r),n.append(s)}return n}var Qt=(e,t,n)=>`M${e} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 -${2*n} 0`,oi={Otter:"M4 13.2C4 9.2 7.6 6.5 12 6.5s8 2.7 8 6.7-3.6 6.3-8 6.3-8-2.3-8-6.3zM5.6 9.6a1.8 1.8 0 1 1 2.7-2.3M18.4 9.6a1.8 1.8 0 1 0-2.7-2.3M9.2 11.6h.01M14.8 11.6h.01M11 14h2l-1 1zM9.8 15.8l-3.2.4M9.9 17l-2.7 1.1M14.2 15.8l3.2.4M14.1 17l2.7 1.1",Fox:"M3.5 4l5 3.5h7l5-3.5-1.5 8.5L12 20l-7-7.5zM9 12h.01M15 12h.01M12 17h.01",Owl:`M5 4.5l3 2.5h8l3-2.5V14a7 7 0 0 1-14 0z${Qt(7.4,11.5,1.9)}${Qt(12.8,11.5,1.9)}M11.3 14.6l.7 1 .7-1`,Bear:`${Qt(5,13.5,7)}M8.9 7.22A2.8 2.8 0 1 0 5.89 10.09M18.11 10.09A2.8 2.8 0 1 0 15.1 7.22M9.4 12.6h.01M14.6 12.6h.01M10.3 16.4c0-1 .8-1.6 1.7-1.6s1.7.6 1.7 1.6-.8 1.6-1.7 1.6-1.7-.6-1.7-1.6z`,Rabbit:`${Qt(6.5,15.5,5.5)}M9.6 10.5C8.2 6.5 8.4 2.5 9.8 2.5s2.4 3.5 1.6 7.5M14.4 10.5c1.4-4 1.2-8-.2-8s-2.4 3.5-1.6 7.5M10 15h.01M14 15h.01M11.3 17.3l.7.5.7-.5`};function Oo(e){let t=/[\p{L}\p{N}]/u.exec(e);if(!t)return"";let n=t[0].toUpperCase();return[...n].length===1?n:t[0]}var yt=(e,t)=>Oo(t)||me(e);function Pe(e,t){return v("span",{class:`av c${In(e)}`,"aria-hidden":"true","data-animal":me(e)},Oo(t)||Ce([oi[Qe[On(e)]]],24))}var ri=320;function Zt(e,t){setTimeout(()=>{e.remove(),t?.()},ri)}function en(e){return requestAnimationFrame(()=>{e.offsetWidth,e.classList.add("in")}),e}var Nn=null,$n=e=>{Nn=e},Io=()=>Nn?.note()??null,wt="pu-source";function tn(e){let t=v("textarea",{class:"input",rows:"1","aria-label":e.label}),n=v("button",{class:"send",type:"button","aria-label":"Send",title:"Send",inert:!0},Z("send")),o=v("span",{class:"tools"});o.hidden=!0;let r=v("div",{class:"row"},e.before,t,o,n),s=e.kind??"comment",l=!1,c=new Set,m=()=>{for(let d of[...c])d()},u=()=>{let d=t.value.trim()!=="";n.classList.toggle("show",d),n.inert=!d,t.style.height="auto",t.style.height=`${Math.max(27,t.scrollHeight)}px`},g=()=>{let d=-1,S=0,C=(p,y)=>{d<0&&(d=t.selectionStart,S=0);let P=t.value.slice(0,d),O=p&&P&&!/\s$/.test(P)&&!/^\s/.test(p)?" ":"";t.setRangeText(O+p,d,d+S,"end"),S=O.length+p.length,y&&(d=-1),u()};return{update:p=>C(p,!1),commit:p=>C(p,!0),cancel:()=>{d>=0&&S&&t.setRangeText("",d,d+S,"end"),d=-1,S=0,u()}}},E=new Map,T=()=>{let d=(Nn?.tools()??[]).filter(S=>S.available?.()!==!1);for(let[S,C]of E)d.some(p=>p.id===S)||(C.remove(),E.delete(S));for(let S of d){if(E.has(S.id))continue;let C=v("button",{class:"ib tool",type:"button","aria-label":S.label,title:S.label,"aria-pressed":"false"},Ce(S.icon,15));C.addEventListener("mousedown",p=>p.preventDefault()),C.addEventListener("click",p=>{p.stopPropagation();try{S.press({kind:s,thread:e.thread?.()??null,text:()=>t.value,focus:()=>t.focus({preventScroll:!0}),connected:()=>r.isConnected,setPressed:y=>C.setAttribute("aria-pressed",String(y)),dictate:g,onEnd:y=>(c.add(y),()=>c.delete(y))})}catch(y){globalThis.reportError?.(y)}}),E.set(S.id,C),o.append(C)}o.hidden=E.size===0};T(),r.addEventListener(wt,T);let L=async()=>{let d=t.value.trim();if(!(!d||l)){l=!0;try{await e.V(d),n.matches(":focus")&&t.focus(),t.value="",u(),m()}catch{}finally{l=!1}}};return r.addEventListener("mousedown",d=>{d.target===t||n.contains(d.target)||o.contains(d.target)||(d.preventDefault(),t.focus({preventScroll:!0}),t.setSelectionRange(t.value.length,t.value.length))}),t.addEventListener("input",u),t.addEventListener("keydown",d=>{d.stopPropagation(),d.key==="Enter"&&!d.shiftKey&&!d.isComposing?(d.preventDefault(),L()):d.key==="Escape"&&(d.preventDefault(),t.value="",u(),t.blur(),m(),e._?.())}),n.addEventListener("click",d=>{d.stopPropagation(),L()}),{element:r,input:t,focus:()=>t.focus({preventScroll:!0})}}var Et=1,No=["sync","menu","notify","note","composer","panel","styles","status","overlay","here","sign"],ii=/^[a-z][a-z0-9-]{1,23}$/,si=new Set(["local","file","page","user","pipeup","presence","sync"]),ai=1e4,nn=class{constructor(t,n,o){this.ctx=t;this.shadow=n;this.after=o;$n({tools:()=>this.U,note:()=>[...this.X.values()].at(-1)??null})}G=0;$=[];X=new Map;J=new Map;U=[];Q=new Set;R=new Set;q=new Set;K=new Map;k=new Map;z=new Map;remote={n:0,who:new Set};last=0;timer=0;de="";subscribe(t){return this.q.add(t),()=>void this.q.delete(t)}changed(t){t&&this.G++;for(let n of[...this.q])n(t);for(let n of this.ctx.t.querySelectorAll(".row, .draft"))n.dispatchEvent(new Event(wt))}H(t,n){let o=this.z.get(t)??this.z.set(t,new Set).get(t),r=()=>void(o.delete(r)&&n());return o.add(r),r}pe(){return[...this.J.values()].map(t=>t.text).join(" \xB7 ")}Ae(t,n){return this.$.push(n),this.changed(!0),{update:()=>this.changed(!1),remove:this.H(t,()=>{this.$.splice(this.$.indexOf(n),1),this.changed(!0)})}}ue(t,n,o){o?t.set(n,o):t.delete(n),this.changed(!1)}Le(t,n){return this.U.push(n),this.changed(!1),this.H(t,()=>{this.U.splice(this.U.indexOf(n),1),this.changed(!1)})}closed(){return this.ctx.state.hidden&&!this.ctx.state.d}Me(t,n){this.closed()?this.k.set(t,n):this.ctx.Z(n)}flush(){if(this.closed()||this.k.size===0)return;let t=[...this.k.values()].at(-1);this.k.clear(),this.ctx.Z(t)}Ce(){return this.shadow.activeElement instanceof HTMLTextAreaElement||[...this.ctx.t.querySelectorAll("textarea")].some(t=>t.value.trim()!=="")}Pe(t){this.ctx.state.hidden||this.ctx.w(t)}Oe(t,n){if(!(n==="local"||n==="")){for(let{body:o}of t)o.author===this.ctx.doc.me||o.kind!=="create"&&o.kind!=="reply"||(this.remote.n++,this.remote.who.add(o.name||me(o.author)));this.fe()}}fe(t=Math.max(0,this.last+ai-Date.now())){this.timer||!this.remote.n||(this.timer=window.setTimeout(()=>{if(this.timer=0,this.ctx.state.hidden||this.Ce())return this.fe(1e3);let{n,who:o}=this.remote;this.remote={n:0,who:new Set},this.last=Date.now(),this.ctx.w(`${n} new comment${n===1?"":"s"} from ${o.size===1?[...o][0]:`${o.size} people`}`)},t))}Ie(t){let n=this.K.get(t);return n||(n=v("div",{class:"ov","aria-hidden":"true","data-addon":t}),this.ctx.t.insertBefore(n,this.after.nextSibling),this.K.set(t,n)),n}Ne(t,n){let o=this.ctx.host.ownerDocument.defaultView?.CSSStyleSheet,r=o&&"replaceSync"in o.prototype&&"adoptedStyleSheets"in this.shadow?new o:null;r&&(r.replaceSync(n),this.shadow.adoptedStyleSheets=[...this.shadow.adoptedStyleSheets,r]);let s=r??this.shadow.appendChild(v("style",{},n));return this.H(t,()=>r?this.shadow.adoptedStyleSheets=this.shadow.adoptedStyleSheets.filter(l=>l!==r):s.remove())}he(t,n,o){return n.add(o),this.H(t,()=>n.delete(o))}$e(t,n){return this.he(t,this.Q,n)}Re(t,n){let o=this.he(t,this.R,n);return this.call(this.R,n,this.ge()),o}ge(){let{state:t}=this.ctx,n=this.shadow.activeElement;return{shown:!t.hidden,commentMode:t.l,allOpen:t.c,dark:this.ctx.t.classList.contains("dark"),view:this.ctx.p.view(),writing:n instanceof HTMLTextAreaElement?n.closest("[data-thread]")?.dataset.thread??"":null}}S(){for(let o of[...this.Q])this.call(this.Q,o);if(this.R.size===0)return;let t=this.ge(),n=JSON.stringify(t);if(n!==this.de){this.de=n;for(let o of[...this.R])this.call(this.R,o,t)}}call(t,n,...o){try{n(...o)}catch(r){t.delete(n),globalThis.reportError?.(r)}}He(t,n,o){let r=this.ctx.t,s=this.shadow.activeElement,l=v("button",{class:"ib",type:"button","aria-label":"Close"},Ce(["M6 6l12 12M18 6L6 18"],15)),c=v("div",{class:"xp",role:"dialog","aria-label":o.label,"data-addon":t},v("div",{class:"hd"},v("span",{},o.label),l),v("div",{class:"xb"},n)),m=[...r.children].filter(E=>E instanceof HTMLElement&&!E.inert);for(let E of m)E.inert=!0;r.append(c),c.offsetWidth,c.classList.add("show");let u=E=>{E.key==="Escape"&&(E.stopPropagation(),E.preventDefault(),g())},g=this.H(t,()=>{window.removeEventListener("keydown",u,!0);for(let E of m)E.inert=!1;c.classList.remove("show"),c.inert=!0,window.setTimeout(()=>c.remove(),300),s?.focus?.({preventScroll:!0});try{o.onClose?.()}catch(E){globalThis.reportError?.(E)}});return l.addEventListener("click",g),window.addEventListener("keydown",u,!0),(c.querySelector("button, input, textarea, select, a[href]")??c).focus?.({preventScroll:!0}),{close:g}}clear(t){for(let n of[...this.z.get(t)??[]])n();this.z.delete(t),this.K.get(t)?.remove(),this.K.delete(t);for(let n of[this.X,this.J,this.k])n.delete(t);this.changed(!0)}destroy(){window.clearTimeout(this.timer),$n(null),this.q.clear()}},kt=new Map,bt=null,xe=(()=>{let e=globalThis.Pipeup;return e?.VERSION?e:null})();function $o(){return xe?xe.addons():[...kt.values()].map(e=>({...e.info}))}function xt(e){if(xe)return xe.use(e);let t=l=>console.warn(`pipeup: ${l}`),n=e;if(!n||typeof n!="object"||typeof n.id!="string"||!ii.test(n.id)||si.has(n.id)||typeof n.setup!="function"||typeof n.network?.says!="string")return t("an add-on needs an id of 2 to 24 lowercase letters, digits and dashes (not a reserved one), a setup function and a network statement");if(kt.has(n.id))return t(`the add-on "${n.id}" is already registered; the second is ignored`);let o={id:n.id,version:String(n.version??""),network:n.network,state:"waiting"},r=(n.needs??[]).find(l=>!No.includes(l));n.api!==Et?(o.state="off",o.reason=`needs add-on API ${String(n.api)}; this Pipeup has ${Et}`):r&&(o.state="off",o.reason=`this Pipeup has no ${r} slot`);let s={addon:e,info:o};kt.set(n.id,s),bt?.i&&o.state==="waiting"&&Ro(s,bt)}function on(){if(xe)return!0;let e=globalThis,t=e.pipeupAddons;if(Array.isArray(t))for(let n of t)xt(n);else if(t&&typeof t=="object"&&t.push!==xt)return!1;return e.pipeupAddons={push:xt},!0}function li(e){return e instanceof Error?e.message:String(e)}async function Ro(e,t){let{addon:n,info:o}=e,r=new AbortController,s=new Set,{surface:l,doc:c}=t,m=()=>!r.signal.aborted,u=Object.assign(()=>{},{update(){},remove(){},close(){}}),g=p=>(...y)=>m()?p(...y):u,E={id:c.id,me:c.me,get name(){return c.name},threads:()=>c.threads(),ops:()=>c.ops(),onChange:p=>{let y=c.onChange(p);return s.add(y),()=>{y(),s.delete(y)}}},T=n.id,L={api:Et,version:t.version,document:E,root:t.root,ephemeral:t.ephemeral,signal:r.signal,has:p=>No.includes(p),off:p=>{S=String(p)},merge:p=>m()?c.merge(p,T):Promise.resolve(0),addMenuItem:g(p=>l.Ae(T,p)),notify:g(p=>l.Me(T,p)),announce:g(p=>l.Pe(p)),setComposerNote:g(p=>l.ue(l.X,T,p)),addComposerTool:g(p=>l.Le(T,p)),openPanel:g((p,y)=>l.He(T,p,y)),addStyles:g(p=>l.Ne(T,p)),setStatus:g(p=>l.ue(l.J,T,p)),overlay:()=>l.Ie(T),onFrame:g(p=>l.$e(T,p)),where:p=>l.ctx.p.view(p),isHere:p=>l.ctx.p.u(p),go:p=>l.ctx.p.W(p),onUi:g(p=>l.Re(T,p)),avatar:(p,y)=>{let P=Pe(p,y);return P.classList.add("in"),P},sign:(p,y)=>c.sign(`${T}/${p}`,y)},d,S,C=()=>{if(m()){r.abort();for(let p of[...s])p();try{d?.()}catch(p){globalThis.reportError?.(p)}l.clear(T),o.state==="on"&&(o.state="waiting")}};e.stop=C;try{if(d=await n.setup(L),!m()){d?.();return}if(S!==void 0){C(),o.state="off",o.reason=S;return}o.state="on",delete o.reason}catch(p){o.state="failed",o.reason=li(p),C(),o.state="failed",globalThis.reportError?.(p)}}function Ho(e){let t={...e,i:!0};bt=t;for(let n of kt.values())n.info.state==="waiting"&&Ro(n,t);return()=>{t.i=!1,bt===t&&(bt=null);for(let n of[...kt.values()].reverse())n.stop?.(),delete n.stop;e.surface.destroy()}}var ci={code:"KeyC"},St=typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform)?"\u21E7\u2325C":"Shift+Alt+C",Rn="Shift+Alt+C";function Do(e){return e.code===ci.code&&e.shiftKey&&e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.repeat&&!e.getModifierState("AltGraph")}function di(e){let t=v("button",{class:"me",type:"button",tabindex:"-1","aria-hidden":"true"});t.addEventListener("mousedown",p=>p.preventDefault());let n=tn({label:"Comment",kind:"comment",before:t,V:e.V,_:e._}),o=v("div",{class:"note"}),r=()=>{let p=Io();o.textContent=p??"",o.hidden=!p};r();let s=v("div",{class:"say"}),l=v("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"}),c=v("div",{class:"nf"},l),m=v("div",{class:"you"},s,c),u="",g=!1,E=()=>{let p=e.name(),y=p?"change":"add your name";if(t.title=p?"Change your name":"Add your name",!t.lastChild||u!==p){let O=Pe(e.me,p),x=t.lastChild;x?(en(O),Zt(x)):O.classList.add("in"),t.append(O),u=p}let P=v("button",{type:"button"},y);P.addEventListener("click",L),s.replaceChildren(v("span",{class:"nm"},p||`You're ${me(e.me)}`)," \xB7 ",P)},T=p=>{m.classList.toggle("naming",p),Q(s,p),Q(c,!p)};function L(p){p.stopPropagation(),l.value=e.name(),T(!0),l.focus({preventScroll:!0}),l.select()}let d=()=>{T(!1),n.focus()};t.addEventListener("click",L),l.addEventListener("keydown",p=>{if(p.stopPropagation(),p.key==="Escape")p.preventDefault(),d();else if(p.key==="Enter"){p.preventDefault();let y=l.value.trim();if(!y||y===e.name())return d();if(g)return;g=!0,e.rename(y).finally(()=>{g=!1,E(),d()})}}),E(),T(!1);let S=v("div",{class:"ctx"},e.label),C=v("div",{class:"draft"},S,o,n.element,m);return C.addEventListener(wt,r),{element:C,ve:()=>{let{selectionStart:p,selectionEnd:y}=n.input;return()=>{n.focus(),n.input.setSelectionRange(p,y)}},ee:p=>{S.hidden=p},ye:p=>{S.textContent=p},focus:()=>n.focus(),De:()=>n.input.value.trim()===""}}function rn(e,t){let n=di({label:t.label,me:e.doc.me,name:()=>e.d.name(),rename:o=>e.d.rename(o),V:o=>e.Be(o),_:()=>e.Fe()});return e.D(n),n}function sn(e,t){if(t.state==="orphaned"||!t.element||e.quote)return null;let n=t.element.getBoundingClientRect();if(!n.width&&!n.height)return null;if(e.point)return{x:n.left+e.point.x*n.width,y:n.top+e.point.y*n.height};let o=t.element.ownerDocument.createRange();o.selectNodeContents(t.element);let r=o.getBoundingClientRect();return{x:r.width?Math.min(n.right-8,r.right+6):n.right-8,y:(r.height?r.top:n.top)+8}}function Tt(e){return e.range?[...e.range.getClientRects()]:[]}function Hn(e,t){let n=Tt(t)[0];if(n)return n.top;if(t.state==="orphaned"||!t.element)return null;let o=t.element.getBoundingClientRect();return e.point?o.top+e.point.y*o.height:o.top}function At(e,t){let n=Tt(t).at(-1);if(n)return{x:n.left,y:n.bottom,below:!0};let o=sn(e,t);return o?{...o,below:!1}:null}function Bo(e,t,n){for(let o of n)if(e>=o.left&&e<=o.right&&t>=o.top&&t<=o.bottom)return!0;return!1}function Fo(e,t,n=10){let o=[...e].sort((c,m)=>c.T-m.T),r=new Array(o.length).fill(0),s=o.findIndex(c=>c.id===t),l=c=>o[c];if(s<0)o.forEach((c,m)=>{r[m]=m===0?c.T:Math.max(c.T,(r[m-1]??0)+l(m-1).height+n)});else{r[s]=l(s).T;for(let c=s+1;c<o.length;c++)r[c]=Math.max(l(c).T,(r[c-1]??0)+l(c-1).height+n);for(let c=s-1;c>=0;c--)r[c]=Math.min(l(c).T,(r[c+1]??0)-l(c).height-n)}return new Map(o.map((c,m)=>[c.id,r[m]??0]))}var Lt=320,pi=300,Oe=()=>window.innerWidth>=900?400:pi,ui=480,et=()=>window.innerWidth<=ui;function an(e){let t=window.innerWidth;return{width:e&&!et()?t-Lt:t,height:window.innerHeight}}function ln(e,t,n,o=12){let r,s;return e.below?(r=Math.min(e.x,n.width-t.width-o),s=e.y+8,s+t.height>n.height-o&&(s=e.y-t.height-40)):(r=e.x+14,r+t.width>n.width-o&&(r=e.x-t.width-28),s=Math.min(e.y-12,n.height-t.height-o)),{left:Math.max(o,r),top:Math.max(o,s)}}function Vo(e,t,n,o=12,r=44){let s=e.top-r>=8,l=e.top+e.height+8+(s?0:r),c=e.top-8-(s?r:0)-t.height,m=l+t.height<=n.height-o||c<o,u=m?l:c;return{above:!m,left:Math.max(o,Math.min(e.left,n.width-t.width-o)),top:Math.max(o,u)}}function cn(e,t,n){let o=e.top-t.height-10;return o<8&&(o=e.top+e.height+10),{left:Math.max(8,Math.min(e.left+e.width/2-t.width/2,n.width-t.width-8)),top:o}}function dn(e,t){let n=e.resolved.get(t.id);return n?.range?.startContainer??n?.element??null}var _e=e=>(t,n)=>{let o=dn(e,t),r=dn(e,n),s=l=>l.anchor.point??{x:0,y:-1};return o!==r?!r||o&&o.compareDocumentPosition(r)&4?-1:1:s(t).y-s(n).y||s(t).x-s(n).x};var pn=e=>`${e} ${e===1?"reply":"replies"}`;function ft(e,t,n){let o={...n},r=e.id,s=v("div",{class:"rbox always"},v("div",{},tn({label:"Reply",kind:"reply",thread:()=>r,V:p=>t.reply(r,p),_:t.close}).element)),l=v("div",{}),c=v("span",{class:"note"},"This thread was resolved. Your words are kept until you send or clear them.");c.hidden=!0,s.prepend(c);let m=v("div",{}),u=null,g=v("div",{},m,v("div",{class:"more"},l)),E=new Map,T=new Map,L=new Map,d=p=>{let y=yt(p.author,p.name),P=E.get(p.id),O=P?.e;if((!O||P.key!==y)&&(O=en(Pe(p.author,p.name)),P)){let H=P.e;L.set(p.id,H),Zt(H,()=>L.get(p.id)===H&&L.delete(p.id))}O.title=de(p),T.set(p.id,{key:y,e:O});let x=L.get(p.id);return x?[x,O]:[O]},S=(p,y,P)=>{let O=v("button",{class:"ib",type:"button","aria-label":y,title:y},Z(p));return O.addEventListener("click",x=>{x.stopPropagation(),P()}),O};function C(p,y={}){Object.assign(o,y),r=p.id;let P=(o.now??Date.now)(),O=p.root.replies.length,x=W=>v("span",{class:"who"},`${de(W)} \xB7 ${Ze(W.at,P)}`),H=W=>v("div",{class:W.deleted?"tx del":"tx"},...W.deleted?["Deleted"]:[...Jt(W.text),W.edited?" (edited)":""]),q=p.resolved?"Resolved"+(O?` \xB7 ${pn(O)}`:""):O?pn(O):"",F=v("div",{class:o.Y==="column"&&q?"ft has-rest":"ft"},o.Y==="column"&&q?v("span",{class:"rest"},q):null,v("span",{class:"hover"},x(p.root),v("span",{class:"acts"},S("copy","Copy thread",()=>t.copy(p.id)),p.resolved?S("reopen","Reopen",()=>void t.reopen(p.id)):S("resolve","Resolve",()=>void t.resolve(p.id))))),z=o.lost?v("div",{class:"ctx"},`${o.place||"No longer on the page"} \u2014 it read \u201C${be(o.lost,120)}\u201D`):o.quote?v("div",{class:"ctx"},`\u201C${be(o.quote,80)}\u201D`):null;T=new Map;let J=v("div",{class:"root"},...d(p.root),z,H(p.root),F);m.replaceWith(J),m=J,u?.remove(),u=O?v("div",{class:"rps"},...p.root.replies.map(W=>v("div",{class:"it"},...d(W),H(W),v("div",{class:"rft"},x(W))))):null,u&&l.prepend(u),E=T;let D=s.querySelector("textarea").value.trim()!=="";c.hidden=!(p.resolved&&D),p.resolved&&!D?s.remove():s.parentNode!==l&&l.append(s),g.className=p.resolved?"thread resolved":"thread",g.setAttribute("data-thread",p.id)}return C(e),{element:g,update:C}}var fi="a,button,input,select,textarea,label,summary,[role=button],[contenteditable]",mi=400;function Dn(e,t){let n=new Map,o=v("div",{class:"tip",role:"tooltip"}),r=v("div",{class:"mark"}),s=v("div",{class:"pop",role:"dialog","aria-label":"Comment thread"});o.inert=s.inert=!0,e.t.append(r,o,s);let l=v("div",{class:"bub pin ghost","aria-hidden":"true"}),c=[],m=null,u=null,g=null,E=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,T=0,L=null,d=null,S=null,C=0,p=M=>c.find($=>$.id===M)??null,y=()=>t.te||e.state.c,P=!1,O=M=>{let $=e.resolved.get(M.id);return $?At(M.anchor,$):null};function x(M,$,R){let{left:B,top:Y}=ln($,{width:M.offsetWidth||R,height:M.offsetHeight},an(e.state.c));M.style.left=`${B}px`,M.style.top=`${Y}px`}function H(M){let $=M&&y()&&e.state.i!==M?p(M):null,R=$?O($):null;if(!$||!R){S=null,o.classList.remove("show"),Q(o,!0);return}if(S!==$.id){let B=$.root.replies.length;o.replaceChildren(v("div",{class:"tx clamp"},...$.root.deleted?["Deleted"]:Jt($.root.text)),v("div",{class:"who"},`${de($.root)}${B?` \xB7 ${B} ${B===1?"reply":"replies"}`:""}`)),S=$.id}x(o,R,260),o.classList.contains("show")||o.offsetWidth,o.classList.add("show"),o.inert=!1}function q(M){L=M,H(M),e.L(M)}function F(M){if(window.clearTimeout(C),M!==null){q(M);return}C=window.setTimeout(()=>q(null),y()?mi:0)}o.addEventListener("mouseenter",()=>window.clearTimeout(C)),o.addEventListener("mouseleave",()=>F(null)),o.addEventListener("click",M=>{M.stopPropagation();let $=S;$&&(window.clearTimeout(C),q(null),e.open($))});function z(M){let $=n.get(M.id);if($)return $;let R=v("button",{class:"bub",type:"button","data-thread":M.id});return R.addEventListener("mouseenter",()=>F(M.id)),R.addEventListener("mouseleave",()=>F(null)),R.addEventListener("click",B=>{B.stopPropagation(),H(null),e.open(M.id)}),e.t.insertBefore(R,r),n.set(M.id,R),R}let J=!1;function D(){let M=e.state.o,$=g&&M&&!M.anchor.quote&&!M.anchor.point?M.resolved.element:null;if($){let{left:B,top:Y,above:_}=Vo($.getBoundingClientRect(),{width:s.offsetWidth||Oe(),height:s.offsetHeight},{width:window.innerWidth,height:window.innerHeight}),K=g?.above!==null&&g?.above!==_;if(g&&(g.above=_),K&&oe())return;s.style.left=`${B}px`,s.style.top=`${Y}px`;return}let R=g&&M?At(M.anchor,M.resolved):m?O(m):null;R&&x(s,R,Oe())}let W=M=>e.state.l&&!M.anchor.quote&&!M.anchor.point;function oe(M=()=>{}){return window.clearTimeout(T),E?(s.classList.remove("show"),T=window.setTimeout(()=>{M(),D(),s.classList.add("show")},220),!0):(M(),s.classList.add("glide"),T=window.setTimeout(()=>s.classList.remove("glide"),450),!1)}function Se(){if(!y())return null;let M=e.state.o;return M?M.anchor.quote||M.anchor.point||e.state.l?null:M.resolved.element:!m||m.anchor.quote||m.anchor.point?null:e.resolved.get(m.id)?.element??null}function se(M){c=M;let $=new Set;for(let _ of M){if(!e.B(_)||_.anchor.quote)continue;let K=e.resolved.get(_.id);if(!K||K.state==="orphaned")continue;$.add(_.id);let j=z(_);j.classList.toggle("done",_.resolved),j.classList.toggle("on",e.state.i===_.id),j.classList.toggle("pin",_.anchor.point!==void 0);let ee=`Comment on ${Me(K.element)}: ${be(_.root.text,60)}`;j.getAttribute("aria-label")!==ee&&j.setAttribute("aria-label",ee)}Xt(e.t,M.filter(_=>$.has(_.id)).sort(_e(e)).map(_=>n.get(_.id)),r);for(let[_,K]of n)$.has(_)||(K.classList.remove("in"),n.delete(_),window.setTimeout(()=>K.remove(),300));H(L),P!==e.state.c&&s.classList.contains("show")&&!E&&oe(),P=e.state.c;let R=t.te?e.state.o:null;if(R){let _=R.anchor.point??R.resolved.element;g?.of!==R?(window.clearTimeout(T),s.classList.remove("glide"),g={s:rn(e,R),of:R,at:_,above:null},g.s.ee(W(R)),s.replaceChildren(g.s.element),s.inert=!1,g.s.focus(),m=null,u=null,D(),s.classList.add("show")):g&&(g.at!==_&&(g.at=_,g.above=null,oe(()=>g?.s.ye(R.label))),g.s.ee(W(R)));let K=!e.p.u(R.anchor.view);K!==J&&(J=K,s.classList.toggle("show",!K),s.inert=K,K||D());return}g&&(window.clearTimeout(T),s.classList.remove("glide"),g=null,J=!1,e.D(null));let B=y()&&e.state.i?p(e.state.i):null;if(!B||!e.B(B)){m=null,u=null,s.classList.remove("show"),Q(s,!0);return}let Y=B.anchor.quote?.exact??null;!m||!u||m.id!==B.id?(u=ft(B,e.j,{Y:"popover",quote:Y}),s.replaceChildren(u.element),m=B,D(),s.classList.add("show"),s.inert=!1):m!==B&&(u.update(B,{quote:Y}),m=B)}function le(){for(let[B,Y]of n){let _=p(B),K=e.resolved.get(B),j=_&&K?sn(_.anchor,K):null;if(!j||j.y<-40||j.y>window.innerHeight+40){Y.style.visibility="hidden";continue}Y.style.visibility="",Y.style.left=`${j.x}px`,Y.style.top=`${j.y}px`,Y.classList.contains("in")||(Y.offsetWidth,Y.classList.add("in"))}let M=e.state.o,$=M?.anchor.point&&e.p.u(M.anchor.view)?sn(M.anchor,M.resolved):null;$?(l.style.left=`${$.x}px`,l.style.top=`${$.y}px`,l.classList.contains("in")||(e.t.insertBefore(l,r),l.offsetWidth,l.classList.add("in"))):l.classList.contains("in")&&(l.classList.remove("in"),window.setTimeout(()=>l.classList.contains("in")||l.remove(),300)),s.classList.contains("show")&&D();let R=Se();r.classList.toggle("show",R!==null),R&&Ve(r,R.getBoundingClientRect(),4)}let ce=M=>{if(e.m(M)){let R=M.composedPath()[0];d!==null&&!(R instanceof Element&&R.closest(".tip,.bub"))&&F(null),d=null;return}let $=e.ne(M.clientX,M.clientY)?.id??null;$!==d&&(d=$,F($))},Te=M=>{if(e.m(M))return;let $=window.getSelection();if($&&!$.isCollapsed||(e.state.l?M.altKey:M.target instanceof Element&&M.target.closest(fi)))return;let R=e.ne(M.clientX,M.clientY);R&&(e.we(M),H(null),e.open(R.id))};return window.addEventListener("pointermove",ce,{capture:!0,passive:!0}),window.addEventListener("click",Te,!0),{f:se,S:le,destroy(){window.clearTimeout(C),window.clearTimeout(T),window.removeEventListener("pointermove",ce,!0),window.removeEventListener("click",Te,!0),e.D(null);for(let M of n.values())M.remove();l.remove(),o.remove(),r.remove(),s.remove()}}}var hi={display:"block",position:"static",clips:!1,off:!1},gi=48,vi="button link img figure region list listitem tab tabpanel article navigation complementary banner contentinfo form search group dialog menu menuitem checkbox switch radio slider textbox combobox option row cell heading table".split(" ").map(e=>`[role=${e}]`),yi=["button,a,input,select,textarea,label,summary,details,img,svg,canvas,video,picture,figure,figcaption,table,th,td","li,ul,ol,dl,dt,dd,p,h1,h2,h3,h4,h5,h6,blockquote,pre","section,article,aside,nav,header,footer,main,form,fieldset",...vi].join(","),Bn="a,button,label,summary,[role=button],[role=link],[role=tab],[role=option],[role=menuitem]",wi=`${Bn},input,select,textarea,img,svg,canvas,video,picture,[role=img]`,_o=24,bi=.6,un=2,Fn=(e,t)=>Math.abs(e.left-t.left)<=un&&Math.abs(e.top-t.top)<=un&&Math.abs(e.width-t.width)<=un&&Math.abs(e.height-t.height)<=un;function Uo(e,t){let n=t.s(e);if(n.width<2||n.height<2)return!1;if(e.hasAttribute("data-pipeup-id"))return!0;let o=t.oe();return n.width*n.height<=bi*o.width*o.height&&(e.matches(yi)||t.Ve(e)||e.childElementCount>1&&!e.parentElement?.closest(Bn)&&t._e(e))}function Mt(e,t,n){if(e===t||!t.contains(e)||e.closest("[data-pipeup-ignore]"))return null;let o=null;for(let s=e;s&&s!==t&&!o;s=s.parentElement)Uo(s,n)&&(o=s);if(!o||o.hasAttribute("data-pipeup-id"))return o;let r=n.s(o);for(let s=o.parentElement;s&&s!==t&&Fn(n.s(s),r);s=s.parentElement)if(s.hasAttribute("data-pipeup-id"))return s;return o}function Vn(e,t,n){let o=n.s(e);for(let r=e.parentElement;r&&r!==t;){let s=Mt(r,t,n);if(!s)return null;if(!Fn(n.s(s),o))return s;r=s.parentElement}return null}function qo(){return{s:e=>e.getBoundingClientRect(),Ve:e=>{let t=getComputedStyle(e),n=t.backgroundColor!=="transparent"&&!/,\s*0\)$/.test(t.backgroundColor),o=["top","right","bottom","left"].some(r=>parseFloat(t.getPropertyValue(`border-${r}-width`))>0);return n||o||t.backgroundImage!=="none"||t.boxShadow!=="none"},_e:e=>/^(inline-)?(flex|grid)$/.test(getComputedStyle(e).display),flow:e=>{let t=getComputedStyle(e),n=[t.overflowX,t.overflowY];return{display:t.display,position:t.position,clips:n.some(o=>o==="hidden"||o==="clip")&&!n.some(o=>o==="auto"||o==="scroll")&&e!==document.documentElement&&e!==document.body,off:t.pointerEvents==="none"}},oe:()=>({width:innerWidth,height:innerHeight})}}var xi=(e,t)=>e.left<t.left+t.width&&t.left<e.left+e.width&&e.top<t.top+t.height&&t.top<e.top+e.height,Ei=(e,t)=>{let n=Math.max(e.left,t.left),o=Math.max(e.top,t.top);return{left:n,top:o,width:Math.max(0,Math.min(e.left+e.width,t.left+t.width)-n),height:Math.max(0,Math.min(e.top+e.height,t.top+t.height)-o)}};function _n(e,t,n=()=>!0){let o=[],r=(s,l,c,m,u,g)=>{for(let E of s.children){if(E.hasAttribute("data-pipeup-ignore")||E.getAttribute("aria-hidden")==="true"||!n(E))continue;let T=t.flow?.(E)??hi,L=E.offsetParent,d=T.position==="fixed"||T.position==="absolute"&&!!m&&!(L&&m.contains(L)),S=d?null:c,C=t.s(E),p=C.width>0&&C.height>0;if(S&&p&&!xi(C,S))continue;let y=E.matches(Bn),O=(T.display.startsWith("inline")||g)&&!E.matches(wi)&&(T.display==="inline"||C.height<=gi),x=C.width<=_o&&C.height<=_o,H=E.hasAttribute("data-pipeup-id")||!u&&!T.off&&!O&&!(x&&!y),q=l;H&&Uo(E,t)&&(l&&Fn(t.s(l.e),C)?(E.hasAttribute("data-pipeup-id")||!l.e.hasAttribute("data-pipeup-id"))&&(l.e=E):o.push(q={e:E,I:l,E:0}));let F=T.clips&&p;r(E,q,F?S?Ei(S,C):C:S,F?E:d?null:m,u||y,/^inline-(flex|grid)$/.test(T.display)||g&&/(flex|grid)$/.test(T.display))}};r(e,null,null,null,!1,!1);for(let s=o.length-1;s>=0;s--){let l=o[s];l.I&&(l.I.E=Math.max(l.I.E,l.E+1))}return o}var tt=(e,t)=>e.filter(n=>n.E<=t&&(!n.I||n.I.E>t)),Ko=(e,t)=>e.filter(n=>n.I===t);var fn="a,button,summary,[role=button],[role=link],[role=switch],[role=tab],[role=checkbox],input[type=checkbox],input[type=radio],input[type=submit],input[type=button],input[type=reset]",ki=`${fn},input,select,textarea,[contenteditable]:not([contenteditable=false]),[tabindex]:not([tabindex="-1"])`,zo=["click","dblclick","auxclick","submit","contextmenu","dragstart"],Wo=[...["over","out","enter","leave","down","up"].flatMap(e=>[`pointer${e}`,`mouse${e}`]),"mousemove","touchstart","touchmove","touchend","touchcancel"],Si=400,Un="Tab moves between blocks \xB7 \u2191 \u2193 change level \xB7 Enter comments \xB7 Esc to finish \xB7 F7 selects text",Ti=4,Ai=150;function Yo(e){let t=qo(),n=v("span",{hidden:!0},Un),o=v("div",{class:"pick"},n),r=[0,1].map(()=>{let i=v("div",{class:"km",tabindex:"-1",role:"button"},v("span",{hidden:!0}),v("span",{hidden:!0}));return i.inert=!0,i.addEventListener("keydown",st),i.addEventListener("click",f=>{f.stopPropagation(),Ge()}),i.addEventListener("focus",()=>o.classList.add("kf")),i.addEventListener("blur",()=>o.classList.remove("kf")),i}),s=v("span",{class:"lbl"}),l=(i,f,b,a)=>{let w=v("button",{class:"nb",type:"button","aria-label":i,title:f},Z(b,16));return w.addEventListener("click",A=>{A.stopPropagation(),a()}),w},c=l("Around it","Select the block around it","expand",ke),m=l("Inside it","Select a block inside it","shrink",Re),u=l("Pin","Pin its centre","pin",()=>e.be(()=>j(d??x,{x:.5,y:.5}))),g=v("div",{class:"namebar",role:"group","aria-label":"Chosen block"},s,c,m,u);g.inert=!0;let E=e.t.querySelector(".launch");for(let i of[o,...r,g])e.t.insertBefore(i,E);g.addEventListener("mousedown",i=>i.preventDefault());let T=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,L=null,d=null,S=null,C=null,p=0,y=()=>{},P=null,O=()=>{},x=null,H=0,q=0,F=!1,z=null,J=null,D=null,W=0,oe=-1,Se=!0,se=null,le=null,ce=i=>!e.m(i)&&!(i.target instanceof Element&&i.target.closest("[data-pipeup-ignore]"));function Te(){C&&(o.classList.toggle("glide",performance.now()<p),Ve(o,C.getBoundingClientRect(),4))}function M(){if(!P)return;g.classList.toggle("glide",performance.now()<p&&g.classList.contains("show"));let{left:i,top:f}=cn(P.getBoundingClientRect(),{width:g.offsetWidth||200,height:g.offsetHeight||34},{width:window.innerWidth,height:window.innerHeight});g.style.left=`${i}px`,g.style.top=`${f}px`}function $(i,f){C=i,p=f?performance.now()+Si:0,Te(),o.classList.add("show")}function R(i,f){let b=getComputedStyle(i);if(b.opacity==="0")return f(),()=>{};let a=0,w=()=>{window.clearTimeout(a),i.removeEventListener("transitionend",N)},A=()=>{w(),f()},N=U=>{U.target===i&&U.propertyName==="opacity"&&A()},V=Math.max(...b.transitionDuration.split(",").map(U=>parseFloat(U)*1e3||0));return a=window.setTimeout(A,V+100),i.addEventListener("transitionend",N),w}function B(i){if(i!==L){if(L=i,y(),!i){o.classList.remove("show");return}getComputedStyle(o).opacity==="0"?$(i,!1):T?(o.classList.remove("show"),y=R(o,()=>$(i,!1))):$(i,!0)}}function Y(i){d=i,o.classList.toggle("on",i!==null),B(i),_(i)}function _(i){O(),g.inert=!i,i?T?(g.classList.remove("show"),O=R(g,()=>K(i))):K(i):(g.classList.remove("show"),P=null)}function K(i){s.textContent=s.title=Me(i),c.hidden=Vn(i,e.root,t)===null,m.hidden=(x?Ye(i).length:_n(i,t,he).length)===0;let f=g.classList.contains("show");P=i,M(),f||(g.offsetWidth,g.classList.add("show"))}function j(i,f){let b;try{b=Ut(i,e.root,f,e.p.view(i))}catch(A){e.re(A);return}let a={anchor:b,label:f?`Pin on ${Me(i).replace(/^[A-Z](?=[a-z])/,A=>A.toLowerCase())}`:Me(i),ranges:[],resolved:{state:"attached",element:i,range:null}},w=e.state.o;x&&(x=i,oe=-1),Y(f?null:i),S=w??a,e.Ue(a),e.w(f?a.label:`Commenting on ${a.label}`)}function ee(i){e.be(()=>j(i))}function Ue(i){let f=(i.target instanceof Element?Mt(i.target,e.root,t):null)??e.root;f!==e.root&&(z=f);let b=f.getBoundingClientRect();b.width&&b.height&&j(f,{x:(i.clientX-b.left)/b.width,y:(i.clientY-b.top)/b.height})}function Ee(i){let f=window.getSelection();if(f&&!f.isCollapsed)return;if(e.state.o&&(i.altKey||!e.C())){e.N();return}if(!i.altKey&&e.ne(i.clientX,i.clientY))return;if(e.state.i&&e.open(null),x&&i.detail&&ge(),i.altKey){Ue(i);return}let b=i.target instanceof Element?Mt(i.target,e.root,t):null;b&&(z=b),b?j(b):(e.N(),Y(null))}let qe=i=>{if(e.m(i))return;if(!ce(i)){d||B(null);return}if(i.stopPropagation(),d||e.state.o)return;let f=!ut()&&i.target instanceof Element?Mt(i.target,e.root,t):null;if(x){if(!f||f===x||(W+=Math.abs(i.movementX)+Math.abs(i.movementY),W<=Ti))return;ge()}f&&(z=f),B(f)},Ie=()=>{ut()&&(x&&ge(),d||B(null))},te=i=>{ce(i)&&(i.stopPropagation(),(i.type==="pointerdown"||i.type==="mousedown")&&i.target instanceof Element&&i.target.closest(ki)&&i.preventDefault())},Ke=i=>{if(!ce(i))return;let f=i.target;if((f===le||f.form&&f.form===le?.form)&&(i.type==="submit"||i.type==="click"&&!i.detail)){le=i.type==="click"&&f.type==="submit"?f.form:null;return}i.preventDefault(),i.stopPropagation(),i.type==="click"&&!e.state.d&&!e.qe(i)&&Ee(i)},X=i=>{if(le=null,h="",i.key==="Tab"&&Ae(i))return i.preventDefault(),i.stopPropagation(),h=i.key,e.N(),e.state.i&&e.open(null),e.state.d&&(e.state.d=!1,e.f()),$e(i.shiftKey?-1:1);if(!(!ce(i)||!(i.target instanceof Element)))if((i.key==="Enter"||i.key===" ")&&i.target.closest(fn)){if(!x){le=i.target;return}i.preventDefault(),i.stopPropagation()}else i.key==="Enter"&&!x&&i.target.form&&(le=i.target)},Ae=i=>{if(i.ctrlKey||i.metaKey||i.altKey||i.isComposing)return!1;let f=i.composedPath()[0];return!(f instanceof Element)||r.some(b=>b===f)?!1:e.m(i)?!!f.closest(".launch,.menu")&&!f.closest("input,textarea,select,[contenteditable]"):!i.composedPath().some(b=>b instanceof Element&&b.hasAttribute("data-pipeup-ignore"))},pe=()=>e.t.getRootNode().activeElement,ue=()=>r.some(i=>i===pe()),he=i=>(i.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0})!==!1||getComputedStyle(i).display==="contents")&&e.p.u(e.p.view(i)),re=()=>(se?.some(i=>!i.e.isConnected)&&(se=null),se??=_n(e.root,t,he)),Ne=i=>re().find(f=>f.e===i),ae=(i,f=!1)=>{let b=i.getBoundingClientRect();return b.bottom>0&&b.top<window.innerHeight&&(!f||b.top>=0)},ze=()=>{let i=tt(re(),0);return i.find(f=>ae(f.e,!0))??i.find(f=>ae(f.e))??i[0]},We=i=>e.doc.threads().filter(f=>e.B(f)&&i.contains(dn(e,f))).sort(_e(e));function rt(i,f){let[b,a]=i.children,w=tt(re(),H),A=We(f).length;b.textContent=`${qt(f)}, ${w.findIndex(U=>U.e===f)+1} of ${w.length}${A?`, has ${A} comment${A===1?"":"s"}`:""}`;let N=(f.innerText??f.textContent??"").length<=Ai;a.textContent=Pn(f);let V=Se?[n]:[];Se=!1,i.ariaLabelledByElements!==void 0?(i.ariaLabelledByElements=N?[b,f]:[b,a],i.ariaDescribedByElements=N?V:[...V,f]):i.setAttribute("aria-label",`${b.textContent}, ${a.textContent}`)}function ne(i,f=!0){W=0;let b=re(),a=b.find(A=>A.e===i);if(a&&!tt(b,H).includes(a)&&(H=a.E),i!==x&&(oe=-1),i!==d&&(d=null),x=i,B(i),_(i),i.scrollIntoView({block:"nearest",inline:"nearest",behavior:T?"auto":"smooth"}),!f)return;e.Ke();let w=r[q^=1];rt(w,i),Ve(w,i.getBoundingClientRect(),4),w.inert=!1,w.focus({preventScroll:!0}),r[q^1].inert=!0}function fe(){se=null;let i=document.activeElement;J=pe()??i;let f=Ne(z),b=f??(i&&i!==document.body&&e.root.contains(i)&&!i.closest("[data-pipeup-ignore]")?re().filter(a=>a.e.contains(i)).pop():void 0)??ze();return b?(f||(H=b.E),F=!0,ne(b.e),!0):!1}function ge(){let i=ue();z=x,x=null,B(null),_(null);for(let f of r)Q(f,!0);return i}function it(){let i=J;i&&i!==document.body&&i.isConnected&&i.focus?.({preventScroll:!0}),(!i||i===document.body||!i.matches?.(":focus"))&&e.t.querySelector(".launch .mode")?.focus({preventScroll:!0})}function Ye(i){let f=Ne(i);return f?Ko(re(),f):[]}function je(i){let f=tt(re(),H),b=f.findIndex(w=>w.e===x),a=f[b<0?i>0?0:f.length-1:(b+i+f.length)%f.length];a&&ne(a.e)}function $e(i){if(x)return je(i);se=null;let f=document.activeElement;J=pe()??f;let b=z?.isConnected?z:null,a=b&&Ne(b),w;if(a){H=a.E;let A=tt(re(),H),N=A.indexOf(a);w=A[(N+i+A.length)%A.length]}else if(b){H=0;let A=tt(re(),0),N=U=>(b.compareDocumentPosition(U.e)&Node.DOCUMENT_POSITION_FOLLOWING)!==0,V=U=>U.e.contains(b);i>0?w=A.find(U=>N(U)&&!V(U))??A[0]:w=A.filter(U=>!N(U)&&!V(U)).pop()??A[A.length-1]}else w=ze(),w&&(H=w.E);if(!w)return e.w("Nothing here to comment on");F=!0,ne(w.e)}function ke(){let i=d??x,f=i&&Vn(i,e.root,t);if(!f)return e.w("Nothing around it");if((!D||!i.contains(D))&&(D=i),d)return ee(f);ne(f)}function Re(){let i=d??x,f=i?Ye(i):[],b=f.find(a=>D&&a.e.contains(D))??f.find(a=>ae(a.e))??f[0];if(!b)return e.w("Nothing inside it");d?ee(b.e):ne(b.e)}function Ge(i=!1){if(!x)return;if(e.state.o&&!e.C())return e.ze();if(!i)return j(x);let f=We(x);if(!f.length)return e.w("No comments on this block");oe=(oe+1)%f.length,e.open(f[oe].id),f.length>1&&e.w(`Comment ${oe+1} of ${f.length} on this block`)}function st(i){if(["Tab","ArrowUp","ArrowDown","Enter"," ","Escape"].includes(i.key)&&!(i.key.startsWith("Arrow")&&(i.metaKey||i.ctrlKey||i.altKey))){if(i.preventDefault(),i.stopPropagation(),h=i.key,i.key==="Escape")return void e.ie();if(i.key==="Enter"||i.key===" ")return Ge(i.shiftKey&&i.key==="Enter");i.key==="Tab"&&e.N(),e.state.i&&e.open(null),i.key==="Tab"?je(i.shiftKey?-1:1):i.key==="ArrowUp"?ke():Re()}}let He=()=>{let i=pe();return i?!!i.closest("[inert]"):!document.activeElement||document.activeElement===document.body},h="",k=!1,I=i=>{k&&window.removeEventListener("keyup",I,!0),i.key===h&&(h="",i.preventDefault(),i.stopPropagation())};window.addEventListener("keyup",I,!0),window.addEventListener("pointermove",qe,!0),document.addEventListener("selectionchange",Ie);for(let i of Wo)window.addEventListener(i,te,!0);for(let i of zo)window.addEventListener(i,Ke,!0);return window.addEventListener("keydown",X,!0),{ie(){return d?(Y(null),!0):!1},se:()=>x!==null,We:()=>F&&!x,xe:fe,ae(){x&&!ue()&&ne(x)},f(){if(se=null,x&&!(x.isConnected&&he(x))){let b=ze();b?ne(b.e,ue()||He()):ge()}let i=e.t.querySelector(".launch");if(i&&g.nextElementSibling!==i&&!ue()&&!g.contains(pe()))for(let b of[o,...r,g])e.t.insertBefore(b,i);let f=e.state.o;S&&f!==S?(S=null,Y(null),x&&ne(x,He())):f&&!S&&(L||d)&&Y(null)},S(){Te(),M(),x&&Ve(r[q],x.getBoundingClientRect(),4)},destroy(){ge()&&it();for(let i of r)i.remove();y(),O(),k=!0,h||window.removeEventListener("keyup",I,!0),window.removeEventListener("pointermove",qe,!0),document.removeEventListener("selectionchange",Ie);for(let i of Wo)window.removeEventListener(i,te,!0);for(let i of zo)window.removeEventListener(i,Ke,!0);window.removeEventListener("keydown",X,!0),o.classList.remove("show"),g.classList.remove("show"),Q(g,!0),R(o,()=>o.remove()),R(g,()=>g.remove())}}}var Li=300,Mi=32,Ci=220,Ct=320,Pi=24,jo=24;function qn(e,t=!1){let n=e.ownerDocument.documentElement,o=n.getAttribute("data-pipeup-layout");if(o==="bubbles"||e.querySelector("[data-pipeup-slide]"))return null;let r=e.querySelector("article, main, [role=main]")??(o==="column"?e:null);if(!r)return null;if(n.hasAttribute("data-pipeup-reserve")){let c=n.clientWidth,u=getComputedStyle(r).maxWidth,g;return u.endsWith("px")?g=parseFloat(u):u.endsWith("%")?g=parseFloat(u)/100*c:g=r.getBoundingClientRect().width,o!=="column"&&c<g+Ct-(t?Pi:0)?null:{x:c-Ct+jo,width:Ct-2*jo}}let s=r.getBoundingClientRect().right;if(window.innerWidth-s<Li&&o!=="column")return null;let l=s+Mi;return{x:l,width:Math.max(220,Math.min(300,window.innerWidth-l-16))}}function Kn(e,t){let n=e.resolved.get(t.id);return!n||n.state==="orphaned"&&!e.k.has(t.id)}function Go(e){let t=v("div",{class:"col"});e.t.append(t);let n=new Map,o=null,r=new ResizeObserver(()=>c()),s=d=>Kn(e,d);function l(d){let S=e.resolved.get(d.id),C=S?Hn(d.anchor,S):null;return C===null?Number.POSITIVE_INFINITY:C+window.scrollY-4}function c(){let d=[],S=[];for(let[O,x]of n){let H=l(x.thread);if(Number.isFinite(H))x.placed=H;else if(e.k.has(O)){if(x.placed===null){x.e.classList.add("wait");continue}H=x.placed}Number.isFinite(H)?d.push({id:O,T:H,height:x.e.offsetHeight}):S.push({id:O,height:x.e.offsetHeight})}let C=e.state.o,p=C?Hn(C.anchor,C.resolved):null;o&&p!==null&&d.push({id:"draft",T:p+window.scrollY-4,height:o.e.offsetHeight});let y=Fo(d,o?"draft":e.state.i),P=Math.max(0,...d.map(O=>(y.get(O.id)??0)+O.height))+24;for(let O of S)y.set(O.id,P),P+=O.height+10;for(let[O,x]of n){if(x.e.classList.contains("wait")){if(!y.has(O))continue;x.e.style.transition="none",x.e.style.transform=`translateY(${Math.round(y.get(O))}px)`,x.e.offsetWidth,x.e.style.transition="",x.e.classList.remove("wait");continue}x.e.style.transform=`translateY(${Math.round(y.get(O)??0)}px)`}o&&(o.e.style.transform=`translateY(${Math.round(y.get("draft")??0)}px)`)}function m(d,S){d.thread=S,d.lost=s(S),d.view.update(S,{lost:d.lost?S.anchor.snapshot:null})}function u(d){let S=s(d),C=ft(d,e.j,{Y:"column",lost:S?d.anchor.snapshot:null}),p=v("div",{class:"th","data-thread":d.id},v("button",{class:"opn sr",type:"button","data-thread":d.id}),C.element);return p.style.transition="none",p.addEventListener("mouseenter",()=>e.L(d.id)),p.addEventListener("mouseleave",()=>e.L(null)),p.addEventListener("click",()=>e.open(d.id)),t.append(p),r.observe(p),{e:p,thread:d,lost:S,placed:null,view:C}}function g(d){r.unobserve(d),d.classList.add("out"),window.setTimeout(()=>d.remove(),Ci)}function E(){let d=e.state.o;if(o&&o.of!==d&&(g(o.e),o=null,d||e.D(null)),!d)return;let S=!o;if(o)o.s.ye(d.label);else{let C=rn(e,d),p=v("div",{class:"th on"},C.element);p.style.transition="none",t.append(p),r.observe(p),o={e:p,s:C,of:d}}o.s.ee(e.state.l&&!d.anchor.quote&&!d.anchor.point),S&&o.s.focus()}function T(d){Q(t,e.state.c);let S=new Set,C=[],p=e.state.i!==null||e.state.o!==null;for(let y of d){if(!e.B(y))continue;S.add(y.id);let P=n.get(y.id);P?(P.thread!==y||P.lost!==s(y))&&m(P,y):(P=u(y),n.set(y.id,P),C.push(P.e));let O=P.e,x=e.state.i===y.id;O.classList.toggle("on",x);let H=O.firstElementChild,q=y.root.replies.length;H.setAttribute("aria-label",`Open thread: ${be(y.root.text,60)}, ${pn(q)}`),H.setAttribute("aria-expanded",String(x)),Q(H,x);let F=O.querySelector(".more");F&&Q(F,!x),O.classList.toggle("dim",p&&!x),O.classList.toggle("hot",e.state.L===y.id&&!x),O.classList.toggle("resolved",y.resolved),O.classList.toggle("lost",P.lost)}for(let[y,P]of n)S.has(y)||(n.delete(y),g(P.e));E(),Xt(t,d.filter(y=>S.has(y.id)).sort(_e(e)).map(y=>n.get(y.id).e),o?.e??null)&&t.offsetWidth,c(),o&&C.push(o.e);for(let y of C)y.offsetWidth,y.style.transition=""}function L(){let d=qn(e.root,!0);d&&(t.style.width=`${d.width}px`,t.style.transform=`translate(${d.x}px, ${-window.scrollY}px)`)}return{f:T,S:L,destroy(){r.disconnect(),e.D(null),t.remove()}}}var Xo="[data-pipeup-ignore],input,textarea,select,[contenteditable]:not([contenteditable=false])";function Jo(e){let t=v("button",{type:"button","aria-label":"Comment",title:"Comment"},Z("comment",17)),n=v("div",{class:"selbar"},t);n.inert=!0,e.t.append(n);let o=null,r=0,s=!1,l=L=>{let d=L&&(L.nodeType===Node.ELEMENT_NODE?L:L.parentElement);return!!d&&e.root.contains(d)&&!d.closest(Xo)};function c(){if(!o)return;let{left:L,top:d}=cn(o.getBoundingClientRect(),{width:n.offsetWidth||36,height:n.offsetHeight||34},{width:window.innerWidth,height:window.innerHeight});n.style.left=`${L}px`,n.style.top=`${d}px`}function m(){o=null,n.inert=!0,n.classList.remove("show")}function u(L=!1){let d=ut();if(!e.state.l||!d||!l(d.anchorNode)||!l(d.focusNode)){m();return}!o&&!L&&e.w("Enter comments on the selected words"),o=d.getRangeAt(0).cloneRange(),c(),n.inert=!1,n.classList.add("show")}t.addEventListener("mousedown",L=>L.preventDefault()),t.addEventListener("click",L=>{if(L.stopPropagation(),e.state.o&&!e.C())return e.N();let d=o;if(!d)return;let S;try{S=_t(d,e.root,e.p.view(d.commonAncestorContainer))}catch(p){e.re(p),m();return}let C=be(d.toString().replace(/\s+/g," ").trim(),60);window.getSelection()?.removeAllRanges(),m(),e.Ye({anchor:S,label:`\u201C${C}\u201D`,ranges:[d],resolved:{state:"attached",element:null,range:d}})});let g=()=>{window.clearTimeout(r),r=window.setTimeout(()=>s||u(),250),o&&(ut()||m())};document.addEventListener("selectionchange",g);let E=L=>{L.type!=="keyup"&&(s=L.type==="mousedown"),!(s||e.m(L))&&window.setTimeout(()=>u(L.type==="mouseup"),0)};window.addEventListener("mousedown",E,!0),window.addEventListener("mouseup",E,!0),window.addEventListener("keyup",E,!0);let T=L=>{L.key!=="Enter"||!o||e.m(L)||L.target instanceof Element&&L.target.closest(`${Xo},${fn}`)||(L.preventDefault(),L.stopPropagation(),t.click())};return window.addEventListener("keydown",T,!0),{f(){!e.state.l&&o&&m()},S(){o&&c()},destroy(){window.removeEventListener("mousedown",E,!0),window.removeEventListener("mouseup",E,!0),window.removeEventListener("keyup",E,!0),window.removeEventListener("keydown",T,!0),window.clearTimeout(r),document.removeEventListener("selectionchange",g),n.remove()}}}async function zn(e,t){try{await navigator.clipboard.writeText(e);return}catch{}let n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.cssText="position:fixed;opacity:0;pointer-events:none",t.append(n),n.select();let o=document.execCommand("copy");if(n.remove(),!o)throw new Error("pipeup: your browser blocked copying")}var Oi=3e3,Qo="Hidden on the page";function Zo(e){let t=[v("span",{class:"n"}),v("span",{class:"n"})],n=Z("comment",20,1.4);n.lastElementChild.setAttribute("stroke-width","1.6");let o=v("button",{class:"mode",type:"button","aria-label":"Comment","aria-keyshortcuts":Rn,"aria-haspopup":"menu","aria-expanded":"false"},v("span",{class:"plus"},n),v("span",{class:"cnt"},Z("bubble",34,1.4),...t),v("span",{class:"dot"})),r=document.createTextNode("Comment"),s=v("span",{class:"ttip","aria-hidden":"true"},r,v("small",{},St)),l=v("div",{class:"launch"},o,s),c=v("div",{class:"menu",role:"menu","aria-label":"Comments"}),m=v("div",{class:"list",role:"menu","aria-label":"All comments"}),u=v("span",{class:"pn"}),g=v("button",{class:"ib",type:"button","aria-label":"Close"},Z("close")),E=v("button",{class:"hs",type:"button",role:"switch","aria-checked":"false"},"Show resolved",v("span",{class:"sw","aria-hidden":"true"}));E.addEventListener("click",h=>{h.stopPropagation(),e.d.je()});let T=v("div",{class:"all",role:"dialog","aria-label":"All comments"},v("div",{class:"hd"},v("span",{},"All comments"),u,E,g),m),L=v("div",{class:"pop side",role:"dialog","aria-label":"Comment thread"});c.inert=T.inert=L.inert=!0,e.t.append(c,l,T);let d=!1,S=null,C=0,p=[],y=0,P=null,O=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,x=h=>{d=e.state.d=h,h&&e.addons.flush(),window.clearTimeout(C),C=0,h||S?.(!0),c.classList.toggle("show",h),Q(c,!h),o.setAttribute("aria-expanded",String(h))},H=(h,k=!1)=>{e.state.c!==h&&(e.state.c=h,e.f(),h?(q(m)[0]??g).focus({preventScroll:!0}):k&&o.focus({preventScroll:!0}))},q=(h=c)=>[...h.querySelectorAll(".mi")],F=()=>c.getRootNode().activeElement,z=()=>{x(!1),o.focus({preventScroll:!0})},J=h=>{let k=q(h.currentTarget);if(k.length===0)return;let I=F(),i=k.indexOf(I),f=b=>{h.preventDefault(),k[(b+k.length)%k.length]?.focus({preventScroll:!0})};h.key==="ArrowDown"?f(i+1):h.key==="ArrowUp"?f(i<0?k.length-1:i-1):h.key==="Home"?f(0):h.key==="End"&&f(k.length-1)};c.addEventListener("keydown",J),m.addEventListener("keydown",J),g.addEventListener("click",h=>{h.stopPropagation(),H(!1,!0)});let D=h=>Kn(e,h),W=h=>p.filter(k=>!k.resolved&&(h===void 0||e.F(k)===h)).length,oe=()=>W(!1),Se=()=>W(!0),se=()=>W(),le=h=>{let k=h.anchor.view?.slide,I=e.p.u(h.anchor.view)?"":zt(h.anchor.view);return k&&e.p.slide()!==null?`On slide ${k}`:I?`In ${I}`:Qo},ce=(h,k,I="")=>v("div",{role:"group","aria-label":I?`${h} \xB7 ${I}`:h},v("div",{class:"sec","aria-hidden":"true"},h,I&&v("b",{},I)),...k);function Te(h,k){let I=e.p.slide(),i=new Map;for(let f of h){let b=f.thread,a=I!==null?b.anchor.view?.slide??I:e.F(b)?e.p.u(b.anchor.view)?"":zt(b.anchor.view):null;i.set(a,[...i.get(a)??[],f])}if(I===null){let f=i.get(null)??[];return i.delete(null),[...f.map(k),...[...i].map(([b,a])=>ce(b||Qo,a.map(k)))]}return[...i].sort(([f],[b])=>Number(f)-Number(b)||0).map(([f,b])=>ce(`Slide ${f} \xB7 ${b.filter(a=>!a.thread.resolved).length} open`,b.map(k),f===I?"This slide":""))}function M(){let h=F()?.dataset.thread,k=e.d.all().filter(b=>!b.thread.resolved||e.state.M),I=b=>{let a=b.thread,w=Pe(a.root.author,a.root.name);w.classList.add("in");let A=v("button",{class:a.resolved?"mi done":"mi",type:"button",role:"menuitem","data-thread":a.id},w,v("span",{},v("span",{class:"clamp"},a.root.deleted?"Deleted":a.root.text),v("small",{},D(a)?`\u201C${be(a.anchor.snapshot,80)}\u201D`:b.location.where)));return A.addEventListener("click",N=>{N.stopPropagation(),$(a.id,A.getBoundingClientRect().top)}),A},i=k.filter(b=>D(b.thread));u.textContent=String(se()),E.setAttribute("aria-checked",String(e.state.M)),m.replaceChildren(k.length?"":v("div",{class:"sec",role:"presentation"},"No open comments"),...Te(k.filter(b=>!D(b.thread)),I),i.length?ce("No longer on the page",i.map(I)):"");let f=q(m);h&&f.find(b=>b.dataset.thread===h)?.focus({preventScroll:!0})}function $(h,k){et()&&(e.state.O=!0,H(!1)),B(h,k)}let R="";function B(h,k){let I=p.find(i=>i.id===h);if(I){if(R=h,!e.F(I))return Y(I,k);if(e.state.o&&!e.C())return e.N();e.p.W(I.anchor.view??{}).then(()=>{e.Ee();let i=p.find(f=>f.id===h);i&&R===h&&(e.state.c||e.state.O)&&Y(i,k)})}}function Y(h,k){let I=h.id,i=e.resolved.get(I),f=i&&!D(h)&&!e.F(h)?i.element??i.range?.startContainer.parentElement??null:null;if(f?.scrollIntoView({block:"center",inline:"nearest",behavior:O?"auto":"smooth"}),f&&i&&At(h.anchor,i)&&f.checkVisibility?.({visibilityProperty:!0})!==!1){K(),e.open(I);return}e.open(null),et()&&(e.state.O=!0,e.f()),_(h,k)}function _(h,k){let I=!D(h)&&e.F(h),i={quote:h.anchor.quote?.exact??null,lost:D(h)||I?h.anchor.snapshot:null,place:I?le(h):null};if(P?.id===h.id?P.view.update(h,i):(P={id:h.id,view:ft(h,e.j,{Y:"popover",...i})},L.replaceChildren(P.view.element)),k===void 0)return;L.isConnected||(e.t.insertBefore(L,T),L.offsetWidth);let f=an(e.state.c),{left:b,top:a}=ln({x:f.width,y:k,below:!1},{width:Oe(),height:L.offsetHeight},f);L.style.left=`${b}px`,L.style.top=`${a}px`,L.classList.add("show"),L.inert=!1,e.Ge(h.id)}function K(h=!1){P&&(P=null,L.classList.remove("show"),Q(L,!0),h&&e.state.O&&(e.state.O=!1,e.f()))}function j(h,k,I=!1,...i){let f=v("button",{class:"mi",type:"button",role:I?"menuitemcheckbox":"menuitem"},h,v("span",{class:"lb"}),...i,I&&v("span",{class:"sw","aria-hidden":"true"}),v("span",{class:"tt","aria-hidden":"true"}));return f.addEventListener("click",b=>{b.stopPropagation(),k(b)}),f}let ee=(h,k,I,i)=>{let f=h.querySelector(".lb");f.textContent!==k&&(f.textContent=k),h.querySelector(".tt").textContent=I,h.setAttribute("aria-description",I),i!==void 0&&h.setAttribute("aria-checked",String(i))},Ue=()=>v("div",{class:"sep",role:"separator"}),Ee=v("span",{class:"ma"}),qe=v("span",{class:"kc"}),Ie="",te=j(Ee,it,!1,qe);te.dataset.item="name";let Ke=j(Z("copy"),()=>{z(),e.d.copyAll("ai")}),X=j(Z("lines"),()=>{z(),e.d.copyAll("text")}),Ae=v("span",{class:"kc"}),pe=j(Z("list"),()=>{x(!1),H(!0)},!1,Ae),ue=j(Z("comment"),h=>{let k=!e.state.l&&h.detail===0;e.Xe(!e.state.l,k),k&&x(!1)},!0,v("span",{class:"kc","aria-hidden":"true"},St));ue.dataset.item="comment",ue.setAttribute("aria-keyshortcuts",Rn);let he=v("div",{class:"sec",role:"presentation"}),re=Ue(),Ne=Ue(),ae=new Map,ze=h=>{let k=ae.get(h);return k||(k=j(Ce(h.icon,15),()=>{h.checked||z(),Promise.resolve().then(()=>h.select()).catch(I=>e.re(I)).finally(()=>d&&fe())},!!h.checked,v("span",{class:"kc"})),ae.set(h,k)),k},We=()=>[te,re,Ke,X,pe,...e.addons.$.map(ze),Ne,ue],rt=-1,ne=h=>{try{return h()}catch(k){return globalThis.reportError?.(k),""}};function fe(){let h=se(),k=e.d.name(),I=k||me(e.doc.me);if(ee(te,I,k?"The name on your comments":"Add a name to show on your comments"),te.setAttribute("aria-label",`${I}, ${k?"edit":"add"} your name`),qe.replaceChildren(k?Z("edit",13):"Add name"),yt(e.doc.me,k)!==Ie){Ie=yt(e.doc.me,k);let f=Pe(e.doc.me,k);f.classList.add("in"),Ee.replaceChildren(f)}ee(Ke,"Copy as Markdown","Markdown, with where each thread is"),ee(X,"Copy as Text","Just the words"),ee(pe,"All comments","Every thread, and where it is"),Ae.textContent=h?String(h):"";let i=e.addons.pe();he.textContent=i,i?!he.isConnected&&c.contains(te)&&c.prepend(he):he.remove();for(let f of e.addons.$){let b=ae.get(f);if(!b)continue;let a;try{a=f.checked?.()}catch(w){globalThis.reportError?.(w)}ee(b,ne(f.label),ne(f.hint),a),b.querySelector(".kc").textContent=f.count?ne(f.count):""}ee(ue,"Start commenting",e.state.l?"Turn off to hide the comments again":"Shows the comments; choose any part of the page to comment on it",e.state.l)}function ge(){fe(),(rt!==e.addons.G||!c.contains(te))&&(c.replaceChildren(...We()),rt=e.addons.G,fe())}function it(){let h=v("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"});h.value=e.d.name();let k=v("div",{class:"ed"},Ee.cloneNode(!0),h),I=(i,f=!1)=>{if(S!==I)return;S=null;let b=h.value.trim();i&&b&&b!==e.d.name()&&e.d.rename(b).then(fe),k.replaceWith(te),f&&te.focus({preventScroll:!0})};S=I,h.addEventListener("keydown",i=>{i.stopPropagation(),(i.key==="Enter"||i.key==="Escape")&&(i.preventDefault(),I(i.key==="Enter",!0))}),h.addEventListener("blur",()=>I(!0)),te.replaceWith(k),h.focus({preventScroll:!0})}o.addEventListener("click",h=>{if(h.stopPropagation(),d){x(!1);return}ge(),x(!0),h.detail===0&&q().at(-1)?.focus({preventScroll:!0})});let Ye=!1,je=()=>{Ye=T.contains(F())},$e=h=>{let k=h.composedPath();d&&!k.includes(c)&&!k.includes(o)&&(x(!1),e.state.l&&!e.m(h)&&(e.we(h),h.preventDefault(),h.stopPropagation())),e.state.c&&!e.m(h)&&H(!1,Ye&&(!document.activeElement||document.activeElement===document.body)),!k.includes(L)&&!k.includes(T)&&K(!0)},ke=h=>{if(!d||h.pointerType==="touch"||h.type==="pointerout"&&h.relatedTarget)return;let k=h.composedPath();h.type==="pointerover"&&(k.includes(c)||k.includes(o))?(window.clearTimeout(C),C=0):C||(C=window.setTimeout(()=>{C=0,S||x(!1)},Oi))},Re={n:0,label:""},Ge=()=>{let{n:h,label:k}=Re,I=e.addons.pe(),i=`Comment${e.state.l?", comment mode on":""}${k?`, ${k}`:h?`, ${h} open`:""}${I?`, ${I}`:""}`;o.getAttribute("aria-label")!==i&&o.setAttribute("aria-label",i);let f=(k||"Comment")+(I?` \xB7 ${I}`:"");r.data!==f&&(r.data=f)},st=e.addons.subscribe(h=>{Ge(),!(!d||S)&&(h?ge():fe())});window.addEventListener("pointerdown",je,!0),window.addEventListener("click",$e,!0),window.addEventListener("pointerover",ke,!0),window.addEventListener("pointerout",ke,!0);let He=h=>{if(h.key!=="Escape"||S)return;let k=h.composedPath()[0];if(d)z();else if(e.state.c&&!(k instanceof HTMLTextAreaElement&&!T.contains(k)))H(!1,!0);else if(P)K(!0),e.j.close();else return;h.stopPropagation()};return window.addEventListener("keydown",He,!0),{f(h){p=h;let k=oe();if(k!==y){if(k){let[b,a]=t[0].classList.contains("on")?t:[t[1],t[0]];a.textContent=k>99?"99+":String(k),a.classList.toggle("s",k>99),b.classList.remove("on"),a.classList.add("on")}o.classList.toggle("has",k>0),y=k}let I=Se(),i=I?`${k} here \xB7 ${I} ${e.p.slide()!==null?"on other slides":"in other views"}`:"";o.classList.toggle("else",I>0),Re={n:k,label:i},Ge(),o.classList.toggle("on",e.state.l),d&&!e.state.d&&x(!1),d&&fe();let f=e.state.c;if(T.classList.toggle("full",et()),T.classList.contains("show")!==f&&(T.classList.toggle("show",f),Q(T,!f)),f&&M(),P){let b=h.find(a=>a.id===P?.id);!b||e.state.i||b.resolved&&!e.state.M?K():_(b)}},S(){},destroy(){st(),window.removeEventListener("pointerdown",je,!0),window.removeEventListener("click",$e,!0),window.removeEventListener("pointerover",ke,!0),window.removeEventListener("pointerout",ke,!0),window.clearTimeout(C),window.removeEventListener("keydown",He,!0),c.remove(),T.remove(),L.remove(),l.remove()}}}var Pt="[data-pipeup-slide]",er=1e3,tr=["scroll","resize","keyup","click","transitionend","slidechanged"],Wn=null,It=null,mn=new Set,Yn=new Set,Ot=e=>{try{e()}catch(t){globalThis.reportError?.(t)}};function or(e){let t=null;if(e){t={};let n=0;for(let[o,r]of Object.entries(e))if(!(typeof r!="string"||o==="slide"||o.length>G.viewKey||r.length>G.viewValue)){if(++n>=G.viewEntries)break;t[o]=r}}Wn=t;for(let n of Yn)n()}function rr(e){return mn.add(e),()=>void mn.delete(e)}function hn(e){It=typeof e?.current=="function"&&typeof e.go=="function"?e:null}function Ii(e,t,n){let o=t.oe(),r=null,s=0,l=0;for(let c of e){if(!t.shown(c))continue;let m=t.s(c),u=Math.min(m.left+m.width,o.width)-Math.max(m.left,0),g=Math.min(m.top+m.height,o.height)-Math.max(m.top,0);if(u<=0||g<=0)continue;let E=Math.round(u*g),T=t.opacity(c);(E>s||E===s&&(T>l||T===l&&c===n))&&(r=c,s=E,l=T)}return r}function Ni(e,t,n){return t!==null?e?.slide===void 0||e.slide===t:!e||!n?!0:Object.entries(e).every(([o,r])=>o==="label"||o==="slide"||n[o]===r)}function $i(){return{s:e=>e.getBoundingClientRect(),shown:e=>e.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0})!==!1,opacity:e=>parseFloat(getComputedStyle(e).opacity)||0,oe:()=>({width:window.innerWidth,height:window.innerHeight})}}var nr=()=>{let e=window.Reveal;return typeof e?.getIndices=="function"&&typeof e.slide=="function"?e:null};function ir(e,t,n=$i()){let o=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,r=null,s=null,l=0,c=!1,m=()=>[...e.querySelectorAll(Pt)],u=()=>[...e.querySelectorAll(".slides > section")],g=y=>typeof y=="string"&&y.length>0&&y.length<=G.viewValue?y:null,E=y=>g(y?.getAttribute("data-pipeup-slide"));function T(){if(It){let P=null;if(Ot(()=>{let O=It.current();Number.isInteger(O)&&O>0&&(P=String(O))}),P!==null)return P}let y=nr();if(y){let P=null;if(Ot(()=>{let O=y.getIndices().h,x=u()[O];P=E(x?.matches(Pt)?x:x?.querySelector(Pt))??g(String(O+1))}),P!==null)return P}return r&&!r.isConnected&&(r=null),r=Ii(m(),n,r)??r,E(r)}function L(){l=0,s=T(),t()}let d=()=>{!l&&!c&&(l=requestAnimationFrame(L))},S=y=>Ni(y,s,Wn);function C(y){if(S(y))return Promise.resolve(!0);let P=y.slide,O=nr(),x=m().find(F=>E(F)===P),H=/^[1-9]\d{0,5}$/.test(P??"");if(H&&It)Ot(()=>It.go(Number(P)));else if(H&&O){let F=x?u().findIndex(z=>z===x||z.contains(x)):-1;Ot(()=>O.slide(F>=0?F:Number(P)-1))}else if(mn.size)for(let F of mn)Ot(()=>F({...y}));else if(x)x.scrollIntoView({block:"start",behavior:o?"auto":"smooth"});else return Promise.resolve(!1);let q=performance.now();return new Promise(F=>{let z=W=>{clearTimeout(J),F(W)},J=setTimeout(()=>z(!1),er),D=()=>{if(c)return z(!1);if(s=T(),S(y))return z(!0);if(performance.now()-q>=er)return z(!1);requestAnimationFrame(D)};requestAnimationFrame(D)})}let p=new MutationObserver(y=>{y.some(P=>P.target instanceof Element&&P.target.matches(Pt))&&d()});p.observe(e,{subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]});for(let y of tr)window.addEventListener(y,d,{capture:!0,passive:!0});return Yn.add(d),s=T(),{slide:()=>s,view(y){let P=y instanceof Element?y:y?.parentElement,O=E(P?.closest(Pt))??s,x={...O!==null?{slide:O}:{},...Wn};return Object.keys(x).length?x:void 0},u:S,W:C,destroy(){c=!0,cancelAnimationFrame(l),p.disconnect();for(let y of tr)window.removeEventListener(y,d,!0);Yn.delete(d)}}}var jn=["pipeup-quote","pipeup-on","pipeup-done"],Ri={"pipeup-quote":[[250,227,188,.75],[250,200,100,.28]],"pipeup-on":[[247,212,154,.95],[250,200,100,.42]],"pipeup-done":[[180,178,169,.22],[180,178,169,.2]]},Hi=(e,t)=>jn.map(n=>{let[o,r,s,l]=Ri[n][e?1:0];return`::highlight(${n}){background-color:rgba(${o},${r},${s},${+(l*t).toFixed(3)})}`}).join("");function ar(){return typeof CSS<"u"&&"highlights"in CSS&&typeof Highlight<"u"}var Di="<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><rect x='7' y='7' width='23' height='23' rx='4' fill='none' stroke='#534AB7' stroke-width='2' stroke-dasharray='4 3'/><path d='M3 2v15l4-3.5 3 6.5 2.5-1.2-3-6.3H15z' fill='#fff' stroke='#2C2C2A' stroke-width='1.2' stroke-linejoin='round'/></svg>",Bi=`:not([data-pipeup-ignore],[data-pipeup-ignore] *){cursor:url("data:image/svg+xml,${encodeURIComponent(Di)}") 3 2,crosshair!important}`;function lr(e=document,t=!1){let n=e.defaultView?.CSSStyleSheet;if(!n||!("replaceSync"in n.prototype)||!("adoptedStyleSheets"in e))return{ke(){},Se(){},le(){},Te(){},remove:()=>sr()};let o=new n,r=null,s=!1,l=1,c=0,m="",u=0,g=()=>o.replaceSync(Hi(t,l)+(r===null?"":`:root{--pipeup-gutter:${r}px}`)+(s?Bi:"")+(c||m?`html{--pipeup-panel:${c}px;${c?`margin-right:${c}px!important;`:""}${m}}`:""));return g(),e.adoptedStyleSheets=[...e.adoptedStyleSheets,o],{ke(E){E!==r&&(r=E,g())},Se(E){E!==s&&(s=E,g())},le(E){l=E,g()},Te(E,T){E!==c&&(c=E,m=T?"":"transition:margin-right .34s cubic-bezier(.4,0,.2,1)!important",clearTimeout(u),!E&&m&&(u=window.setTimeout(()=>{m="",g()},400)),g())},remove(){clearTimeout(u),e.adoptedStyleSheets=e.adoptedStyleSheets.filter(E=>E!==o),sr()}}}function cr(e){if(ar())for(let t of jn)CSS.highlights.set(t,new Highlight(...e[t.slice(7)]))}function sr(){if(ar())for(let e of jn)CSS.highlights.delete(e)}var Gn=':host{all:initial}*{box-sizing:border-box}button{appearance:none;font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}svg{display:block}.layer{all:initial;display:block;position:fixed;inset:0;pointer-events:none;font:13px/1.5 var(--pu-font,system-ui,sans-serif);color:var(--k);--k:#2C2C2A;--mu:#5F5E5A;--fa:#888780;--ln:#E5E3DA;--ru:#ECEAE2;--so:#FAFAF7;--su:#FFFFFF;--ho:#F1EFE8;--as:color-mix(in srgb,var(--pu-accent,#534AB7) 12%,transparent);--sh:0 8px 28px rgba(44,44,42,.1);--in:.26s;--mv:.34s;--out:.2s;--pl:1.2s;--eo:cubic-bezier(.22,.61,.36,1);--eio:cubic-bezier(.4,0,.2,1);--ei:cubic-bezier(.4,0,1,1);--pu-text:var(--k);--pu-muted:var(--mu);--pu-faint:var(--fa);--pu-line:var(--ln);--pu-surface:var(--su);--pu-soft:var(--so);--pu-hover:var(--ho);--pu-shadow:var(--sh);--pu-ease:var(--eo)}.layer.dark{--k:#ECEBE6;--mu:#B4B2A9;--fa:#8D8B84;--ln:#3A3936;--ru:#34332F;--so:#22221F;--su:#1B1B19;--ho:#2C2C29;--sh:0 8px 28px rgba(0,0,0,.45)}.layer.hidden .bub,.layer.hidden .col,.layer.hidden .pop,.layer.hidden .tip,.layer.hidden .mark,.layer.hidden .selbar{opacity:0!important;pointer-events:none!important}.tx{font-size:14px;line-height:1.5;color:var(--k);white-space:pre-wrap;overflow-wrap:anywhere}.tx.del,.who,.rest,.ctx{color:var(--fa)}.who,.rest{font-size:12px}.who{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rft>.who{display:block}.ctx[hidden]{display:none}.ctx{font-size:12px;margin-bottom:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.clamp{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.tx a{color:var(--pu-accent);text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.ft,.rft{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--in) var(--eo),opacity var(--in) var(--eo)}.ft>*,.rft>*{overflow:hidden;min-height:0;display:flex;align-items:center}.root:hover>.ft,.root:focus-within>.ft,.it:hover>.rft,.it:focus-within>.rft{grid-template-rows:1fr;opacity:1}.ft.has-rest{grid-template-rows:1fr;opacity:1}.ft.has-rest>*{grid-area:1/1}.ft .hover{opacity:0;transition:opacity var(--in) var(--eo)}.ft .rest{transition:opacity var(--in) var(--eo)}.root:hover>.ft .hover,.root:focus-within>.ft .hover,.ft:not(.has-rest) .hover{opacity:1}.root:hover>.ft .rest,.root:focus-within>.ft .rest{opacity:0}.acts{margin-left:6px;display:flex;flex:none}.ib{width:24px;height:22px;display:grid;place-items:center;border-radius:6px;color:var(--mu);transition:background-color .2s var(--eo),color .2s var(--eo)}.ib:hover,.ib:focus-visible{background:var(--ho);color:var(--k);outline:none}.rps,.rbox{padding-left:14px}.rps .it{padding-top:6px}.more{display:grid;grid-template-rows:1fr;transition:grid-template-rows var(--mv) var(--eio)}.more>div{overflow:hidden;min-height:0}.th:not(.on) .more{grid-template-rows:0fr}.row{display:flex;align-items:center;gap:8px;padding:8px 0 2px;cursor:text}.input{flex:1;min-width:0;height:27px;display:block;border:0;border-bottom:1px solid var(--ln);outline:none;resize:none;overflow:hidden;font:inherit;font-size:14px;line-height:1.5;padding:3px 0;color:var(--k);background:transparent;transition:border-color var(--in) var(--eo)}.row:hover .input,.input:hover{border-bottom-color:var(--mu)}.input:focus{border-bottom-color:var(--pu-accent)}.ed{display:flex;gap:10px;align-items:center;min-height:34px;padding:6px 10px}.ed .input{font-size:13px;height:22px}.root,.it{position:relative;padding-right:30px}.av{display:grid;place-items:center;width:22px;height:22px;border-radius:32%;font-size:12px;font-weight:600;line-height:1;opacity:0;transform:scale(.85);transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.av.in{opacity:1;transform:none}.av svg{width:80%;height:80%}.root>.av,.it>.av{position:absolute;top:0;right:0}.it>.av{top:6px}.av{--av-l:92%;--av-d:30%;--s:60%;background:hsl(var(--h) var(--s) var(--av-l));color:hsl(var(--h) var(--s) var(--av-d))}.dark .av{--av-l:20%;--av-d:78%}.c0{--h:0}.c1{--h:25}.c2{--h:50}.c3{--h:130}.c4{--h:175}.c5{--h:215}.c6{--h:270}.c7{--h:330}.c8{--h:28;--s:35%}.c9{--h:220;--s:8%}.me{flex:none;display:grid}.me>.av{grid-area:1/1;width:26px;height:26px;font-size:13px}.you{display:grid;padding:0 34px;min-height:24px;font-size:12px;color:var(--fa)}.you>*{grid-area:1/1;display:flex;align-items:center;min-width:0;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.say{white-space:pre;overflow:hidden}.nm{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.say button{flex:none}.say button{color:var(--mu);text-decoration:underline;text-decoration-color:var(--ln);text-underline-offset:2px;transition:color .2s var(--eo)}.say button:hover,.say button:focus-visible{color:var(--pu-accent);outline:none}.nf{opacity:0;transform:translateY(-4px);pointer-events:none}.nf .input{font-size:13px;height:24px}.you.naming .nf{opacity:1;transform:none;pointer-events:auto}.you.naming .say{opacity:0;pointer-events:none}.send{width:26px;height:26px;border-radius:50%;display:grid;place-items:center;color:var(--pu-accent);flex:none;opacity:0;pointer-events:none;transition:opacity var(--in) var(--eo),background-color .2s var(--eo)}.send.show{opacity:1;pointer-events:auto}.send:hover{background:var(--as)}.bub{position:fixed;left:0;top:0;width:20px;height:20px;margin:-20px 0 0 -2px;border-radius:50% 50% 50% 0;background:var(--pu-accent);border:2px solid var(--su);box-shadow:0 1px 4px #0003;pointer-events:auto;opacity:0;transform:translateY(-6px) scale(.9);transform-origin:2px 20px;transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.bub.in{opacity:1;transform:none;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.bub.in:hover,.bub.on{transform:scale(1.18)}.bub.done{background:var(--fa)}.bub.ghost{pointer-events:none}.tip,.pop,.menu,.all,.xp,.toast,.selbar,.namebar,.ttip,.tt,.mode{background:var(--su);border:1px solid var(--ln);box-shadow:var(--sh)}.tip{position:fixed;max-width:260px;border-radius:10px;padding:7px 10px;opacity:0;transform:translateY(3px);transition:opacity .22s var(--eo),transform .26s var(--eo)}.tip.show{opacity:1;transform:none;pointer-events:auto;cursor:pointer;transition:opacity .22s var(--eo),transform .26s var(--eo),left var(--mv) var(--eio),top var(--mv) var(--eio)}.pop{position:fixed;width:var(--pu-pop);border-radius:12px;padding:10px 12px 8px;pointer-events:none;opacity:0;transform:translateY(6px) scale(.98);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.pop.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo)}.pop.show.glide{transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo),left var(--mv) var(--eio),top var(--mv) var(--eio)}.mark{position:fixed;border:2px solid color-mix(in srgb,var(--pu-accent) 50%,transparent);background:var(--as);border-radius:8px;opacity:0;transition:opacity .3s var(--eo)}.mark.show{opacity:1}.pulse{position:fixed;border:2px solid var(--pu-accent);border-radius:8px;background:var(--as);animation:pu-pulse var(--pl) var(--eio) forwards}@keyframes pu-pulse{0%{opacity:0;transform:scale(.985)}35%{opacity:.85;transform:scale(1)}to{opacity:0;transform:scale(1.02)}}.col{position:fixed;left:0;top:0;pointer-events:none;transition:opacity var(--in) var(--eo)}.th{position:absolute;left:0;right:0;top:0;padding:4px 4px 4px 12px;pointer-events:auto;cursor:pointer;box-shadow:inset 2px 0 0 transparent;transition:transform var(--mv) var(--eio),box-shadow var(--in) var(--eo),opacity var(--in) var(--eo)}.th.hot{box-shadow:inset 2px 0 0 var(--ln)}.th.on{box-shadow:inset 2px 0 0 var(--pu-accent);cursor:default}.th.dim{opacity:.45}.th.resolved:not(.on):not(.hot){opacity:.6}.th.lost .ctx{white-space:normal}.th.wait{opacity:0!important;pointer-events:none}.th.out{opacity:0!important;pointer-events:none;transition:opacity var(--out) var(--ei)}.th:has(.opn:focus-visible){box-shadow:inset 2px 0 0 var(--ln);outline:2px solid var(--pu-accent);outline-offset:2px;border-radius:4px}.selbar{position:fixed;display:flex;border-radius:10px;padding:2px;opacity:0;transform:translateY(4px);pointer-events:none;transition:opacity var(--in) var(--eo),transform .3s var(--eo)}.selbar.show{opacity:1;transform:none;pointer-events:auto}.selbar button{width:32px;height:30px;display:grid;place-items:center;border-radius:8px;color:var(--pu-accent);transition:background-color .2s var(--eo)}.selbar button:hover,.selbar button:focus-visible{background:var(--as);outline:none}.pick{position:fixed;left:0;top:0;border:2px solid color-mix(in srgb,var(--pu-accent) 70%,transparent);background:color-mix(in srgb,var(--pu-accent) 6%,transparent);border-radius:8px;pointer-events:none;opacity:0;transition:opacity var(--out) var(--ei),border-color var(--out) var(--ei),border-width var(--out) var(--ei),box-shadow var(--out) var(--ei)}.pick.show{opacity:1;transition-duration:var(--in);transition-timing-function:var(--eo)}.pick.show.glide{transition-property:all;transition-duration:var(--mv);transition-timing-function:var(--eio)}.pick.on{border-color:var(--pu-accent)}.pick.kf{border:3px solid var(--pu-accent);box-shadow:0 0 0 2px var(--su)}.km{position:fixed;left:0;top:0;pointer-events:none;outline:none}.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.namebar{position:fixed;left:0;top:0;display:flex;align-items:center;gap:2px;padding:2px 2px 2px 10px;border-radius:10px;font-size:12px;color:var(--mu);white-space:nowrap;pointer-events:none;opacity:0;transform:translateY(4px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.namebar.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform .3s var(--eo)}.namebar.show.glide{transition-property:all;transition-duration:var(--mv);transition-timing-function:var(--eio)}.namebar .lbl{margin-right:6px;max-width:260px;overflow:hidden;text-overflow:ellipsis}.namebar .nb{padding:4px;display:grid;place-items:center;border-radius:7px;transition:background-color .2s var(--eo),color .2s var(--eo)}.namebar .nb:hover,.namebar .nb:focus-visible{background:var(--ho);color:var(--k);outline:none}.namebar .nb[hidden]{display:none}.launch{position:fixed;right:20px;bottom:20px;pointer-events:auto}.launch .mode{position:relative;display:grid;place-items:center;width:46px;height:46px;border-radius:50%;transition:background-color .3s var(--eo),color .3s var(--eo)}.mode>*,.cnt>*{grid-area:1/1}.mode>*{display:grid;place-items:center;transition:opacity var(--in) var(--eo)}.cnt,.has>.plus{opacity:0}.has>.cnt{opacity:1}.n{font-size:12px;font-weight:500;line-height:1;margin:-1.4px 0 0 1.4px;font-variant-numeric:tabular-nums;opacity:0;transition:opacity var(--in) var(--eo)}.n.s{font-size:9.5px;letter-spacing:-.04em}.n.on{opacity:1}.launch .mode:hover,.launch .mode[aria-expanded=true]{background:var(--ho)}.launch .mode.on{background:var(--pu-accent);color:var(--pu-on,#fff)}.mode>.dot{position:absolute;top:3px;right:3px;width:9px;height:9px;border-radius:50%;background:var(--pu-accent);border:2px solid var(--su);opacity:0}.mode.else>.dot{opacity:1}.ttip{position:absolute;right:0;bottom:54px;white-space:nowrap;border-radius:8px;padding:4px 9px;font-size:12px;pointer-events:none;opacity:0;transform:translateY(3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.ttip small{margin-left:8px}.ttip small,.mi .kc{font-size:12px;color:var(--fa)}.mode:hover+.ttip,.mode:focus-visible+.ttip{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .5s,transform var(--in) var(--eo) .5s}.launch .mode[aria-expanded=true]+.ttip{opacity:0;transition:opacity var(--out) var(--ei)}@media(hover:none){.ttip,.tt{display:none}}.menu{position:fixed;right:20px;bottom:76px;width:290px;border-radius:12px;padding:4px;pointer-events:none;opacity:0;transform:translateY(6px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.menu.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo)}.mi{position:relative;display:flex;gap:10px;align-items:center;width:100%;min-height:34px;text-align:left;padding:6px 10px;border-radius:8px;transition:background-color .2s var(--eo)}.mi:hover,.mi:focus-visible{background:var(--so);outline:none}.mi svg{color:var(--mu);flex:none}.mi small{display:block;color:var(--fa);font-size:12px}.lb{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ma{flex:none;display:grid;margin:-2px 0}.ma .av{width:20px;height:20px;font-size:11px}.mi .av svg{color:inherit}.sep{height:1px;margin:4px 10px;background:var(--ru)}.tt{position:absolute;right:calc(100% + 14px);top:50%;translate:0 -50%;width:max-content;max-width:220px;padding:4px 9px;border-radius:8px;font-size:12px;line-height:1.4;color:var(--mu);pointer-events:none;opacity:0;transform:translate(3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.mi:hover>.tt,.mi:focus-visible>.tt{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .5s,transform var(--in) var(--eo) .5s}@media(max-width:600px){.tt{right:8px;top:auto;bottom:100%;translate:none;transform:translateY(3px)}}.sw{position:relative;flex:none;width:26px;height:16px;border-radius:8px;background:var(--ln);transition:background-color var(--mv) var(--eio)}.sw:before,.sw:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #00000040;transition:transform var(--mv) var(--eio),opacity var(--mv) var(--eio)}.sw:before{opacity:0;transform:translate(10px)}[aria-checked=true]>.sw{background:var(--pu-accent)}[aria-checked=true]>.sw:after{transform:translate(10px)}.tools{display:flex;flex:none;gap:2px}.tools[hidden]{display:none}.tool[aria-pressed=true]{background:var(--as);color:var(--pu-accent)}.note{display:block;padding:0 0 4px;font-size:12px;color:var(--fa)}.note[hidden]{display:none}.ov{position:absolute;inset:0;pointer-events:none;overflow:hidden}.xb{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px 16px 16px;font-size:13px}.xb p{margin:0 0 10px}.all,.xp{position:fixed;top:0;right:0;bottom:0;width:var(--pu-panel);display:flex;flex-direction:column;border-width:0 0 0 1px;opacity:0;transform:translate(100%);transition:transform var(--out) var(--ei),opacity var(--out) var(--ei)}.all.show,.xp.show{opacity:1;transform:none;pointer-events:auto;transition:transform var(--mv) var(--eo),opacity var(--in) var(--eo)}.all.full{width:100%}.hd{display:flex;align-items:center;gap:8px;padding:12px 10px 8px 16px;font-weight:600}.pn{font-weight:400;color:var(--fa)}.hs{margin-left:auto;display:flex;align-items:center;gap:6px;padding:3px 4px 3px 6px;border-radius:6px;font-size:12px;font-weight:400;color:var(--mu);transition:background-color .2s var(--eo)}.hs:hover,.hs:focus-visible{background:var(--ho);outline:none}.list{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px}.all .mi{align-items:flex-start}.all .mi>.av{flex:none}.all .mi>span:last-child{flex:1;min-width:0}.all .mi small{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.all .mi.done{opacity:.6}.layer.listing .col{opacity:0;transition:opacity var(--out) var(--ei)}.sec{padding:8px 10px 2px;font-size:12px;color:var(--fa)}.sec b{margin-left:6px;font-weight:500;color:var(--pu-accent)}.toast{position:fixed;left:50%;bottom:28px;border-radius:10px;padding:8px 14px;font-size:13px;opacity:0;transform:translate(-50%,6px);transition:opacity .3s var(--eo),transform .36s var(--eo)}.toast.show{opacity:1;transform:translate(-50%)}@media(forced-colors:active){.pick.kf{border:3px solid Highlight}.layer :is(.ib,.mi,.nb,.hs,.selbar button,.say button,.xb button):focus-visible{outline:2px solid Highlight}}@media(prefers-reduced-motion:reduce){.bub,.bub.in,.bub.in:hover,.bub.on,.tip,.pop,.selbar,.menu,.all,.xp,.ttip,.tt,.toast{transform:none!important}.sw:after{transform:none!important;transition-property:opacity}[aria-checked=true]>.sw:after{opacity:0}[aria-checked=true]>.sw:before{opacity:1}.th{transition-property:opacity,box-shadow}.tip.show{transition-property:opacity}.pick,.pick.show{transition:opacity .16s ease-in-out}.all,.all.show,.xp,.xp.show{transition-property:opacity}.namebar,.namebar.show{transform:none!important;transition:opacity .16s ease-in-out}.av,.nf{transform:none!important}@keyframes pu-pulse{0%{opacity:0}35%{opacity:.85}to{opacity:0}}}';var dr="#534AB7",Fi="#9A94EE",Vi="rgb(0, 0, 238)";function gn(e){let t=/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)/.exec(e);if(!t||t[1]===void 0||t[2]===void 0||t[3]===void 0)return null;let n=t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]);return{r:Number(t[1]),g:Number(t[2]),b:Number(t[3]),a:n}}function Xn(e){let t=n=>{let o=n/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}var pr=(e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05);function Jn(e){let t=e.ownerDocument,n=t.defaultView;if(!n)return{font:"system-ui, sans-serif",accent:dr,dark:!1,on:"#fff"};let o=t.documentElement,r=n.getComputedStyle(e).fontFamily||"system-ui, sans-serif",s=(n.getComputedStyle(o).getPropertyValue("--pipeup-accent")||o.style.getPropertyValue("--pipeup-accent")).trim(),l=e.querySelector("a[href]"),c=l?n.getComputedStyle(l).color:"",m=gn(n.getComputedStyle(t.body).backgroundColor);(!m||m.a===0)&&(m=gn(n.getComputedStyle(o).backgroundColor));let u=!!(m&&m.a>0?Xn(m)<.2:n.matchMedia?.("(prefers-color-scheme: dark)").matches===!0&&/dark/.test(n.getComputedStyle(o).colorScheme||"")),g=c&&c!==Vi?gn(c):null,E=g&&pr(Xn(g),u?.011:1)>=3,T=s||(E?c:u?Fi:dr),L=gn(T),d=L&&pr(Xn(L),1)<3?"#111":"#fff";return{font:r,accent:T,dark:u,on:d}}function vn(e,t){e.style.setProperty("--pu-font",t.font),e.style.setProperty("--pu-accent",t.accent),e.style.setProperty("--pu-on",t.on),e.classList.toggle("dark",t.dark)}function ur(e,t=document){let n=t.createElement("pipeup-root");n.setAttribute("data-pipeup-ignore",""),n.style.cssText="position:fixed!important;inset:0!important;pointer-events:none!important;z-index:2147483000!important;display:block!important;margin:0!important;visibility:visible!important;opacity:1!important;transform:none!important;filter:none!important;";let o=n.attachShadow({mode:"open"}),r=t.defaultView?.CSSStyleSheet;if(r&&"replaceSync"in r.prototype&&"adoptedStyleSheets"in o){let l=new r;l.replaceSync(Gn),o.adoptedStyleSheets=[l]}else{let l=t.createElement("style");l.textContent=Gn,o.append(l)}let s=t.createElement("div");return s.className="layer",s.style.setProperty("--pu-panel",`${Lt}px`),s.style.setProperty("--pu-pop",`${Oe()}px`),vn(s,e),o.append(s),t.documentElement.append(n),{element:n,shadow:o,t:s,destroy:()=>n.remove()}}var _i=40,Ui=250,qi=120,Ki=2400,zi=4e3,Wi=1e4;function fr(e,t=!1){return qn(e,t)?"column":"bubbles"}function Yi(e){return[...e.state.mode==="column"?[Go(e),Dn(e,{te:!1})]:[Dn(e,{te:!0})],Jo(e),Zo(e)]}var ji=1e3,yn="Shown here, but not saved yet \u2014 it will be saved with your next change",nt=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";function mr(e){let t=Jn(e.root),n=ur(t),o=lr(document,t.dark);o.le(0);let r=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,s=document.documentElement.hasAttribute("data-pipeup-reserve"),l=new Map,c=new Set,m=new WeakSet,u={i:null,L:null,M:!1,hidden:!0,mode:fr(e.root),o:null,l:!1,c:!1,O:!1,d:!1},g=v("div",{class:"toast",role:"status","aria-live":"polite"}),E=v("div",{class:"sr","aria-live":"polite"});n.t.append(g,E);let T=null,L=[],d=null,S=!1,C=0,p=0,y=0,P=0,O=0,x=new Set,H="",q=new Map,F=ir(e.root,()=>{!S&&K()&&X()}),z=!1,J=0;function D(a,w=Ki,A=!1,N=!1){S||(z=A,g.textContent=a,N?g.setAttribute("aria-hidden","true"):g.removeAttribute("aria-hidden"),g.classList.add("show"),window.clearTimeout(C),C=window.setTimeout(()=>g.classList.remove("show"),w))}function W(){z&&(z=!1,window.clearTimeout(C),g.classList.remove("show"))}function oe(a){E.textContent="",cancelAnimationFrame(J),J=requestAnimationFrame(()=>E.textContent=a)}function Se(a){D(nt(a))}function se(a){throw Se(a),a}let le=a=>({thread:a,location:Kt(a.anchor,l.get(a.id)??gt(a.anchor,e.root),e.root)}),ce=a=>(n.t.querySelector(`[data-thread="${a}"] .rbox textarea`)?.value.trim()??"")!=="",Te=a=>u.i!==a||u.M?!1:(d?.se()?d.ae():n.t.querySelector(".launch .mode")?.focus({preventScroll:!0}),!0),M={reply:async(a,w)=>{try{await e.doc.reply(a,w)}catch(A){A instanceof we?D(yn):se(A)}},resolve:async a=>{try{await e.doc.resolve(a),D("Resolved \xB7 Show resolved brings it back")}catch(w){D(w instanceof we?`Resolved \xB7 ${yn}`:nt(w))}Te(a)&&(u.i=null)},reopen:async a=>{try{await e.doc.reopen(a),D("Reopened")}catch(w){D(w instanceof we?`Reopened \xB7 ${yn}`:nt(w))}},close:()=>{ae(null);let a=Ae&&n.t.querySelector(Ae);a?a.focus({preventScroll:!0}):d?.ae(),Ae=""},copy:a=>{try{let w=e.doc.threads().find(N=>N.id===a);if(!w)return;let A=jt(le(w),"ai",location.href,Date.now());zn(A,n.t).then(()=>D("Thread copied as Markdown for AI"),N=>D(nt(N)))}catch(w){D(nt(w))}}},$={copyAll:async a=>{let w=$.all(),A=Gt(w,a,{title:document.title,url:location.href,exportedAt:new Date});try{await zn(A,n.t);let N=w.filter(V=>!V.thread.resolved).length;D(`Copied ${N} thread${N===1?"":"s"}${a==="ai"?" as Markdown for AI":""}`)}catch(N){D(nt(N))}},je:()=>{u.M=!u.M,X()},rename:async a=>{let w=a.replace(/\s+/g," ").trim();try{await Ye(w)?D(`New comments will say ${w}, but this browser couldn't remember it`):D(`New comments will say ${w}`)}catch(A){D(nt(A))}},name:()=>e.doc.name,all:()=>[...e.doc.threads()].sort(_e(B)).map(le)},R={},B={get addons(){return R.surface},doc:e.doc,root:e.root,t:n.t,host:n.element,state:u,resolved:l,k:c,j:M,d:$,p:F,F:a=>x.has(a.id),Ee:()=>{K()&&X()},B:a=>!u.hidden&&(!a.resolved||u.M||ce(a.id))&&!x.has(a.id),Je:(a,w)=>{for(let A of e.doc.threads()){let N=l.get(A.id);if(A.anchor.quote&&B.B(A)&&N?.range&&Bo(a,w,Tt(N)))return A}return null},ne:(a,w)=>B.C()?B.Je(a,w):null,m:a=>a.composedPath().includes(n.element),we:a=>void m.add(a),qe:a=>m.has(a),open:ae,Ge:a=>re(a),L:ze,Ye:We,Ue:rt,C:()=>!T||T.De(),be:a=>{let w=T?.ve();a(),w?.()},ze:()=>{let a=u.o?.anchor.view,w=T?.ve();Promise.resolve(F.u(a)||F.W(a??{}).then(()=>B.Ee())).then(w)},Be:je,Fe:ne,Xe:fe,N:it,D:a=>{T=a},Z:D,w:oe,Ke:W,re:Se,Qe:$e,f:X,ie:ge},Y=R.surface=new nn(B,n.shadow,E);function _(a){let w=performance.now(),A=e.doc.threads();for(let N of A){if(a&&!a.has(N.id))continue;let V=performance.now()-w<_i,U=gt(N.anchor,e.root,{fuzzy:V});l.set(N.id,U),!V&&U.state==="orphaned"?c.add(N.id):c.delete(N.id)}for(let N of[...l.keys()])A.some(V=>V.id===N)||l.delete(N);c.size===0?(window.clearTimeout(P),P=0):P===0&&(P=window.setTimeout(()=>{P=0,!S&&(_(new Set(c)),X())},Ui))}function K(){let a=new Set,w=F.slide()!==null,A=new Set;for(let V of e.doc.threads()){A.add(V.id);let U=l.get(V.id)?.element;(!F.u(V.anchor.view)||!w&&U?.checkVisibility?.({visibilityProperty:!0})===!1)&&a.add(V.id)}x=a;for(let V of q.keys())A.has(V)||q.delete(V);let N=`${F.slide()}|${[...a].join()}`;return N===H?!1:(H=N,!0)}function j(a){let w=[],A=[],N=[];for(let V of a){let U=l.get(V.id);V.resolved&&!u.M||!U?.range||x.has(V.id)||(V.id===u.i||V.id===u.L?A.push(U.range):V.resolved?N.push(U.range):w.push(U.range))}u.o&&F.u(u.o.anchor.view)&&A.push(...u.o.ranges),cr({quote:w,on:A,done:N})}let ee=0,Ue=0,Ee=0;function qe(a){if(a===Ue)return;Ue=a,cancelAnimationFrame(Ee);let w=ee,A=performance.now(),N=a?260:200,V=U=>{let Nt=Math.min(1,(U-A)/N);ee=w+(a-w)*(a?1-(1-Nt)**3:Nt*Nt),o.le(ee),Nt<1&&(Ee=requestAnimationFrame(V))};Ee=requestAnimationFrame(V)}let Ie=0,te=0;function Ke(a){a!==Ie&&(Ie=a,o.Te(a,r),window.clearTimeout(te),te=window.setTimeout(()=>{_(),X()},r?0:400))}function X(){if(S)return;let a=e.doc.threads();if(K(),u.i&&x.has(u.i)){let A=n.t.querySelector(`[data-thread="${u.i}"] .rbox textarea`)?.value;A&&q.set(u.i,A),u.i=null}u.hidden=!u.l&&!u.c&&!u.O&&!u.o,u.hidden&&(u.i=null),qe(u.hidden?0:1),n.t.classList.toggle("hidden",u.hidden),n.t.classList.toggle("listing",u.c);let w=u.c&&!et();Ke(w?Lt:0),o.ke(s?u.mode==="column"&&!u.hidden&&!w?Ct:0:null),j(a);for(let A of L)A.f(a);d?.f(a),u.hidden||Y.flush()}let Ae="",pe=()=>n.t.getRootNode().activeElement,ue="input,textarea,select,[contenteditable]:not([contenteditable=false])",he=()=>{let a=pe();return a instanceof HTMLTextAreaElement&&a.value!==""||!!document.activeElement?.matches(ue)};function re(a,w=he(),A=pe()){let N=[...n.t.querySelectorAll(`[data-thread="${a}"] .rbox textarea`)].find(U=>!U.closest("[inert]")),V=A?.getAttribute("data-thread");Ae=V?`.${A.classList[0]}[data-thread="${V}"]`:"",!(w||!N)&&N.focus({preventScroll:!0})}function Ne(){let a=u.o;return!a||B.C()?!1:(F.u(a.anchor.view)||F.W(a.anchor.view??{}),!0)}function ae(a,w=!1){if(a&&Ne())return;if(u.i===a&&!u.o)return a?re(a):void 0;let A=!w&&he(),N=pe();if(a||(u.O=!1),u.i=a,a&&(u.o=null,$e(a)),X(),a){let V=q.get(a),U=V&&n.t.querySelector(`[data-thread="${a}"] .rbox textarea`);U&&!U.value&&(U.value=V,U.dispatchEvent(new Event("input",{bubbles:!0}))),q.delete(a),w&&d?.se()?d.ae():re(a,A,N)}}function ze(a){u.L!==a&&(u.L=a,a&&a!==u.i&&$e(a),X())}function We(a){W(),u.c=!1,u.o=a,u.i=null,X()}function rt(a){if(!u.o)return We(a);Object.assign(u.o,a),X()}function ne(){u.o&&(u.o=null,X())}function fe(a,w=!1){u.l!==a&&(u.l=a,o.Se(a),a?(u.i=null,u.c=!1,d=Yo(B)):(W(),d?.destroy(),d=null,oe("Comment mode off")),X(),d&&(w&&d.xe(),w?d.se()?D(Un,Wi,!0,!0):D("Nothing here to comment on"):D(`Click anything to comment, or Tab between blocks \xB7 Option-click (Alt-click) to pin \xB7 ${St} or Esc to finish`,zi,!0)))}function ge(){u.o&&(F.u(u.o.anchor.view)||B.C())?ne():u.i?ae(null):d&&!d.ie()&&fe(!1)}function it(){if(u.o){Ne()||ne();return}u.i&&ae(null)}async function Ye(a){try{return await e.onName(a),!1}catch(w){if(e.doc.name!==a)throw w;return!0}}async function je(a){let w=u.o;if(w)try{let A=await e.doc.comment(w.anchor,a);u.o=null,_(new Set([A])),ae(A,!0)}catch(A){if(A instanceof we){u.o=null,_(new Set([A.id])),ae(A.id,!0),D(yn);return}se(A)}}function $e(a){let w=l.get(a);if(!w||w.state==="orphaned")return;let A=w.range?Tt(w):w.element?[w.element.getBoundingClientRect()]:[];for(let N of A.slice(0,6)){let V=v("div",{class:"pulse"});Ve(V,N,4),n.t.prepend(V),window.setTimeout(()=>V.remove(),1300)}}function ke(){for(let a of L)a.destroy();L=Yi(B),X()}let Re=()=>{if(!S){for(let a of L)a.S();d?.S(),Y.S(),O=requestAnimationFrame(Re)}},Ge=a=>{let w=a.composedPath()[0];return w instanceof Element&&w.closest(ue)!==null},st=a=>{if(a.key==="Escape")return ge();if(Do(a)&&!a.isComposing&&!a.defaultPrevented&&!Ge(a)){if(a.preventDefault(),d?.We()&&d.xe())return;fe(!u.l,!0)}},He=a=>{if(B.m(a)||m.has(a))return;let w=window.getSelection();w&&!w.isCollapsed||it()},h=()=>{n.t.style.setProperty("--pu-pop",`${Oe()}px`);let a=fr(e.root,u.mode==="column");a!==u.mode?(u.mode=a,ke()):X()};function k(){let a=performance.now();p===0&&(y=a),window.clearTimeout(p);let w=Math.min(qi,Math.max(0,y+ji-a));p=window.setTimeout(()=>{p=0,_(),X()},w)}let I=new MutationObserver(a=>{a.every(w=>n.element.contains(w.target))||k()});window.addEventListener("keydown",st),window.addEventListener("click",He),window.addEventListener("resize",h),I.observe(e.root,{subtree:!0,childList:!0,characterData:!0});let i=new MutationObserver(()=>vn(n.t,Jn(e.root)));for(let a of[document.documentElement,document.body])i.observe(a,{attributes:!0});let f=new ResizeObserver(k);f.observe(e.root);let b=e.doc.onChange((a,w,A)=>{Y.Oe(w,A),_(),X()});return _(),ke(),O=requestAnimationFrame(Re),{ctx:B,destroy(){S=!0,cancelAnimationFrame(O),cancelAnimationFrame(Ee),cancelAnimationFrame(J),F.destroy(),window.clearTimeout(te),window.clearTimeout(C),window.clearTimeout(p),window.clearTimeout(P),I.disconnect(),f.disconnect(),i.disconnect(),b(),window.removeEventListener("keydown",st),window.removeEventListener("click",He),window.removeEventListener("resize",h),d?.destroy();for(let a of L)a.destroy();Y.destroy(),o.remove(),n.destroy()}}}var ot=null,Gi=4e3;function Qn(e={}){if(xe)return xe.mount(e);if(!on())return Promise.reject(new Error("pipeup: another copy of Pipeup owns the add-on queue. Remove one script."));if(ot)return ot;let t=Ji(e,()=>t).catch(n=>{throw ot===t&&(ot=null),n});return ot=t,t}function Xi(e,t){return new Promise((n,o)=>{let r=setTimeout(()=>o(new Error("timed out")),t);e.then(n,o).finally(()=>clearTimeout(r))})}async function Ji(e,t){let n=document.documentElement.getAttribute("data-pipeup-doc"),{id:o,key:r}=n?await Bt(n):{id:`page-${Fe(location.origin+location.pathname)}`,key:null},s,l=!1,c;if(e.store)s=e.store,c=await dt(s);else try{let d=pt.open();s=await Xi(d,Gi).catch(S=>{throw d.then(C=>C.close(),()=>{}),S}),c=await dt(s)}catch{s=new ct,l=!0,c=await dt(s)}let m=e.name?.trim();m&&m!==c.name&&(c={...c,name:m},await s.saveProfile(c));let u=await lt.open({doc:o,key:r,store:s,identity:c.identity,name:c.name});hn(e.slides??null);let g;try{g=mr({doc:u,root:e.root??document.body,onName:async d=>{u.name=d,c={...c,name:d},await s.saveProfile(c)}})}catch(d){throw hn(null),d}l&&g.ctx.Z("This browser can't keep comments for this page \u2014 copy the comments (Copy as Markdown) to keep them");let E=()=>void u.flush().catch(d=>globalThis.reportError?.(d)),T=Ho({surface:g.ctx.addons,doc:u,root:e.root??document.body,ephemeral:l,version:vt}),L=!1;return window.addEventListener("pagehide",E),{document:u,flush:()=>u.flush(),unmount:()=>{L||(L=!0,window.removeEventListener("pagehide",E),T(),g.destroy(),hn(null),ot===t()&&(ot=null))}}}function hr(){let e=document.documentElement;if(!e.hasAttribute("data-pipeup-doc")||e.getAttribute("data-pipeup-auto")==="off")return;let t=()=>void Qn().catch(n=>console.error(n));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}typeof document<"u"&&(xe?console.warn(`pipeup: Pipeup is on this page twice (${xe.VERSION} and ${vt}); the first one is used. Remove one script.`):(on(),hr()));return xr(Qi);})();
|
|
11
11
|
|
|
12
12
|
"use strict";(()=>{function X(n){let t=globalThis;(t.pipeupAddons||=[]).push(n),typeof addEventListener=="function"&&addEventListener("load",()=>{t.Pipeup||console.error(`pipeup: the "${n.id}" add-on needs Pipeup on the page too; load pipeup.min.js.`)},{once:!0})}var f=n=>new TextEncoder().encode(n),Y=n=>new TextDecoder().decode(n);function v(n){let t="";for(let e=0;e<n.length;e+=32768)t+=String.fromCharCode(...n.subarray(e,e+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function y(n){let t=n.replace(/-/g,"+").replace(/_/g,"/"),e=atob(t+"=".repeat((4-t.length%4)%4));return Uint8Array.from(e,r=>r.charCodeAt(0))}function S(n){let t="";for(let e=0;e<n.length;e+=32768)t+=String.fromCharCode(...n.subarray(e,e+32768));return btoa(t)}function V(n){return Uint8Array.from(atob(n),t=>t.charCodeAt(0))}var P=n=>crypto.getRandomValues(new Uint8Array(n));async function L(n){return new Uint8Array(await crypto.subtle.digest("SHA-256",n))}var xe=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;function W(n,t=document){let e=xe.exec(t.documentElement.getAttribute("data-pipeup-doc")?.trim()??"");return e&&e[1]===n?y(e[2]):null}var Se=n=>f(`pipeup/v1/doc:${n}`);async function ce(n,t,e,r){let i=await crypto.subtle.importKey("raw",n,"HKDF",!1,["deriveBits"]);return crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:Se(t),info:f(e)},i,r)}function Q(n,t){return{docId:n,key:async e=>crypto.subtle.importKey("raw",await ce(t,n,`pipeup/v1/${e}/key`,256),"AES-GCM",!1,["encrypt","decrypt"]),addr:async e=>v(new Uint8Array(await ce(t,n,`pipeup/v1/${e}/address`,128))),aad:e=>`pipeup/v1/${e}:${n}`}}var Pe=1e6,Te=1e3;async function le(n,t,e=1/0){let r=new Blob([n]).stream().pipeThrough(t).getReader(),i=[],o=0;for(;;){let{done:d,value:c}=await r.read();if(d)break;if(o+=c.length,o>e)throw r.cancel(),new Error("too large");i.push(c)}let s=new Uint8Array(o),a=0;for(let d of i)s.set(d,a),a+=d.length;return s}var A=(n,t,e)=>D(n,t,{pipeup:1,doc:n.docId,sealed:!1,ops:e});async function D(n,t,e){let r=f(JSON.stringify(e)),i=P(12),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:i,additionalData:f(n.aad(t))},await n.key(t),await le(r,new CompressionStream("deflate-raw"))),s=new Uint8Array(13+o.byteLength);return s[0]=1,s.set(i,1),s.set(new Uint8Array(o),13),s}async function I(n,t,e){try{if(e.length<29||e[0]!==1)return null;let r=await crypto.subtle.decrypt({name:"AES-GCM",iv:e.slice(1,13),additionalData:f(n.aad(t))},await n.key(t),e.slice(13));return JSON.parse(Y(await le(new Uint8Array(r),new DecompressionStream("deflate-raw"),Pe)))}catch{return null}}function C(n,t){let e=t;if(e?.pipeup!==1||e.doc!==n.docId||!Array.isArray(e.ops)||e.ops.length>Te)return null;let r=0;for(let i of e.ops){let o=i?.body?.v;typeof o=="number"&&o!==1&&r++}return{ops:e.ops,newer:r}}async function ee(n,t,e){return C(n,await I(n,t,e))}var te=n=>`pu1.${v(n)}`,ne=n=>{if(!/^pu1\.[A-Za-z0-9_-]+$/.test(n))return null;try{return y(n.slice(4))}catch{return null}};async function re(n,t={}){let e=new Map,r={get:async i=>e.get(i),set:async(i,o)=>void e.set(i,o),lasting:!1};if(t.memory||typeof indexedDB>"u")return r;try{let i=await new Promise((s,a)=>{let d=setTimeout(()=>a(new Error("timed out")),4e3),c=indexedDB.open(`pipeup-addon-${n}`,1);c.onupgradeneeded=()=>c.result.createObjectStore("kv"),c.onsuccess=()=>{clearTimeout(d),s(c.result)},c.onerror=c.onblocked=()=>{clearTimeout(d),a(c.error??new Error("blocked"))}}),o=(s,a)=>new Promise((d,c)=>{let m=a(i.transaction("kv",s).objectStore("kv"));m.onsuccess=()=>d(m.result),m.onerror=()=>c(m.error)});return{get:s=>o("readonly",a=>a.get(s)),set:async(s,a)=>void await o("readwrite",d=>d.put(a,s)),lasting:!0}}catch{return r}}var h=class extends Error{constructor(e,r=!1){super(`try again in ${e} s`);this.seconds=e;this.limit=r;this.name="RetryAfter"}};var Oe=100,pe=5e3,Be=5e3,Ue=3e5,_e=3600,E=class{constructor(t){this.o=t}state="idle";lastOk=0;known=new Set;outbox=new Map;rejected=new Set;inbound=[];inboundTimer=0;sendTimer=0;lastSend=0;backoff=0;off=null;listeners=new Set;stopped=!1;get waiting(){return this.outbox.size}pending(){return[...this.outbox.values()]}onState(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){t&&(this.state=t);for(let e of[...this.listeners])e()}async start(){let{document:t,transport:e,signal:r}=this.o;this.off=t.onChange((o,s,a)=>{if(a===this.o.id)return;let d=!1;for(let c of s)this.want(c)&&(d=this.outbox.set(c.body.id,c).size>0||d);d&&this.schedule(),this.emit()}),r.addEventListener("abort",()=>this.stop(),{once:!0}),await e.start(o=>this.deliver(o));let i=await e.remoteIds?.();if(i)for(let o of i)this.known.add(o);this.rescan()}stop(){this.stopped||(this.stopped=!0,this.off?.(),clearTimeout(this.inboundTimer),clearTimeout(this.sendTimer),this.o.transport.stop())}want(t){return!this.known.has(t.body.id)&&!this.rejected.has(t.body.id)&&this.o.sendable(t)}rescan(){this.outbox.clear();for(let t of this.o.document.ops())this.want(t)&&this.outbox.set(t.body.id,t);this.schedule(),this.emit()}deliver(t){this.inbound.push(...t),this.inboundTimer||(this.inboundTimer=setTimeout(()=>void this.drain(),Oe))}async drain(){this.inboundTimer=0;let t=this.inbound.splice(0),e=t.map(i=>i?.body?.id).filter(i=>typeof i=="string");for(let i=0;i<t.length;i+=pe)try{await this.o.merge(t.slice(i,i+pe))}catch(o){o?.name!=="UnsavedChangeError"&&globalThis.reportError?.(o)}let r=new Set(this.o.document.ops().map(i=>i.body.id));for(let i of e)r.has(i)?(this.known.add(i),this.outbox.delete(i)):this.rejected.add(i);this.lastOk=Date.now(),this.emit()}schedule(t=this.o.delay??0){if(this.stopped||this.sendTimer||this.outbox.size===0)return;let e=typeof this.o.gap=="function"?this.o.gap():this.o.gap??0,r=Math.max(t,this.lastSend+e-Date.now(),this.backoff);this.sendTimer=setTimeout(()=>void this.send(),r)}async send(){if(this.sendTimer=0,this.stopped||this.o.signal.aborted||this.outbox.size===0)return;let t=[...this.outbox.values()].slice(0,this.o.batch??500);this.emit("sending");try{await this.o.transport.send(t);for(let e of t)this.known.add(e.body.id),this.outbox.delete(e.body.id);this.lastSend=Date.now(),this.lastOk=this.lastSend,this.backoff=0,this.emit("idle")}catch(e){e instanceof h?(this.backoff=Math.min(e.seconds,_e)*1e3*(1+Math.random()*.2),this.emit("limited")):(this.backoff=Math.min(Ue,this.backoff?this.backoff*2:Be),this.emit("offline"))}this.schedule()}};var dt=2n**256n-2n**32n-977n;var Me="sharing isn't set up for this page",M="data-pipeup-share isn't a sharing address",$e=/^(localhost|127\.0\.0\.1|\[::1\])$/,he=/^[A-Za-z0-9_-]{43}$/,T=n=>({kind:"off",reason:n});function ue(n,t=!1){let e=n?.trim();if(!e)return T(Me);let r;try{r=new URL(e)}catch{return T(M)}if(r.protocol!=="https:"&&!(t&&r.protocol==="http:"&&$e.test(r.hostname)))return T(M);let i=r.origin+r.pathname,o=r.hash.slice(1);if(o.startsWith("pm1.")){let[a,d,...c]=o.slice(4).split(".");return!he.test(a??"")||c.length||d!==void 0&&!/^[A-Za-z0-9_-]+$/.test(d)||r.search||!/\/m\/[A-Za-z0-9_-]{22,64}$/.test(i)?T(M):{kind:"mailbox",mailbox:i,key:y(a),...d?{token:d}:{}}}let s=/^\?([A-Za-z0-9_-]{8,64})$/.exec(r.search)?.[1];return!s||!he.test(o)?T(M):{kind:"privatebin",base:i,paste:s,key:y(o)}}var g=class extends Error{constructor(e){super(e);this.kind=e;this.name="Problem"}},fe={Accept:"application/json"},N=(n,t,e)=>n(t,{headers:fe,credentials:"omit",signal:e}),O=n=>({method:"POST",headers:fe,credentials:"omit",body:JSON.stringify(n)}),me=n=>{let t={403:"closed",404:"gone",507:"full"}[n];return t&&new g(t)};async function B(n){let t=await n.text(),e=t.length<1e7&&JSON.parse(t);if(!e||typeof e!="object")throw new Error("the answer was not usable");return[e,t.length]}function $(n,t=9e5){let e=[],r=0;for(let i of n)r+=JSON.stringify(i).length,(!e.length||r>t||e.at(-1).length>=500)&&(e.push([]),r=JSON.stringify(i).length),e.at(-1).push(i);return e}var U=(n,t)=>new Promise(e=>{let r=setTimeout(e,n);t?.addEventListener("abort",()=>{clearTimeout(r),e()},{once:!0})}),z=(n,t=10)=>{let e=Number(n.headers.get("Retry-After"));return e>0?Math.min(e,3600):t},_=n=>n.map(t=>t?.body?.id).filter(t=>typeof t=="string");var Re=524288,Le=1e3,De=async n=>v(await L(f(n))).slice(0,22),j=class{constructor(t,e,r,i){this.a=t;this.l=e;this.f=r;this.signal=i}ids=new Set;expires=null;moved=!1;big=!1;cursor="";seen=new Set;memo=null;async read(){let t=[],e=0;for(let r=0;r<Le;){let i=`${this.a.mailbox}/ops${this.cursor?`?since=${encodeURIComponent(this.cursor)}`:""}`,o=await N(this.f,i,this.signal);if(o.status===404)throw new g("gone");if(o.status===409&&e++<2){this.cursor="";continue}if(!o.ok)throw new Error(`HTTP ${o.status}`);r++;let[s]=await B(o);for(let a of Array.isArray(s.batches)?s.batches:[]){if(typeof a?.id!="string"||typeof a.ct!="string"||this.seen.has(a.id))continue;this.seen.add(a.id);let d=ne(a.ct),c=d&&await ee(this.l,"share",d);if(c){t.push(c);for(let m of _(c.ops))this.ids.add(m)}}if(typeof s.next=="string"&&(this.cursor=s.next),this.expires=typeof s.expires=="string"&&Date.parse(s.expires)||null,s.more!==!0)break}return t}async req(t){let e=t.map(o=>o.body.id).join();if(this.memo?.key!==e){let o=te(await A(this.l,"share",t));this.memo={key:e,ct:o,id:await De(o)}}let{ct:r,id:i}=this.memo;return[`${this.a.mailbox}/ops`,O({id:i,ct:r,token:this.a.token})]}async post(t){for(let e of $(t))await this.one(e)}async one(t){let[e,r]=await this.req(t),i=async()=>{let d=t.length>>1;await this.one(t.slice(0,d)),await this.one(t.slice(d))};if(r.body.length>Re&&t.length>1)return i();let o=await this.f(e,{...r,signal:this.signal}),s=o.status;if(s===200||s===201||s===400)return;if(s===413&&t.length>1)return i();let a=me(s);if(a)throw a;if(s===429){let[d]=await B(o).catch(()=>[{}]),c=Number(d.retryAfter);throw new h(o.headers.get("Retry-After")?z(o):c>0?Math.min(c,3600):10)}throw new Error(`HTTP ${s}`)}};var H=class{constructor(t,e){this.me=t;this.held=new Set(e?.held),this.kept=new Set(e?.kept),this.recv=new Set(e?.recv),this.send=e?.send??!0,this.noted=e?.noted??!1,this.gen=e?.gen??null,this.init=e?.init??!1}held;kept;recv;send;noted;gen;init;hold(t){if(!this.init){this.init=!0;for(let{body:e}of t)e.author===this.me&&this.held.add(e.id)}}sendable(t){let e=t.body;if(this.recv.has(e.id))return!0;if(e.author!==this.me||this.held.has(e.id)||this.kept.has(e.id))return!1;let r=[e.target,e.thread].find(i=>i&&(this.held.has(i)||this.kept.has(i)));if(r)(this.held.has(r)?this.held:this.kept).add(e.id);else if(!this.send)this.kept.add(e.id);else return(e.kind==="create"||e.kind==="reply")&&(this.noted=!0),!0;return!1}decide(t){if(!t)for(let e of this.held)this.kept.add(e);this.held.clear()}};var Ie=256e3,Ce=16,Ne=/^[A-Za-z0-9_-]{8,64}$/,ge=()=>[S(P(16)),S(P(8)),1e5,256,128,"aes","gcm","none"],ze=(n,t)=>({v:2,adata:ge(),ct:S(t),pasteid:n,parentid:n});async function q(n){if(n.status===429)throw new h(z(n));if(!n.ok)throw new Error(`HTTP ${n.status}`);let[t]=await B(n);if(t.status===0)return t;let e=Number(/\d+/.exec(String(t.message??""))?.[0]);throw new h(e>=1&&e<=3600?e:30,!0)}async function je(n,t,e,r="never",i){let o=S(await A(e,"share",[])),s=await q(await n(t,{...O({v:2,adata:[ge(),"plaintext",1,0],ct:o,meta:{expire:r}}),signal:i}));if(typeof s.id!="string"||typeof s.deletetoken!="string")throw new Error("the answer had no paste id");return{id:s.id,deleteToken:s.deletetoken}}async function He(n,t,e,r){return n(t,O({pasteid:e,deletetoken:r}))}async function qe(n,t,e,r){let i=await N(n,`${t}?${e}`,r);if(i.status===404)return null;if(!i.ok)throw new Error(`HTTP ${i.status}`);let[o,s]=await B(i);if(o.status!==0)return null;let a=o.meta?.time_to_live;return{j:o,size:s,ttl:typeof a=="number"&&a>0?a*1e3:null}}var F=class{constructor(t,e,r,i,o,s=()=>{}){this.a=t;this.l=e;this.f=r;this.signal=i;this.onGen=s;this.head=o||t.paste,this.trail.push(t.paste)}ids=new Set;expires=null;moved=!1;big=!1;head;trail=[];seen=new Map;async scan(t,e){let r;for(let i of Array.isArray(t)?t:[]){if(typeof i?.id!="string"||typeof i.ct!="string")continue;let o=this.seen.get(i.id);if(o===void 0){o=null;let s=null;try{i.ct.length<14e5&&(s=V(i.ct))}catch{}let a=s&&await I(this.l,"share",s),d=a?.next,c=typeof d=="string"?null:C(this.l,a);if(typeof d=="string"&&Ne.test(d))o=d;else if(c){e.push(c);for(let m of _(c.ops))this.ids.add(m)}this.seen.set(i.id,o)}r??=o??void 0}return r}async read(){let t=[],e=this.head,r=!1,i=!1;for(let o=0;;){let s=await qe(this.f,this.a.base,e,this.signal);if(!s){if(i)break;if(!r&&e!==this.a.paste){r=!0,e=this.a.paste;continue}throw new g("gone")}i=!0,e!==this.head&&(this.head=e,this.trail.push(e),this.ids.clear(),this.moved=!0,this.onGen(e));let a=s.j.comments,d=await this.scan(a,t);this.expires=s.ttl&&Date.now()+s.ttl;let c=(Array.isArray(a)?a[0]?.ct?.length:0)??0;if(this.big=!d&&s.size>Ie&&s.size>2*c,!d||++o>=Ce)break;e=d}return t}ask(t,e){return[this.a.base,O(ze(t,e))]}async req(t){return this.ask(this.head,await A(this.l,"share",t))}go(t,e){return this.f(t,{...e,signal:this.signal})}async post(t){for(let e of $(t))await q(await this.go(...await this.req(e)))}async roll(t){let e=async s=>{for(let a=0;;a++)try{return await s()}catch(d){if(!(d instanceof h)||a>5||this.signal?.aborted)throw d;await U(d.seconds*1e3*(1+Math.random()*.2),this.signal)}},r=this.head,i=await e(()=>je(this.f,this.a.base,this.l,"never",this.signal));for(let s of $(t))await e(async()=>q(await this.go(...this.ask(i.id,await A(this.l,"share",s)))));await e(async()=>q(await this.go(...this.ask(r,await D(this.l,"share",{next:i.id})))));let o=await this.read();return this.head!==i.id&&await He(this.f,this.a.base,i.id,i.deleteToken).catch(()=>{}),o}};function Fe(n,t,e,r=Math.random()){let i=t?3e5:n<6e5?25e3+r*1e4:n<18e5?12e4:3e5;return Math.min(3e5,i*2**e)}var K=class{constructor(t,e){this.b=t;this.o=e}id="share";problem=null;offline=!1;newer=0;deliver=()=>{};active=Date.now();errors=0;ok=!1;timer;busy=null;again=!1;limit=0;rolling=!1;ready=null;stopped=!1;off=[];async start(t){this.deliver=t;let e=(i,o,s)=>{i&&(i.addEventListener(o,s),this.off.push(()=>i.removeEventListener(o,s)))},r=globalThis;r.addEventListener&&(e(globalThis,"focus",()=>void this.poll()),e(globalThis,"online",()=>void this.poll()),e(globalThis,"pagehide",()=>this.flush()),e(r.document,"visibilitychange",()=>r.document?.visibilityState==="visible"&&void this.poll())),await this.poll()}stop(){this.stopped=!0,clearTimeout(this.timer);for(let t of this.off.splice(0))t()}async remoteIds(){return this.ok?this.b.ids:null}poll(){if(this.busy)return this.again=!0,this.busy;let t=async()=>{do this.again=!1,await this.read();while(this.again&&!this.stopped)};return this.busy=t().finally(()=>this.busy=null)}bump(){this.active=Date.now()}async read(){clearTimeout(this.timer);try{let t=await this.b.read();this.offline=!1,this.errors=0,this.ok=!0,this.newer+=t.reduce((r,i)=>r+i.newer,0);let e=t.flatMap(r=>r.ops);if(e.length&&(this.active=Date.now(),this.deliver(e)),this.b.moved){this.b.moved=!1;let r=this.o.allowed().filter(i=>!this.b.ids.has(i.body.id));r.length&&await this.b.post(r).catch(()=>{})}this.b.big&&!this.rolling&&this.roll()}catch(t){t instanceof g?this.problem=t.kind:(this.offline=!0,this.errors++)}if(this.o.changed(),!this.stopped&&this.problem!=="gone"){let t=globalThis.document?.visibilityState==="hidden";this.timer=setTimeout(()=>void this.poll(),Fe(Date.now()-this.active,t,this.errors))}}lock(t,e=0){let r=this.o.lock,i=globalThis.navigator?.locks;return r?i?new Promise((o,s)=>{i.request(r,{signal:this.o.signal},async()=>{try{o(await t())}catch(a){s(a)}await U(e,this.o.signal)}).catch(s)}):U(Math.random()*5e3,this.o.signal).then(t):t()}get gap(){return Math.max(this.o.gap,this.limit)}async guarded(t){try{await this.lock(t,this.gap),this.offline=!1}catch(e){throw e instanceof h?(e.limit&&(this.limit=Math.max(this.limit,e.seconds*1e3)),e):e instanceof g?(this.problem=e.kind,this.o.changed(),new h(3600)):(this.offline=!0,this.o.changed(),e)}}async send(t){if(this.problem)throw new h(3600);this.bump(),await this.guarded(async()=>{await this.poll();let e=t.filter(r=>!this.b.ids.has(r.body.id));if(e.length){await this.b.post(e);for(let r of e)this.b.ids.add(r.body.id)}})}async prepare(t){try{this.ready=t.length&&JSON.stringify(t).length<4e4?await this.b.req(t):null}catch{this.ready=null}}flush(){let t=this.ready;this.ready=null,!(!t||this.problem||typeof t[1].body!="string"||t[1].body.length>64e3)&&(this.o.fetch??fetch)(t[0],{...t[1],keepalive:!0}).catch(()=>{})}async roll(){this.rolling=!0;try{await U(Math.random()*3e4,this.o.signal),await this.guarded(async()=>{if(await this.poll(),!this.b.big||!this.b.roll)return;let e=(await this.b.roll(this.o.allowed())).flatMap(r=>r.ops);e.length&&this.deliver(e)})}catch{}finally{this.rolling=!1}}};var Ke="Comments here are shared with everyone who has this page.",Ge=7*864e5,ye=["M12 16V4M7 9l5-5 5 5M5 20h14"],Je=["M7 11V8a5 5 0 0 1 10 0v3M6 11h12v9H6z"];function be(n={}){return{id:"share",api:1,version:"0.4.1",needs:["sync","menu","notify","note"],network:{when:"page-configured",to:["page"],says:"Sends the comments you choose to share, sealed so only people with this page can read them, to the sharing service the page names. That service sees when and how much is sent, and your network address."},async setup(t){let e=t.document,r=ue(n.share??document.documentElement.getAttribute("data-pipeup-share"),!0);if(r.kind==="off")return t.off(r.reason);if(!W(e.id))return t.off("needs a document identity");let i=Q(e.id,r.key),o=await re("share",{memory:t.ephemeral}),s=await o.get(`doc:${e.id}`),a=new H(e.me,s);a.hold(e.ops());let d=Promise.resolve(),c=()=>{d=d.then(()=>o.set(`doc:${e.id}`,{...a})).catch(()=>{})};c();let m={gone:"The shared copy is gone",closed:"This page can't send to the shared copy; ask the author for the current file",full:"The shared copy is full; the author can start it again"},ie=new Set,oe=(l,u)=>ie.has(l)||(ie.add(l),t.notify(u)),x=()=>{for(let l of R)l.update();t.setStatus({text:de()}),t.setComposerNote(a.send&&!a.noted&&p.problem!=="gone"?Ke:null),p.newer&&oe("newer",`${p.newer} comments come from a newer version of Pipeup; this page can't show them yet.`),p.problem&&oe(p.problem,m[p.problem]+(p.problem==="gone"?". Your comments stay on this machine.":"."))},se=(l,u)=>fetch(l,u),ae=r.kind==="mailbox"?new j(r,i,se,t.signal):new F(r,i,se,t.signal,a.gen,l=>{a.gen=l,c()}),p=new K(ae,{signal:t.signal,gap:1e4,lock:`pipeup-share:${e.id}`,allowed:()=>e.ops().filter(l=>a.sendable(l)),changed:x}),b=new E({id:"share",document:e,merge:async l=>{let u=await t.merge(l),k=new Set(e.ops().map(w=>w.body.id));for(let w of _(l))k.has(w)&&a.recv.add(w);return c(),u},transport:p,sendable:l=>{let u=a.sendable(l);return a.noted!==s?.noted&&c(),u},signal:t.signal,delay:2e3,gap:()=>p.gap}),G;b.onState(()=>{x(),clearTimeout(G),G=setTimeout(()=>void p.prepare(b.pending()),1e3)});let we=new URL(r.kind==="mailbox"?r.mailbox:r.base).host,de=()=>{let l=b.waiting;return p.problem?m[p.problem]:a.send?p.offline||b.state==="offline"?"Shared \xB7 offline, sends when back":l?`Shared \xB7 ${l} change${l===1?"":"s"} waiting`:"Shared \xB7 up to date":"Shared \xB7 not sending your comments"},ve=()=>{let l=ae.expires;return p.problem==="gone"?"Your comments stay on this machine. The author can start sharing again.":[`Your comments are encrypted and sent to ${we} so others with this page see them. The service can't read them. People who already have your comments, by file or live, could pass them on.`,t.ephemeral&&"This browser can't keep comments; the shared copy keeps the ones you send.",!o.lasting&&"This browser won't remember this choice.",l&&l-Date.now()<Ge&&`The shared copy expires on ${new Date(l).toLocaleDateString("en-GB",{day:"numeric",month:"long"})}.`].filter(Boolean).join(" ")},R=[],J=(l,u,k,w,ke,Ae)=>R[R.push(t.addMenuItem({id:l,icon:u,label:k,hint:w,select:ke,checked:Ae}))-1],Z=e.ops().filter(l=>a.held.has(l.body.id)&&(l.body.kind==="create"||l.body.kind==="reply")).length;if(J("send",ye,()=>a.send||p.problem?de():"Send my comments",ve,()=>{a.send=!a.send,c(),b.rescan(),x()},()=>a.send),Z){let l=o.lasting?"":" This browser won't remember this choice.",u=k=>()=>{a.decide(k),c();for(let w of R.splice(1))w.remove();b.rescan(),x()};J("share-earlier",ye,()=>`Share my ${Z} earlier comment${Z===1?"":"s"}`,()=>`Send the comments you wrote before this page was shared.${l}`,u(!0)),J("keep-earlier",Je,()=>"Keep them on this machine",()=>`Never send the comments you wrote before this page was shared.${l}`,u(!1))}return x(),b.start().then(x,l=>globalThis.reportError?.(l)),e.onChange((l,u,k)=>{k==="local"&&u.length&&p.bump()}),()=>{clearTimeout(G),b.stop()}}}}X(be());})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipeup/share",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Share Pipeup comments through an encrypted service (PrivateBin or your own HTTP mailbox).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Pipeup contributors",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"LICENSE"
|
|
31
31
|
],
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"pipeup": "0.5.
|
|
33
|
+
"pipeup": "0.5.1"
|
|
34
34
|
},
|
|
35
35
|
"pipeup": {
|
|
36
36
|
"network": {
|