@panphora/clayjs 1.19.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +1 -1
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +8349 -8125
- package/dist/m/attrs/{refetch-on-save-ZUE7PSCI.js → refetch-on-save-DPGJJMGN.js} +1 -1
- package/dist/m/attrs/save-freeze-MTFVVYV5.js +1 -0
- package/dist/m/{c-DHUCEMXE.js → c-2VB555FG.js} +1 -1
- package/dist/m/{c-KGHVFRR3.js → c-3AXJDL2P.js} +1 -1
- package/dist/m/{c-FOOE4GML.js → c-3GJ4XARY.js} +1 -1
- package/dist/m/c-3TWCKFOP.js +1 -0
- package/dist/m/{c-LPCZOYTX.js → c-3YH6JSIL.js} +1 -1
- package/dist/m/{c-AIWN4QN4.js → c-44B5ODN7.js} +2 -2
- package/dist/m/{c-WQWIRWO3.js → c-5FEU5MMY.js} +1 -1
- package/dist/m/{c-S2U6NJU4.js → c-62HZW5DH.js} +1 -1
- package/dist/m/{c-ZGDYHKG3.js → c-67ILSNPR.js} +1 -1
- package/dist/m/c-67LGZ52V.js +20 -0
- package/dist/m/{c-ZRUQ5FSU.js → c-7SXYQCN4.js} +1 -1
- package/dist/m/{c-LACAAQFB.js → c-AL4RBJF2.js} +1 -1
- package/dist/m/{c-L42OLXWM.js → c-ANNFZFLN.js} +1 -1
- package/dist/m/{c-QO4HNGCQ.js → c-B4VYNXTQ.js} +1 -1
- package/dist/m/{c-7PRJCA3E.js → c-BJPZCWAV.js} +1 -1
- package/dist/m/{c-V52FE5FI.js → c-BTLFLLML.js} +1 -1
- package/dist/m/c-C4IIQZGJ.js +1 -0
- package/dist/m/{c-5T6NZHNM.js → c-CAWNFER6.js} +1 -1
- package/dist/m/c-CSNE5EIF.js +1 -0
- package/dist/m/{c-DVYGFTSK.js → c-DDDOKPI6.js} +2 -2
- package/dist/m/{c-2RARVIAK.js → c-DHXPDLW6.js} +1 -1
- package/dist/m/{c-WCXLG3MV.js → c-E4IBSAQM.js} +1 -1
- package/dist/m/{c-IVTRVENZ.js → c-EDSPKYMA.js} +1 -1
- package/dist/m/{c-2Y4DOHSY.js → c-EFD6QNTE.js} +1 -1
- package/dist/m/{c-7MG5RU63.js → c-EGTIAL6P.js} +1 -1
- package/dist/m/{c-FCNAO2MI.js → c-EOCKLMKX.js} +1 -1
- package/dist/m/{c-UXFUJEZO.js → c-EOCZ2YVL.js} +1 -1
- package/dist/m/{c-K72SY2TL.js → c-EZ7B5AZT.js} +1 -1
- package/dist/m/{c-UPD33ZPE.js → c-FDAXZ2PM.js} +1 -1
- package/dist/m/{c-P3CK66NT.js → c-FNVQAACK.js} +1 -1
- package/dist/m/c-FSWRGBVQ.js +1 -0
- package/dist/m/c-FTWGYI5E.js +1 -0
- package/dist/m/{c-WKNRJX3C.js → c-GKEATME6.js} +1 -1
- package/dist/m/{c-QINHDETP.js → c-GPGYKER7.js} +1 -1
- package/dist/m/{c-FWKHM4E7.js → c-GSRLXYWL.js} +1 -1
- package/dist/m/{c-B7J4K2AE.js → c-GVPNDIKJ.js} +2 -2
- package/dist/m/{c-D3E4WJ4M.js → c-HDWZEJHM.js} +49 -32
- package/dist/m/{c-FTQKI7SP.js → c-I2IFKJX2.js} +1 -1
- package/dist/m/c-ICMAOOGK.js +1 -0
- package/dist/m/{c-HUISJXHF.js → c-J3BXFTZS.js} +1 -1
- package/dist/m/{c-BIJALSRD.js → c-JDZDF2QM.js} +1 -1
- package/dist/m/{c-UDHIVLYH.js → c-JH5FF4NL.js} +1 -1
- package/dist/m/{c-OYRZ7XG2.js → c-JHJR5BQX.js} +1 -1
- package/dist/m/{c-V44KWI2L.js → c-JOH753EJ.js} +2 -2
- package/dist/m/{c-P3OFYUMA.js → c-JUE7B4OX.js} +1 -1
- package/dist/m/c-K76AUL4I.js +7 -0
- package/dist/m/{c-ZWIOJGMT.js → c-LA2BW7UY.js} +1 -1
- package/dist/m/{c-ICJYHABF.js → c-LDUNOR57.js} +1 -1
- package/dist/m/{c-XSZKP646.js → c-LIBE4HPD.js} +1 -1
- package/dist/m/c-LPUJXRXW.js +1 -0
- package/dist/m/{c-JK3PHE7J.js → c-LQU7TXIH.js} +1 -1
- package/dist/m/{c-5ZQV7KC4.js → c-LV5MABYD.js} +1 -1
- package/dist/m/{c-GWNC3UGL.js → c-M4FSPNQ2.js} +1 -1
- package/dist/m/{c-2KIEGNC4.js → c-MEWUGR4D.js} +1 -1
- package/dist/m/c-MIL4B2JQ.js +1 -0
- package/dist/m/{c-IVMD3FEM.js → c-N7Y52HJH.js} +1 -1
- package/dist/m/{c-O4JMKN6U.js → c-NFR673TL.js} +2 -2
- package/dist/m/{c-ZKNBMNN3.js → c-NLZ5AN4L.js} +1 -1
- package/dist/m/{c-RRZJWFLE.js → c-OABVRYOT.js} +1 -1
- package/dist/m/c-PIVIYLTY.js +1 -0
- package/dist/m/{c-L7JL5TL3.js → c-QY7F6EN6.js} +1 -1
- package/dist/m/{c-UY4QX42B.js → c-RG6XUZFA.js} +1 -1
- package/dist/m/c-RHMPKZZ7.js +1 -0
- package/dist/m/{c-TJAXGIRV.js → c-RQRMPZXD.js} +1 -1
- package/dist/m/{c-GY422N3Q.js → c-RS77ODLY.js} +1 -1
- package/dist/m/{c-BAUBNYXK.js → c-RT3C74GY.js} +1 -1
- package/dist/m/{c-CAS3NND4.js → c-S5IEIZCN.js} +1 -1
- package/dist/m/{c-HXPHZN7Q.js → c-SBSMJIPC.js} +1 -1
- package/dist/m/c-SFKI6OLM.js +2 -0
- package/dist/m/{c-4FJTBE6I.js → c-SJPD46ZO.js} +4 -4
- package/dist/m/{c-JCP3XDSJ.js → c-SO63UGPQ.js} +1 -1
- package/dist/m/{c-PLP4JKFC.js → c-TUGVINJR.js} +1 -1
- package/dist/m/{c-Q26MME6N.js → c-TWCXBWS3.js} +1 -1
- package/dist/m/{c-GNDL3TKB.js → c-U5X57T4L.js} +1 -1
- package/dist/m/{c-ZS4US2XV.js → c-UXEVJ63W.js} +1 -1
- package/dist/m/{c-KJJPV77R.js → c-V2J5C5MT.js} +1 -1
- package/dist/m/{c-7PYNAULW.js → c-VBLFAQD2.js} +1 -1
- package/dist/m/{c-ERQSNR6K.js → c-VQCEOGKH.js} +2 -2
- package/dist/m/{c-YVZ2L7CE.js → c-VSPAFOKU.js} +1 -1
- package/dist/m/{c-L6FLIUXP.js → c-VY6XRBOW.js} +1 -1
- package/dist/m/{c-2KL3BD52.js → c-W23KVGUO.js} +1 -1
- package/dist/m/{c-AXGY2WTB.js → c-W3K23S72.js} +1 -1
- package/dist/m/c-WFMRX5RZ.js +1 -0
- package/dist/m/{c-BWFVSBDF.js → c-WN3MXOLT.js} +1 -1
- package/dist/m/{c-MIKZEG5I.js → c-XD5MOROJ.js} +1 -1
- package/dist/m/{c-CQQDL6O4.js → c-XQSXKIKM.js} +1 -1
- package/dist/m/{c-I4MQHOEY.js → c-Y33LUUIQ.js} +1 -1
- package/dist/m/{c-JDARJDOT.js → c-YQUJ74R3.js} +1 -1
- package/dist/m/{c-F6G2OGYG.js → c-YSB6JKV2.js} +2 -2
- package/dist/m/{c-BHZYSHW4.js → c-ZJLU56DV.js} +1 -1
- package/dist/m/{c-DKLS74XB.js → c-ZQXNHZZT.js} +2 -2
- package/dist/m/{c-TNEM3RNM.js → c-ZSCBEB7I.js} +1 -1
- package/dist/m/core/{admin-attrs-YY7T5FGU.js → admin-attrs-ZG7R5V3E.js} +1 -1
- package/dist/m/core/{autosave-RVJPYLRT.js → autosave-VPORYJSE.js} +1 -1
- package/dist/m/core/{conflict-notice-2WGT52LH.js → conflict-notice-JMAZLVRX.js} +1 -1
- package/dist/m/core/{persist-UKXV5KLA.js → persist-3OPWJKZS.js} +1 -1
- package/dist/m/core/{recovery-ZOUOJVIX.js → recovery-DRFZRJED.js} +1 -1
- package/dist/m/core/{save-A5JXV6ME.js → save-AOJBDSOK.js} +1 -1
- package/dist/m/core/{save-core-MKRPSEEO.js → save-core-IOCMXO5L.js} +1 -1
- package/dist/m/core/{snapshot-NU3YM6GR.js → snapshot-O7II2AGG.js} +1 -1
- package/dist/m/core/unsaved-warning-U5VUJFOE.js +1 -0
- package/dist/m/events/{index-RN2JNGBV.js → index-B6TGDYMG.js} +1 -1
- package/dist/m/internals/{index-TGLQINN3.js → index-HDRANDWE.js} +1 -1
- package/dist/m/lib/{cache-bust-MUMFXZK6.js → cache-bust-NH7VBWHO.js} +1 -1
- package/dist/m/lib/{region-policy-SB2AWVG5.js → region-policy-KWBPROWF.js} +1 -1
- package/dist/m/{loader-34YPFKOH.js → loader-ZVPK4ZN3.js} +1 -1
- package/dist/m/manifest-5498AFD3.js +1 -0
- package/dist/m/manifest-edit-62A5A00F.js +1 -0
- package/dist/m/manifest.json +1215 -1171
- package/dist/m/options/{options-EJMS3K24.js → options-55LQHSJ4.js} +1 -1
- package/dist/m/page/{editor-WRQGHDSG.js → editor-EY2WAAGB.js} +2 -2
- package/dist/m/plugins/{ai-edit-X2L2KIEP.js → ai-edit-J5VLSW5I.js} +1 -1
- package/dist/m/plugins/{demo-OYO5GCAO.js → demo-42BSYQ7T.js} +1 -1
- package/dist/m/plugins/{derive-FRE5JJQE.js → derive-QVI3LI3A.js} +1 -1
- package/dist/m/plugins/{live-7C36XEI2.js → live-5EZN2EYP.js} +1 -1
- package/dist/m/plugins/menu-DM2JHPSR.js +1 -0
- package/dist/m/plugins/{page-BSW6MGDO.js → page-LVW5DWA4.js} +2 -2
- package/dist/m/plugins/{page-view-WFZVTPQK.js → page-view-5KQ76IJB.js} +1 -1
- package/dist/m/plugins/{sortable-4S6SQC3D.js → sortable-WJZZBM7R.js} +1 -1
- package/dist/m/plugins/{source-TJXOIOYY.js → source-CCEUM3OR.js} +1 -1
- package/dist/m/plugins/{undo-NLPGCJQY.js → undo-3JEYK5QY.js} +1 -1
- package/dist/m/plugins/{upgrade-HSUNDNJD.js → upgrade-NW556WJD.js} +1 -1
- package/dist/m/plugins/{upload-NHGJXZK2.js → upload-TTCQRIM5.js} +1 -1
- package/dist/m/plugins/{visitor-drafts-BW43DGY3.js → visitor-drafts-2AWNT23K.js} +2 -2
- package/dist/m/plugins/{visitor-drafts-owner-7ODQG7JX.js → visitor-drafts-owner-MZP45XSG.js} +1 -1
- package/dist/m/plugins/{wire-6OSIL3I7.js → wire-VRYPY6EJ.js} +1 -1
- package/dist/m/{reader-core-PLZYLYLT.js → reader-core-2GXY7SHY.js} +2 -2
- package/dist/m/sync/{live-sync-UXNI6ZF6.js → live-sync-SKPMFYOO.js} +1 -1
- package/dist/m/ui/{index-IVWN2QC4.js → index-QNIPDHXQ.js} +1 -1
- package/dist/m/vendor/{sap-core.vendor-RN4ZVY4X.js → sap-core.vendor-OA5SKL7Q.js} +1 -1
- package/dist/offline-manifest.json +650 -626
- package/docs/guide.md +38 -14
- package/entries/sap.js +1 -1
- package/package.json +3 -2
- package/src/core/conflict-download.js +8 -7
- package/src/core/conflict-notice-ui.js +4 -4
- package/src/core/copy-content.js +103 -0
- package/src/core/download.js +14 -2
- package/src/core/save-size-notice.js +2 -2
- package/src/core/upgrade-run.js +5 -1
- package/src/lib/region-policy.js +1 -1
- package/src/page/features/export-html.js +4 -4
- package/src/page/features/export-markdown.js +2 -2
- package/src/page/recovery-ui.js +2 -2
- package/src/page/save-states.js +4 -4
- package/src/plugins/menu/actions.js +1 -1
- package/src/plugins/menu/style.js +59 -31
- package/src/plugins/menu.js +131 -28
- package/src/plugins/page.js +4 -4
- package/src/plugins/visitor-drafts/prompt.js +12 -12
- package/src/plugins/wire.js +3 -1
- package/src/vendor/sap-core.vendor.js +1 -1
- package/dist/m/attrs/save-freeze-LWGF6XUN.js +0 -1
- package/dist/m/c-DCFSEJZG.js +0 -1
- package/dist/m/c-EXEDYU4H.js +0 -1
- package/dist/m/c-GRXHHFPO.js +0 -1
- package/dist/m/c-HT2DKBV2.js +0 -1
- package/dist/m/c-MCOOHCSG.js +0 -1
- package/dist/m/c-MMXKAX2W.js +0 -1
- package/dist/m/c-VE7RKNKZ.js +0 -7
- package/dist/m/c-VR2BJ4AN.js +0 -1
- package/dist/m/c-WGW764WX.js +0 -1
- package/dist/m/c-WNTYKCDG.js +0 -1
- package/dist/m/c-YBSS55KU.js +0 -20
- package/dist/m/core/unsaved-warning-4ZPEV7BF.js +0 -1
- package/dist/m/manifest-0D166F4F.js +0 -1
- package/dist/m/manifest-edit-3877153E.js +0 -1
- package/dist/m/plugins/menu-MFC4DI5E.js +0 -1
- /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
- /package/dist/m/{c-5JLFROUB.js → c-X5LNHET5.js} +0 -0
- /package/dist/m/plugins/{people-JCHVPF7P.js → people-C7TVBBMR.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as A,b as m,c as n}from"./c-
|
|
1
|
+
import{a as A,b as m,c as n}from"./c-TWCXBWS3.js";import{a as c}from"./c-VKEDWYDF.js";import{f as i}from"./c-3O7OBDCM.js";import{b as l,q as d}from"./c-EGTIAL6P.js";var f="[editmode\\:onclick]";function b(){d(o=>{o.querySelectorAll(f).forEach(t=>{let e=t.getAttribute("onclick");e!==null&&(t.setAttribute("inert-onclick",e),t.removeAttribute("onclick"),n(t,l(t)??t))})})}function p(){i&&c(()=>{E()})}function E(o=document){o.querySelectorAll(f).forEach(t=>{let e=t.getAttribute("inert-onclick");e&&(t.setAttribute("onclick",e),t.removeAttribute("inert-onclick"))})}function D(){document.querySelectorAll(f).forEach(o=>{let t=o.getAttribute("onclick");t&&(o.setAttribute("inert-onclick",t),o.removeAttribute("onclick")),n(o)})}function q(){b(),p()}var O="[viewmode\\:disabled]",S="[viewmode\\:readonly]",u=[[O,"disabled"],[S,"readonly"]];function k(){d(o=>{for(let[t,e]of u)o.querySelectorAll(t).forEach(r=>{if(r.hasAttribute(e))return;let a=l(r),s=a?m(a,e):null;r.setAttribute(e,s===null?"":s),n(r,a??r)})})}function h(){i&&c(()=>{x()})}function x(o=document){for(let[t,e]of u)o.querySelectorAll(t).forEach(r=>{A(r),r.removeAttribute(e)})}function M(){for(let[o,t]of u)document.querySelectorAll(o).forEach(e=>{let r=m(e,t);r===null?e.removeAttribute(t):e.setAttribute(t,r),n(e)})}function P(){k(),h()}export{f as a,E as b,D as c,q as d,O as e,S as f,x as g,M as h,P as i};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as E}from"./c-KBS3UV6B.js";import{i as x,j as I}from"./c-
|
|
1
|
+
import{c as E}from"./c-KBS3UV6B.js";import{i as x,j as I}from"./c-SJPD46ZO.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-XQSXKIKM.js";import"./c-67ILSNPR.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as C}from"./c-44B5ODN7.js";import{G as b,J as A,m as f}from"./c-QIXT3Q7C.js";import"./c-E4IBSAQM.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var D=`
|
|
2
2
|
[data-page-heading]{display:block}
|
|
3
3
|
[data-page-heading]>span[data-page-icon]{display:inline-block;font-size:34px;line-height:1;margin-block-end:.2em}
|
|
4
4
|
[data-page-heading]>img[data-page-cover]{display:block;width:100%;height:180px;object-fit:cover;border-radius:var(--page-image-radius, 6px);margin-block-end:.6em}
|
|
5
5
|
[data-page-heading]>h1{font-family:var(--page-font-display);font-size:var(--page-h1-size);font-weight:var(--page-h1-weight);letter-spacing:var(--page-h1-tracking);line-height:var(--page-h1-line);color:var(--page-ink-strong);margin-block:0 .6em}
|
|
6
|
-
`,v=null,P=()=>v??=import("./c-
|
|
6
|
+
`,v=null,P=()=>v??=import("./c-EOCZ2YVL.js").catch(r=>{throw v=null,r});function z(r){let t=typeof r=="string"?r:"";return!t.trim()||typeof Intl>"u"||typeof Intl.Segmenter!="function"||[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(t)].length!==1?!1:[...t].length<=32&&new TextEncoder().encode(t).length<=128}function S(r){let t=0;for(let i=0;i<r.childCount;i++){let a=r.child(i);if(a.type===f.nodes.heading&&a.attrs.level===1&&a.attrs.parent==null)return{index:i,at:t,node:a};t+=a.nodeSize}return null}function L(r,t){let i=r.createElement("img");return i.setAttribute("data-page-cover",""),i.setAttribute("src",t.pageCoverSrc),i.setAttribute("alt",t.pageCoverAlt??""),i.setAttribute("style",`object-position:${t.pageCoverX}% ${t.pageCoverY}%`),i}var g=class{constructor(t,i){this.node=t,this.decorated=!!(t.attrs.pageIcon||t.attrs.pageCoverSrc);let a=i.dom.ownerDocument,p=a.createElement(`h${t.attrs.level}`);if(p.setAttribute("data-id",t.attrs.id),this.dom=this.contentDOM=p,!this.decorated)return;let l=a.createElement("header");if(l.setAttribute("data-id",t.attrs.id),l.setAttribute("data-page-heading","1"),p.removeAttribute("data-id"),t.attrs.pageCoverSrc&&l.append(L(a,t.attrs)),t.attrs.pageIcon){let c=a.createElement("span");c.setAttribute("data-page-icon",""),c.setAttribute("aria-hidden","true"),c.textContent=t.attrs.pageIcon,l.append(c)}l.append(p),this.dom=l}update(t){return this.decorated!==!!(t.attrs.pageIcon||t.attrs.pageCoverSrc)||!t.sameMarkup(this.node)?!1:(this.node=t,!0)}ignoreMutation(t){return!this.contentDOM.contains(t.target)}};function W({view:r=null}={}){if(!r)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let t=r.dom.ownerDocument,i=null,a=null;function p(){try{let n=r.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},e=r.coordsAtPos(r.state.selection.from);return{x:Math.max(8,e.left-n.left),y:e.bottom+6-n.top}}catch{return null}}function l(n){let e=n.picker.activeId();e?r.dom.setAttribute("aria-activedescendant",e):r.dom.getAttribute("aria-activedescendant")?.startsWith(n.picker.el.id)&&r.dom.removeAttribute("aria-activedescendant")}function c(){let n=a;if(n){a=null;for(let[e,o,u,d]of n.listen)e.removeEventListener(o,u,d);r.dom.getAttribute("aria-activedescendant")?.startsWith(`${n.picker.el.id}-`)&&r.dom.removeAttribute("aria-activedescendant"),n.picker.destroy()}}function j(n,e){let o=S(r.state.doc);if((o?o.node.attrs.id:null)!==n.owner)return{ok:!1,code:"stale-target"};let d=r.state.tr;if(o)d.setNodeMarkup(o.at,null,{...o.node.attrs,pageIcon:e});else{let s=r.state.doc.maybeChild(0);d.insert(0,f.nodes.heading.create({id:A(),pos:b(null,s?.attrs.pos??null),parent:null,level:1,pageIcon:e}))}return r.dispatch(C(d)),{ok:!0,icon:e}}async function m(n){let e=a;if(!e)return{ok:!1,code:"not-editing"};let o=e.picker.personAt(n);return c(),o?z(o.char)?x(r,()=>j(e,o.char)):{ok:!1,code:"invalid-icon"}:{ok:!1,code:"no-emoji"}}function w(n){let e=a;if(!e||I(n,r))return;let o=()=>{n.preventDefault(),n.stopPropagation()};n.key==="ArrowDown"||n.key==="ArrowUp"?(o(),e.picker.move(n.key==="ArrowDown"?1:-1),l(e)):n.key==="Enter"?(o(),m(e.picker.index())):(n.key==="Escape"||n.key==="Tab")&&(o(),c())}async function M(n){c();let e={owner:S(r.state.doc)?.node.attrs.id??null,picker:null,listen:[]};e.picker=E({document:t,label:"Choose a page icon",empty:"No emoji found",onPick:s=>m(s)}),a=e;let o=(s,h,k,y)=>{s.addEventListener(h,k,y),e.listen.push([s,h,k,y])};o(t,"keydown",s=>w(s),!0),o(r.dom,"input",()=>c()),o(t,"mousedown",s=>{e.picker.el.contains(s.target)||c()},!0),(r.dom.parentElement??t.body).appendChild(e.picker.el);let u,d;try{let s=await P();d=s.filterEmoji,i??=s.emojiLibrary(),u=await i()}catch(s){return c(),{ok:!1,code:"unavailable",error:s}}return a!==e?{ok:!1,code:"not-editing"}:(e.picker.show(d(u,n?.query),p()),l(e),{ok:!0,picker:!0})}return{nodeViews:{heading:(n,e)=>new g(n,e)},css:D,async run(n){return M(n)},dispose(){c()}}}export{W as createFeature,z as isIconGlyph,S as titleOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Gt}from"./c-4ASQPRQL.js";import{a as Dt}from"./c-GQ6F6IDK.js";import{c as F}from"./c-I2SCCUEW.js";import{b as He}from"./c-5VYOWDTI.js";import{a as Wt,d as ne,e as Be,f as b,h as N}from"./c-FWKHM4E7.js";import{a as Ge,b as Qt,c as Vt,d as $t}from"./c-5JLFROUB.js";import{a as Kt}from"./c-UGHH4MB3.js";import{a as Pt}from"./c-ZWIOJGMT.js";import{a as Ot,e as Rt,f as P,g as bt,h as Nt,i as Ft,l as Ut,t as qt,v as Bt,w as Ht}from"./c-B7J4K2AE.js";import{b as It,h as qe}from"./c-EK63G3CG.js";import{a as Fe,c as kt,g as Lt,h as Ue}from"./c-NQJRVJ56.js";import{a as Oe,f as Ie,h as Q}from"./c-IJUK2GPW.js";import{b as K,e as Ct,f as w}from"./c-3O7OBDCM.js";import{i as At,k as Tt}from"./c-N7JPUPGC.js";import{D as Ne,h as Re,q as be,t as _t,x as V,y as me}from"./c-7MG5RU63.js";import{d as xt}from"./c-VG5XIN4T.js";import{a as pe}from"./c-2YYDMLNZ.js";import{d as St,e as yt,g as Et,h as wt}from"./c-HA6INT6J.js";import{k as Mt}from"./c-DCFSEJZG.js";var hn="clay:debug:autosave";function ve(){try{return localStorage.getItem(hn)==="true"}catch{return!1}}function ge(){return import("./c-CFHW5AMY.js").catch(e=>(console.warn("[autosave-debug] Failed to load the debug logger:",e),null))}function he(e,t){ve()&&ge().then(n=>n?.logSaveCheck(e,t))}function re(e,t=""){ve()&&ge().then(n=>n?.logBaseline(e,t))}function Yt(e,t){ve()&&ge().then(n=>n?.logUnloadDiffSync(e,t))}function zt(){ve()&&ge().then(e=>e?.preloadIfEnabled())}var U=Number.NEGATIVE_INFINITY;function Sn({firstDirtyAt:e=U,lastActivityAt:t=U,finishedAt:n=U,costMs:o=0}={}){let r=e??U,i=t??U,a=n??U,f=Math.min(3e4,Math.max(1200,4*o)),u=Math.max(i,a)+1500,m=Math.max(r+1e4,a+f);return Math.max(a+1200,Math.min(u,m))}function Xt({now:e=()=>Date.now(),setTimer:t=(r,i)=>setTimeout(r,i),clearTimer:n=r=>clearTimeout(r),run:o=()=>{}}={}){let r=null,i=null,a=U,f=0,u=null,m=null,c=!1,p=!1;function S(){return Sn({firstDirtyAt:r,lastActivityAt:i,finishedAt:a,costMs:f})}function y(){if(!c||p)return;let E=S();if(u!==null){if(m===E)return;n(u)}m=E,u=t(d,Math.max(0,E-e()))}function d(){if(u=null,m=null,!(!c||p)){if(e()<S()){y();return}g()}}function g(){c=!1,p=!0,r=null,i=null;let E;try{E=o()}catch{l();return}Promise.resolve(E).then(l,l)}function l(){p=!1,a=e(),c&&y()}function s({at:E=e()}={}){r===null&&(r=E),i=E,c=!0,y()}function v(){c=!0,y()}function M(E){E>0&&(f=Math.max(E,f*.8))}return{noteActivity:s,request:v,noteCost:M,dueAt:S,costEstimate:()=>f,pending:()=>c||p,running:()=>p}}be(e=>{for(let t of wt)e.removeAttribute(t)});be(e=>{for(let t of[...St,...yt,...Et])e.removeAttribute(t)});var x=null;function A(e,t="",n="",o=null){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus",e);let r=new CustomEvent(`clay:save-${e}`,{detail:{msg:t,msgType:n,timestamp:Date.now(),...o||{}}});document.dispatchEvent(r)}function nt(){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","offline")}function yn(){x=setTimeout(()=>{A("saving")},500)}window.addEventListener("offline",()=>{nt()});window.addEventListener("online",()=>{document.documentElement.getAttribute("savestatus")==="offline"&&I().then(e=>{e.msgType==="skipped"&&document.documentElement.getAttribute("savestatus")==="offline"&&document.documentElement.setAttribute("savestatus","saved")})});var q=!1,L="",C="",ie=0,Ee=new Set,D=!1,k=!1,we=!1,B=0,$e=!1;function En(){B++}function rn(){B!==0&&(B--,!(B>0)&&(fe&&(fe=!1,J=setTimeout(dt,0)),$e&&($e=!1,ke())))}function wn(){return B>0}var $=0,te=!1,ae=!1,Ae=!1;function de(e=null){return $===0||an(e)}function rt(){return te}function An(){if(te)return!0;try{let e=V({flushUndo:!1});return gt(e)?!1:e!==C}catch{return!0}}function Tn(){let e="idle",t=0;return{get phase(){return e},get open(){return e==="open"},changedWhileClosed(){return e==="quiesced"&&Be()!==t},start(){e==="idle"&&(e="open")},quiesce(){e==="open"&&(e="quiesced",t=Be(),$++)},resume(){e==="quiesced"&&(e="open",$--,!($>0)&&(Wn(),tn()))},stop(){if(e==="stopped")return;let n=e==="quiesced";(n||e==="open")&&An()&&(Ae=!0),e="stopped",n&&($--,$===0&&tn())}}}var jt=!1,oe=null,Ye=null,ze=!1;function Ir(e=R){if(!oe||oe.generation!==e)return null;let{bytes:t,etag:n}=oe;return{bytes:t,etag:n}}function Rr({represented:e}={}){let t=b(),{forComparison:n,forDirty:o}=me(),r=typeof e?.etag=="string"&&e.etag?e.etag:null;return!(ze&&r!==null&&r!==Ye)&&Ae&&(n!==L||o!==C)?{ok:!1,code:"pending-input"}:(Ae=!1,ue(n,o),W=n,Z=!1,pt=!0,Ye=r,ze=!0,N(t),document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:baseline-settled")),{ok:!0})}var ot=Promise.resolve(!1),Te=!1,Cn=()=>(Te=!0,Lt().catch(()=>!1).then(e=>(Te=!1,e)));function br(){return{id:"clay:save",order:10,prepare(e={}){let t=Tn();return e.initial===!0&&t.start(),{enable(){ot=Cn();let n=e.represented?.etag;typeof n=="string"&&n&&kt(n),e.initial!==!0&&(Mn(),t.start())},quiesce:()=>t.quiesce(),resume:()=>t.resume(),dispose:()=>t.stop()}}}}function Mn(){jt||(jt=!0,Wt(),Oe(),vn(),gn())}var O=0,Xe=!1,Ce=!1,st="Waiting for the AI edit to be kept or reverted",Y=new Map;function Nr(e=st){O++,Y.set(e,(Y.get(e)||0)+1)}function Fr({replay:e=!0,reason:t=st}={}){let n=Y.get(t)||0;if(n===0||(n===1?Y.delete(t):Y.set(t,n-1),O--,O>0))return;let o=Xe,r=Ce;Xe=!1,Ce=!1,e&&(o?I():r&&ke())}function Ur(){return O>0}function it(){return O===0?null:Y.keys().next().value||st}function on(e,t){if(O===0)return!1;Xe=!0,Q();let n=h(it());return e(n),t(n),n}var H=!1,se=null;function xn(e){se=e??null,!H&&(H=!0,En())}function Pn(){H&&(H=!1,se=null,rn())}function je(){return H}function qr(e){if(!H||se&&e!==se)return;H=!1,se=null,!He()&&ne()||(document.documentElement.getAttribute("savestatus")==="conflict"&&document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-conflict-resolved",{detail:{timestamp:Date.now()}}))),document.dispatchEvent(new CustomEvent("clay:save-conflict-released",{detail:{etag:e??null}})),rn()}function h(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function at(e){return(ne()||F())&&(te=!0),h(e)}function sn(){return{ok:!1,msg:"You are not allowed to save this document.",msgType:"forbidden",code:"forbidden",status:403,sent:!1,etag:null}}function ut(){return Ct()===!1}var lt=new Set,R=0;function Br(){return R}function Hr(e){typeof e=="number"&&(R=e)}function _n(e=R){let t=Object.freeze({generation:e});return lt.add(t),t}function Dn(e){lt.delete(e)}function an(e){return!!e&<.has(e)&&e.generation===R}function z(e,t){e!=null&&$t({captureId:e,ok:t.ok===!0,etag:t.etag??null})}function kn(e,t,n,o,r,i=null,a=null,f=!1){if(z(a,e),e.ok)te=!1,ue(t,n),Me=i,oe={bytes:i,etag:Fe(),generation:R},Ye=oe.etag,ze=!0,Ae=!1,q=!1,N(r),A("saved",e.msg||"Saved",e.msgType,{etag:e.etag??null,captureId:a}),re(o,`${L.length} chars`),Pn();else if(e.msgType==="conflict"){if(f){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","saved");return}xn(e.conflictEtag),A("conflict",e.msg,e.msgType,{hadTimeout:e.hadTimeout===!0,changedBy:e.changedBy??null,afterTimeout:e.afterTimeout===!0,etag:e.conflictEtag??null,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a})}else if(e.msgType!=="skipped"){let u={status:e.status??null,hadTimeout:e.hadTimeout===!0,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a};navigator.onLine?A("error",e.msg,"",u):A("offline",e.msg,"",u)}}function un(){if(!(!D&&!k)&&!Ut()){if(D){D=!1,k=!1,I();return}k=!1,et.request()}}function Gr(){return q}function Wr(e){q=e}function Kr(){return L}function ft(){return C}var Me=null;function Qr(){return Me}function ue(e,t){L=e,C=t,ie++}function Vr(e){ue(e,e)}var G=()=>typeof performance<"u"&&performance.now?performance.now():Date.now();var Ln=4,Jt="Save cancelled: the page changed while it prepared",X=null,le=null,We=null,ln=!1;function fn(){return We||(We=import("./c-KGHVFRR3.js").then(e=>(le=e,e),e=>(ln=!0,console.info("clayjs: sliced save off ("+(e&&e.message?e.message:e)+"); saves prepare in one task"),null))),We}function On(){try{return performance.getEntriesByType("navigation")[0]?.decodedBodySize||0}catch{return 0}}var In=()=>typeof Me=="string"?Me.length:On();function xe(){return ln||document.hidden||Ft()?!1:In()>=307200}function Zt(e,t,n){return n?"morph":R!==t.generation||!w?"mode":de(e.permit)?ut()?"refused":ie!==t.baselines?"newer save":Math.max(qe(),e.pageFormatFloor)>t.floor?"floor":null:"session"}function Rn(e=150,t=2e3){return new Promise(n=>{let o=G(),r=null,i=()=>{document.removeEventListener("clay:sync-applied",a),n()},a=()=>{clearTimeout(r),r=setTimeout(i,Math.max(0,Math.min(e,t-(G()-o))))};document.addEventListener("clay:sync-applied",a),a()})}async function ct({explicit:e,forced:t=!1,forSave:n,forComparison:o,forDirty:r,captureId:i,gateToken:a,costMs:f,pageFormatFloor:u=0,quietConflict:m=!1,laneHeld:c=!1,lane:p=null,capture:S,noteRecovery:y,release:d,callback:g}){if(y(),e&&!t){if(q=r!==C,he("savePage dirty check",!q),!q){Q(),N(a),d();let s=h("No changes to save");return z(i,s),typeof g=="function"&&g(s),{result:s,dispatched:!1}}}else if(!e){let s=!Z||o!==W,v=o!==L;if(he("throttled vs baseline",!s),he("throttled vs lastSave",!v),!(s&&v)){let M=!1;try{M=!v&&(!document.querySelector(Mt)||ne()&&r===C)}catch(ht){console.error("savePageThrottled: dirty domain check failed",ht)}M&&N(a),et.noteCost(f),d();let E=h("No changes to save");return z(i,E),typeof g=="function"&&g(E),{result:E,dispatched:!1}}if(q=!0,!c&&P()){D=!0,d();let M=h("Save already in progress");return z(i,M),typeof g=="function"&&g(M),{result:M,dispatched:!1}}}yn();let l={forComparison:o,forDirty:r};return Ee.add(l),we=!0,new Promise(s=>{qt(n,i,v=>{we=!1,Ee.delete(l);let M=G();kn(v,l.forComparison,l.forDirty,t?"updated after force save":"updated after save",a,n,i,m),e||et.noteCost(f+(G()-M)),typeof g=="function"&&g(v),s({result:v,dispatched:!0}),c||un()},{capture:S,pageFormatFloor:u,lane:p})})}async function bn(e,t){let n={over:!1},o=()=>{n.over=!0};document.addEventListener("clay:sync-applied",o);try{for(let i=0;i<2;i++){let a=b(),f={generation:R,baselines:ie,floor:Math.max(qe(),e.pageFormatFloor)},u=le.beginSaveCapture({requestRefresh:!0,forRequest:!0,pageFormatMarker:f.floor?{name:It,content:String(f.floor)}:null});Qt(u.captureId);let m=null,c={get aborted(){let d=Zt(e,f,n.over);return d&&(m=d),!!d}},p;try{p=await le.runPreparedSteps(u.steps(),{budgetMs:Ln,signal:c})}catch(d){console.error(`${e.explicit?"savePage":"savePageThrottled"}: preparing the save failed`,d),u.drop();let g={msg:d&&d.message?d.message:"Save failed",msgType:"error",code:d?.code??null,etag:null};return A("error",g.msg,"",{sent:!1,code:g.code}),z(u.captureId,g),typeof e.callback=="function"&&e.callback(g),{result:g,dispatched:!1}}let S=p.aborted?m:Zt(e,f,n.over);if(!S){let d=p.result;return await ct({explicit:e.explicit,forced:e.forced,forSave:d.forSave,forComparison:d.forComparison,forDirty:d.forDirty,captureId:d.captureId,gateToken:a,costMs:p.activeMs,pageFormatFloor:e.pageFormatFloor,quietConflict:e.quietConflict,laneHeld:!0,lane:t,capture:d,noteRecovery:()=>Vt(d.captureId,d.forSave),release:()=>u.drop(),callback:e.callback})}u.drop();let y=h(Jt);if(S==="session"&&(ae=!0),z(u.captureId,y),!(S==="floor"&&i===0)){if(S==="morph"&&e.explicit&&i===0){await Rn(),n.over=!1;continue}return typeof e.callback=="function"&&e.callback(y),{result:y,dispatched:!1}}}let r=h(Jt);return typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}}finally{document.removeEventListener("clay:sync-applied",o),Nt(t)}}function cn(e){let t=bt();if(!t)return!1;let n=bn(e,t).catch(o=>{console.error("save: preparing the save failed",o);let r={msg:o&&o.message?o.message:"Save failed",msgType:"error",code:o?.code??null,etag:null};return A("error",r.msg,"",{sent:!1,code:r.code}),typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}});return X=n,n.then(o=>{X===n&&(X=null),e.resolve(o.result),e.settleSoonQueued(o.result),(o.dispatched||D||k||_e.length)&&un()}),!0}function De(e,t=()=>{}){return Te?ot.then(()=>De(e,t)):ee?ce.then(()=>Pe(e,t)):Pe(e,t)}function Pe({kind:e,permit:t=null},n=()=>{}){let o=e==="explicit";return new Promise(r=>{if(!w&&!window.clay?.testMode){o&&Q();let s=h("Not in edit mode");return T().forEach(v=>v(s)),n(s),r(s)}if(!de(t)){ae=!0;let s=at("Save session is quiesced");return o&&T().forEach(v=>v(s)),n(s),r(s)}if(ut()){o&&Q();let s=sn();return A("error",s.msg,"",{code:s.code,status:s.status,sent:!1}),T().forEach(v=>v(s)),n(s),r(s)}if(o){let s=on(n,r);if(s){T().forEach(v=>v(s));return}if(P()){D=!0;let v=h("Save already in progress");return n(v),r(v)}}else{if(O>0){Ce=!0;let s=h(it());return n(s),r(s)}if(P()&&!Z&&we){k=!0;let s=h("Save already in progress");return n(s),r(s)}if(X){k=!0;let s=h("Save already in progress");return n(s),r(s)}if(!Z&&!ne()){let s=h("No changes to save");return n(s),r(s)}}let i=window.clay?.source?.ensureForSave?.();if(i)return i.then(()=>r(Pe({kind:e,permit:t},n)));if(xe()&&!le){fn().then(()=>r(Pe({kind:e,permit:t},n)));return}let a=o?T():[],f=s=>a.forEach(v=>v(s));if(!navigator.onLine&&nt(),xe()&&cn({explicit:o,forced:!1,permit:t,pageFormatFloor:0,quietConflict:!1,settleSoonQueued:f,callback:n,resolve:r}))return;let m=G(),c,p,S,y,d,g=b();try{c=Ne({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(s){console.error(`${o?"savePage":"savePageThrottled"}: captureForSaveAndComparison failed`,s),o?(Q(),A("error",s.message,"",{sent:!1,code:s.code??null})):A("error",s.message);let v={msg:s.message,msgType:"error",code:o?s.code??null:null,etag:null};typeof n=="function"&&n(v),r(v),f(v);return}let l=G()-m;ct({explicit:o,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:l,capture:c,noteRecovery:()=>Ge({captureId:d,html:p}),release:()=>Re(c),callback:n}).then(s=>{r(s.result),f(s.result)})})}function I(e=()=>{}){return De({kind:"explicit"},e)}function Nn(e,t=()=>{}){return De({kind:"explicit",permit:e},t)}function j(e=()=>{},{quietConflict:t=!1,pageFormatFloor:n=0,permit:o=null}={}){return Te?ot.then(()=>j(e,{quietConflict:t,pageFormatFloor:n,permit:o})):new Promise(r=>{if(!w&&!window.clay?.testMode){let l=h("Not in edit mode");return T().forEach(s=>s(l)),e(l),r(l)}if(!de(o)||o&&!an(o)){let l=at("Save session is quiesced");return T().forEach(s=>s(l)),e(l),r(l)}if(ut()){let l=sn();return A("error",l.msg,"",{code:l.code,status:l.status,sent:!1}),T().forEach(s=>s(l)),e(l),r(l)}let i=on(e,r);if(i){T().forEach(l=>l(i));return}if(P()){D=!0;let l=h("Save already in progress");return T().forEach(s=>s(l)),e(l),r(l)}let a=window.clay?.source?.ensureForSave?.();if(a)return a.then(()=>r(j(e,{quietConflict:t,pageFormatFloor:n,permit:o})));if(!navigator.onLine&&nt(),xe()&&!le){fn().then(()=>r(j(e,{quietConflict:t,pageFormatFloor:n,permit:o})));return}let u=T(),m=l=>u.forEach(s=>s(l));if(xe()&&cn({explicit:!0,forced:!0,permit:o,pageFormatFloor:n,quietConflict:t,settleSoonQueued:m,callback:e,resolve:r}))return;let c,p,S,y,d,g=b();try{c=Ne({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(l){console.error("savePageForce: captureForSaveAndComparison failed",l),A("error",l.message,"",{sent:!1,code:l.code??null});let s={msg:l.message,msgType:"error",code:l.code??null,etag:null};typeof e=="function"&&e(s),r(s),m(s);return}ct({explicit:!0,forced:!0,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:0,pageFormatFloor:n,quietConflict:t,capture:c,noteRecovery:()=>Ge({captureId:d,html:p}),release:()=>Re(c),callback:e}).then(l=>{r(l.result),m(l.result)})})}Ht(e=>j(()=>{},{permit:e}));function Fn(e){let t=["clay:save-saved","clay:save-error","clay:save-offline","clay:save-conflict"];return new Promise((n,o)=>{let r=null,i=()=>{clearTimeout(r);for(let u of t)document.removeEventListener(u,a)},a=()=>{i(),n()},f=e-Date.now();if(f<=0){o(Object.assign(new Error("Save timed out."),{state:"failed"}));return}r=setTimeout(()=>{i(),o(Object.assign(new Error("Save timed out."),{state:"failed"}))},f);for(let u of t)document.addEventListener(u,a)})}function _(e,t){return Object.assign(new Error(e),{state:t})}function Un(e,t){return new Promise((n,o)=>{let r=t-Date.now();if(r<=0)return o(_("Save timed out.","failed"));let i=setTimeout(()=>{document.removeEventListener(e,a),o(_("Save timed out.","failed"))},r),a=()=>{clearTimeout(i),n()};document.addEventListener(e,a,{once:!0})})}async function $r({keepalive:e=!1,timeoutMs:t=15e3,permit:n=null}={}){if(!w)return{state:"view",etag:null};let o=Date.now()+t,r=n||_n(),i={over:!1},a=null,f=new Promise((u,m)=>{a=setTimeout(()=>m(_("Save timed out.","failed")),Math.max(0,t))});try{return await Promise.race([qn(e,o,r,i),f])}catch(u){throw u&&typeof u.state=="string"?u:_(u?.message||"Save failed","failed")}finally{i.over=!0,clearTimeout(a),n||Dn(r)}}async function qn(e,t,n,o={over:!1}){if(dn()||await Un("clay:baseline-settled",t),o.over)return null;let r=!1,i=null;for(let a=0;a<4;a++){if(X&&(await X,o.over)||P()&&(await Fn(t),o.over))return null;if(je())throw _("This document has a conflict to resolve.","conflict");let f=b();if(!tt()){if(N(f),F())throw _("This document has unsaved work a save cannot write.","blocked");return te=!1,{state:r?"saved":"clean",etag:i??Fe()}}if(o.over)return null;let u=await Rt(e,()=>Nn(n));if(u.msgType!=="skipped"){if(!u.ok)throw _(u.msg||"Save failed",u.msgType==="conflict"||je()?"conflict":"failed");r=!0,i=u.etag??null}}throw _("The document kept changing while saving.","failed")}async function Yr(e=()=>{}){return await Ue({fresh:!0}),j(e)}function zr(e){!w||K||Bt(e,t=>{t.ok?window.location.reload():t.msgType==="skipped"?A("error",t.msg||"Template not saved"):A("error",t.msg||"Failed to save template")})}var Bn=Dt(e=>De({kind:"automatic"},e),1200),Hn=250,Gn=1e3,J=null,en=0,Je=[],_e=[],fe=!1,T=()=>{let e=_e;return _e=[],e};function dt(){if(J=null,B>0||!de()){fe=!0;return}let e=Je;if(Je=[],P()){_e.push(...e),I();return}I().then(t=>e.forEach(n=>n(t)))}function Xr(){let e=Date.now();return J===null?en=e:clearTimeout(J),new Promise(t=>{Je.push(t),J=setTimeout(dt,Math.max(0,Math.min(Hn,en+Gn-e)))})}function Wn(){ae&&(ae=!1,ke())}function tn(){fe&&(fe=!1,J=setTimeout(dt,0))}var W="",Z=!0,pt=!1;function dn(){return pt}var Ke=!1,Kn=250,Qn=1250,Qe=null,pn="clay:paint-heal:"+location.pathname;function mn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return String(t>>>0)}function Vn(e){try{return localStorage.getItem(pn)===mn(e)}catch{return!1}}function $n(e){try{localStorage.setItem(pn,mn(e))}catch{}}function Yn(){return xt(_t({flushUndo:!1}))}function jr(e){!w||K||(clearTimeout(Qe),Qe=setTimeout(async()=>{Qe=null,ee&&await ce;let t=typeof e=="function"?e():e;t==null||!He()||!dn()||je()||wn()||V({flushUndo:!1})===C&&t!==Yn()&&(Vn(t)||($n(t),j(()=>{},{quietConflict:!0})))},Kn+Math.random()*Qn))}var Se=null,Ve=null,ee=0,ce=Promise.resolve(),mt=!1,vt=[];function zn(){return Ve??=import("./c-KNPDOMDY.js").catch(e=>(Ve=null,console.error("style-comparisons failed to load",e),null)),Ve}async function Xn(e){try{if(Se||(Se=(await zn())?.styleComparisonStripper??null),!Se)return;let t=Se(e);L=t(L),C=t(C),W=t(W);for(let n of Ee)n.forComparison=t(n.forComparison),n.forDirty=t(n.forDirty)}catch(t){console.error("style adoption failed",t)}finally{ee--,vt.shift()}}var ye=e=>e.replace(/&/g,"&").replace(/"/g,""");function jn(e){if(e.name!==void 0){let n=[`data-name="${ye(e.name)}"`];return e.legacyId!==void 0&&n.push(`id="${ye(e.legacyId)}"`),n}let t=[ye(e.href)];try{let{pathname:n}=new URL(e.href);n&&t.push(ye(n))}catch{}return t}function Jn(e){let t=[L,C,W];for(let n of Ee)t.push(n.forComparison,n.forDirty);return t.some(n=>n&&e.some(o=>o&&n.includes(o)))}function Zn(e,t){let n=[];for(let{markers:i,tag:a}of t)for(let f of i)for(let u=e.indexOf(f);u>=0;u=e.indexOf(f,u+f.length)){let m=e.lastIndexOf("<",u);if(m<0||e.slice(m+1,m+1+a.length).toLowerCase()!==a)continue;let c=a==="style"?e.indexOf("</style",u):u;if(c<0)continue;let p=e.indexOf(">",c);p>=0&&n.push([m,p+1])}n.sort((i,a)=>i[0]-a[0]);let o="",r=0;for(let[i,a]of n)i<r||(o+=e.slice(r,i),r=a);return o+e.slice(r)}Kt(e=>{let t=jn(e);Jn(t)&&(ee||(mt=!1),ee++,vt.push({markers:t,tag:e.name!==void 0?"style":"link"}),ce=ce.then(()=>Xn(e)))});function Jr(){return ce}function gt(e){return!ee||mt||F()||P()||D||k||te||typeof e!="string"?!1:e===Zn(C,vt)}var er=500,tr=3e3,nr=1e4,Ze=null;function rr(){pe.holdSettle=!1,Ze&&Ze()}function nn(){if(!w)return;let e=!1,t=null,{forComparison:n,forDirty:o}=me();ue(n,o);let r=ie;W=n,re("immediate capture",`${n.length} chars`);let i=["keydown","pointerdown","drop","input","change","paste"],a=new Set(["Shift","Control","Alt","Meta"]),f=c=>{c.type==="keydown"&&a.has(c.key)||(mt=!0,e||(Ke=!0))};i.forEach(c=>document.addEventListener(c,f,!0));let u=()=>{if(!e){if(e=!0,t&&t(),!Ke&&ie===r){let c=b(),{forComparison:p,forDirty:S}=me();ue(p,S),W=p,N(c),re("settled capture",`${p.length} chars`)}else re("settled skipped",Ke?"user edited":"save occurred during settle");Z=!1,document.documentElement.setAttribute("savestatus","saved"),pt=!0,document.dispatchEvent(new CustomEvent("clay:baseline-settled"))}};Ze=u;let m=()=>{pe.holdSettle||u()};t=Pt.onAnyChange({debounce:er,omitChangeDetails:!0,require:"autosave"},m),setTimeout(()=>{e||m()},tr),setTimeout(()=>{!e&&pe.holdSettle&&rr()},nr)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",nn):nn();function ke(e=()=>{}){if(!w){let t=h("Not in edit mode");return e(t),Promise.resolve(t)}if(O>0){Ce=!0;let t=h(it());return e(t),Promise.resolve(t)}if(!de()){ae=!0;let t=at("Save session is quiesced");return e(t),Promise.resolve(t)}if(B>0){$e=!0;let t=h("Autosave suspended");return e(t),Promise.resolve(t)}if(!Z&&we){k=!0;let t=h("Save already in progress");return e(t),Promise.resolve(t)}return Bn(e).catch(t=>{let n={ok:!1,msg:t?.message||"Save failed",msgType:"error",code:null,etag:null};return A("error",n.msg),n})}var et=Xt({now:G,run:()=>ke()});function vn(){document.addEventListener("keydown",function(e){if((window.navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)&&e.keyCode==83){if(!w)return;e.preventDefault(),e.isTrusted&&Ie(),I()}})}function gn(){document.addEventListener("click",e=>{e.target.closest("[trigger-save]")&&(e.isTrusted&&Ie(),I())})}function or(){w&&(Ue(),Ot(),Oe(),vn(),gn())}or();var Zr=I;var Le=!1;function ao({isCurrent:e,reload:t}){return e()?(Le=!0,setTimeout(()=>{Le=!1},1e3),t(),!0):!1}zt();function sr(){return rt()?!0:w?F()?!0:K?Tt():window.clay?.demo?!1:tt():!1}function tt(){if(!w)return!1;try{let e=V();return gt(e)?!1:e!==ft()}catch{return!0}}window.addEventListener("beforeunload",e=>{if(!w&&!rt())return;if(Le){Le=!1;return}if(!((!K||At())&&!sr())&&(e.preventDefault(),e.returnValue="",!window.clay?.demo&&!F()))try{let n=V(),o=ft();n!==o&&Yt(n,o)}catch{}});export{ao as a,sr as b,tt as c,En as d,rn as e,wn as f,de as g,rt as h,Tn as i,Ir as j,Rr as k,br as l,Nr as m,Fr as n,Ur as o,it as p,je as q,qr as r,Br as s,Hr as t,_n as u,Dn as v,Gr as w,Wr as x,Kr as y,ft as z,Qr as A,ue as B,Vr as C,I as D,j as E,$r as F,Yr as G,zr as H,Xr as I,dn as J,Yn as K,jr as L,Jr as M,gt as N,rr as O,ke as P,et as Q,vn as R,gn as S,or as T,Zr as U};
|
|
1
|
+
import{a as Gt}from"./c-4ASQPRQL.js";import{a as Dt}from"./c-GQ6F6IDK.js";import{c as F}from"./c-I2SCCUEW.js";import{b as He}from"./c-5VYOWDTI.js";import{a as Wt,d as ne,e as Be,f as b,h as N}from"./c-GSRLXYWL.js";import{a as Ge,b as Qt,c as Vt,d as $t}from"./c-X5LNHET5.js";import{a as Kt}from"./c-UGHH4MB3.js";import{a as Pt}from"./c-LA2BW7UY.js";import{a as Ot,e as Rt,f as P,g as bt,h as Nt,i as Ft,l as Ut,t as qt,v as Bt,w as Ht}from"./c-GVPNDIKJ.js";import{b as It,h as qe}from"./c-EK63G3CG.js";import{a as Fe,c as kt,g as Lt,h as Ue}from"./c-NQJRVJ56.js";import{a as Oe,f as Ie,h as Q}from"./c-IJUK2GPW.js";import{b as K,e as Ct,f as w}from"./c-3O7OBDCM.js";import{i as At,k as Tt}from"./c-N7JPUPGC.js";import{D as Ne,h as Re,q as be,t as _t,x as V,y as me}from"./c-EGTIAL6P.js";import{d as xt}from"./c-VG5XIN4T.js";import{a as pe}from"./c-2YYDMLNZ.js";import{d as St,e as yt,g as Et,h as wt}from"./c-HA6INT6J.js";import{k as Mt}from"./c-ICMAOOGK.js";var hn="clay:debug:autosave";function ve(){try{return localStorage.getItem(hn)==="true"}catch{return!1}}function ge(){return import("./c-CFHW5AMY.js").catch(e=>(console.warn("[autosave-debug] Failed to load the debug logger:",e),null))}function he(e,t){ve()&&ge().then(n=>n?.logSaveCheck(e,t))}function re(e,t=""){ve()&&ge().then(n=>n?.logBaseline(e,t))}function Yt(e,t){ve()&&ge().then(n=>n?.logUnloadDiffSync(e,t))}function zt(){ve()&&ge().then(e=>e?.preloadIfEnabled())}var U=Number.NEGATIVE_INFINITY;function Sn({firstDirtyAt:e=U,lastActivityAt:t=U,finishedAt:n=U,costMs:o=0}={}){let r=e??U,i=t??U,a=n??U,f=Math.min(3e4,Math.max(1200,4*o)),u=Math.max(i,a)+1500,m=Math.max(r+1e4,a+f);return Math.max(a+1200,Math.min(u,m))}function Xt({now:e=()=>Date.now(),setTimer:t=(r,i)=>setTimeout(r,i),clearTimer:n=r=>clearTimeout(r),run:o=()=>{}}={}){let r=null,i=null,a=U,f=0,u=null,m=null,c=!1,p=!1;function S(){return Sn({firstDirtyAt:r,lastActivityAt:i,finishedAt:a,costMs:f})}function y(){if(!c||p)return;let E=S();if(u!==null){if(m===E)return;n(u)}m=E,u=t(d,Math.max(0,E-e()))}function d(){if(u=null,m=null,!(!c||p)){if(e()<S()){y();return}g()}}function g(){c=!1,p=!0,r=null,i=null;let E;try{E=o()}catch{l();return}Promise.resolve(E).then(l,l)}function l(){p=!1,a=e(),c&&y()}function s({at:E=e()}={}){r===null&&(r=E),i=E,c=!0,y()}function v(){c=!0,y()}function M(E){E>0&&(f=Math.max(E,f*.8))}return{noteActivity:s,request:v,noteCost:M,dueAt:S,costEstimate:()=>f,pending:()=>c||p,running:()=>p}}be(e=>{for(let t of wt)e.removeAttribute(t)});be(e=>{for(let t of[...St,...yt,...Et])e.removeAttribute(t)});var x=null;function A(e,t="",n="",o=null){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus",e);let r=new CustomEvent(`clay:save-${e}`,{detail:{msg:t,msgType:n,timestamp:Date.now(),...o||{}}});document.dispatchEvent(r)}function nt(){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","offline")}function yn(){x=setTimeout(()=>{A("saving")},500)}window.addEventListener("offline",()=>{nt()});window.addEventListener("online",()=>{document.documentElement.getAttribute("savestatus")==="offline"&&I().then(e=>{e.msgType==="skipped"&&document.documentElement.getAttribute("savestatus")==="offline"&&document.documentElement.setAttribute("savestatus","saved")})});var q=!1,L="",C="",ie=0,Ee=new Set,D=!1,k=!1,we=!1,B=0,$e=!1;function En(){B++}function rn(){B!==0&&(B--,!(B>0)&&(fe&&(fe=!1,J=setTimeout(dt,0)),$e&&($e=!1,ke())))}function wn(){return B>0}var $=0,te=!1,ae=!1,Ae=!1;function de(e=null){return $===0||an(e)}function rt(){return te}function An(){if(te)return!0;try{let e=V({flushUndo:!1});return gt(e)?!1:e!==C}catch{return!0}}function Tn(){let e="idle",t=0;return{get phase(){return e},get open(){return e==="open"},changedWhileClosed(){return e==="quiesced"&&Be()!==t},start(){e==="idle"&&(e="open")},quiesce(){e==="open"&&(e="quiesced",t=Be(),$++)},resume(){e==="quiesced"&&(e="open",$--,!($>0)&&(Wn(),tn()))},stop(){if(e==="stopped")return;let n=e==="quiesced";(n||e==="open")&&An()&&(Ae=!0),e="stopped",n&&($--,$===0&&tn())}}}var jt=!1,oe=null,Ye=null,ze=!1;function Ir(e=R){if(!oe||oe.generation!==e)return null;let{bytes:t,etag:n}=oe;return{bytes:t,etag:n}}function Rr({represented:e}={}){let t=b(),{forComparison:n,forDirty:o}=me(),r=typeof e?.etag=="string"&&e.etag?e.etag:null;return!(ze&&r!==null&&r!==Ye)&&Ae&&(n!==L||o!==C)?{ok:!1,code:"pending-input"}:(Ae=!1,ue(n,o),W=n,Z=!1,pt=!0,Ye=r,ze=!0,N(t),document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:baseline-settled")),{ok:!0})}var ot=Promise.resolve(!1),Te=!1,Cn=()=>(Te=!0,Lt().catch(()=>!1).then(e=>(Te=!1,e)));function br(){return{id:"clay:save",order:10,prepare(e={}){let t=Tn();return e.initial===!0&&t.start(),{enable(){ot=Cn();let n=e.represented?.etag;typeof n=="string"&&n&&kt(n),e.initial!==!0&&(Mn(),t.start())},quiesce:()=>t.quiesce(),resume:()=>t.resume(),dispose:()=>t.stop()}}}}function Mn(){jt||(jt=!0,Wt(),Oe(),vn(),gn())}var O=0,Xe=!1,Ce=!1,st="Waiting for the AI edit to be kept or reverted",Y=new Map;function Nr(e=st){O++,Y.set(e,(Y.get(e)||0)+1)}function Fr({replay:e=!0,reason:t=st}={}){let n=Y.get(t)||0;if(n===0||(n===1?Y.delete(t):Y.set(t,n-1),O--,O>0))return;let o=Xe,r=Ce;Xe=!1,Ce=!1,e&&(o?I():r&&ke())}function Ur(){return O>0}function it(){return O===0?null:Y.keys().next().value||st}function on(e,t){if(O===0)return!1;Xe=!0,Q();let n=h(it());return e(n),t(n),n}var H=!1,se=null;function xn(e){se=e??null,!H&&(H=!0,En())}function Pn(){H&&(H=!1,se=null,rn())}function je(){return H}function qr(e){if(!H||se&&e!==se)return;H=!1,se=null,!He()&&ne()||(document.documentElement.getAttribute("savestatus")==="conflict"&&document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-conflict-resolved",{detail:{timestamp:Date.now()}}))),document.dispatchEvent(new CustomEvent("clay:save-conflict-released",{detail:{etag:e??null}})),rn()}function h(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function at(e){return(ne()||F())&&(te=!0),h(e)}function sn(){return{ok:!1,msg:"You are not allowed to save this document.",msgType:"forbidden",code:"forbidden",status:403,sent:!1,etag:null}}function ut(){return Ct()===!1}var lt=new Set,R=0;function Br(){return R}function Hr(e){typeof e=="number"&&(R=e)}function _n(e=R){let t=Object.freeze({generation:e});return lt.add(t),t}function Dn(e){lt.delete(e)}function an(e){return!!e&<.has(e)&&e.generation===R}function z(e,t){e!=null&&$t({captureId:e,ok:t.ok===!0,etag:t.etag??null})}function kn(e,t,n,o,r,i=null,a=null,f=!1){if(z(a,e),e.ok)te=!1,ue(t,n),Me=i,oe={bytes:i,etag:Fe(),generation:R},Ye=oe.etag,ze=!0,Ae=!1,q=!1,N(r),A("saved",e.msg||"Saved",e.msgType,{etag:e.etag??null,captureId:a}),re(o,`${L.length} chars`),Pn();else if(e.msgType==="conflict"){if(f){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","saved");return}xn(e.conflictEtag),A("conflict",e.msg,e.msgType,{hadTimeout:e.hadTimeout===!0,changedBy:e.changedBy??null,afterTimeout:e.afterTimeout===!0,etag:e.conflictEtag??null,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a})}else if(e.msgType!=="skipped"){let u={status:e.status??null,hadTimeout:e.hadTimeout===!0,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a};navigator.onLine?A("error",e.msg,"",u):A("offline",e.msg,"",u)}}function un(){if(!(!D&&!k)&&!Ut()){if(D){D=!1,k=!1,I();return}k=!1,et.request()}}function Gr(){return q}function Wr(e){q=e}function Kr(){return L}function ft(){return C}var Me=null;function Qr(){return Me}function ue(e,t){L=e,C=t,ie++}function Vr(e){ue(e,e)}var G=()=>typeof performance<"u"&&performance.now?performance.now():Date.now();var Ln=4,Jt="Save cancelled: the page changed while it prepared",X=null,le=null,We=null,ln=!1;function fn(){return We||(We=import("./c-3AXJDL2P.js").then(e=>(le=e,e),e=>(ln=!0,console.info("clayjs: sliced save off ("+(e&&e.message?e.message:e)+"); saves prepare in one task"),null))),We}function On(){try{return performance.getEntriesByType("navigation")[0]?.decodedBodySize||0}catch{return 0}}var In=()=>typeof Me=="string"?Me.length:On();function xe(){return ln||document.hidden||Ft()?!1:In()>=307200}function Zt(e,t,n){return n?"morph":R!==t.generation||!w?"mode":de(e.permit)?ut()?"refused":ie!==t.baselines?"newer save":Math.max(qe(),e.pageFormatFloor)>t.floor?"floor":null:"session"}function Rn(e=150,t=2e3){return new Promise(n=>{let o=G(),r=null,i=()=>{document.removeEventListener("clay:sync-applied",a),n()},a=()=>{clearTimeout(r),r=setTimeout(i,Math.max(0,Math.min(e,t-(G()-o))))};document.addEventListener("clay:sync-applied",a),a()})}async function ct({explicit:e,forced:t=!1,forSave:n,forComparison:o,forDirty:r,captureId:i,gateToken:a,costMs:f,pageFormatFloor:u=0,quietConflict:m=!1,laneHeld:c=!1,lane:p=null,capture:S,noteRecovery:y,release:d,callback:g}){if(y(),e&&!t){if(q=r!==C,he("savePage dirty check",!q),!q){Q(),N(a),d();let s=h("No changes to save");return z(i,s),typeof g=="function"&&g(s),{result:s,dispatched:!1}}}else if(!e){let s=!Z||o!==W,v=o!==L;if(he("throttled vs baseline",!s),he("throttled vs lastSave",!v),!(s&&v)){let M=!1;try{M=!v&&(!document.querySelector(Mt)||ne()&&r===C)}catch(ht){console.error("savePageThrottled: dirty domain check failed",ht)}M&&N(a),et.noteCost(f),d();let E=h("No changes to save");return z(i,E),typeof g=="function"&&g(E),{result:E,dispatched:!1}}if(q=!0,!c&&P()){D=!0,d();let M=h("Save already in progress");return z(i,M),typeof g=="function"&&g(M),{result:M,dispatched:!1}}}yn();let l={forComparison:o,forDirty:r};return Ee.add(l),we=!0,new Promise(s=>{qt(n,i,v=>{we=!1,Ee.delete(l);let M=G();kn(v,l.forComparison,l.forDirty,t?"updated after force save":"updated after save",a,n,i,m),e||et.noteCost(f+(G()-M)),typeof g=="function"&&g(v),s({result:v,dispatched:!0}),c||un()},{capture:S,pageFormatFloor:u,lane:p})})}async function bn(e,t){let n={over:!1},o=()=>{n.over=!0};document.addEventListener("clay:sync-applied",o);try{for(let i=0;i<2;i++){let a=b(),f={generation:R,baselines:ie,floor:Math.max(qe(),e.pageFormatFloor)},u=le.beginSaveCapture({requestRefresh:!0,forRequest:!0,pageFormatMarker:f.floor?{name:It,content:String(f.floor)}:null});Qt(u.captureId);let m=null,c={get aborted(){let d=Zt(e,f,n.over);return d&&(m=d),!!d}},p;try{p=await le.runPreparedSteps(u.steps(),{budgetMs:Ln,signal:c})}catch(d){console.error(`${e.explicit?"savePage":"savePageThrottled"}: preparing the save failed`,d),u.drop();let g={msg:d&&d.message?d.message:"Save failed",msgType:"error",code:d?.code??null,etag:null};return A("error",g.msg,"",{sent:!1,code:g.code}),z(u.captureId,g),typeof e.callback=="function"&&e.callback(g),{result:g,dispatched:!1}}let S=p.aborted?m:Zt(e,f,n.over);if(!S){let d=p.result;return await ct({explicit:e.explicit,forced:e.forced,forSave:d.forSave,forComparison:d.forComparison,forDirty:d.forDirty,captureId:d.captureId,gateToken:a,costMs:p.activeMs,pageFormatFloor:e.pageFormatFloor,quietConflict:e.quietConflict,laneHeld:!0,lane:t,capture:d,noteRecovery:()=>Vt(d.captureId,d.forSave),release:()=>u.drop(),callback:e.callback})}u.drop();let y=h(Jt);if(S==="session"&&(ae=!0),z(u.captureId,y),!(S==="floor"&&i===0)){if(S==="morph"&&e.explicit&&i===0){await Rn(),n.over=!1;continue}return typeof e.callback=="function"&&e.callback(y),{result:y,dispatched:!1}}}let r=h(Jt);return typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}}finally{document.removeEventListener("clay:sync-applied",o),Nt(t)}}function cn(e){let t=bt();if(!t)return!1;let n=bn(e,t).catch(o=>{console.error("save: preparing the save failed",o);let r={msg:o&&o.message?o.message:"Save failed",msgType:"error",code:o?.code??null,etag:null};return A("error",r.msg,"",{sent:!1,code:r.code}),typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}});return X=n,n.then(o=>{X===n&&(X=null),e.resolve(o.result),e.settleSoonQueued(o.result),(o.dispatched||D||k||_e.length)&&un()}),!0}function De(e,t=()=>{}){return Te?ot.then(()=>De(e,t)):ee?ce.then(()=>Pe(e,t)):Pe(e,t)}function Pe({kind:e,permit:t=null},n=()=>{}){let o=e==="explicit";return new Promise(r=>{if(!w&&!window.clay?.testMode){o&&Q();let s=h("Not in edit mode");return T().forEach(v=>v(s)),n(s),r(s)}if(!de(t)){ae=!0;let s=at("Save session is quiesced");return o&&T().forEach(v=>v(s)),n(s),r(s)}if(ut()){o&&Q();let s=sn();return A("error",s.msg,"",{code:s.code,status:s.status,sent:!1}),T().forEach(v=>v(s)),n(s),r(s)}if(o){let s=on(n,r);if(s){T().forEach(v=>v(s));return}if(P()){D=!0;let v=h("Save already in progress");return n(v),r(v)}}else{if(O>0){Ce=!0;let s=h(it());return n(s),r(s)}if(P()&&!Z&&we){k=!0;let s=h("Save already in progress");return n(s),r(s)}if(X){k=!0;let s=h("Save already in progress");return n(s),r(s)}if(!Z&&!ne()){let s=h("No changes to save");return n(s),r(s)}}let i=window.clay?.source?.ensureForSave?.();if(i)return i.then(()=>r(Pe({kind:e,permit:t},n)));if(xe()&&!le){fn().then(()=>r(Pe({kind:e,permit:t},n)));return}let a=o?T():[],f=s=>a.forEach(v=>v(s));if(!navigator.onLine&&nt(),xe()&&cn({explicit:o,forced:!1,permit:t,pageFormatFloor:0,quietConflict:!1,settleSoonQueued:f,callback:n,resolve:r}))return;let m=G(),c,p,S,y,d,g=b();try{c=Ne({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(s){console.error(`${o?"savePage":"savePageThrottled"}: captureForSaveAndComparison failed`,s),o?(Q(),A("error",s.message,"",{sent:!1,code:s.code??null})):A("error",s.message);let v={msg:s.message,msgType:"error",code:o?s.code??null:null,etag:null};typeof n=="function"&&n(v),r(v),f(v);return}let l=G()-m;ct({explicit:o,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:l,capture:c,noteRecovery:()=>Ge({captureId:d,html:p}),release:()=>Re(c),callback:n}).then(s=>{r(s.result),f(s.result)})})}function I(e=()=>{}){return De({kind:"explicit"},e)}function Nn(e,t=()=>{}){return De({kind:"explicit",permit:e},t)}function j(e=()=>{},{quietConflict:t=!1,pageFormatFloor:n=0,permit:o=null}={}){return Te?ot.then(()=>j(e,{quietConflict:t,pageFormatFloor:n,permit:o})):new Promise(r=>{if(!w&&!window.clay?.testMode){let l=h("Not in edit mode");return T().forEach(s=>s(l)),e(l),r(l)}if(!de(o)||o&&!an(o)){let l=at("Save session is quiesced");return T().forEach(s=>s(l)),e(l),r(l)}if(ut()){let l=sn();return A("error",l.msg,"",{code:l.code,status:l.status,sent:!1}),T().forEach(s=>s(l)),e(l),r(l)}let i=on(e,r);if(i){T().forEach(l=>l(i));return}if(P()){D=!0;let l=h("Save already in progress");return T().forEach(s=>s(l)),e(l),r(l)}let a=window.clay?.source?.ensureForSave?.();if(a)return a.then(()=>r(j(e,{quietConflict:t,pageFormatFloor:n,permit:o})));if(!navigator.onLine&&nt(),xe()&&!le){fn().then(()=>r(j(e,{quietConflict:t,pageFormatFloor:n,permit:o})));return}let u=T(),m=l=>u.forEach(s=>s(l));if(xe()&&cn({explicit:!0,forced:!0,permit:o,pageFormatFloor:n,quietConflict:t,settleSoonQueued:m,callback:e,resolve:r}))return;let c,p,S,y,d,g=b();try{c=Ne({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(l){console.error("savePageForce: captureForSaveAndComparison failed",l),A("error",l.message,"",{sent:!1,code:l.code??null});let s={msg:l.message,msgType:"error",code:l.code??null,etag:null};typeof e=="function"&&e(s),r(s),m(s);return}ct({explicit:!0,forced:!0,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:0,pageFormatFloor:n,quietConflict:t,capture:c,noteRecovery:()=>Ge({captureId:d,html:p}),release:()=>Re(c),callback:e}).then(l=>{r(l.result),m(l.result)})})}Ht(e=>j(()=>{},{permit:e}));function Fn(e){let t=["clay:save-saved","clay:save-error","clay:save-offline","clay:save-conflict"];return new Promise((n,o)=>{let r=null,i=()=>{clearTimeout(r);for(let u of t)document.removeEventListener(u,a)},a=()=>{i(),n()},f=e-Date.now();if(f<=0){o(Object.assign(new Error("Save timed out."),{state:"failed"}));return}r=setTimeout(()=>{i(),o(Object.assign(new Error("Save timed out."),{state:"failed"}))},f);for(let u of t)document.addEventListener(u,a)})}function _(e,t){return Object.assign(new Error(e),{state:t})}function Un(e,t){return new Promise((n,o)=>{let r=t-Date.now();if(r<=0)return o(_("Save timed out.","failed"));let i=setTimeout(()=>{document.removeEventListener(e,a),o(_("Save timed out.","failed"))},r),a=()=>{clearTimeout(i),n()};document.addEventListener(e,a,{once:!0})})}async function $r({keepalive:e=!1,timeoutMs:t=15e3,permit:n=null}={}){if(!w)return{state:"view",etag:null};let o=Date.now()+t,r=n||_n(),i={over:!1},a=null,f=new Promise((u,m)=>{a=setTimeout(()=>m(_("Save timed out.","failed")),Math.max(0,t))});try{return await Promise.race([qn(e,o,r,i),f])}catch(u){throw u&&typeof u.state=="string"?u:_(u?.message||"Save failed","failed")}finally{i.over=!0,clearTimeout(a),n||Dn(r)}}async function qn(e,t,n,o={over:!1}){if(dn()||await Un("clay:baseline-settled",t),o.over)return null;let r=!1,i=null;for(let a=0;a<4;a++){if(X&&(await X,o.over)||P()&&(await Fn(t),o.over))return null;if(je())throw _("This document has a conflict to resolve.","conflict");let f=b();if(!tt()){if(N(f),F())throw _("This document has unsaved work a save cannot write.","blocked");return te=!1,{state:r?"saved":"clean",etag:i??Fe()}}if(o.over)return null;let u=await Rt(e,()=>Nn(n));if(u.msgType!=="skipped"){if(!u.ok)throw _(u.msg||"Save failed",u.msgType==="conflict"||je()?"conflict":"failed");r=!0,i=u.etag??null}}throw _("The document kept changing while saving.","failed")}async function Yr(e=()=>{}){return await Ue({fresh:!0}),j(e)}function zr(e){!w||K||Bt(e,t=>{t.ok?window.location.reload():t.msgType==="skipped"?A("error",t.msg||"Template not saved"):A("error",t.msg||"Failed to save template")})}var Bn=Dt(e=>De({kind:"automatic"},e),1200),Hn=250,Gn=1e3,J=null,en=0,Je=[],_e=[],fe=!1,T=()=>{let e=_e;return _e=[],e};function dt(){if(J=null,B>0||!de()){fe=!0;return}let e=Je;if(Je=[],P()){_e.push(...e),I();return}I().then(t=>e.forEach(n=>n(t)))}function Xr(){let e=Date.now();return J===null?en=e:clearTimeout(J),new Promise(t=>{Je.push(t),J=setTimeout(dt,Math.max(0,Math.min(Hn,en+Gn-e)))})}function Wn(){ae&&(ae=!1,ke())}function tn(){fe&&(fe=!1,J=setTimeout(dt,0))}var W="",Z=!0,pt=!1;function dn(){return pt}var Ke=!1,Kn=250,Qn=1250,Qe=null,pn="clay:paint-heal:"+location.pathname;function mn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return String(t>>>0)}function Vn(e){try{return localStorage.getItem(pn)===mn(e)}catch{return!1}}function $n(e){try{localStorage.setItem(pn,mn(e))}catch{}}function Yn(){return xt(_t({flushUndo:!1}))}function jr(e){!w||K||(clearTimeout(Qe),Qe=setTimeout(async()=>{Qe=null,ee&&await ce;let t=typeof e=="function"?e():e;t==null||!He()||!dn()||je()||wn()||V({flushUndo:!1})===C&&t!==Yn()&&(Vn(t)||($n(t),j(()=>{},{quietConflict:!0})))},Kn+Math.random()*Qn))}var Se=null,Ve=null,ee=0,ce=Promise.resolve(),mt=!1,vt=[];function zn(){return Ve??=import("./c-KNPDOMDY.js").catch(e=>(Ve=null,console.error("style-comparisons failed to load",e),null)),Ve}async function Xn(e){try{if(Se||(Se=(await zn())?.styleComparisonStripper??null),!Se)return;let t=Se(e);L=t(L),C=t(C),W=t(W);for(let n of Ee)n.forComparison=t(n.forComparison),n.forDirty=t(n.forDirty)}catch(t){console.error("style adoption failed",t)}finally{ee--,vt.shift()}}var ye=e=>e.replace(/&/g,"&").replace(/"/g,""");function jn(e){if(e.name!==void 0){let n=[`data-name="${ye(e.name)}"`];return e.legacyId!==void 0&&n.push(`id="${ye(e.legacyId)}"`),n}let t=[ye(e.href)];try{let{pathname:n}=new URL(e.href);n&&t.push(ye(n))}catch{}return t}function Jn(e){let t=[L,C,W];for(let n of Ee)t.push(n.forComparison,n.forDirty);return t.some(n=>n&&e.some(o=>o&&n.includes(o)))}function Zn(e,t){let n=[];for(let{markers:i,tag:a}of t)for(let f of i)for(let u=e.indexOf(f);u>=0;u=e.indexOf(f,u+f.length)){let m=e.lastIndexOf("<",u);if(m<0||e.slice(m+1,m+1+a.length).toLowerCase()!==a)continue;let c=a==="style"?e.indexOf("</style",u):u;if(c<0)continue;let p=e.indexOf(">",c);p>=0&&n.push([m,p+1])}n.sort((i,a)=>i[0]-a[0]);let o="",r=0;for(let[i,a]of n)i<r||(o+=e.slice(r,i),r=a);return o+e.slice(r)}Kt(e=>{let t=jn(e);Jn(t)&&(ee||(mt=!1),ee++,vt.push({markers:t,tag:e.name!==void 0?"style":"link"}),ce=ce.then(()=>Xn(e)))});function Jr(){return ce}function gt(e){return!ee||mt||F()||P()||D||k||te||typeof e!="string"?!1:e===Zn(C,vt)}var er=500,tr=3e3,nr=1e4,Ze=null;function rr(){pe.holdSettle=!1,Ze&&Ze()}function nn(){if(!w)return;let e=!1,t=null,{forComparison:n,forDirty:o}=me();ue(n,o);let r=ie;W=n,re("immediate capture",`${n.length} chars`);let i=["keydown","pointerdown","drop","input","change","paste"],a=new Set(["Shift","Control","Alt","Meta"]),f=c=>{c.type==="keydown"&&a.has(c.key)||(mt=!0,e||(Ke=!0))};i.forEach(c=>document.addEventListener(c,f,!0));let u=()=>{if(!e){if(e=!0,t&&t(),!Ke&&ie===r){let c=b(),{forComparison:p,forDirty:S}=me();ue(p,S),W=p,N(c),re("settled capture",`${p.length} chars`)}else re("settled skipped",Ke?"user edited":"save occurred during settle");Z=!1,document.documentElement.setAttribute("savestatus","saved"),pt=!0,document.dispatchEvent(new CustomEvent("clay:baseline-settled"))}};Ze=u;let m=()=>{pe.holdSettle||u()};t=Pt.onAnyChange({debounce:er,omitChangeDetails:!0,require:"autosave"},m),setTimeout(()=>{e||m()},tr),setTimeout(()=>{!e&&pe.holdSettle&&rr()},nr)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",nn):nn();function ke(e=()=>{}){if(!w){let t=h("Not in edit mode");return e(t),Promise.resolve(t)}if(O>0){Ce=!0;let t=h(it());return e(t),Promise.resolve(t)}if(!de()){ae=!0;let t=at("Save session is quiesced");return e(t),Promise.resolve(t)}if(B>0){$e=!0;let t=h("Autosave suspended");return e(t),Promise.resolve(t)}if(!Z&&we){k=!0;let t=h("Save already in progress");return e(t),Promise.resolve(t)}return Bn(e).catch(t=>{let n={ok:!1,msg:t?.message||"Save failed",msgType:"error",code:null,etag:null};return A("error",n.msg),n})}var et=Xt({now:G,run:()=>ke()});function vn(){document.addEventListener("keydown",function(e){if((window.navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)&&e.keyCode==83){if(!w)return;e.preventDefault(),e.isTrusted&&Ie(),I()}})}function gn(){document.addEventListener("click",e=>{e.target.closest("[trigger-save]")&&(e.isTrusted&&Ie(),I())})}function or(){w&&(Ue(),Ot(),Oe(),vn(),gn())}or();var Zr=I;var Le=!1;function ao({isCurrent:e,reload:t}){return e()?(Le=!0,setTimeout(()=>{Le=!1},1e3),t(),!0):!1}zt();function sr(){return rt()?!0:w?F()?!0:K?Tt():window.clay?.demo?!1:tt():!1}function tt(){if(!w)return!1;try{let e=V();return gt(e)?!1:e!==ft()}catch{return!0}}window.addEventListener("beforeunload",e=>{if(!w&&!rt())return;if(Le){Le=!1;return}if(!((!K||At())&&!sr())&&(e.preventDefault(),e.returnValue="",!window.clay?.demo&&!F()))try{let n=V(),o=ft();n!==o&&Yt(n,o)}catch{}});export{ao as a,sr as b,tt as c,En as d,rn as e,wn as f,de as g,rt as h,Tn as i,Ir as j,Rr as k,br as l,Nr as m,Fr as n,Ur as o,it as p,je as q,qr as r,Br as s,Hr as t,_n as u,Dn as v,Gr as w,Wr as x,Kr as y,ft as z,Qr as A,ue as B,Vr as C,I as D,j as E,$r as F,Yr as G,zr as H,Xr as I,dn as J,Yn as K,jr as L,Jr as M,gt as N,rr as O,ke as P,et as Q,vn as R,gn as S,or as T,Zr as U};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as u}from"./c-VJYEVRYK.js";import{B as M}from"./c-
|
|
1
|
+
import{a as u}from"./c-VJYEVRYK.js";import{B as M}from"./c-44B5ODN7.js";import{b,d as x,m as v}from"./c-QIXT3Q7C.js";import"./c-VHNSBD2M.js";var{Plugin:R}=b,{Decoration:D}=x;var O=[["","Plain text"],["javascript","JavaScript"],["typescript","TypeScript"],["jsx","JSX"],["tsx","TSX"],["json","JSON"],["html","HTML"],["css","CSS"],["python","Python"],["shellscript","Shell"],["sql","SQL"],["go","Go"],["rust","Rust"],["java","Java"],["c","C"],["cpp","C++"],["csharp","C#"],["ruby","Ruby"],["php","PHP"],["yaml","YAML"],["markdown","Markdown"],["diff","Diff"],["swift","Swift"],["kotlin","Kotlin"],["xml","XML"]],L=new Set(O.map(([s])=>s)),T={js:"javascript",mjs:"javascript",ts:"typescript",py:"python",sh:"shellscript",bash:"shellscript",shell:"shellscript",zsh:"shellscript",rb:"ruby",yml:"yaml",md:"markdown",htm:"html",golang:"go",rs:"rust","c++":"cpp",cs:"csharp","c#":"csharp",kt:"kotlin"},m=s=>{let t=String(s??"").trim().toLowerCase(),e=T[t]??t;return L.has(e)?e:""},n=s=>({color:s}),C={name:"page",appearance:"light",cssVariables:{prefix:"--page-code-token-"},style:{syntax:{comment:n("comment"),keyword:n("keyword"),operator:n("keyword"),preproc:n("keyword"),"punctuation.special":n("keyword"),string:n("string-expression"),"string.escape":n("constant"),"string.regex":n("constant"),"string.special":n("constant"),number:n("constant"),boolean:n("constant"),constant:n("constant"),type:n("constant"),property:n("constant"),enum:n("constant"),variant:n("constant"),namespace:n("constant"),label:n("constant"),function:n("function"),constructor:n("function"),selector:n("function"),attribute:n("function"),"variable.parameter":n("parameter"),tag:n("string-expression"),link_uri:n("link"),link_text:n("link"),"diff.plus":n("string-expression"),"diff.minus":n("keyword"),title:{font_weight:700},emphasis:{font_style:"italic"},"emphasis.strong":{font_weight:700}}}},E=null;async function P(s,t){E??=import("./c-3OWDMNJR.js");let{codeToTokens:e}=await E;return e(s,{lang:t,theme:C}).tokens}var _="var(--page-code-token-foreground)",A=s=>{let t=[];return s.color&&s.color!==_&&t.push(`color: ${s.color}`),s.fontStyle&1&&t.push("font-style: italic"),s.fontStyle&2&&t.push("font-weight: 600"),s.fontStyle&4&&t.push("text-decoration: underline"),t.join("; ")},H=200,y=class{constructor(t,e,i){this.view=t,this.run=e,this.delay=i,this.cache=new Map,this.pending=new Set,this.visible=new Set,this.targets=new Map,this.timer=0;let c=t.dom.ownerDocument.defaultView.IntersectionObserver;this.io=c?new c(a=>{for(let o of a){let r=o.target.dataset.id;this.targets.get(r)===o.target&&this.visible[o.isIntersecting?"add":"delete"](r)}this.schedule(0)},{rootMargin:"200px 0px"}):null,this.schedule(0)}update(t,e){(!e||t.state.doc!==e.doc)&&this.schedule(this.delay)}schedule(t){clearTimeout(this.timer),this.timer=setTimeout(()=>this.pass(),t)}pass(){let{view:t}=this;if(t.isDestroyed)return;let e=[],i=new Map,c=u.getState(t.state);t.state.doc.forEach((o,r)=>{if(o.type!==v.nodes.code_block)return;let p=o.attrs.id,d=t.nodeDOM(r);d&&i.set(p,d);let g=m(o.attrs.lang);if(!g)return;let k=o.textContent,l=`${g}
|
|
2
2
|
${k}`,w=this.cache.get(l);if(w)for(let h of w){let S=A(h);S&&h.content&&e.push(D.inline(r+1+h.offset,r+1+h.offset+h.content.length,{style:S}))}else{if(e.push(...c.find(r,r+o.nodeSize)),this.io&&!this.visible.has(p)||this.pending.has(l))return;this.pending.add(l),this.run(k,g).then(h=>h.flat(),()=>[]).then(h=>{this.pending.delete(l),this.cache.set(l,h),this.cache.size>H&&this.cache.delete(this.cache.keys().next().value),this.schedule(0)})}}),this.track(i);let a=o=>o.map(r=>`${r.from}:${r.to}:${r.type.attrs.style}`).join("|");a(e)!==a(u.getState(t.state).find())&&t.dispatch(t.state.tr.setMeta(u,e).setMeta("addToHistory",!1))}track(t){if(this.io){for(let[e,i]of this.targets)t.get(e)!==i&&(this.io.unobserve(i),this.targets.delete(e),this.visible.delete(e));for(let[e,i]of t)this.targets.get(e)!==i&&(this.targets.set(e,i),this.io.observe(i))}}destroy(){clearTimeout(this.timer),this.io?.disconnect()}};function j(s,{tokenize:t=P,delay:e=300}={}){let i=new y(s,t,e),c=s.dispatch.bind(s),a=s.state.doc,o=p=>{if(c(p),s.state.doc===a)return;let d={doc:a};a=s.state.doc,i.update(s,d)};s.dispatch=o;let r=i.destroy.bind(i);return i.destroy=()=>{s.dispatch===o&&(s.dispatch=c),r()},i}var f=class{constructor(t,e,i){this.node=t,this.view=e,this.getPos=i;let c=e.dom.ownerDocument;this.dom=c.createElement("pre"),this.contentDOM=c.createElement("code"),this.select=c.createElement("select"),this.select.className="page-code-lang",this.select.contentEditable="false",this.select.setAttribute("aria-label","Code language");for(let[a,o]of O)this.select.append(new Option(o,a));this.select.addEventListener("change",()=>this.setLang(this.select.value)),this.dom.append(this.select,this.contentDOM),this.render(t)}render(t){this.node=t,this.dom.dataset.id=t.attrs.id??"";let e=m(t.attrs.lang);e?this.dom.dataset.lang=e:delete this.dom.dataset.lang,this.select.value=e}setLang(t){let e=this.getPos();e==null||t===m(this.node.attrs.lang)||(this.view.dispatch(M(this.view.state.tr.setNodeMarkup(e,null,{...this.node.attrs,lang:t}))),this.view.focus())}update(t){return t.type!==this.node.type?!1:(this.render(t),!0)}stopEvent(t){return this.select.contains(t.target)}ignoreMutation(t){return t.type!=="selection"&&this.select.contains(t.target)}};function X({view:s=null,highlight:t={}}={}){let e=s?j(s,t):null;return{id:"code",nodeViews:{code_block:(i,c,a)=>new f(i,c,a)},css:null,dispose(){e?.destroy()}}}export{X as createFeature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./c-CSNE5EIF.js";import"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import{g as m,l as v,n as x,q as s}from"./c-BJ7YQ5QZ.js";import{a as p}from"./c-4JZDZFF6.js";import{e as f}from"./c-VAK7SG37.js";import{b as w}from"./c-MHI3GYKF.js";import"./c-RHMPKZZ7.js";import{b as c}from"./c-NUHP2XDB.js";import{f as l}from"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var $="Download a copy, then reduce its size; saving still works.",b="Download a copy to keep your work.",t=null,r=null,i=null,a=null;function h(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"an unknown size":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.max(1,Math.round(e/1024))} KB`:`${e} bytes`}function y({bytes:e,maxBytes:n,state:S}){let u=`At the last save attempt: ${h(e)} of ${h(n)}.`;return S==="over"?`This host can't save a file this size. ${u} ${b}`:`This file is getting large. ${u} ${$}`}function o(){if(!t)return;let e=window.visualViewport,n=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;c(t,"bottom",`calc(${16+n}px + env(safe-area-inset-bottom,0px))`)}async function z(){await d({})}function A(){t=v("div",["position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483000","display:flex","align-items:center","gap:10px 12px","width:max-content","max-width:calc(100vw - 24px)","flex-wrap:wrap","padding:8px 8px 8px 14px","text-align:left",`color-scheme:${p()}`]),t.setAttribute("clay","editor-ui"),t.setAttribute("data-clay-save-size",""),t.setAttribute("role","status"),r=x("span",[],""),i=m("Download my copy",{small:!0,onClick:z}),s(i,!1,"inline-flex"),t.append(r,i),document.body.appendChild(t),o(),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o)}function M(e){t||A(),r.textContent=y(e),s(i,e.state==="over","inline-flex"),o(),w(t,{background:f.surface})}function E(){t&&(window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o),t.remove(),t=null,r=null,i=null)}function g(e){let n=e?.detail;n&&(n.state==="near"||n.state==="over"?M(n):E())}function k(){l||L()}function N(e){l&&(a||=new AbortController,document.addEventListener("clay:save-size",g,{signal:a.signal}),document.addEventListener("clay:modechange",k,{signal:a.signal}),e?.type==="clay:save-size"&&g(e))}function L(){a?.abort(),a=null,E()}export{N as start,L as stop};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{g as p}from"./c-
|
|
1
|
+
import{g as p}from"./c-ICMAOOGK.js";var h=`:host { all: initial !important; display: contents !important; }
|
|
2
2
|
:host([hidden]) { display: none !important; }
|
|
3
3
|
@media print { :host { display: none !important; } }`,l=new WeakMap,u=new WeakSet,m=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function S(e){if(e.ctrlKey||e.metaKey||e.altKey||e.key?.length!==1&&!m.has(e.key))return;let t=e.composedPath()[0];!t?.matches?.("input, textarea, select")&&!t?.isContentEditable||t.getRootNode().host?.localName==="clay-editor-ui"&&e.stopPropagation()}function w(e){if(!(!e||u.has(e))){u.add(e);for(let t of["keydown","keypress","keyup"])e.addEventListener(t,S,!0)}}function g(e,t){return"adoptedStyleSheets"in t&&typeof e.defaultView?.CSSStyleSheet?.prototype?.replaceSync=="function"}function k(e,t){let r=l.get(e);r||l.set(e,r=new Map);let o=r.get(t);return o||(o=new e.defaultView.CSSStyleSheet,o.replaceSync(t),r.set(t,o)),o}function A({name:e,content:t,css:r=[],parent:o=document.body,before:y=null,attributes:f={}}){let a=o.ownerDocument,n=a.createElement("clay-editor-ui");n.setAttribute("data-clay-ui",e),p(n,"editor-ui");for(let[i,d]of Object.entries(f))n.setAttribute(i,d);p(t,"editor-ui");let s=n.attachShadow({mode:"open"}),c=[h,...r];if(g(a,s))s.adoptedStyleSheets=c.map(i=>k(a,i));else for(let i of c){let d=a.createElement("style");d.textContent=i,s.append(d)}return s.append(t),w(a.defaultView),o.insertBefore(n,y),{host:n,shadow:s,content:t,remove:()=>n.remove()}}export{h as a,A as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as L}from"./c-
|
|
1
|
+
import{b as L}from"./c-QY7F6EN6.js";import{f as b,g as h,j as p,l as E,n as m}from"./c-BJ7YQ5QZ.js";import{e as i,f as d,g as x}from"./c-VAK7SG37.js";import{b as w}from"./c-MHI3GYKF.js";import{b as o}from"./c-NUHP2XDB.js";var g={success:{edge:i.teal,icon:d.toastSuccess},error:{edge:i.ox,icon:d.toastWarning},warning:{edge:i.brass,icon:d.toastWarning},info:{edge:i.brass,icon:d.toastInfo}},M=d.toastClose,P=["opacity:0","transform:translateX(24px)"];function $(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches?"none":"opacity .5s ease-in-out, transform .5s ease-in-out"}function A(){let e=document.querySelector('clay-editor-ui[data-clay-ui="toasts"]')?.shadowRoot.querySelector("[data-clay-toasts]");if(e)return e;let t=p("div",["position:fixed","top:18px","right:18px","z-index:9999","display:flex","flex-direction:column","align-items:flex-end","gap:10px","width:min(330px, calc(100vw - 36px))","pointer-events:none"]);return t.setAttribute("data-clay-toasts",""),t.setAttribute("aria-live","polite"),L({name:"toasts",content:t}),t}function k(e,t,{detail:n="",actions:r=[]}={}){let c=g[t],s=E("div",["display:flex","align-items:flex-start",...x.toast,"width:100%",`border-inline-start:3px solid ${c.edge}`,"cursor:pointer","pointer-events:auto",...P,`transition:${$()}`]);s.setAttribute("data-clay-toast",t);let l=p("div",["flex:1 1 auto","min-width:0","display:flex","flex-direction:column","gap:8px"]),f=p("div",["display:flex","align-items:flex-start","gap:8px"]),v=m("span",["display:inline-grid","flex:none","padding-top:1px",`color:${c.edge}`]);v.innerHTML=c.icon,b(v.firstElementChild,16);let T=m("span",["flex:1 1 auto","min-width:120px",...x.toastTitle,"overflow-wrap:anywhere"],e);if(f.append(v,T),l.append(f),n&&l.append(m("span",["display:block",`color:${i.muted}`,"overflow-wrap:anywhere"],n)),r.length){let y=p("div",["display:flex","flex-wrap:wrap","gap:8px"]);for(let{label:C,onClick:I}of r)y.append(h(C,{small:!0,variant:"quiet",onClick:I}));l.append(y)}return s.append(l),s}function D(e){let t=p("button",["flex:none","display:inline-grid","place-items:center",...x.toastClose,"cursor:pointer"]);t.type="button",t.setAttribute("aria-label","Dismiss"),t.title="Dismiss",t.innerHTML=M,b(t.firstElementChild,14);let n=r=>{o(t,"color",r?i.ink:i.muted),o(t,"background",r?i.sunk:"transparent")};return t.addEventListener("pointerenter",()=>n(!0)),t.addEventListener("pointerleave",()=>n(!1)),t.addEventListener("focus",()=>{n(!0),o(t,"outline",`2px solid ${i.brass}`),o(t,"outline-offset","1px")}),t.addEventListener("blur",()=>{n(!1),o(t,"outline","none")}),t.addEventListener("click",e),t}function S(e){A().append(e),w(e,{background:i.surface}),setTimeout(()=>{o(e,"opacity","1"),o(e,"transform","none")},10)}function u(e,t){o(e,"opacity","0"),o(e,"transform","translateX(24px)"),setTimeout(()=>{e.remove(),t?.()},500)}function H(e,t="success"){let n=k(e,g[t]?t:"success");n.addEventListener("click",()=>u(n)),S(n),setTimeout(()=>u(n),6600)}var a=new Map;function R(e,t="warning",{detail:n="",actions:r=[]}={}){let c=a.get(e);c&&(u(c),a.delete(e));let s=k(e,g[t]?t:"warning",{detail:n,actions:r});o(s,"cursor","default");let l=D(f=>{f.stopPropagation(),u(s,()=>{a.get(e)===s&&a.delete(e)})});s.append(l),a.set(e,s),S(s)}function U(e,{now:t=!1}={}){let n=a.get(e);if(n){if(a.delete(e),t){n.remove();return}u(n)}}var W=H;export{R as a,U as b,W as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=["text/html","application/xhtml+xml"];function i(t){return typeof t!="string"?!1:c.includes(t.split(";")[0].trim().toLowerCase())}function s(t=location.pathname){let o=t.split("/").filter(Boolean).pop();if(!o)return t.endsWith("/")||t===""?"index":"page";let n=o;try{n=decodeURIComponent(o)}catch{}return n.replace(/\.(html?|htmlclay)$/i,"")||"page"}async function d({html:t,name:o,type:n="text/html"}){let r=null;try{let l=t;if(i(n)&&typeof t=="string"&&/clay|data-paid-only/i.test(t)){let{stripCopyContent:a}=await import("./c-C4IIQZGJ.js");l=a(t)}r=URL.createObjectURL(new Blob([l],{type:n}));let e=document.createElement("a");return e.setAttribute("clay","no-save no-watch no-snapshot"),e.href=r,e.download=o,e.style.setProperty("display","none","important"),document.body.appendChild(e),e.click(),e.remove(),setTimeout(()=>URL.revokeObjectURL(r),4e4),!0}catch(l){return console.error("clayjs: could not build the download",l),r&&URL.revokeObjectURL(r),!1}}export{s as a,d as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O}from"./c-
|
|
1
|
+
import{a as O}from"./c-WN3MXOLT.js";import{d as A}from"./c-XGH4GS2T.js";var p=1,D=8*1024,B=256,L=1024,Y=128,X=128,G=Object.freeze(["title","description","labels","members","dates","checklist","comment","attachments"]),m=250,E=5e3,ie=15e3;var W=new Set(["kind","id","field"]),$=new Set(["kind","v","epoch","generation","selection"]),q=new Set(["kind","anchor","head"]),F=new Set(["kind","ids"]),J=new Set(["kind","block","row","col"]),V=new Set(["block","rel"]),H=/^[\x20-\x7e]+$/,U=/^[A-Za-z0-9+/]+={0,2}$/,Z=/[\u0000-\u001f\u007f]/,o=e=>({ok:!1,reason:e}),a=e=>({ok:!0,target:e}),g=e=>!!e&&typeof e=="object"&&!Array.isArray(e),d=(e,t)=>{for(let n of Object.keys(e))if(!t.has(n))return!1;return!0};function T(e){let t=0;for(let n of e){let s=n.codePointAt(0);t+=s<128?1:s<2048?2:s<65536?3:4}return t}function u(e){return typeof e=="string"&&e.length>0&&!Z.test(e)&&T(e)<=B}function Q(e){if(typeof e!="string"||!e.length||e.length%4!==0||!U.test(e))return!1;let t=e.endsWith("==")?2:e.endsWith("=")?1:0;return e.length/4*3-t<=L}function _(e){return!g(e)||!d(e,V)||!u(e.block)||!Q(e.rel)?null:{block:e.block,rel:e.rel}}function v(e){if(!g(e))return null;if(e.kind==="text"){if(!d(e,q))return null;let t=_(e.anchor),n=_(e.head);return t&&n?{kind:"text",anchor:t,head:n}:null}if(e.kind==="blocks"){if(!d(e,F)||!Array.isArray(e.ids)||!e.ids.length||e.ids.length>X)return null;for(let t of e.ids)if(!u(t))return null;return{kind:"blocks",ids:[...e.ids]}}return e.kind==="cell"?!d(e,J)||!u(e.block)||!u(e.row)||!u(e.col)?null:{kind:"cell",block:e.block,row:e.row,col:e.col}:null}function w(e){return T(JSON.stringify(e))<=D}function ee(e){if(!d(e,W))return o("key");let t=e.id;if(typeof t!="string"||!t.length||t.length>Y||!H.test(t))return o("id");if(e.field===void 0){let s={kind:"record",id:t};return w(s)?a(s):o("size")}if(typeof e.field!="string"||!G.includes(e.field))return o("field");let n={kind:"record",id:t,field:e.field};return w(n)?a(n):o("size")}function te(e){if(!d(e,$))return o("key");if(e.v!==p)return o("version");if(!u(e.epoch))return o("epoch");if(!Number.isSafeInteger(e.generation)||e.generation<0)return o("generation");let t=v(e.selection);if(!t)return o("selection");let n={kind:"page",v:p,epoch:e.epoch,generation:e.generation,selection:t};return w(n)?a(n):o("size")}function y(e){return e===null?a(null):typeof e=="string"?O.test(e)?a(e):o("path"):g(e)?e.kind==="record"?ee(e):e.kind==="page"?te(e):o("kind"):o("shape")}function R(e){let t=y(e===void 0?null:e);return!t.ok||t.target!==null&&typeof t.target=="object"&&t.target.kind!=="record"?null:t.target}function z(e){return e==null?"":typeof e=="string"?`path:${e}`:`target:${JSON.stringify(e)}`}function C(e,t=null){let n=Array.isArray(e)?e:[],s=[];for(let i of n){if(!g(i))continue;let r=u(i.id)?i.id:null;if(!r)continue;let h=Number.isSafeInteger(i.n)&&i.n>=0?i.n:0,c=t&&t.get(r);if(c&&h<c.n){s.push(c);continue}let f=y(i.editing===void 0?null:i.editing);s.push({id:r,you:i.you===!0,n:h,editing:f.ok?f.target:null})}return s}function I(e){if(!g(e))return null;let t=u(e.id)?e.id:null,n=typeof e.token=="string"&&e.token.length?e.token:null;return t&&n?{id:t,token:n}:null}function N({target:e=null,session:t=null,n=0}){if(e==null||typeof e=="string")return{editing:e??null};let s=t&&typeof t.token=="string"&&t.token.length?t.token:null;return s?!Number.isSafeInteger(n)||n<0?null:{v:p,session:s,n,editing:e}:e.kind==="record"?{editing:e}:null}var ne=()=>Object.freeze({supported:!1,recordAwareness:!1,pageAwareness:!1,people:Object.freeze([]),anonymous:0}),S=class{constructor(){this.supported=!1,this.recordAwareness=!1,this.pageAwareness=!1,this.people=[],this.anonymous=0,this.snapshot=ne(),this.listeners=new Set,this.sessions=new Map,this.session=null,this.target=null,this.heldKey="",this.owner=null,this.explicit=!1,this.connecting=null,this.n=0,this.sentKey=null,this.timer=null,this.timerKind=null,this.inflight=!1,this.inflightOwner=null,this.inflightKey=null}getSnapshot(){return this.snapshot}subscribe(t){if(typeof t!="function")throw new TypeError("clay.presence.subscribe needs a listener function");return this.listeners.add(t),t(this.snapshot),()=>{this.listeners.delete(t)}}setCapabilities({supported:t=!1,recordAwareness:n=!1,pageAwareness:s=!1}={}){let i=t===!0,r=n===!0,h=s===!0;return i===this.supported&&r===this.recordAwareness&&h===this.pageAwareness?this.snapshot:(this.supported=i,this.recordAwareness=r,this.pageAwareness=h,this.emit())}receive(t){let n=t&&typeof t=="object"?t:{},s=Array.isArray(n.people)?n.people:[],i=this.sessions,r=new Map,h=[];for(let l of s){if(!l||typeof l.id!="string"||!l.id)continue;let P=typeof l.name=="string"&&l.name.trim()?l.name.trim():"Someone",x=C(l.sessions,i);for(let K of x)r.set(K.id,K);let b={id:l.id,name:P,you:l.you===!0,editing:R(l.editing),sessions:x};typeof l.canEdit=="boolean"&&(b.canEdit=l.canEdit),h.push(b)}this.people=h,this.sessions=r;let c=n.anonymous;this.anonymous=typeof c=="number"&&Number.isFinite(c)&&c>0?Math.floor(c):0;let f=I(n.selfSession),M=!this.session||!this.session.token;f&&(this.session=f);let j=this.emit();return f&&M&&this.owner&&this.target!==null&&(this.sentKey=null,this.flush()),j}clear(){return this.people=[],this.anonymous=0,this.sessions=new Map,this.session=null,this.cancel(),this.sentKey=null,this.emit()}setTarget(t){let n=y(t===void 0?null:t);return n.ok?(this.explicit=!0,this.hold(n.target)):!1}setGeneric(t){if(this.explicit)return!1;let n=y(t===void 0?null:t);return n.ok?this.hold(n.target):!1}releaseTarget(){return this.explicit?(this.explicit=!1,this.hold(null)):!1}hold(t){let n=z(t);return n===this.heldKey?(this.owner&&this.sentKey!==n&&this.schedule(m),!0):(this.target=t,this.heldKey=n,t===null?(this.cancel(),this.flush(),!0):(this.schedule(m),!0))}attachTransport(t){if(!t||typeof t.send!="function")throw new TypeError("clay.presence.attachTransport needs a transport with a send function");let n=this,s={send:t.send,get active(){return n.owner===s},detach(){if(n.owner!==s)return;let i=n.heldKey===""&&typeof n.inflightKey=="string"&&n.inflightKey!=="";if(n.owner=null,n.session=null,n.n=0,n.sentKey=null,n.inflight=!1,n.inflightOwner=null,n.inflightKey=null,n.cancel(),n.target=null,n.heldKey="",n.explicit=!1,n.clear(),i)try{Promise.resolve(s.send({editing:null})).catch(()=>{})}catch{}}};return this.owner=s,this.session=null,this.n=0,this.sentKey=null,this.inflight=!1,this.inflightOwner=null,this.inflightKey=null,this.cancel(),this.target!==null&&this.flush(),s}connect({send:t=null}={}){return this.connecting?this.connecting:(this.connecting=A().then(n=>{let s=Array.isArray(n?.extensions)?n.extensions:[],i=n?.document&&typeof n.document=="object"?n.document.awareness:null;if(i&&i.transport==="broadcast"&&(s.includes("page-awareness-v1")||s.includes("record-awareness-v1"))){let r=typeof i.scope=="string"&&i.scope?i.scope:null;return import("./c-62HZW5DH.js").then(({localPresence:h})=>{let c=h({scope:r,store:this}),f=c.start();return f?Object.defineProperty(f,"stop",{value:()=>c.stop()}):null})}return typeof t=="function"&&s.includes("presence-editing")?this.attachTransport({send:t}):null}).finally(()=>{this.connecting=null}),this.connecting)}reconnect(){this.session=null,this.n=0,this.sentKey=null,this.cancel(),!(!this.owner||this.target===null)&&this.flush()}emit(){let t=this.people.map(n=>Object.freeze({...n,sessions:Object.freeze(n.sessions)}));this.snapshot=Object.freeze({supported:this.supported,recordAwareness:this.recordAwareness,pageAwareness:this.pageAwareness,people:Object.freeze(t),anonymous:this.anonymous});for(let n of[...this.listeners])n(this.snapshot);return this.snapshot}schedule(t,n="coalesce"){if(this.timer!==null){if(this.timerKind==="coalesce")return;clearTimeout(this.timer)}this.timerKind=n,this.timer=setTimeout(()=>{this.timer=null,this.timerKind=null,this.flush()},t)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null,this.timerKind=null)}renew(){this.timer!==null||!this.owner||this.target===null||this.schedule(E,"renew")}flush(){if(this.inflight)return;let t=this.owner;if(!t)return;let n=this.n+1,s=N({target:this.target,session:this.session,n});if(!s)return;this.cancel(),this.sentKey=this.heldKey,this.inflight=!0,this.inflightOwner=t,this.inflightKey=this.sentKey,s.v===p&&(this.n=n);let i=r=>{if(this.inflightOwner===t&&(this.inflight=!1,this.inflightOwner=null,this.inflightKey=null,this.owner===t)){if(this.heldKey!==this.sentKey){this.flush();return}r?this.renew():this.schedule(E,"renew")}};Promise.resolve(t.send(s)).then(r=>i(!!r),()=>i(!1))}},k=new S,ce=k;if(typeof window<"u"&&(window.clay=window.clay||{},!window.clay.presence)){window.clay.presence=k;try{document.dispatchEvent(new CustomEvent("clay:presence-ready",{detail:{presence:k}}))}catch{}}export{p as a,E as b,ie as c,y as d,S as e,k as f,ce as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f,b as u}from"./c-7SWMYKAI.js";import{b as l}from"./c-UGHH4MB3.js";import{a as s}from"./c-
|
|
1
|
+
import{a as f,b as u}from"./c-7SWMYKAI.js";import{b as l}from"./c-UGHH4MB3.js";import{a as s}from"./c-LA2BW7UY.js";var c=(t=[])=>i=>{let e=(i.getAttribute("clay")??"").split(/\s+/).filter(Boolean),n=["no-dirty",...t].filter(r=>!e.includes(r));n.length&&i.setAttribute("clay",[...e,...n].join(" "))},p=c();function S(t,i){return y(t,i)}function b(t,i,e,n=[]){return y(t,i,e,n)}function y(t,i,e,n=[]){let r=typeof i=="string",a=r?{name:t,legacyId:e}:{href:f(t)},d=e===void 0?[]:document.querySelectorAll(`style[id="${e}"]:not([data-name])`);s.pause();try{l(a);for(let o of d)o.dataset.name=t;if(r){let o=u(t,i,c(n));return e!==void 0&&(o.id=e),o}return u(t,o=>{p(o),o.getAttribute("href")!==t&&o.setAttribute("href",t)})}finally{s.resume()}}export{S as a,b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as O}from"./c-
|
|
1
|
+
import{x as O}from"./c-44B5ODN7.js";import{H as x,I as C,J as $,a as A,m as N}from"./c-QIXT3Q7C.js";import"./c-VHNSBD2M.js";var g=N.nodes,H=e=>e.attrs.parent??null,_=e=>{let a=new Set;return e.forEach(t=>t.forEach(o=>a.add(o.attrs.col))),C(e.attrs.cols).filter(t=>a.has(t))};function S(e,a){let t=a.ownerDocument,o=t.createElement("thead").appendChild(t.createElement("tr"));for(let s of _(e)){let p=e.attrs.cols[s],r=o.appendChild(t.createElement("th"));r.setAttribute("data-col",s),r.setAttribute("scope","col"),p.kind&&r.setAttribute("data-kind",p.kind),p.width&&(r.setAttribute("data-width",String(p.width)),r.style.width=`${p.width}px`),r.textContent=p.name??""}a.prepend(o.parentNode),e.attrs.sort&&a.setAttribute("data-sort",JSON.stringify(e.attrs.sort))}function v(e,a){let t=[];e.forEach((o,s,p)=>{let r=a[p];if(!r||r.nodeType!==1)return;if(o.type===g.table&&S(o,r),o.type!==g.list_item||H(o)!==null){t=[];return}let f=r.ownerDocument,{indent:d,kind:i}=o.attrs,l=i==="ordered"?"OL":"UL";for(;t.length&&t.at(-1).indent>d;)t.pop();if(t.at(-1)?.indent===d&&t.at(-1).list.tagName!==l&&t.pop(),!t.length||t.at(-1).indent<d){let c=f.createElement(l);t.length?t.at(-1).li.append(c):r.before(c),t.push({indent:d,list:c,li:null})}let u=f.createElement("li");i==="check"&&(u.innerHTML=`<input type="checkbox" disabled${o.attrs.checked?" checked":""}>`),u.append(...r.childNodes),t.at(-1).list.append(u),t.at(-1).li=u,r.remove()})}var T=e=>/[\t\n\r"]/.test(e)?`"${e.replace(/"/g,'""')}"`:e;function q(e){if(!e.content.firstChild?.type.spec.group?.includes("block"))return null;let a="",t=[],o=!1;return e.content.forEach((s,p,r)=>{let f=s.type===g.list_item,d=s.textBetween(0,s.content.size,`
|
|
2
2
|
|
|
3
3
|
`);if(f){let{indent:i,kind:l}=s.attrs;for(;t.length&&t.at(-1).indent>i;)t.pop();t.at(-1)?.indent===i&&t.at(-1).kind!==l&&t.pop(),(!t.length||t.at(-1).indent<i)&&t.push({indent:i,kind:l,n:0});let u=t.at(-1),c=l==="ordered"?`${++u.n}.`:l==="check"?`- [${s.attrs.checked?"x":" "}]`:"-";d=`${" ".repeat(t.length-1)}${c} ${d}`}else t=[];if(s.type===g.table){let i=[_(s).map(l=>T(s.attrs.cols[l].name??""))];s.forEach(l=>{let u=[];l.forEach(c=>u.push(T(c.textContent))),i.push(u)}),d=i.map(l=>l.join(" ")).join(`
|
|
4
4
|
`)}a+=(r?o&&f?`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as g,r as k}from"./c-
|
|
1
|
+
import{m as g,r as k}from"./c-GVPNDIKJ.js";import{a as l,b as n,c as d,h as p}from"./c-NQJRVJ56.js";var b=3e4;function a(){return{ok:!1,code:"failed"}}async function T(o,{etag:r}={}){if(typeof o!="string"||o==="")return a();let m=typeof r=="string"&&r?r:null;if(n()||await p(),!n())return{ok:!1,code:"unsupported"};let s=m||l();if(!s)return{ok:!1,code:"conflict"};let i=new AbortController,y=setTimeout(()=>i.abort(),b);try{let{url:c,options:S}=k(o,!0,i.signal,g(),s),t=await fetch(c,S),f=await t.text(),e={};if(f)try{e=JSON.parse(f)}catch{e={}}if(!t.ok)return t.status===412?{ok:!1,code:"conflict"}:t.status===401||t.status===403?{ok:!1,code:"forbidden"}:a();let u=typeof e.etag=="string"&&e.etag?e.etag:null;return d(u),{ok:!0,etag:u}}catch{return a()}finally{clearTimeout(y)}}export{T as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as z}from"./c-W4JCVLAB.js";import{B as J}from"./c-AIWN4QN4.js";import{d as _,m as F}from"./c-QIXT3Q7C.js";import"./c-VHNSBD2M.js";var{Decoration:ee,DecorationSet:te}=_,c=(t,n,a,e={},o=null)=>{let l=t.createElement(n);a&&(l.className=a);for(let[s,i]of Object.entries(e))i!=null&&i!==!1&&l.setAttribute(s,i===!0?"":String(i));return o!==null&&(l.textContent=o),l},ne=(t,n)=>c(t,"span","page-board-face",{"aria-hidden":"true"},([...String(n).trim()][0]??"?").toUpperCase());function I(t,n){let a=null;return t.state.doc.forEach((e,o)=>{e.attrs.id===n&&e.type===F.nodes.list_item&&e.attrs.kind==="check"&&(a={node:e,pos:o})}),a}function X(t,n,a,e){let o=I(t,n);o&&t.dispatch(J(t.state.tr.setNodeMarkup(o.pos,null,{...o.node.attrs,[a]:e||null})))}var L={person:'<circle cx="8" cy="5.4" r="2.3"/><path d="M3.6 13.2c.6-2.1 2.2-3.3 4.4-3.3s3.8 1.2 4.4 3.3"/>',calendar:'<rect x="2.5" y="3.5" width="11" height="10"/><path d="M2.5 6.8h11M5.5 2v2.4M10.5 2v2.4"/>',clock:'<circle cx="8" cy="8" r="5.5"/><path d="M8 4.8v3.4l2.3 1.4"/>',tick:'<path d="M3.5 8.3l3 3 6-6.2"/>',plus:'<path d="M8 3.5v9M3.5 8h9"/>',clear:'<path d="M4.8 4.8l6.4 6.4M11.2 4.8l-6.4 6.4"/>',"chevron-left":'<path d="M9.8 3.6L5.4 8l4.4 4.4"/>',"chevron-right":'<path d="M6.2 3.6L10.6 8l-4.4 4.4"/>'};function q(t,n){let a=t.createElementNS("http://www.w3.org/2000/svg","svg");return a.setAttribute("viewBox","0 0 16 16"),a.setAttribute("width","14"),a.setAttribute("height","14"),a.setAttribute("fill","none"),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),a.setAttribute("aria-hidden","true"),a.innerHTML=n,a}var Z=t=>String(t).padStart(2,"0"),B=/^\d{4}-\d{2}-\d{2}$/,S=(t=new Date)=>`${t.getFullYear()}-${Z(t.getMonth()+1)}-${Z(t.getDate())}`,ae=t=>{let n=new Date(`${t}T00:00:00Z`);return n.setUTCDate(n.getUTCDate()+1),n.toISOString().slice(0,10)};function oe(t,n){if(!t)return"No date";if(!B.test(t))return t;if(t===n)return"Today";if(t===ae(n))return"Tomorrow";let a=t.slice(0,4)===n.slice(0,4);return new Date(`${t}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",...a?{}:{year:"numeric"},timeZone:"UTC"})}function j(t,{name:n,paths:a,label:e,aria:o,filled:l,overdue:s=!1}){let i=c(t,"button","page-check-chip",{type:"button","data-check":n,"data-filled":String(l),"data-overdue":s?"true":null,"aria-expanded":"false","aria-label":o});return i.append(q(t,a),c(t,"span","page-check-chip-label",{},e)),i}var N=null;function G(t,n,{className:a,label:e,check:o,onKey:l=null}){let s=n.ownerDocument,i=s.defaultView;N&&N.close();for(let d of s.querySelectorAll(".page-check-popup"))d.remove();let y=t.dom.parentNode,h=["relative","absolute","fixed","sticky"].includes(i?.getComputedStyle?.(y)?.position??""),g=y&&h?y:s.body,f=c(s,"div",`page-check-popup ${a}`,{role:"dialog","aria-label":e,"data-check":o}),A=!1,E=()=>{let d=n.getBoundingClientRect(),r=g===s.body?{top:-(i?.scrollY??0),left:-(i?.scrollX??0)}:g.getBoundingClientRect(),u=f.getBoundingClientRect(),p=u.width||Math.min(264,(i?.innerWidth||292)-28),k=(i?.innerHeight??0)-d.bottom-2,b=u.height>0&&k<u.height;f.style.left=`${Math.round(d.right-p-r.left)}px`,f.style.top=`${Math.round((b?d.top-u.height-2:d.bottom+2)-r.top)}px`},C=d=>{if(!f.isConnected)return w();f.contains(d.target)||n.contains(d.target)||w()},w=({focusAnchor:d=!1}={})=>{if(A)return;A=!0,s.removeEventListener("mousedown",C,!0),i?.removeEventListener("resize",E),i?.removeEventListener("scroll",E,!0),N?.panel===f&&(N=null),f.remove(),n.setAttribute("aria-expanded","false");let r=n.dataset.fromKeys==="true";delete n.dataset.fromKeys,d&&r?t.focus():d&&n.focus()};return f.addEventListener("keydown",d=>{if(d.stopPropagation(),d.key==="Escape"){d.preventDefault(),w({focusAnchor:!0});return}l?.(d,f)}),g.append(f),n.setAttribute("aria-expanded","true"),N={panel:f,close:()=>w()},s.addEventListener("mousedown",C,!0),i?.addEventListener("resize",E),i?.addEventListener("scroll",E,!0),{panel:f,close:w,place:E}}function re(t,n){let a=new Map;t.state.doc.forEach(e=>{if(e.type!==F.nodes.list_item||e.attrs.kind!=="check")return;let o=String(e.attrs.owner??"").trim();if(!o)return;let l=o.toLowerCase(),s=a.get(l)??{name:o,count:0};s.count+=1,a.set(l,s)});for(let e of n??[]){let o=String((typeof e=="string"?e:e?.name)??"").trim();o&&!a.has(o.toLowerCase())&&a.set(o.toLowerCase(),{name:o,count:0})}return[...a.values()].sort((e,o)=>e.name.localeCompare(o.name))}function ce(t,n,a){let e=a.ownerDocument,o=I(t,n)?.node.attrs.owner||"",{panel:l,close:s,place:i}=G(t,a,{className:"page-check-owner",label:"Assignee",check:"owner-panel",onKey:(r,u)=>{if(r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;r.preventDefault();let p=[...u.querySelectorAll("input, button:not([disabled])")],k=p.indexOf(e.activeElement),b=r.key==="ArrowDown"?1:-1;(k<0?b>0?p[0]:p[p.length-1]:p[(k+b+p.length)%p.length])?.focus()}}),y=c(e,"input","page-check-search",{type:"text",placeholder:"Find or type a name","aria-label":"Find or type a name"}),h=c(e,"div","page-check-people"),g=c(e,"button","page-check-person page-check-danger",{type:"button","data-check":"clear-owner"});g.append(q(e,L.clear),c(e,"span","page-check-person-name",{},"Remove assignee")),g.disabled=!o,g.addEventListener("click",()=>A(null)),l.append(y,c(e,"div","page-check-subhead",{},"People in this document"),h,c(e,"div","page-check-divider"),g);let f=[],A=r=>{s(),X(t,n,"owner",r)},E=(r,u)=>{let p=r.toLowerCase()===String(o).toLowerCase(),k=c(e,"button","page-check-person",{type:"button","data-check":"owner-option","data-name":r,"aria-pressed":String(p)});return k.append(ne(e,r),c(e,"span","page-check-person-name",{},r),c(e,"span","page-check-person-meta",{},`${u} ${u===1?"item":"items"}`)),p&&k.append(q(e,L.tick)),k.addEventListener("click",()=>A(r)),k},C=r=>{let u=c(e,"button","page-check-person",{type:"button","data-check":"owner-new","data-name":r}),p=c(e,"span","page-check-person-name",{},"Assign to ");return p.append(c(e,"strong",null,{},r)),u.append(q(e,L.plus),p,c(e,"span","page-check-person-meta",{},"New")),u.addEventListener("click",()=>A(r)),u},w=()=>{let r=y.value.trim(),u=r.toLowerCase(),p=re(t,f),k=[];r&&!p.some(b=>b.name.toLowerCase()===u)&&k.push(C(r));for(let b of p)u&&!b.name.toLowerCase().includes(u)||k.push(E(b.name,b.count));h.replaceChildren(...k)};y.addEventListener("keydown",r=>{if(r.stopPropagation(),r.key==="Escape"){r.preventDefault(),s({focusAnchor:!0});return}r.key==="Enter"&&(r.preventDefault(),h.querySelector("button[data-check]")?.click())}),y.addEventListener("input",w),w(),i(),y.focus();let d=globalThis.clay?.people?.available;d&&Promise.resolve().then(()=>d()).then(r=>{!N||N.panel!==l||(f=Array.isArray(r)?r:[],w())}).catch(()=>{})}var se=["January","February","March","April","May","June","July","August","September","October","November","December"],$=(t,n,a)=>new Date(t,n,a),ie=t=>t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),le=t=>t.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),W=t=>{if(!t||!B.test(t))return null;let[n,a,e]=t.split("-").map(Number);return $(n,a-1,e)};function de(t,n,a){let e=a.ownerDocument,o=I(t,n)?.node.attrs.due||null,l=S(),s=new Date,i=$(s.getFullYear(),s.getMonth(),s.getDate()),y=W(o)??i,h=y.getFullYear(),g=y.getMonth(),{panel:f,close:A,place:E}=G(t,a,{className:"page-check-date",label:"Due date",check:"date-panel",onKey:(m,D)=>Q(m,D)}),C=m=>{A(),X(t,n,"due",m)},w=c(e,"div","page-check-quick"),d=(m,D)=>{let M=$(i.getFullYear(),i.getMonth(),i.getDate()+D),x=c(e,"button","page-check-quick-row",{type:"button","data-check":"date-quick","data-date":S(M)});return x.append(q(e,L.calendar),c(e,"span","page-check-quick-label",{},m),c(e,"span","page-check-quick-meta",{},ie(M))),x.addEventListener("click",()=>C(S(M))),x};w.append(d("Today",0),d("Tomorrow",1),d("Next week",7));let r=c(e,"div","page-check-cal"),u=c(e,"div","page-check-cal-head"),p=c(e,"span","page-check-cal-month"),k=c(e,"span","page-check-cal-nav"),b=m=>{let D=$(h,g+m,1);h=D.getFullYear(),g=D.getMonth(),H()},U=c(e,"button","page-check-cal-btn",{type:"button","aria-label":"Previous month"}),O=c(e,"button","page-check-cal-btn",{type:"button","aria-label":"Next month"});U.append(q(e,L["chevron-left"])),O.append(q(e,L["chevron-right"])),U.addEventListener("click",()=>b(-1)),O.addEventListener("click",()=>b(1)),k.append(U,O),u.append(p,k);let Y=c(e,"div","page-check-cal-grid");r.append(u,Y);let H=()=>{p.replaceChildren(c(e,"span",null,{},`${se[g]} `),c(e,"span","page-check-cal-year",{},String(h)));let m=$(h,g,1),D=$(h,g+1,0).getDate(),M=Math.ceil((m.getDay()+D)/7)*7,x=["S","M","T","W","T","F","S"].map(v=>c(e,"span","page-check-cal-dow",{},v)),T=[];for(let v=0;v<M;v+=1){let P=$(h,g,1-m.getDay()+v),R=S(P),V=c(e,"button","page-check-cal-day",{type:"button","data-check":"date-day","data-date":R,"data-outside":String(P.getMonth()!==g),"data-today":String(R===l),"aria-pressed":String(R===o),"aria-label":le(P)},String(P.getDate()));V.addEventListener("click",()=>C(R)),T.push(V)}Y.replaceChildren(...x,...T)},Q=(m,D)=>{let M=e.activeElement?.closest?.('[data-check="date-day"]');if(!M)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),M.click();return}let x={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[m.key];if(!x)return;m.preventDefault();let T=W(M.dataset.date),v=$(T.getFullYear(),T.getMonth(),T.getDate()+x);(v.getMonth()!==g||v.getFullYear()!==h)&&(h=v.getFullYear(),g=v.getMonth(),H()),D.querySelector(`[data-check="date-day"][data-date="${S(v)}"]`)?.focus()},K=c(e,"button","page-check-quick-row page-check-danger",{type:"button","data-check":"clear-date"});K.append(q(e,L.clear),c(e,"span","page-check-quick-label",{},"Clear date")),K.disabled=!o,K.addEventListener("click",()=>C(null)),f.append(w,r,c(e,"div","page-check-divider"),K),H(),E(),(Y.querySelector('[data-check="date-day"][aria-pressed="true"]')??Y.querySelector('[data-check="date-day"][data-today="true"]'))?.focus()}function pe(t,n){let a=t.dom.ownerDocument,e=a.createElement("span");e.className="page-check-controls",e.contentEditable="false",e.dataset.empty=String(!n.attrs.owner&&!n.attrs.due);let o=S(),l=n.attrs.owner||"Unassigned",s=j(a,{name:"owner",paths:L.person,label:l,aria:`Assignee: ${l}`,filled:!!n.attrs.owner}),i=oe(n.attrs.due,o),y=!!n.attrs.due&&!n.attrs.checked&&B.test(n.attrs.due)&&n.attrs.due<o,h=j(a,{name:"date",paths:y?L.clock:L.calendar,label:i,aria:`Due date: ${i}`,filled:!!n.attrs.due,overdue:y});return s.addEventListener("click",()=>ce(t,n.attrs.id,s)),h.addEventListener("click",()=>de(t,n.attrs.id,h)),e.append(s,h),e}function ue(t,n){let a=t.state.selection.$head;if(a.depth!==1||a.parent.type!==F.nodes.list_item||a.parent.attrs.kind!=="check")return!1;let e=a.parent.attrs.id,l=[...t.dom.querySelectorAll(".page-check-controls")].find(s=>s.dataset.item===e)?.querySelector(`[data-check="${n}"]`);return l?(l.dataset.fromKeys="true",l.click(),!0):!1}function he(t){let n=[],a=S();return t.doc.forEach((e,o)=>{e.type!==F.nodes.list_item||e.attrs.kind!=="check"||n.push(ee.widget(o+e.nodeSize-1,l=>{let s=pe(l,e);return s.dataset.item=e.attrs.id,s},{key:`${e.attrs.id}:${e.attrs.owner}:${e.attrs.due}:${e.attrs.checked}:${a}`,side:-1,stopEvent:l=>!!l.target.closest?.(".page-check-chip, .page-check-popup"),ignoreSelection:!0}))}),te.create(t.doc,n)}function ge(t){let n=S(),a=()=>{t.isDestroyed||S()===n||(n=S(),t.dispatch(t.state.tr.setMeta("addToHistory",!1)))},e=t.dom.ownerDocument.defaultView,o=e.setInterval(a,6e4);return e.document.addEventListener("visibilitychange",a),()=>{e.clearInterval(o),e.document.removeEventListener("visibilitychange",a)}}function be({view:t=null}={}){let n=t?z(t,{decorations:he,focusControl:ue}):()=>{},a=t?ge(t):()=>{};return t&&!t.isDestroyed&&t.dispatch(t.state.tr.setMeta("addToHistory",!1)),{id:"checklist",dispose(){n(),a()}}}export{be as createFeature,he as decorations,ue as focusControl};
|
|
1
|
+
import{c as z}from"./c-W4JCVLAB.js";import{B as J}from"./c-44B5ODN7.js";import{d as _,m as F}from"./c-QIXT3Q7C.js";import"./c-VHNSBD2M.js";var{Decoration:ee,DecorationSet:te}=_,c=(t,n,a,e={},o=null)=>{let l=t.createElement(n);a&&(l.className=a);for(let[s,i]of Object.entries(e))i!=null&&i!==!1&&l.setAttribute(s,i===!0?"":String(i));return o!==null&&(l.textContent=o),l},ne=(t,n)=>c(t,"span","page-board-face",{"aria-hidden":"true"},([...String(n).trim()][0]??"?").toUpperCase());function I(t,n){let a=null;return t.state.doc.forEach((e,o)=>{e.attrs.id===n&&e.type===F.nodes.list_item&&e.attrs.kind==="check"&&(a={node:e,pos:o})}),a}function X(t,n,a,e){let o=I(t,n);o&&t.dispatch(J(t.state.tr.setNodeMarkup(o.pos,null,{...o.node.attrs,[a]:e||null})))}var L={person:'<circle cx="8" cy="5.4" r="2.3"/><path d="M3.6 13.2c.6-2.1 2.2-3.3 4.4-3.3s3.8 1.2 4.4 3.3"/>',calendar:'<rect x="2.5" y="3.5" width="11" height="10"/><path d="M2.5 6.8h11M5.5 2v2.4M10.5 2v2.4"/>',clock:'<circle cx="8" cy="8" r="5.5"/><path d="M8 4.8v3.4l2.3 1.4"/>',tick:'<path d="M3.5 8.3l3 3 6-6.2"/>',plus:'<path d="M8 3.5v9M3.5 8h9"/>',clear:'<path d="M4.8 4.8l6.4 6.4M11.2 4.8l-6.4 6.4"/>',"chevron-left":'<path d="M9.8 3.6L5.4 8l4.4 4.4"/>',"chevron-right":'<path d="M6.2 3.6L10.6 8l-4.4 4.4"/>'};function q(t,n){let a=t.createElementNS("http://www.w3.org/2000/svg","svg");return a.setAttribute("viewBox","0 0 16 16"),a.setAttribute("width","14"),a.setAttribute("height","14"),a.setAttribute("fill","none"),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),a.setAttribute("aria-hidden","true"),a.innerHTML=n,a}var Z=t=>String(t).padStart(2,"0"),B=/^\d{4}-\d{2}-\d{2}$/,S=(t=new Date)=>`${t.getFullYear()}-${Z(t.getMonth()+1)}-${Z(t.getDate())}`,ae=t=>{let n=new Date(`${t}T00:00:00Z`);return n.setUTCDate(n.getUTCDate()+1),n.toISOString().slice(0,10)};function oe(t,n){if(!t)return"No date";if(!B.test(t))return t;if(t===n)return"Today";if(t===ae(n))return"Tomorrow";let a=t.slice(0,4)===n.slice(0,4);return new Date(`${t}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",...a?{}:{year:"numeric"},timeZone:"UTC"})}function j(t,{name:n,paths:a,label:e,aria:o,filled:l,overdue:s=!1}){let i=c(t,"button","page-check-chip",{type:"button","data-check":n,"data-filled":String(l),"data-overdue":s?"true":null,"aria-expanded":"false","aria-label":o});return i.append(q(t,a),c(t,"span","page-check-chip-label",{},e)),i}var N=null;function G(t,n,{className:a,label:e,check:o,onKey:l=null}){let s=n.ownerDocument,i=s.defaultView;N&&N.close();for(let d of s.querySelectorAll(".page-check-popup"))d.remove();let y=t.dom.parentNode,h=["relative","absolute","fixed","sticky"].includes(i?.getComputedStyle?.(y)?.position??""),g=y&&h?y:s.body,f=c(s,"div",`page-check-popup ${a}`,{role:"dialog","aria-label":e,"data-check":o}),A=!1,E=()=>{let d=n.getBoundingClientRect(),r=g===s.body?{top:-(i?.scrollY??0),left:-(i?.scrollX??0)}:g.getBoundingClientRect(),u=f.getBoundingClientRect(),p=u.width||Math.min(264,(i?.innerWidth||292)-28),k=(i?.innerHeight??0)-d.bottom-2,b=u.height>0&&k<u.height;f.style.left=`${Math.round(d.right-p-r.left)}px`,f.style.top=`${Math.round((b?d.top-u.height-2:d.bottom+2)-r.top)}px`},C=d=>{if(!f.isConnected)return w();f.contains(d.target)||n.contains(d.target)||w()},w=({focusAnchor:d=!1}={})=>{if(A)return;A=!0,s.removeEventListener("mousedown",C,!0),i?.removeEventListener("resize",E),i?.removeEventListener("scroll",E,!0),N?.panel===f&&(N=null),f.remove(),n.setAttribute("aria-expanded","false");let r=n.dataset.fromKeys==="true";delete n.dataset.fromKeys,d&&r?t.focus():d&&n.focus()};return f.addEventListener("keydown",d=>{if(d.stopPropagation(),d.key==="Escape"){d.preventDefault(),w({focusAnchor:!0});return}l?.(d,f)}),g.append(f),n.setAttribute("aria-expanded","true"),N={panel:f,close:()=>w()},s.addEventListener("mousedown",C,!0),i?.addEventListener("resize",E),i?.addEventListener("scroll",E,!0),{panel:f,close:w,place:E}}function re(t,n){let a=new Map;t.state.doc.forEach(e=>{if(e.type!==F.nodes.list_item||e.attrs.kind!=="check")return;let o=String(e.attrs.owner??"").trim();if(!o)return;let l=o.toLowerCase(),s=a.get(l)??{name:o,count:0};s.count+=1,a.set(l,s)});for(let e of n??[]){let o=String((typeof e=="string"?e:e?.name)??"").trim();o&&!a.has(o.toLowerCase())&&a.set(o.toLowerCase(),{name:o,count:0})}return[...a.values()].sort((e,o)=>e.name.localeCompare(o.name))}function ce(t,n,a){let e=a.ownerDocument,o=I(t,n)?.node.attrs.owner||"",{panel:l,close:s,place:i}=G(t,a,{className:"page-check-owner",label:"Assignee",check:"owner-panel",onKey:(r,u)=>{if(r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;r.preventDefault();let p=[...u.querySelectorAll("input, button:not([disabled])")],k=p.indexOf(e.activeElement),b=r.key==="ArrowDown"?1:-1;(k<0?b>0?p[0]:p[p.length-1]:p[(k+b+p.length)%p.length])?.focus()}}),y=c(e,"input","page-check-search",{type:"text",placeholder:"Find or type a name","aria-label":"Find or type a name"}),h=c(e,"div","page-check-people"),g=c(e,"button","page-check-person page-check-danger",{type:"button","data-check":"clear-owner"});g.append(q(e,L.clear),c(e,"span","page-check-person-name",{},"Remove assignee")),g.disabled=!o,g.addEventListener("click",()=>A(null)),l.append(y,c(e,"div","page-check-subhead",{},"People in this document"),h,c(e,"div","page-check-divider"),g);let f=[],A=r=>{s(),X(t,n,"owner",r)},E=(r,u)=>{let p=r.toLowerCase()===String(o).toLowerCase(),k=c(e,"button","page-check-person",{type:"button","data-check":"owner-option","data-name":r,"aria-pressed":String(p)});return k.append(ne(e,r),c(e,"span","page-check-person-name",{},r),c(e,"span","page-check-person-meta",{},`${u} ${u===1?"item":"items"}`)),p&&k.append(q(e,L.tick)),k.addEventListener("click",()=>A(r)),k},C=r=>{let u=c(e,"button","page-check-person",{type:"button","data-check":"owner-new","data-name":r}),p=c(e,"span","page-check-person-name",{},"Assign to ");return p.append(c(e,"strong",null,{},r)),u.append(q(e,L.plus),p,c(e,"span","page-check-person-meta",{},"New")),u.addEventListener("click",()=>A(r)),u},w=()=>{let r=y.value.trim(),u=r.toLowerCase(),p=re(t,f),k=[];r&&!p.some(b=>b.name.toLowerCase()===u)&&k.push(C(r));for(let b of p)u&&!b.name.toLowerCase().includes(u)||k.push(E(b.name,b.count));h.replaceChildren(...k)};y.addEventListener("keydown",r=>{if(r.stopPropagation(),r.key==="Escape"){r.preventDefault(),s({focusAnchor:!0});return}r.key==="Enter"&&(r.preventDefault(),h.querySelector("button[data-check]")?.click())}),y.addEventListener("input",w),w(),i(),y.focus();let d=globalThis.clay?.people?.available;d&&Promise.resolve().then(()=>d()).then(r=>{!N||N.panel!==l||(f=Array.isArray(r)?r:[],w())}).catch(()=>{})}var se=["January","February","March","April","May","June","July","August","September","October","November","December"],$=(t,n,a)=>new Date(t,n,a),ie=t=>t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),le=t=>t.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),W=t=>{if(!t||!B.test(t))return null;let[n,a,e]=t.split("-").map(Number);return $(n,a-1,e)};function de(t,n,a){let e=a.ownerDocument,o=I(t,n)?.node.attrs.due||null,l=S(),s=new Date,i=$(s.getFullYear(),s.getMonth(),s.getDate()),y=W(o)??i,h=y.getFullYear(),g=y.getMonth(),{panel:f,close:A,place:E}=G(t,a,{className:"page-check-date",label:"Due date",check:"date-panel",onKey:(m,D)=>Q(m,D)}),C=m=>{A(),X(t,n,"due",m)},w=c(e,"div","page-check-quick"),d=(m,D)=>{let M=$(i.getFullYear(),i.getMonth(),i.getDate()+D),x=c(e,"button","page-check-quick-row",{type:"button","data-check":"date-quick","data-date":S(M)});return x.append(q(e,L.calendar),c(e,"span","page-check-quick-label",{},m),c(e,"span","page-check-quick-meta",{},ie(M))),x.addEventListener("click",()=>C(S(M))),x};w.append(d("Today",0),d("Tomorrow",1),d("Next week",7));let r=c(e,"div","page-check-cal"),u=c(e,"div","page-check-cal-head"),p=c(e,"span","page-check-cal-month"),k=c(e,"span","page-check-cal-nav"),b=m=>{let D=$(h,g+m,1);h=D.getFullYear(),g=D.getMonth(),H()},U=c(e,"button","page-check-cal-btn",{type:"button","aria-label":"Previous month"}),O=c(e,"button","page-check-cal-btn",{type:"button","aria-label":"Next month"});U.append(q(e,L["chevron-left"])),O.append(q(e,L["chevron-right"])),U.addEventListener("click",()=>b(-1)),O.addEventListener("click",()=>b(1)),k.append(U,O),u.append(p,k);let Y=c(e,"div","page-check-cal-grid");r.append(u,Y);let H=()=>{p.replaceChildren(c(e,"span",null,{},`${se[g]} `),c(e,"span","page-check-cal-year",{},String(h)));let m=$(h,g,1),D=$(h,g+1,0).getDate(),M=Math.ceil((m.getDay()+D)/7)*7,x=["S","M","T","W","T","F","S"].map(v=>c(e,"span","page-check-cal-dow",{},v)),T=[];for(let v=0;v<M;v+=1){let P=$(h,g,1-m.getDay()+v),R=S(P),V=c(e,"button","page-check-cal-day",{type:"button","data-check":"date-day","data-date":R,"data-outside":String(P.getMonth()!==g),"data-today":String(R===l),"aria-pressed":String(R===o),"aria-label":le(P)},String(P.getDate()));V.addEventListener("click",()=>C(R)),T.push(V)}Y.replaceChildren(...x,...T)},Q=(m,D)=>{let M=e.activeElement?.closest?.('[data-check="date-day"]');if(!M)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),M.click();return}let x={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[m.key];if(!x)return;m.preventDefault();let T=W(M.dataset.date),v=$(T.getFullYear(),T.getMonth(),T.getDate()+x);(v.getMonth()!==g||v.getFullYear()!==h)&&(h=v.getFullYear(),g=v.getMonth(),H()),D.querySelector(`[data-check="date-day"][data-date="${S(v)}"]`)?.focus()},K=c(e,"button","page-check-quick-row page-check-danger",{type:"button","data-check":"clear-date"});K.append(q(e,L.clear),c(e,"span","page-check-quick-label",{},"Clear date")),K.disabled=!o,K.addEventListener("click",()=>C(null)),f.append(w,r,c(e,"div","page-check-divider"),K),H(),E(),(Y.querySelector('[data-check="date-day"][aria-pressed="true"]')??Y.querySelector('[data-check="date-day"][data-today="true"]'))?.focus()}function pe(t,n){let a=t.dom.ownerDocument,e=a.createElement("span");e.className="page-check-controls",e.contentEditable="false",e.dataset.empty=String(!n.attrs.owner&&!n.attrs.due);let o=S(),l=n.attrs.owner||"Unassigned",s=j(a,{name:"owner",paths:L.person,label:l,aria:`Assignee: ${l}`,filled:!!n.attrs.owner}),i=oe(n.attrs.due,o),y=!!n.attrs.due&&!n.attrs.checked&&B.test(n.attrs.due)&&n.attrs.due<o,h=j(a,{name:"date",paths:y?L.clock:L.calendar,label:i,aria:`Due date: ${i}`,filled:!!n.attrs.due,overdue:y});return s.addEventListener("click",()=>ce(t,n.attrs.id,s)),h.addEventListener("click",()=>de(t,n.attrs.id,h)),e.append(s,h),e}function ue(t,n){let a=t.state.selection.$head;if(a.depth!==1||a.parent.type!==F.nodes.list_item||a.parent.attrs.kind!=="check")return!1;let e=a.parent.attrs.id,l=[...t.dom.querySelectorAll(".page-check-controls")].find(s=>s.dataset.item===e)?.querySelector(`[data-check="${n}"]`);return l?(l.dataset.fromKeys="true",l.click(),!0):!1}function he(t){let n=[],a=S();return t.doc.forEach((e,o)=>{e.type!==F.nodes.list_item||e.attrs.kind!=="check"||n.push(ee.widget(o+e.nodeSize-1,l=>{let s=pe(l,e);return s.dataset.item=e.attrs.id,s},{key:`${e.attrs.id}:${e.attrs.owner}:${e.attrs.due}:${e.attrs.checked}:${a}`,side:-1,stopEvent:l=>!!l.target.closest?.(".page-check-chip, .page-check-popup"),ignoreSelection:!0}))}),te.create(t.doc,n)}function ge(t){let n=S(),a=()=>{t.isDestroyed||S()===n||(n=S(),t.dispatch(t.state.tr.setMeta("addToHistory",!1)))},e=t.dom.ownerDocument.defaultView,o=e.setInterval(a,6e4);return e.document.addEventListener("visibilitychange",a),()=>{e.clearInterval(o),e.document.removeEventListener("visibilitychange",a)}}function be({view:t=null}={}){let n=t?z(t,{decorations:he,focusControl:ue}):()=>{},a=t?ge(t):()=>{};return t&&!t.isDestroyed&&t.dispatch(t.state.tr.setMeta("addToHistory",!1)),{id:"checklist",dispose(){n(),a()}}}export{be as createFeature,he as decorations,ue as focusControl};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as l}from"./c-Q3XOWZEV.js";var O="clay",y="data-paid-only",g="no-copy",m="no-copy-unless:paid-forms",C=/[\t\n\f\r ]+/;function a(n,t){return n.attrs?.find(e=>e.name===t)?.value??null}function L(n){return n.content?[...n.childNodes||[],n.content]:n.childNodes||[]}function f(n,t){t(n);for(let e of L(n))f(e,t)}function d(n){return(a(n,O)??"").split(C)}function N(n){let t=[],e=a(n,y);return e!==null&&t.push(e),d(n).includes(m)&&t.push("forms"),[...new Set(t)]}function b(n){let t=null;return f(n,e=>{let o=e.sourceCodeLocation?.endOffset;typeof o=="number"&&o>=0&&(t===null||o>t)&&(t=o)}),t}function k(n){let t=n.sourceCodeLocation;if(typeof t?.endOffset=="number"&&t.endOffset>=0)return t.endOffset;let e=b(n)??t?.startTag?.endOffset??null;return e===null?null:(console.warn(`clayjs: <${n.tagName}> has no end offset; removing through ${e}`),e)}function h(n,t){let e=[];return f(l(n,{sourceCodeLocationInfo:!0}),o=>{let c=N(o),s=d(o).includes(g),i=t===null?c.length>0:c.some(p=>t.includes(p));if(!s&&!i)return;let r=o.sourceCodeLocation?.startOffset,u=typeof r=="number"?k(o):null;typeof r=="number"&&r>=0&&u!==null&&u>r&&e.push({start:r,end:u})}),e.filter((o,c)=>!e.some((s,i)=>i!==c&&s.start<=o.start&&o.end<=s.end))}function I(n,t){let e=n.lastIndexOf(`
|
|
2
|
+
`,t-1);return e<0||/\S/.test(n.slice(e+1,t))?t:n[e-1]==="\r"?e-1:e}function S(n,t){let e=[...t].sort((s,i)=>s.start-i.start),o=n,c=n.length;for(let s=e.length-1;s>=0;s-=1){let{start:i,end:r}=e[s];if(r>c)continue;let u=I(n,i);u>=r||(o=o.slice(0,u)+o.slice(r),c=u)}return o}function E(n,t=null){return typeof n!="string"||!/clay|data-paid-only/i.test(n)?n:S(n,h(n,t))}export{E as a};
|