@panphora/clayjs 1.25.0 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +4432 -3831
- package/dist/m/attrs/{save-freeze-MH3AOD56.js → save-freeze-PUYX32AK.js} +1 -1
- package/dist/m/{c-XHZIKRCV.js → c-2A2ATCIH.js} +1 -1
- package/dist/m/{c-BOMQIQ3V.js → c-2EFMJYGJ.js} +1 -1
- package/dist/m/{c-JD2VFAYG.js → c-2GB34XL4.js} +2 -2
- package/dist/m/{c-CITLTVQ4.js → c-2TJCFPX4.js} +1 -1
- package/dist/m/c-33SS5A4Y.js +1 -0
- package/dist/m/{c-V2FPBRO6.js → c-34J5HC7N.js} +1 -1
- package/dist/m/{c-ZEA3DCG3.js → c-3AAQJAKJ.js} +1 -1
- package/dist/m/c-3F3AADKG.js +1 -0
- package/dist/m/{c-GDNZEOOZ.js → c-3WX5FABT.js} +1 -1
- package/dist/m/{c-QWB53KRW.js → c-3XNTQQEJ.js} +1 -1
- package/dist/m/{c-AI3H6ETU.js → c-3Y234AUB.js} +2 -2
- package/dist/m/{c-GEAG5XAK.js → c-42RLKGEY.js} +1 -1
- package/dist/m/{c-XQTERKQA.js → c-44WITKWQ.js} +1 -1
- package/dist/m/c-47M4QHCK.js +1 -0
- package/dist/m/{c-UOUUI265.js → c-4M2T676V.js} +1 -1
- package/dist/m/{c-3E2IK5HU.js → c-4NAYDOWH.js} +1 -1
- package/dist/m/{c-TLQINES7.js → c-4OZZ7ENT.js} +2 -2
- package/dist/m/{c-QDVG4NAZ.js → c-5IIEOPIV.js} +1 -1
- package/dist/m/{c-4Q6QIODW.js → c-755ZOHOM.js} +1 -1
- package/dist/m/c-7Q4XYDF4.js +1 -0
- package/dist/m/c-7RHOMAMR.js +1 -0
- package/dist/m/{c-BCWYEG6P.js → c-7Z2625LX.js} +1 -1
- package/dist/m/{c-C6YZNU6E.js → c-A3OKSYRI.js} +1 -1
- package/dist/m/{c-RGAALCDU.js → c-A5IYL7JI.js} +1 -1
- package/dist/m/c-A5LASUEZ.js +1 -0
- package/dist/m/c-AQVQKFKB.js +1 -0
- package/dist/m/{c-IESDKFO6.js → c-ASGHHLFX.js} +1 -1
- package/dist/m/c-ASMLERFA.js +7 -0
- package/dist/m/{c-ORLPQFNU.js → c-AZM34SPO.js} +1 -1
- package/dist/m/{c-TCFVG3I4.js → c-BHLYQGTA.js} +1 -1
- package/dist/m/{c-ZORVIXUR.js → c-C27EVUQ6.js} +1 -1
- package/dist/m/{c-SUAC5RSG.js → c-C5UGNOC2.js} +1 -1
- package/dist/m/c-C6DXZIXD.js +1 -0
- package/dist/m/{c-WSTUCBHV.js → c-CPRGR2II.js} +1 -1
- package/dist/m/{c-NFQFV7OP.js → c-D2OPWOWO.js} +1 -1
- package/dist/m/{c-PRZNJUYZ.js → c-D4N4UJCQ.js} +2 -2
- package/dist/m/{c-D62HRSZK.js → c-DAUQ6JZ3.js} +1 -1
- package/dist/m/{c-5PZYDWTW.js → c-DDCYVLGG.js} +1 -1
- package/dist/m/{c-FBOO2UY3.js → c-DVMDYRAE.js} +1 -1
- package/dist/m/{c-WGQVSKKC.js → c-DYTBSJBI.js} +1 -1
- package/dist/m/{c-O2QZDVZ2.js → c-EEWPNUM2.js} +1 -1
- package/dist/m/{c-MFB74XVN.js → c-EHAR4RJJ.js} +2 -2
- package/dist/m/c-EIDZHQHZ.js +1 -0
- package/dist/m/c-ELXMSEN5.js +1 -0
- package/dist/m/c-FC5RUFPR.js +1 -0
- package/dist/m/{c-V4B3RUWB.js → c-GFASNR55.js} +1 -1
- package/dist/m/{c-4AE2A2LK.js → c-GNFDX6SU.js} +1 -1
- package/dist/m/{c-UD4VDBGJ.js → c-H3M6UDNV.js} +1 -1
- package/dist/m/{c-MUM53J5J.js → c-H4M2T4A6.js} +1 -1
- package/dist/m/{c-U7F66I64.js → c-HYNM5U6B.js} +1 -1
- package/dist/m/c-J2YYLEVM.js +1 -0
- package/dist/m/c-J2ZW4HMR.js +1 -0
- package/dist/m/{c-WCG6AKA7.js → c-JC4RZW4E.js} +1 -1
- package/dist/m/c-K2ZHQMPF.js +1 -0
- package/dist/m/{c-Z2OZFX3N.js → c-L6KVXPBO.js} +1 -1
- package/dist/m/{c-JWW6BHWD.js → c-LUBZU4AZ.js} +4 -4
- package/dist/m/{c-SEVOS4UE.js → c-LYNLY3MR.js} +1 -1
- package/dist/m/{c-NADLYVAH.js → c-MHTO3QAD.js} +1 -1
- package/dist/m/{c-SFYTKRU7.js → c-MKAUC6DB.js} +1 -1
- package/dist/m/c-MLMJUNRV.js +1 -0
- package/dist/m/{c-WDFQ7PBU.js → c-MMEVDN6D.js} +1 -1
- package/dist/m/{c-KYTVZT4D.js → c-NW4ZFKCY.js} +1 -1
- package/dist/m/{c-YFO6ZJLQ.js → c-O3DPFZCE.js} +1 -1
- package/dist/m/c-O4YIDULY.js +1 -0
- package/dist/m/c-OZOACVUD.js +1 -0
- package/dist/m/{c-MV7TEUTD.js → c-OZVK3TFI.js} +1 -1
- package/dist/m/c-PP3CUF3U.js +1 -0
- package/dist/m/{c-GY4BREDT.js → c-QL4NYM2L.js} +1 -1
- package/dist/m/c-RES2S5Q3.js +1 -0
- package/dist/m/c-RFGELYEU.js +2 -0
- package/dist/m/c-RGFPLQGV.js +1 -0
- package/dist/m/{c-FKTALXNV.js → c-STAPQ2X6.js} +1 -1
- package/dist/m/c-SYVF6ZMF.js +1 -0
- package/dist/m/{c-X3V4RWMA.js → c-T5IWJOMW.js} +1 -1
- package/dist/m/{c-DT7E76Z2.js → c-T7LOTEWO.js} +1 -1
- package/dist/m/{c-SFZRY6RT.js → c-TWB5ZQU4.js} +1 -1
- package/dist/m/c-U35T5NAY.js +1 -0
- package/dist/m/c-UW6MMZ4V.js +1 -0
- package/dist/m/c-VGG3UR7I.js +1 -0
- package/dist/m/c-VU4WEWPH.js +4 -0
- package/dist/m/{c-5Q5XBN56.js → c-W7LWCJHD.js} +1 -1
- package/dist/m/c-WOJ2RTV4.js +1 -0
- package/dist/m/{c-ZJG6C2WL.js → c-WOWGGNCJ.js} +1 -1
- package/dist/m/{c-SXZYVXD6.js → c-XCOQNISP.js} +1 -1
- package/dist/m/{c-IL5IVTOG.js → c-XS7G6U3Z.js} +1 -1
- package/dist/m/{c-HGG7M2S3.js → c-Y3J5LDKB.js} +1 -1
- package/dist/m/{c-JB5YU57S.js → c-Y3MPVURA.js} +1 -1
- package/dist/m/c-Y6HH7LTM.js +1 -0
- package/dist/m/{c-52OC3OH3.js → c-YRDKVEGR.js} +1 -1
- package/dist/m/{c-WVCT3ITX.js → c-YZGWSCMT.js} +1 -1
- package/dist/m/{c-YX2MC7YL.js → c-ZJ7726FO.js} +1 -1
- package/dist/m/core/{admin-attrs-ZI6K6UGM.js → admin-attrs-43JBA6JB.js} +1 -1
- package/dist/m/core/{autosave-BSM2ABJL.js → autosave-HD7Y7UNV.js} +1 -1
- package/dist/m/core/{conflict-notice-7EQLDYPA.js → conflict-notice-Y2NTMDGJ.js} +1 -1
- package/dist/m/core/{persist-2SZO3PCE.js → persist-MX3VYVBN.js} +1 -1
- package/dist/m/core/{save-K6Q47J2X.js → save-JZ7R4ET2.js} +1 -1
- package/dist/m/core/{save-core-U3Z44XBO.js → save-core-I4N6S4ED.js} +1 -1
- package/dist/m/core/{site-edits-CFMF6GHD.js → site-edits-TIJDPG6H.js} +1 -1
- package/dist/m/core/{snapshot-PWCHYFL6.js → snapshot-N5MKDGNI.js} +1 -1
- package/dist/m/core/{unsaved-warning-2WRZLJH5.js → unsaved-warning-BP6ZY3PG.js} +1 -1
- package/dist/m/internals/{index-FSLC4M7J.js → index-3LAVREAU.js} +1 -1
- package/dist/m/{loader-RC54UV7H.js → loader-7ORQVRCK.js} +1 -1
- package/dist/m/manifest-A27A4278.js +1 -0
- package/dist/m/manifest-edit-E8A61EB4.js +1 -0
- package/dist/m/manifest.json +1099 -1039
- package/dist/m/page/{editor-PKSPJ2XJ.js → editor-HS2CAV3W.js} +5 -5
- package/dist/m/plugins/{ai-edit-3LG6MGS3.js → ai-edit-WDV2GLDU.js} +2 -2
- package/dist/m/plugins/{cms-T2HLI7JG.js → cms-4KET6RZT.js} +9 -9
- package/dist/m/plugins/{derive-7DR5TUDH.js → derive-R4USHZ7P.js} +1 -1
- package/dist/m/plugins/{indicator-CTKX4EY7.js → indicator-OLPZ4WFI.js} +1 -1
- package/dist/m/plugins/{live-IFLL6YN5.js → live-CO4VJS46.js} +1 -1
- package/dist/m/plugins/{menu-YJZ3JWBC.js → menu-ESEFQARM.js} +1 -1
- package/dist/m/plugins/{page-GTDPYGE4.js → page-L3VKIQU2.js} +2 -2
- package/dist/m/plugins/{page-view-NMCCU6MF.js → page-view-6KNTXABH.js} +1 -1
- package/dist/m/plugins/{people-6WIWCZEG.js → people-EBWE337I.js} +1 -1
- package/dist/m/plugins/quickcrop-VNRXGRPC.js +26 -0
- package/dist/m/plugins/{richclay-L3BZMX4I.js → richclay-V6WKJTUF.js} +17 -17
- package/dist/m/plugins/sortable-BAG3MSWS.js +1 -0
- package/dist/m/plugins/{source-7LSGOV46.js → source-OYHDXKTB.js} +1 -1
- package/dist/m/plugins/undo-WUK2NLBA.js +1 -0
- package/dist/m/plugins/{upgrade-MMPZUCDM.js → upgrade-SZQJYEQQ.js} +1 -1
- package/dist/m/plugins/{visitor-drafts-V5YB7XDH.js → visitor-drafts-ZE6PCAFP.js} +2 -2
- package/dist/m/plugins/{visitor-menu-QDV2MYJN.js → visitor-menu-5XY57JQA.js} +1 -1
- package/dist/m/plugins/{wire-3YGUO3GE.js → wire-S5ATC4QI.js} +1 -1
- package/dist/m/reader-core-AHOAP5DH.js +77 -0
- package/dist/m/sync/{live-sync-XMXXZS3G.js → live-sync-DX4K5GDB.js} +1 -1
- package/dist/m/ui/index-G7ZJXNMG.js +1 -0
- package/dist/m/vendor/{sap-core.vendor-JANUQULT.js → sap-core.vendor-5TWOJYVM.js} +4 -4
- package/dist/offline-manifest.json +707 -677
- package/dist/server/core.cjs +4245 -2614
- package/dist/server/markdown.cjs +1 -0
- package/dist/server/markdown.mjs +7 -0
- package/docs/guide.md +26 -37
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +5 -5
- package/package.json +6 -2
- package/packed-contract.json +3 -0
- package/src/attrs/save-freeze.js +1 -1
- package/src/core/admin-contenteditable.js +1 -1
- package/src/core/admin-inputs.js +1 -1
- package/src/core/admin-onclick.js +1 -1
- package/src/core/admin-resources.js +5 -2
- package/src/core/conflict-notice-ui.js +59 -34
- package/src/core/save.js +9 -9
- package/src/core/snapshot.js +56 -43
- package/src/core/stale-host-notice.js +20 -7
- package/src/page/editor.js +10 -4
- package/src/page/import-markdown.js +22 -8
- package/src/page/save-projection.js +1 -1
- package/src/plugins/quickcrop.js +128 -69
- package/src/plugins/sortable.js +25 -9
- package/src/server/markdown/index.js +23 -0
- package/src/sync/conflicts.js +3 -1
- package/src/sync/data-guard-notice.js +137 -18
- package/src/ui/bevel-controls.js +4 -1
- package/src/ui/dialogs.js +11 -7
- package/src/ui/modal.js +9 -7
- package/src/ui/toast.js +67 -32
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +7 -7
- package/src/vendor/richclay.vendor.js +16 -16
- package/src/vendor/sap-core.vendor.js +4 -4
- package/tool-generation/context.md +69 -0
- package/tool-generation/system.md +1 -1
- package/dist/m/c-277QP5ET.js +0 -1
- package/dist/m/c-5SZ6KFR5.js +0 -1
- package/dist/m/c-CU33V6RW.js +0 -4
- package/dist/m/c-CVSWLX3X.js +0 -1
- package/dist/m/c-DXPOFLEJ.js +0 -1
- package/dist/m/c-EODTTNVA.js +0 -1
- package/dist/m/c-ESK4S67I.js +0 -1
- package/dist/m/c-FDWR3FL7.js +0 -1
- package/dist/m/c-FJDTDGDA.js +0 -1
- package/dist/m/c-FYDKYW6E.js +0 -1
- package/dist/m/c-HKSLOVU4.js +0 -1
- package/dist/m/c-IJHF4IO6.js +0 -1
- package/dist/m/c-IUL7PU4P.js +0 -1
- package/dist/m/c-K4M76VPM.js +0 -7
- package/dist/m/c-M7ITYKMF.js +0 -1
- package/dist/m/c-MR75YPRT.js +0 -1
- package/dist/m/c-NHXOBD6A.js +0 -1
- package/dist/m/c-NVU3DORS.js +0 -1
- package/dist/m/c-PNZIJFG7.js +0 -1
- package/dist/m/c-RHPHMTF2.js +0 -2
- package/dist/m/c-RWJ3OSCP.js +0 -1
- package/dist/m/c-SGG6MUXW.js +0 -1
- package/dist/m/c-SXNSSHPP.js +0 -1
- package/dist/m/c-TFLRT5JX.js +0 -1
- package/dist/m/c-U65PREMC.js +0 -1
- package/dist/m/c-VMXCX52Q.js +0 -1
- package/dist/m/c-YYGUHSZR.js +0 -1
- package/dist/m/manifest-3B84C829.js +0 -1
- package/dist/m/manifest-edit-1CB79AD4.js +0 -1
- package/dist/m/plugins/quickcrop-X5MRIBAP.js +0 -26
- package/dist/m/plugins/sortable-365SRRL3.js +0 -1
- package/dist/m/plugins/undo-UES4KS7B.js +0 -1
- package/dist/m/reader-core-VR7EL4WV.js +0 -77
- package/dist/m/ui/index-MGTWOW2C.js +0 -1
- /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
- /package/dist/m/plugins/{quickcrop-X5MRIBAP.js.LEGAL.txt → quickcrop-VNRXGRPC.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-L3BZMX4I.js.LEGAL.txt → richclay-V6WKJTUF.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{d as De,h as Je,i as et}from"./c-TRS6TM6O.js";import{a as Ue,b as We}from"./c-Y3J5LDKB.js";import{a as He,b as Ke}from"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import"./c-RHMPKZZ7.js";import{d as Ze}from"./c-QHWJ5ZIJ.js";import{a as Se,b as je,c as V,d as Qe,h as pe,i as Le,j as u}from"./c-J2ZW4HMR.js";import{a as te,e as ce,f as de}from"./c-A5LASUEZ.js";import"./c-4JZDZFF6.js";import{b as W,c as ee,e as l,f as qe}from"./c-5RZNFTWD.js";import{b as Ge}from"./c-PKCCHJ5X.js";import"./c-46XYM55L.js";import{a as se,b as T,c as Ve}from"./c-NUHP2XDB.js";import{a as Xe,r as q}from"./c-FC5RUFPR.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{f as Re}from"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import"./c-EHAR4RJJ.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import{f as Ye}from"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var I="light-dark(#D08A1E, #E3A33F)",ht=5e3,gt=4e3,mt=500,wt={"another-tab":"in another tab","another-person":"by someone else","an-agent":"by an agent"},yt='<svg viewBox="0 0 12 12" width="12" height="12" aria-hidden="true"><path d="M2.5 9.5h7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="square"/></svg>',H=(e,t)=>`${e} ${t}${e===1?"":"s"}`,xt="This spot changed again. Review the latest edit or download your copy.",vt="A data value can't be put back from here. Download your copy to keep yours.",w="hidden",Y=!1,L=[],ne=new Set,B=new Set,m=null,Me=0,O=null,b=null,fe=null,h=null,R=!1,K=!1,Ce=!1,Q=new Map,he=0,ue=!1,ie=!1,k=null,X=null,D=null,Be=0,z=!1,ge=0,me=null,re=null,$=[],v=[],ae=!1,we=null,ye=null,c=null,a=null,P=null,G=new Map,M=()=>window.clay?.conflicts||null,ot=()=>$.reduce((e,t)=>e+t.conflicts.length,0)+v.length,_e=()=>{let e=window.clay?.undo;return e&&typeof e.kept=="function"?e:null},xe=()=>M()?.list().filter(e=>!e.claimedBy&&e.kind!=="apply-incomplete")??[],Ie=()=>M()?.list().filter(e=>!e.claimedBy&&e.kind==="apply-incomplete")??[];function Oe(){return O?"upgraded":m?"refused":xe().length?"replaced":Ie().length?"failed":$.length||v.length?"recovered":null}function g(e,t,n){let o=Ve(e,t,n);return t[0]==="all:initial"&&T(o,"color-scheme","inherit"),o.setAttribute("clay",Se),o}function _(e,t){return G.set(t,e),e}function j(e,t){return te(a)&&(de(e,a,t),se(e,ce(a,t,{}))),e}function le(){if(!c)return;let e=window.visualViewport,t=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;T(c,"bottom",`calc(${16+t}px + env(safe-area-inset-bottom,0px))`),re&&T(re,"max-height",`${Math.max(160,(e?.height||window.innerHeight)-32)}px`)}function bt(){c=g("div",["all:initial","position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483001","display:none","flex-direction:column","align-items:center","max-width:calc(100vw - 24px)",`font:14px/1.5 ${W}`,`color:${l.ink}`,"text-align:left"]),c.setAttribute("data-clay-conflict",""),document.body.appendChild(c),window.visualViewport?.addEventListener("resize",le),window.visualViewport?.addEventListener("scroll",le)}function d(){if(ue)return;ue=!0;let e=()=>{ue=!1,y()};typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function y(){a=Ze(),ie&&(ie=!1,m&&!q()&&(m=null));let e=Oe();if(e?w==="hidden"&&(w="bar"):(w="hidden",Y=!1,ne.clear(),B.clear(),L=[],x(),me=null,z=!1),!c){if(w==="hidden"&&!k||!document.body)return;bt()}!c.isConnected&&document.body&&document.body.appendChild(c);let t=document.activeElement,n=null;for(let[s,r]of G)r===t&&(n=s);let o=P?P.scrollTop:0;G=new Map,P=null,re=null,c.replaceChildren(),k?c.append(Tt(k)):w==="bar"?c.append(At(e)):w==="panel"&&c.append(Ct(e)),T(c,"display",k||w!=="hidden"?"flex":"none"),P&&(P.scrollTop=o);let i=D||n;i&&G.has(i)&&G.get(i).focus({preventScroll:!0}),k||(D=null),le(),te(a)?(de(c,a,["conflict.root"]),se(c,ce(a,["conflict.root"],{})),T(c,"color-scheme",a.scheme==="light dark"?"light":a.scheme)):(c.removeAttribute("data-clay-part"),Ge(c))}function it(){return j(g("span",["all:initial","display:inline-block","flex:none","width:8px","height:8px","border-radius:50%",`background:${I}`]),["conflict.dot"])}function rt(){return wt[m?.changedBy]||null}function kt(e,t){if(e==="upgraded")return O;if(e==="refused"){let n=rt();return!n&&m.afterTimeout?"This page changed elsewhere, possibly by your own save that timed out. Your edits here are safe.":`This page changed ${n||"elsewhere"}. Your edits here are safe.`}return e==="failed"?"A sync update did not finish. Your edits here are safe.":e==="recovered"?`${H(t,"change")} replaced before this page loaded ${t===1?"is":"are"} still here.`:`Another edit replaced ${H(t,"change")}.`}function $t(e,t){return e==="upgraded"?O:e==="refused"?`This page changed ${rt()||"elsewhere"}`:e==="failed"?"A sync update did not finish":e==="recovered"?`${H(t,"change")} kept from before this page loaded`:`Another edit replaced ${H(t,"change")}`}function Tt(e){let t=pe("div",["display:block",`background:${l["teal-soft"]}`,"padding:10px 14px","width:max-content","max-width:calc(100vw - 24px)"],{theme:a,parts:["conflict.panel"]});return te(a)&&se(t,[`background:${l["teal-soft"]}`]),t.setAttribute("role","status"),t.textContent=e,t}function At(e){let t=e==="failed"?Ie().length:e==="recovered"?ot():xe().length,n=pe("div",["display:flex","flex-wrap:wrap","align-items:center","gap:10px 12px","padding:8px 8px 8px 14px","width:max-content","max-width:calc(100vw - 24px)"],{theme:a,parts:["conflict.panel"]}),o=kt(e,t);return o!==me&&(n.setAttribute("role",e==="refused"?"alert":"status"),me=o),n.append(it(),u("span",[],o,{theme:a,parts:["conflict.text"]})),e==="upgraded"?(n.append(_(V("Reload",{variant:"primary",onClick:()=>window.location.reload(),theme:a,parts:["conflict.button"],labelParts:["conflict.buttonLabel"]}),"reload")),n):(n.append(_(V("Review",{onClick:Ot,theme:a,parts:["conflict.button"],labelParts:["conflict.buttonLabel"]}),"review")),n)}function A(e,t,{variant:n="default",onClick:o,push:i=!1}={}){let r=window.innerWidth<480?["flex:1 1 100%",...n==="primary"?["order:-1"]:[]]:i?["margin-left:auto"]:[];return _(V(e,{variant:n,onClick:o,extra:r,theme:a,parts:["conflict.button"],labelParts:["conflict.buttonLabel"]}),t)}function E(e){return u("div",["display:block","padding:0 16px 12px",`color:${l["ink-2"]}`,"font-size:13.5px"],e,{theme:a,parts:["conflict.text"]})}function Ct(e){let t=e==="replaced"?xe():e==="failed"?Ie():[],n=e==="refused"?xe():t,o=e==="recovered"?ot():t.length;if(ne.size)for(let p of t)ne.has(p.id)||B.add(p.id);for(let p of[...B])t.some(F=>F.id===p)||B.delete(p);let i=$t(e,o),s=Math.max(160,(window.visualViewport?.height||window.innerHeight)-32),r=pe("div",["display:flex","flex-direction:column","width:520px","max-width:calc(100vw - 24px)",`max-height:${s}px`],{theme:a,parts:["conflict.panel"]});re=r,r.setAttribute("role","dialog"),r.setAttribute("aria-label",i);let f=j(g("div",["all:initial","display:flex","align-items:center","gap:8px","padding:12px 12px 8px 16px",`font:14px/1.5 ${W}`,`color:${l.ink}`]),["conflict.header"]),C=_(u("b",["font-weight:600","font-size:14.5px","outline:none"],i,{theme:a,parts:["conflict.title"]}),"title");C.setAttribute("tabindex","-1"),f.append(it(),C),e==="replaced"&&B.size&&f.append(u("span",[`font:600 10.5px/1 ${ee}`,"letter-spacing:.12em","text-transform:uppercase","padding:3px 6px",`color:color-mix(in srgb, ${l.brass} 80%, ${l.ink})`,`background:${l["brass-soft"]}`],`${B.size} new`));let J=g("span",["all:initial","display:inline-flex","margin-left:auto"]),Fe=_(Qe(yt,{label:"Minimize",onClick:at,theme:a,parts:["close","conflict.close"]}),"minimize");if(Fe.title="Minimize to the bar. Nothing is accepted until you choose.",J.append(Fe),f.append(J),r.append(f),e==="recovered")return Bt(r),r;if(e==="refused"){if(r.append(E("Your edits here are safe and not saved yet; nothing will be overwritten until you choose. Their version is not on this page, so there is no list of edits to compare. Keep yours, which saves over theirs, or accept theirs, which reloads the page and drops your unsaved edits.")),n.length&&r.append(E(`${H(n.length,"earlier replaced edit")} ${n.length===1?"is":"are"} also held in this tab. Download my copy includes them.`)),R&&r.append(E("That did not save either. Your edits here are still here.")),z&&r.append(E("Something changed on the page after your first press, so nothing was dropped. Press Accept theirs again if you still want their version.")),b){let p=j(g("div",["all:initial","display:block","margin:0 16px 12px","padding:8px 10px",`background:color-mix(in srgb, ${I} 14%, transparent)`,`color:${l.ink}`,`font:13px/1.5 ${W}`]),["conflict.warning"]);p.append(g("b",["all:initial","font:inherit","font-weight:700","color:inherit"],"This drops your unsaved edits."),document.createTextNode(" Download your copy first if you might want them. Press again to confirm.")),r.append(p)}}else e==="upgraded"?r.append(E("Its layout and code changed with it, so this page stops here. Reload to see the new version.")):e==="failed"?r.append(E("Part of an update from elsewhere could not be applied, so this page may be missing some of it. Your edits here are safe. Download a copy of the page as you had it, or accept to keep the page as it is.")):r.append(E("The page is showing the other edit. This stays until you choose. You can also save a copy of the page as you had it."));let N=j(g("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]),["conflict.actions"]);if(e==="upgraded")return N.append(A("Reload","reload",{variant:"primary",onClick:()=>window.location.reload(),push:!0})),r.append(N),L=[],r;let ft=A(Ce?"Try again":K?"Downloaded":"Download my copy","download",{onClick:Yt});if(N.append(ft),e==="refused"){let p=A(h==="overwrite"?"Saving\u2026":R?"Try again":"Keep mine","keep",{onClick:Vt});p.setDisabled(h==="overwrite"),N.append(p,A(b?"Yes, drop my edits":"Accept theirs","accept",{variant:"primary",onClick:qt,push:!0}))}else{if(e==="replaced"){let p=M().hasPendingApply(),F=A(p?"Finishing the incoming edit\u2026":h==="revert"?"Putting back\u2026":"Revert to mine","revert",{onClick:Ft});F.setDisabled(p||h==="revert"),N.append(F)}N.append(A("Accept theirs","accept",{variant:"primary",onClick:Nt,push:!0}))}if(r.append(N),e==="replaced")if(Y)r.append(Et(t));else{let p=g("div",["all:initial","display:flex","align-items:center","gap:8px",`border-top:1px solid ${l.line}`,"padding:8px 10px 8px 16px",`color:${l.muted}`,`font:13px/1.5 ${W}`]),F=g("span",["all:initial","display:inline-flex","margin-left:auto"]);F.append(_(V("See the edits",{small:!0,onClick:lt,theme:a,parts:["conflict.button"],labelParts:["conflict.buttonLabel"]}),"list")),p.append(g("span",["all:initial","font:inherit","color:inherit"],H(t.length,"edit")),F),r.append(p)}L=n.map(p=>p.id);for(let p of t)ne.add(p.id);return r}function Et(e){let t=Le(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`],{theme:a,parts:["conflict.well","conflict.list"]}),n=g("div",["all:initial","position:sticky","top:0","z-index:1","display:flex","align-items:center","gap:8px","padding:8px 12px",`background:${l.sunk}`,`border-bottom:1px solid ${l["line-2"]}`,`color:${l.muted}`,`font:600 10.5px/1 ${ee}`,"letter-spacing:.12em","text-transform:uppercase"]),o=g("span",["all:initial","display:inline-flex","margin-left:auto"]);return o.append(_(V("Hide",{small:!0,variant:"quiet",onClick:lt,theme:a,parts:["conflict.button"],labelParts:["conflict.buttonLabel"]}),"list")),n.append(g("span",["all:initial","font:inherit","color:inherit","letter-spacing:inherit","text-transform:inherit"],"Replaced edits"),o),t.append(n),e.forEach((i,s)=>t.append(Pt(i,s))),P=t,t}function Ne(e){let t=e.context?.label||e.name||(e.context?.kind==="entry"?"Entry":"Edit");return e.context?.field?`${t} \xB7 ${e.context.field}`:t}var St={"content-changed":"the page changed there","structure-changed":"the structure changed there","target-detached":"that part of the page is gone","duplicate-id":"another part of the page now has the same id",protected:"that region keeps its own history",unsupported:"this kind of step cannot be put back"},Lt=e=>St[e]||"the page changed there";function Rt(e,t){let n=Array.isArray(e)?e:[];for(let o of n){if(!o||o.kind!=="text"&&o.kind!=="value")continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}for(let o of n){if(!o||o.kind!=="add"&&o.kind!=="remove")continue;let i=Array.isArray(o.nodes)?o.nodes.find(s=>typeof s?.html=="string"&&s.html):null;if(i)return{text:He(i.html).replace(/\s+/g," ").trim(),id:o.parent?.id??null}}for(let o of n){if(!o)continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}return{text:"",id:null}}function Dt(e){if(e==null||typeof document>"u")return"";let t=window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/["\\]/g,"\\$&"),n=null;try{n=document.querySelector(`[data-id="${t}"]`)}catch{return""}if(!n)return"";let o=n.matches?.("input, textarea, select")?n.value:null;return(typeof o=="string"?o:n.textContent??"").replace(/\s+/g," ").trim()}function zt(e){let t=e?.payload&&typeof e.payload=="object"?e.payload:{},n=String(e?.key??""),o={id:e?.id,revision:e?.revision,record:e,kind:e?.kind??"conflict"};if(n.startsWith("app:"))return{...o,name:typeof t.label=="string"&&t.label?t.label:n.slice(4),sentence:"",yours:typeof t.text=="string"?t.text:"",now:""};let i=t.direction==="redo"?"redo":"undo",f=((Array.isArray(t.context)?t.context:[]).find(J=>typeof J?.label=="string"&&J.label)??null)?.label||typeof t.label=="string"&&t.label||"Edit",C=Rt(t.steps,i);return{...o,name:f,sentence:`The ${i} of "${f}" was not applied because ${Lt(t.code)}.`,yours:C.text,now:C.id==null?"":Dt(C.id)}}function Mt(e){let t=_e();if(!e.record||typeof t?.reviewActionsFor!="function")return[];try{return(t.reviewActionsFor(e.record)||[]).filter(n=>n&&typeof n.run=="function"&&n.label)}catch{return[]}}var tt=e=>({before:"",hit:e,after:"",cutBefore:!1,cutAfter:!1});function nt(e){let t=u("div",["display:block","padding:8px 12px 10px"],void 0,{theme:a,parts:["conflict.row"],role:null}),n=u("div",["display:flex","align-items:center","gap:8px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"],void 0,{theme:a,parts:["conflict.location"],role:null});if(n.append(u("span",[],Ne(e))),t.append(n),e.sentence&&t.append(u("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],e.sentence)),e.yours){let i=u("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${ee}`,...e.sentence?["margin-top:4px"]:[]]);i.append(...ve("Yours",tt(e.yours),{mine:!0})),e.now&&i.append(...ve("Now",tt(e.now),{mine:!1})),t.append(i)}let o=g("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","margin-top:8px"]);return Mt(e).forEach((i,s)=>{let r=A(i.label,`run:${e.id}:${s}`,{onClick:()=>Wt(e,i,r)});o.append(r)}),o.append(A(we===e.id?"Copied":"Copy",`copy:${e.id}`,{onClick:()=>Kt(e)})),o.append(A("Dismiss",`dismiss:${e.id}`,{onClick:()=>st(e)})),t.append(o),t}function Bt(e){e.append(E($.length?"These copies were replaced before this page loaded. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.":"These copies were kept because an undo could not be put back or the page set them aside. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.")),ae&&e.append(E("That action did not run. The copy is still here."));let t=Le(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`],{theme:a,parts:["conflict.well","conflict.list"]});for(let o of $)for(let i of o.conflicts)t.append(nt(i));for(let o of v)t.append(nt(o));P=t,e.append(t);let n=j(g("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]),["conflict.actions"]);($.some(o=>o.root)||v.length)&&n.append(A(K?"Downloaded":"Download my copy","download",{onClick:Ut})),e.append(n),L=[]}function ve(e,t,{mine:n}){let o=[u("span",[`color:${l.faint}`,`font-family:${W}`],e,{theme:a,parts:["conflict.valueLabel"],role:null})],i=u("span",["display:-webkit-box","-webkit-line-clamp:2","-webkit-box-orient:vertical","overflow:hidden","overflow-wrap:anywhere",...n?[`color:${l.ink}`]:[`color:${l.muted}`]],void 0,{theme:a,parts:[n?"conflict.mine":"conflict.theirs","conflict.value"],role:null}),s=(t.cutBefore?"\u2026":"")+t.before+t.hit+t.after+(t.cutAfter?"\u2026":"");i.title=s,t.before&&i.append(u("span",[`color:${l.faint}`],(t.cutBefore?"\u2026":"")+t.before,{theme:a,parts:["conflict.before"],role:null}));let r=u("span",n?[`background:color-mix(in srgb, ${I} 18%, transparent)`,"padding:0 4px"]:t.before||t.after?["text-decoration:underline",`text-decoration-color:color-mix(in srgb, ${I} 70%, transparent)`,"text-underline-offset:3px"]:[],t.hit||"(empty)",{theme:a,parts:["conflict.value"],role:null});return i.append(r),t.after&&i.append(u("span",[`color:${l.faint}`],t.after+(t.cutAfter?"\u2026":""),{theme:a,parts:["conflict.after"],role:null})),o.push(i),o}function Pt(e,t){let n=Ke(e),o=u("div",["display:block","padding:8px 12px 10px",...t?[`border-top:1px solid ${l.line}`]:[]],void 0,{theme:a,parts:["conflict.row"],role:null}),i=u("div",["display:flex","align-items:center","gap:4px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"],void 0,{theme:a,parts:["conflict.location"],role:null});if(i.append(u("span",[],n.name)),n.target&&n.target.isConnected&&i.append(_(_t(n),`eye:${e.id}`)),o.append(i),n.sentence&&o.append(u("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],n.sentence)),Q.has(e.id)&&o.append(u("div",["display:block","font-size:13px","margin-top:4px",`color:${I}`],Q.get(e.id))),n.yours){let s=u("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${ee}`,...n.sentence?["margin-top:4px"]:[]]);s.append(...ve("Yours",n.yours,{mine:!0})),n.now&&s.append(...ve("Now",n.now,{mine:!1})),o.append(s)}return o}function _t(e){let t=["all:initial","color-scheme:inherit","box-sizing:border-box","cursor:pointer","display:inline-grid","place-items:center","width:22px","height:20px",`color:${l.ink}`],n=g("button",t);n.type="button",n.innerHTML=qe.conflictEye,je(n.firstElementChild,16),n.setAttribute("aria-label",`Show ${e.name} on page`),n.title="Show on page";let o=["button","conflict.button"];de(n,a,o);let i=s=>{n.style.cssText="";let r=te(a)?[...t,...ce(a,o,{}),...s]:[...t,...s];for(let f of r){let C=f.indexOf(":");n.style.setProperty(f.slice(0,C),f.slice(C+1),"important")}};return n.addEventListener("pointerenter",()=>i([`background:color-mix(in srgb, ${I} 16%, transparent)`])),n.addEventListener("pointerleave",()=>i([])),n.addEventListener("focus",()=>i([`outline:2px solid ${l.brass}`,"outline-offset:1px"])),n.addEventListener("blur",()=>i([])),n.addEventListener("click",()=>It(e.target)),n}var S=null,be=null,ke=null;function $e(){clearTimeout(be),window.removeEventListener("scroll",oe,!0),window.removeEventListener("resize",oe),S?.remove(),S=null,ke=null}function oe(){if(!S||!ke)return;let e=ke.getBoundingClientRect();T(S,"left",`${e.left}px`),T(S,"top",`${e.top}px`),T(S,"width",`${e.width}px`),T(S,"height",`${e.height}px`)}function It(e){if($e(),!e||!e.isConnected)return;let n=!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",o=c?.getBoundingClientRect().top??0,i=c&&o>0?Math.max(0,window.innerHeight-o):0;if(!i)e.scrollIntoView?.({block:"center",behavior:n});else{e.scrollIntoView?.({block:"center",behavior:"instant"});let s=e.getBoundingClientRect(),r=window.innerHeight-i,f=s.height>r-24?s.top-12:s.top+s.height/2-r/2;window.scrollBy?.({top:f,behavior:n})}ke=e,S=j(g("div",["all:initial","color-scheme:inherit","position:fixed","pointer-events:none","z-index:2147483001",`outline:2px solid ${I}`,"outline-offset:3px",`background:color-mix(in srgb, ${I} 14%, transparent)`]),["conflict.previewRing"]),document.body.appendChild(S),oe(),window.addEventListener("scroll",oe,!0),window.addEventListener("resize",oe),be=setTimeout($e,2500)}function Ot(){O||(w="panel",D="title",y())}function at(){$e(),w="bar",x(),D="review",y()}function lt(){Y=!Y,Y&&B.clear(),y()}function Nt(){let e=M(),t=L.filter(n=>{let o=e?.get(n);return o&&!o.claimedBy});e&&t.length&&e.acknowledge(t,{reason:"accepted"}),w=Oe()?"bar":"hidden",D="review",d()}async function Ft(){let e=M();if(h||!e||e.hasPendingApply())return;let t=L.filter(r=>{let f=e.get(r);return f&&!f.claimedBy});if(!t.length)return;h="revert",y();let n=!0,o=r=>{n=!!c?.contains(r.target)};document.addEventListener("focus",o,!0);let i;try{let{revertConflicts:r}=await import("./c-QL4NYM2L.js");i=await r(t)}catch(r){console.error("[clay] Revert to mine did not finish",r),i={revertedIds:[],blockedIds:t,saveResult:null}}finally{document.removeEventListener("focus",o,!0)}h=null;for(let r of i.blockedIds)Q.set(r,M()?.get(r)?.kind==="json"?vt:xt);w=Oe()?"bar":"hidden",D=n?"review":null;let s=i.saveResult&&(i.saveResult.ok||i.saveResult.msg==="Save already in progress");i.revertedIds.length&&s?Ee(`Put back ${H(i.revertedIds.length,"change")}. Saving.`):y()}var Z=null;async function Yt(){let e=M(),t=m?e?.list()??[]:L.map(o=>e?.get(o)).filter(Boolean),n=await We(t,{refused:!!m});Ce=!n,K=n,clearTimeout(Z),n&&(Z=setTimeout(()=>{K=!1,d()},1200)),y()}async function U(){let e=null;if(De())try{e=await Je()}catch{e=null}let t=_e(),n=null;if(t)try{n=await t.kept()}catch{n=null}let o=!1;if(e?.ok?($=e.records,o=!0):!De()&&$.length&&($=[],o=!0),n?.ok){let i=(Array.isArray(n.records)?n.records:[]).filter(r=>r&&r.supported!==!1).map(zt);i.length===v.length&&i.every((r,f)=>r.id===v[f].id&&r.revision===v[f].revision)||(o=!0),v=i}else n&&v.length&&(v=[],o=!0);o&&d()}async function Ht(e){try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("clay",Se),t.style.setProperty("position","fixed","important"),t.style.setProperty("opacity","0","important"),document.body?.append(t),t.select();let n=!1;try{n=document.execCommand?.("copy")===!0}catch{}return t.remove(),n}async function Kt(e){let t=e.record?e.yours:`${Ne(e)}
|
|
2
|
+
|
|
3
|
+
Yours:
|
|
4
|
+
${e.yours}
|
|
5
|
+
|
|
6
|
+
Now:
|
|
7
|
+
${e.now}`;if(!await Ht(t)){Ee("Could not copy. Select the text instead.");return}we=e.id,clearTimeout(ye),ye=setTimeout(()=>{we=null,d()},1200),y()}async function Ut(){let e=$.find(o=>o.root),t=[];for(let o of $)for(let i of o.conflicts)t.push({id:i.id,kind:i.kind,name:Ne(i),yours:i.yours,now:i.now,sentence:i.sentence});for(let o of v)t.push({id:o.id,kind:o.kind,name:o.name,yours:o.yours,now:o.now,sentence:o.sentence});let n=await Ue({html:e?.root??null,edits:t});Ce=!n,K=n,clearTimeout(Z),n&&(Z=setTimeout(()=>{K=!1,d()},1200)),y()}async function st(e){let t;try{t=e.record?await _e()?.dismissKept(e.id,{revision:e.revision}):await et([e.id]),t||={ok:!1}}catch{t={ok:!1}}t.ok||Ee("That copy could not be dismissed."),await U(),d()}var ze=new Set;async function Wt(e,t,n=null){if(!ze.has(t)){ze.add(t),n&&(n.disabled=!0,n.setAttribute("aria-busy","true")),ae=!1;try{let o=null;try{o=await t.run(e.record)}catch{o=null}if(o?.ok===!0&&o?.dismiss===!0){await st(e);return}ae=o?.ok!==!0,await U(),d()}finally{ze.delete(t),n&&n.isConnected&&(n.disabled=!1,n.removeAttribute("aria-busy"))}}}function ct(e){e?.detail?.ok===!0&&(ae=!1,U(),d())}function x(){clearTimeout(fe),fe=null,b=null}async function Vt(){if(h)return;let e=++ge;h="overwrite",R=!1,x(),y();let t;try{t=await window.clay?.save?.overwrite?.()}catch{t={ok:!1}}e!==ge||h!=="overwrite"||(!t?.ok&&q()&&(h=null,R=!0),d())}function qt(){if(!b){b={refusalGeneration:Me,ledgerRevision:he,dirtyGeneration:Re().gen},Be=Date.now(),z=!1,clearTimeout(fe),fe=setTimeout(()=>{x(),d()},ht),y();return}if(Date.now()-Be<mt)return;let e=b;Xe({isCurrent:()=>b===e&&e.refusalGeneration===Me&&e.ledgerRevision===he&&e.dirtyGeneration===Re().gen,reload:()=>window.location.reload()})||(x(),z=!0,y())}function Ee(e){k=e,clearTimeout(X),X=setTimeout(()=>{k=null,d()},gt),y()}function Gt(){U(),d()}function dt(){he++,b&&x();for(let e of[...Q.keys()])M()?.get(e)||Q.delete(e);U(),d()}function pt(e){O=e?.detail&&e.detail.message||"This document was upgraded.",k=null,clearTimeout(X),x(),h=null,R=!1,z=!1,w="bar",d()}function ut(e){let t=e?.detail||{};m={generation:++Me,changedBy:t.changedBy,afterTimeout:!!t.afterTimeout,etag:t.etag??null},k=null,clearTimeout(X),x(),h=null,R=!1,ge++,z=!1,d()}function Pe(e){if(q()){e.type==="clay:save-saved"&&queueMicrotask(()=>{q()||Pe(e)});return}let t=h==="overwrite"&&e.type==="clay:save-saved";(m||h)&&(m=null,h=null,R=!1,z=!1,x()),t?Ee("Saved your version over theirs."):d()}function jt(){m&&(ie=!0,d())}function Qt(){!m||q()||(m=null,h=null,R=!1,z=!1,x(),d())}function Xt(e){if(e.key!=="Escape")return;if(b){e.preventDefault(),x(),y();return}if(w!=="panel")return;let t=document.activeElement;t&&t!==document.body&&!c?.contains(t)||(e.preventDefault(),at())}function Zt(e){!b||c?.contains(e.target)||(x(),d())}function Jt(e){k&&D&&!c?.contains(e.target)&&(D=null)}function en(){Ae=new AbortController;let{signal:e}=Ae;document.addEventListener("clay:document-upgraded",pt,{signal:e}),Ye&&(document.addEventListener("clay:sync-conflicts-changed",dt,{signal:e}),document.addEventListener("clay:unsaved-state-changed",d,{signal:e}),document.addEventListener("clay:save-conflict",ut,{signal:e}),document.addEventListener("clay:save-saved",Pe,{signal:e}),document.addEventListener("clay:save-conflict-resolved",Pe,{signal:e}),document.addEventListener("clay:sync-applied",jt,{signal:e}),document.addEventListener("clay:save-conflict-released",Qt,{signal:e}),document.addEventListener("keydown",Xt,{signal:e}),document.addEventListener("input",Zt,{capture:!0,signal:e}),document.addEventListener("focus",Jt,{capture:!0,signal:e}),document.addEventListener("clay:conflict-store-changed",Gt,{signal:e}),document.addEventListener("clay:undo-kept",ct,{signal:e}),M()?.size&&d(),U(),Promise.resolve(window.clay?.ready).catch(()=>{}).then(()=>{e.aborted||U()}))}var tn={"clay:sync-conflicts-changed":dt,"clay:save-conflict":ut,"clay:document-upgraded":pt,"clay:undo-kept":ct},Te=!1,Ae=null;function gn(e){Te||(Te=!0,en());let t=e&&tn[e.type];t&&t(e),m&&(ie=!0,d())}function mn(){Te&&(Te=!1,Ae?.abort(),Ae=null,x(),clearTimeout(X),X=null,clearTimeout(Z),Z=null,clearTimeout(ye),ye=null,clearTimeout(be),be=null,$e(),window.visualViewport?.removeEventListener("resize",le),window.visualViewport?.removeEventListener("scroll",le),c?.remove(),c=null,G=new Map,P=null,re=null,w="hidden",Y=!1,L=[],ne.clear(),B.clear(),Q.clear(),k=null,m=null,O=null,h=null,R=!1,ge++,b=null,Be=0,z=!1,$=[],v=[],ae=!1,ue=!1,ie=!1,D=null,me=null,K=!1,Ce=!1,we=null)}var wn={state:()=>({view:w,listOpen:Y,renderedIds:L.slice(),refused:m,armed:b,busy:h,ledgerRevision:he,upgraded:O}),render:y,resetUpgrade:()=>{O=null}};export{I as WARN,wn as _test,d as schedule,gn as start,mn as stop,Ee as toast};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a}from"./c-PZ4XEPUP.js";import{L as u}from"./c-
|
|
1
|
+
import{b as a}from"./c-PZ4XEPUP.js";import{L as u}from"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import{i as s}from"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d=20,i=null,l=!1,c=[];function h(){i||l||(l=!0,import("./c-OIDRZKAF.js").then(e=>{i=e,l=!1,f()},e=>{l=!1,console.error("clayjs: the conflict recovery module could not be downloaded; conflicts stay in this tab only",e)}))}function f(){if(!i){h();return}for(;c.length;){let e=c.shift();try{i.recordConflicts(e)}catch(o){console.error("clayjs: the conflict could not be stored for a later reload; it is still here",o)}}}function m(e,o){let t=null;try{t=a(e)}catch{}let n=r=>r?(r.cutBefore?"\u2026":"")+r.before+r.hit+r.after+(r.cutAfter?"\u2026":""):"";return{id:String(e.id),kind:String(e.kind??""),key:e.recovery?.key==null?"":String(e.recovery.key),name:t?.name?String(t.name):"",sentence:t?.sentence?String(t.sentence):"",yours:n(t?.yours),now:n(t?.now),context:o}}function y(e){try{let t=(e.recoveryRoot??e.root)?.cloneNode?.(!0);if(!t)return null;for(let n of s)t.removeAttribute(n);return u(t,{prepared:e.domain==="save"})}catch(o){return console.error("clayjs: the conflict recovery page could not be serialized; the conflict text is still stored",o),null}}function k({apply:e,records:o}){try{c.push({apply:{id:e.id,source:e.source,domain:e.domain,seq:e.seq,etag:e.etag,ticket:e.ticket},root:y(e),conflicts:o.map(({rec:t,context:n})=>m(t,n))}),c.length>d&&c.shift(),f()}catch(t){console.error("clayjs: the conflict could not be stored for a later reload; it is still here",t)}}function A(e){import("./c-OIDRZKAF.js").then(o=>o.dismissConflicts(e),()=>{}).catch(()=>{})}export{A as dismiss,k as keep};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{w as T}from"./c-
|
|
1
|
+
import{w as T}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{d as g}from"./c-3Y234AUB.js";import{d as f,l as M,n as b}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{e as x}from"./c-RETTCOWO.js";import{a as k}from"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var $="blockeditor-step",l=t=>x.closeHistory(t).setMeta($,!0),y=(t,e)=>!!t&&Object.keys(t.type.attrs).every(r=>t.attrs[r]===e[r]);function C(t,e,r){let o=t.state,{from:n,to:a,empty:u,$from:s}=o.selection,c=o.tr;if(u)y(e.isInSet(o.storedMarks||s.marks()),r)?c.removeStoredMark(e):c.addStoredMark(e.create(r));else{let i=!0;o.doc.nodesBetween(n,a,h=>{i&&h.isText&&!y(e.isInSet(h.marks),r)&&(i=!1)}),i?c.removeMark(n,a,e):c.addMark(n,a,e.create(r))}return t.dispatch(l(c)),!0}function F(t,e){let r=t.state,o=r.tr;return r.selection.empty?o.removeStoredMark(e):o.removeMark(r.selection.from,r.selection.to,e),t.dispatch(l(o)),!0}function p(t,e){let r=t.runFormatCommand;return typeof r!="function"?Promise.resolve({status:"unsupported-host",code:"blockeditor-format-unsupported",retry:!1}):r(e)}function A(t,e,r={},{reset:o=!1}={}){let n=f.marks[e];return n?t.editable?b(t.state,n)?p(t,()=>o?F(t,n):C(t,n,r)):Promise.resolve({status:"refused",code:"mark-not-allowed"}):Promise.resolve({status:"refused",code:"not-editable"}):Promise.resolve({status:"refused",code:"unsupported-format"})}function B(t,e,r,o){let n=t.state.doc,a=()=>{if(t.isDestroyed)return!1;let s=t.state;return s.selection.from!==r||s.selection.to!==o?!1:(t.dispatch(s.tr.replaceSelection(e).scrollIntoView()),!0)},u=()=>{let s=e.content.textBetween(0,e.content.size,`
|
|
2
2
|
`," ");return!t.isDestroyed&&s&&t.state.doc===n&&t.dispatch(t.state.tr.insertText(s,r,o)),!1};p(t,a).then(s=>{s?.status!=="applied"&&(m(t,s?.message??"That format isn\u2019t available here."),u())},u)}function H(t,e,{at:r,from:o,to:n},a){let u=()=>{if(e.isDestroyed)return!1;let s=e.state,c=s.doc.nodeAt(r);if(!c||c.type!==f.nodes.paragraph||c.textContent!=='"')return a();let i=s.tr.delete(r+1,r+2).setNodeMarkup(r,f.nodes.quote,c.attrs);return e.dispatch(l(i.setMeta(t,{transform:i,from:o,to:n,text:" "}))),!0};e.runFormatCommand(u).then(s=>{s?.status!=="applied"&&(s&&m(e,S(s)),a())},a)}var N="This text can\u2019t take that format.",S=t=>t.status==="upgrade-required"?t.message:t.code==="mark-not-allowed"?N:"That format isn\u2019t available here.",m=(t,e)=>{t.isDestroyed||(g(t,e),k(e,"error"))},P=(t,e)=>{e?.status!=="applied"&&m(t,S(e??{}))},d=(t,e,r={},o=void 0)=>{A(t,e,r,o).then(n=>P(t,n))},O=(t,e)=>{p(t,e).then(r=>P(t,r))};function j(t,e,r){if(e==="underline")return d(t,e);let o=e==="text_color"?"Text":"Highlight",n=e==="text_color"?"Automatic":"No highlight";return T(t,r,[...M.map(a=>({key:`${e}_${a}`,label:`${o}: ${a[0].toUpperCase()}${a.slice(1)}`,icon:"\u25CF",run:u=>d(u,e,{color:a})})),{key:`${e}_none`,label:n,icon:"\xD7",run:a=>d(a,e,{},{reset:!0})}])}export{A as formatMark,O as gateTurn,j as nativeMenu,B as pasteFormats,H as quoteFromSpace,m as refuse,p as runFormat,d as runNative};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as K}from"./c-
|
|
1
|
+
import{b as K}from"./c-A3OKSYRI.js";import{d as h}from"./c-3Y234AUB.js";import{d as w,z as C}from"./c-OH2FPYSY.js";import{c as O}from"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var z=`
|
|
2
2
|
:where(article[data-blockeditor], .blockeditor-shell) { --blockeditor-board-lane: 274px; --blockeditor-board-gap: 14px; --blockeditor-board-radius: 8px; --blockeditor-board-panel: 360px; }
|
|
3
3
|
.blockeditor-editor .blockeditor-board { margin-block: 1.1em 1.5em; font-size: 15px; line-height: 1.4; white-space: normal; }
|
|
4
4
|
:is(.blockeditor-board, .blockeditor-board-panel) .i { flex: none; width: 16px; height: 16px; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as A,e as I}from"./c-EQ5NBOGA.js";import{f as b,j as T}from"./c-C7SUMNMI.js";import{c as M}from"./c-BPF2NSPV.js";var B=15e3,P=12e4,K=15e3,V=4e3,W=5e3,U=50,y=new Set(["sent","acked"]),R=new Set(["done","error","cancelled"]),j="wire",a=new Map,k=new Set,f=null,g=null,D=0,h=null;function Q(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`page-${Date.now()}-${Math.random().toString(16).slice(2)}`}function H(e){return new URL(e,window.location.origin).href}function N(){let e=M();return typeof e=="string"&&e!==""?e:null}function w(e){return{id:e.id,type:e.type,state:e.state,helper:e.helper,text:e.text,result:e.result,error:e.error,errorCode:e.errorCode,errorDetails:e.errorDetails,errorSource:e.errorSource,startedAt:e.startedAt}}function m(e,t){let n=w(e);for(let r of k)try{r(n,t||null)}catch(s){console.error("clay.wire: a listener threw",s)}document.dispatchEvent(new CustomEvent("clay:wire-state",{detail:n}))}function Y(e,t){e.state!==t&&(e.state=t,m(e))}function v(e,t,n,{cancelFirst:r=!1,errorCode:s=null}={}){clearTimeout(e.timer),e.timer=setTimeout(()=>{e.timer=null,r&&z(e),l(e,"error",n,{errorCode:s,errorSource:"client"})},t)}function q(e){clearTimeout(e.timer),e.timer=null}function Z(){if(!(a.size<=U))for(let[e,t]of a){if(a.size<=U)break;!y.has(t.state)&&t.state!=="landing"&&a.delete(e)}}function ee(){if(g)return g;let e=N(),t=`/_/wire/subscribe?page-url=${encodeURIComponent(window.location.href)}`+(e?`&token=${encodeURIComponent(e)}`:"");return f=new EventSource(H(t)),f.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch{return}te(r)},f.onerror=()=>{},g=new Promise(n=>{let r=!1,s=()=>{r||(r=!0,n())};f.onopen=s,setTimeout(s,2e3)}),g}function L(){for(let e of a.values())if(y.has(e.state))return;f&&(f.close(),f=null,g=null)}function te(e){if(!e||typeof e.id!="string")return;let t=a.get(e.id);if(!(!t||!y.has(t.state)))switch(e.type){case"wire/ack":e.payload?.mode==="jsonl"&&Number.isFinite(e.payload.budgetMs)&&e.payload.budgetMs>0?(t.structured=!0,v(t,e.payload.budgetMs+K,"the helper did not finish within its execution budget",{cancelFirst:!0,errorCode:"helper_timeout"})):v(t,P,"the agent stopped responding"),Y(t,"acked");break;case"wire/status":t.structured||v(t,P,"the agent stopped responding"),t.text=typeof e.text=="string"?e.text:"",t.state="acked",ne(t,e),m(t,e);break;case"wire/done":t.result=Object.prototype.hasOwnProperty.call(e,"payload")?e.payload:null,t.document==="edit"?ie(t):l(t,"done",null);break;case"wire/error":re(t,e);break;default:break}}function ne(e,t){if(!e.onStatus||typeof t.text!="string")return;let n={text:t.text};t.payload&&typeof t.payload=="object"&&Object.prototype.hasOwnProperty.call(t.payload,"progress")&&(n.progress=t.payload.progress);try{e.onStatus(n)}catch(r){console.error("clay.wire: an onStatus listener threw",r)}}function re(e,t){let n=t.payload,r=n&&typeof n=="object"&&!Array.isArray(n)&&(n.source==="application"||n.source==="host")&&typeof n.code=="string"&&n.code,s=typeof t.text=="string"&&t.text?t.text:"the handler reported an error";if(!r){l(e,"error",s);return}let i=n.source==="host"&&n.code==="helper_cancelled"?"cancelled":"error";l(e,i,s,{errorCode:n.code,errorDetails:Object.prototype.hasOwnProperty.call(n,"details")?n.details:null,errorSource:n.source})}function oe(){h||(h=e=>{if(e.detail?.source!=="peer"){for(let t of a.values())if(t.state==="landing"){l(t,"done",null);return}}},document.addEventListener("clay:sync-applied",h))}function se(){D>0||!h||(document.removeEventListener("clay:sync-applied",h),h=null)}function ie(e){R.has(e.state)||e.state==="landing"||(q(e),e.state="landing",D++,oe(),e.landingTimer=setTimeout(()=>{l(e,"done",null)},V),m(e),L())}function l(e,t,n,r={}){if(R.has(e.state))return;let s=e.state==="landing";if(q(e),clearTimeout(e.landingTimer),e.landingTimer=null,e.abort?.abort(),s&&(D--,se()),e.error=n,Object.prototype.hasOwnProperty.call(r,"errorCode")&&(e.errorCode=r.errorCode),Object.prototype.hasOwnProperty.call(r,"errorDetails")&&(e.errorDetails=r.errorDetails),Object.prototype.hasOwnProperty.call(r,"errorSource")&&(e.errorSource=r.errorSource),e.state=t,e.signal&&e.signalHandler&&(e.signal.removeEventListener("abort",e.signalHandler),e.signalHandler=null),ue(e),m(e),L(),Z(),e.settle){let i=e.settle;e.settle=null,i(w(e))}}var C=0,$=null,E=null;function ae(){return E||(E=import("./core/save-
|
|
1
|
+
import{d as A,e as I}from"./c-EQ5NBOGA.js";import{f as b,j as T}from"./c-C7SUMNMI.js";import{c as M}from"./c-BPF2NSPV.js";var B=15e3,P=12e4,K=15e3,V=4e3,W=5e3,U=50,y=new Set(["sent","acked"]),R=new Set(["done","error","cancelled"]),j="wire",a=new Map,k=new Set,f=null,g=null,D=0,h=null;function Q(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`page-${Date.now()}-${Math.random().toString(16).slice(2)}`}function H(e){return new URL(e,window.location.origin).href}function N(){let e=M();return typeof e=="string"&&e!==""?e:null}function w(e){return{id:e.id,type:e.type,state:e.state,helper:e.helper,text:e.text,result:e.result,error:e.error,errorCode:e.errorCode,errorDetails:e.errorDetails,errorSource:e.errorSource,startedAt:e.startedAt}}function m(e,t){let n=w(e);for(let r of k)try{r(n,t||null)}catch(s){console.error("clay.wire: a listener threw",s)}document.dispatchEvent(new CustomEvent("clay:wire-state",{detail:n}))}function Y(e,t){e.state!==t&&(e.state=t,m(e))}function v(e,t,n,{cancelFirst:r=!1,errorCode:s=null}={}){clearTimeout(e.timer),e.timer=setTimeout(()=>{e.timer=null,r&&z(e),l(e,"error",n,{errorCode:s,errorSource:"client"})},t)}function q(e){clearTimeout(e.timer),e.timer=null}function Z(){if(!(a.size<=U))for(let[e,t]of a){if(a.size<=U)break;!y.has(t.state)&&t.state!=="landing"&&a.delete(e)}}function ee(){if(g)return g;let e=N(),t=`/_/wire/subscribe?page-url=${encodeURIComponent(window.location.href)}`+(e?`&token=${encodeURIComponent(e)}`:"");return f=new EventSource(H(t)),f.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch{return}te(r)},f.onerror=()=>{},g=new Promise(n=>{let r=!1,s=()=>{r||(r=!0,n())};f.onopen=s,setTimeout(s,2e3)}),g}function L(){for(let e of a.values())if(y.has(e.state))return;f&&(f.close(),f=null,g=null)}function te(e){if(!e||typeof e.id!="string")return;let t=a.get(e.id);if(!(!t||!y.has(t.state)))switch(e.type){case"wire/ack":e.payload?.mode==="jsonl"&&Number.isFinite(e.payload.budgetMs)&&e.payload.budgetMs>0?(t.structured=!0,v(t,e.payload.budgetMs+K,"the helper did not finish within its execution budget",{cancelFirst:!0,errorCode:"helper_timeout"})):v(t,P,"the agent stopped responding"),Y(t,"acked");break;case"wire/status":t.structured||v(t,P,"the agent stopped responding"),t.text=typeof e.text=="string"?e.text:"",t.state="acked",ne(t,e),m(t,e);break;case"wire/done":t.result=Object.prototype.hasOwnProperty.call(e,"payload")?e.payload:null,t.document==="edit"?ie(t):l(t,"done",null);break;case"wire/error":re(t,e);break;default:break}}function ne(e,t){if(!e.onStatus||typeof t.text!="string")return;let n={text:t.text};t.payload&&typeof t.payload=="object"&&Object.prototype.hasOwnProperty.call(t.payload,"progress")&&(n.progress=t.payload.progress);try{e.onStatus(n)}catch(r){console.error("clay.wire: an onStatus listener threw",r)}}function re(e,t){let n=t.payload,r=n&&typeof n=="object"&&!Array.isArray(n)&&(n.source==="application"||n.source==="host")&&typeof n.code=="string"&&n.code,s=typeof t.text=="string"&&t.text?t.text:"the handler reported an error";if(!r){l(e,"error",s);return}let i=n.source==="host"&&n.code==="helper_cancelled"?"cancelled":"error";l(e,i,s,{errorCode:n.code,errorDetails:Object.prototype.hasOwnProperty.call(n,"details")?n.details:null,errorSource:n.source})}function oe(){h||(h=e=>{if(e.detail?.source!=="peer"){for(let t of a.values())if(t.state==="landing"){l(t,"done",null);return}}},document.addEventListener("clay:sync-applied",h))}function se(){D>0||!h||(document.removeEventListener("clay:sync-applied",h),h=null)}function ie(e){R.has(e.state)||e.state==="landing"||(q(e),e.state="landing",D++,oe(),e.landingTimer=setTimeout(()=>{l(e,"done",null)},V),m(e),L())}function l(e,t,n,r={}){if(R.has(e.state))return;let s=e.state==="landing";if(q(e),clearTimeout(e.landingTimer),e.landingTimer=null,e.abort?.abort(),s&&(D--,se()),e.error=n,Object.prototype.hasOwnProperty.call(r,"errorCode")&&(e.errorCode=r.errorCode),Object.prototype.hasOwnProperty.call(r,"errorDetails")&&(e.errorDetails=r.errorDetails),Object.prototype.hasOwnProperty.call(r,"errorSource")&&(e.errorSource=r.errorSource),e.state=t,e.signal&&e.signalHandler&&(e.signal.removeEventListener("abort",e.signalHandler),e.signalHandler=null),ue(e),m(e),L(),Z(),e.settle){let i=e.settle;e.settle=null,i(w(e))}}var C=0,$=null,E=null;function ae(){return E||(E=import("./core/save-JZ7R4ET2.js")),E}async function le(e){if(!b||e.holdsSave)return;let t=await ae();e.state==="sent"&&($=t,e.holdsSave=!0,!(C++>0)&&t.suspendAutosave())}function ue(e){e.holdsSave&&(e.holdsSave=!1,!(--C>0)&&(C=0,$?.resumeAutosave()))}var c=null,de=()=>!c||c.admitted,ce=(e,t,n)=>Object.assign(new Error(`clay.wire: ${e}`),{code:t,pending:n});function O(e){return e.document!=="edit"||e.generation===T().generation&&de()?!0:(l(e,"error","the page changed mode before this request went out",{errorCode:"stale-document",errorSource:"client"}),!1)}function _e(){return{id:"clay:wire",order:900,prepare(e={}){let t={admitted:e.initial===!0};return c=t,{enable(){c===t&&(t.admitted=!0)},quiesce(){if(c!==t)return;t.admitted=!1;let n=[...a.values()].filter(r=>r.document==="edit"&&(r.holdsSave||y.has(r.state))).map(r=>r.id);if(n.length)throw ce("a request on this page has not settled","pending-input",n)},resume(){c===t&&(t.admitted=!0)},dispose(){c===t&&(c=null)}}}}}function fe(e,t){return new Promise(n=>{let r=!1,s=()=>{r||(r=!0,document.removeEventListener(e,s),n())};document.addEventListener(e,s),setTimeout(s,t)})}async function pe(){if(!b)return;let e=window.clay;if(!e||typeof e.save!="function")return;let{isSaveInProgress:t}=await import("./core/save-core-I4N6S4ED.js"),{savesHeld:n,saveHoldReason:r}=await import("./core/save-JZ7R4ET2.js");if(n())throw new Error(r());let s=Date.now()+W;for(let i=0;i<3;i++){t()&&await fe("clay:save-saved",Math.max(0,s-Date.now()));let u=await e.save();if(u?.ok||u?.msgType==="skipped"&&!t())return;if(u?.msgType==="error"||u?.msgType==="unknown")throw new Error(`could not save this page first: ${u.msg||u.msgType}`);if(Date.now()>=s)break}throw new Error("could not save this page before sending")}async function F(e,t){let n={"Content-Type":"application/json","Page-URL":window.location.href},r=N();r&&(n["Save-Token"]=r);let s=await fetch(H("/_/wire/send"),{method:"POST",headers:n,body:JSON.stringify(e),signal:t}),i=null;try{i=await s.json()}catch{i=null}return{ok:s.ok,status:s.status,reply:i}}function he(e,t={}){let n=typeof t.id=="string"&&t.id?t.id:Q(),r=typeof t.type=="string"&&t.type?t.type:"wire/request",s=Object.prototype.hasOwnProperty.call(t,"helper"),i=s&&typeof t.helper=="string"&&t.helper?t.helper:null,u=t.document===void 0?i?"none":"edit":t.document;if(s&&!i)return _(n,r,null,"helper must be a nonempty string","invalid_helper");if(u!=="edit"&&u!=="none")return _(n,r,i,'document must be "edit" or "none"',"invalid_document");if(a.has(n))return _(n,r,i,"a request with this id is already on the wire","duplicate_request");let o={id:n,type:r,state:"sent",helper:i,document:u,structured:!1,onStatus:typeof t.onStatus=="function"?t.onStatus:null,text:"",result:null,error:null,errorCode:null,errorDetails:null,errorSource:null,startedAt:Date.now(),timer:null,landingTimer:null,abort:typeof AbortController=="function"?new AbortController:null,holdsSave:!1,generation:T().generation,settle:null,signal:t.signal&&typeof t.signal.addEventListener=="function"?t.signal:null,signalHandler:null};return o.done=new Promise(d=>{o.settle=d}),a.set(n,o),m(o),o.signal&&(o.signalHandler=()=>x(n),o.signal.addEventListener("abort",o.signalHandler,{once:!0}),o.signal.aborted&&o.signalHandler()),(async()=>{if(o.state!=="sent")return;if(o.helper){let X=await I(j);if(o.state!=="sent")return;if(!X){l(o,"error","this host does not support named wire helpers",{errorCode:"helper_protocol_unsupported",errorSource:"client"});return}}if(!O(o)||o.document==="edit"&&(await le(o),o.state!=="sent"||!O(o)||(await pe(),o.state!=="sent")||!O(o)))return;if(await ee(),o.state!=="sent"){L();return}v(o,B,"the agent never answered",o.helper?{cancelFirst:!0,errorCode:"ack_timeout"}:void 0);let d={type:o.type,id:o.id,text:t.text,payload:e};o.helper&&(d.helper=o.helper),(o.helper||t.document!==void 0)&&(d.document=o.document);let{ok:G,status:J,reply:S}=await F(d,o.abort?.signal);if(o.state!=="sent")return;if(!G){l(o,"error",`the wire refused this request (${J})`);return}let p=S&&S.refused;if(p&&typeof p.code=="string"&&p.code){l(o,"error",p.message||"the handler refused this request",{errorCode:p.code,errorSource:p.source==="application"?"application":"host",errorDetails:null});return}(!S||S.delivered===0)&&l(o,"error",o.helper?`The local program "${o.helper}" is not connected to this file.`:"No program is connected to this file.")})().catch(d=>{l(o,"error",d&&d.message?d.message:String(d))}),{id:n,get state(){return o.state},done:o.done,cancel:()=>x(n)}}function _(e,t,n,r,s){let i={id:e,type:t,state:"error",helper:n,text:"",result:null,error:r,errorCode:s,errorDetails:null,errorSource:"client",startedAt:Date.now()};return{id:e,get state(){return i.state},done:Promise.resolve(w(i)),cancel:()=>!1}}function x(e){let t=a.get(e);return!t||!y.has(t.state)?!1:(z(t),l(t,"cancelled",null),!0)}function z(e){F({type:"wire/cancel",id:e.id}).catch(()=>{})}function ye(e){let t=a.get(e);return t?w(t):void 0}function ge(){return[...a.values()].map(w)}function we(){for(let e of a.values())if(y.has(e.state))return!0;return!1}function me(e){return typeof e!="function"?()=>{}:(k.add(e),()=>k.delete(e))}async function Se(){let e=await A({fresh:!0});if(!e.extensions.includes(j))return[];let t=e.document?.helpers;return Array.isArray(t)?t.filter(n=>n&&typeof n.name=="string"&&["ready","denied","unavailable"].includes(n.state)).map(({name:n,state:r})=>({name:n,state:r})):[]}var ve={send:he,cancel:x,get:ye,list:ge,isBusy:we,on:me,helpers:Se},ke=ve;export{_e as a,ve as b,ke as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"./c-EIDZHQHZ.js";import"./c-QY7F6EN6.js";import"./c-QHWJ5ZIJ.js";import"./c-J2ZW4HMR.js";import"./c-A5LASUEZ.js";import"./c-4JZDZFF6.js";import"./c-5RZNFTWD.js";import"./c-PKCCHJ5X.js";import"./c-46XYM55L.js";import"./c-NUHP2XDB.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{c as default,b as dismissPersistent,a as toastPersistent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"./c-
|
|
1
|
+
import{a,b}from"./c-2TJCFPX4.js";import"./c-Y6HH7LTM.js";import"./c-RHMPKZZ7.js";import"./c-VHNSBD2M.js";export{a as COPY,b as createRecovery};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a}from"./c-J2ZW4HMR.js";import{a as c}from"./c-4JZDZFF6.js";var s=e=>e.nodeType===1&&e.hasAttribute("data-clay-skin");function f(e){for(let t of e.childNodes)if(!s(t))return t;return null}function d(e,t){if(t.parentNode!==e)return!1;for(let n=t.previousSibling;n;n=n.previousSibling)if(!s(n))return!1;return!0}var u=new Map;function y(e){return`
|
|
2
2
|
@layer clay-skin{:is(${e.join(", ")}){color-scheme:${c()} !important}}`}function m(e,t,{roots:n}={}){u.set(e,{css:t,roots:n});let o=document.head||document.documentElement,i=null;for(let l of o.querySelectorAll("style[data-clay-skin]"))l.getAttribute("data-clay-skin")===e&&(i=l);i||(i=document.createElement("style"),i.setAttribute("clay",a),i.setAttribute("data-clay-skin",e));let r=n?t+y(n):t;return i.textContent!==r&&(i.textContent=r),d(o,i)||o.insertBefore(i,f(o)),i}typeof document<"u"&&document.addEventListener("clay:sync-applied",()=>{for(let[e,{css:t,roots:n}]of u)m(e,t,{roots:n})});export{m as a};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as me,b as pe,c as he}from"./c-SIM7Z3U7.js";import{a as de,b as fe}from"./c-OYW5MFPZ.js";import{a as F,b as U,c as ue}from"./c-H3FNLBHN.js";import{C as X,E as le,h as z,l as ce,m as Y}from"./c-AI3H6ETU.js";import{A as se,d as N,x as oe}from"./c-OH2FPYSY.js";import"./c-VPXCXBDT.js";import{b as $,c as ae,d as R}from"./c-Z6MROEQ4.js";import{b as ie}from"./c-Q26XHBLQ.js";import{a as H,b as V}from"./c-RETTCOWO.js";import{a as re}from"./c-3LDGIBMN.js";import"./c-VHNSBD2M.js";var ge=16384,we=i=>new TextEncoder().encode(JSON.stringify(i)).length,G=class extends Error{constructor(n,t=n){super(t),this.name="ToolRequestError",this.code=n}};function Oe(i){let n=re(i);for(Array.isArray(n.tables)||(n.tables=[]),Array.isArray(n.outline)||(n.outline=[]);we(n)>ge;){let t=[...n.tables].reverse().find(r=>Array.isArray(r.rows)&&r.rows.length);if(t)t.rows.pop();else if(n.outline.length)n.outline.pop();else break}if(we(n)>ge)throw new G("context-too-large");return n}var Me=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;function ve({transport:i,newId:n=Me}){let t=null,r=s=>{!s||s.discarded||s.done||(s.discarded=!0,t===s&&(t=null),i.cancel(s.requestId),s.resolve({requestId:s.requestId,code:"discarded",message:"Candidate discarded"}))};return{request(s,a,v=null,h=null){let o=Oe(a);t&&r(t);let m=n(),l={requestId:m,discarded:!1,done:!1};l.promise=new Promise(u=>{l.resolve=u}),t=l;let e={protocol:"blockeditor-tool/1",requestId:m,prompt:s,context:o,target:v,current:h};l.request=e;let f=u=>{if(!(l.discarded||l.done||u?.requestId!==m))if(l.done=!0,t===l&&(t=null),u?.artifact!==void 0){let g=F(u.artifact),d=U(u.state),p=g.ok?d.ok?null:d:g;l.resolve(p?{requestId:m,code:p.code,message:p.code}:u)}else l.resolve(typeof u?.code=="string"?u:{requestId:m,code:"invalid-result",message:"invalid-result"})};try{let u=g=>f({requestId:m,code:typeof g?.code=="string"?g.code:"transport-error",message:String(g?.message??g)});Promise.resolve(i.request(e)).then(f,u)}catch(u){f({requestId:m,code:typeof u?.code=="string"?u.code:"transport-error",message:String(u?.message??u)})}return l},discard:r,async wait(s,{signal:a}={}){if(a?.aborted)throw new DOMException("Aborted","AbortError");let v,h=await(a?Promise.race([s.promise,new Promise((o,m)=>{v=()=>m(new DOMException("Aborted","AbortError")),a.addEventListener("abort",v,{once:!0})})]).finally(()=>a.removeEventListener("abort",v)):s.promise);if(h?.code)throw new G(h.code,h.message);return h}}}var J=class extends Error{constructor(n){super(n),this.name="ToolTransportError",this.code=n}};function ye({getWire:i=()=>globalThis.window?.clay?.wire??null}={}){let n=new Map;return{request(t,{onStatus:r=null}={}){let s=i();if(!s||typeof s.send!="function")return Promise.reject(new J("no-wire"));let a=t?.requestId,v;try{v=s.send(t,{helper:"blockeditor-tool",document:"none",id:a,onStatus:r})}catch{return Promise.reject(new J("no-wire"))}return n.set(a,v),Promise.resolve(v.done).then(h=>{if(n.get(a)===v&&n.delete(a),h?.state==="done"){let o=h.result??{};return{requestId:typeof o.requestId=="string"?o.requestId:a,artifact:o.artifact,state:o.state,model:o.model}}return{requestId:a,code:h?.errorCode||(h?.state==="cancelled"?"cancelled":"transport-error"),message:h?.error||"the helper reported an error"}},()=>({requestId:a,code:"transport-error",message:"the helper reported an error"}))},cancel(t){let r=n.get(t);n.delete(t),r?.cancel?.()}}}var{Selection:Be}=V,W="This page is not open for editing any more.",Ie="AI tool making isn't available on this page right now.",Te="This document can't save tool data.",K="The place for this tool moved. Close this and run /ai where you want the tool.",be="This tool changed while you were revising, so nothing was replaced. Ask again.",Q="AI did not make a usable tool. Try again.",Ne="The tool data from AI is too large or not usable. Try again.",xe="This tool's data changed while AI was working, so it was not replaced. Ask again to include the latest data.",Ae="The tool could not be saved, so it was not added. Try again.",Re="Your tool is in the document, but saving failed. It will be saved with your next edit.";function _(i,n){let t=null;return i.forEach((r,s,a)=>{r.attrs.id===n&&(t={node:r,at:s,index:a})}),t}function Pe(i,n){let t=i.selection.$head,r=Math.min(Math.max(t.index(0),0),i.doc.childCount-1);return{hostId:i.doc.child(r)?.attrs.id??null,slashText:n?i.doc.textBetween(n.from,n.to):null,slashOffset:n&&t.depth?n.from-t.before(1)-1:null}}function Z(i,n){let t=n?.hostId?_(i.doc,n.hostId):null;if(!t)return null;let r=i.doc.maybeChild(t.index+1),s=t.node.isTextblock&&(t.node.content.size===0||t.node.textContent===n.slashText);return{...t,replace:s,pos:s?t.node.attrs.pos:oe(t.node.attrs.pos,r?.attrs.pos??null),insertAt:s?t.at:t.at+t.node.nodeSize}}function _e(i,n,t){let r=i.state,s=Z(r,t);if(!s)return!1;let{node:a,at:v,insertAt:h,replace:o}=s,m=N.nodes.tool.create({id:n.id,pos:s.pos,parent:a.attrs.parent??null,artifact:n.artifact,rev:n.rev,state:n.state}),l=r.tr;if(!o&&t?.hostId===a.attrs.id&&t.slashText&&t.slashOffset>=0){let f=v+1+t.slashOffset,u=f+t.slashText.length;u<=v+a.nodeSize-1&&r.doc.textBetween(f,u)===t.slashText&&l.delete(f,u)}let e=l.mapping.map(h);return l.replaceWith(e,o?l.mapping.map(v+a.nodeSize):e,m),l.setSelection(Be.near(l.doc.resolve(Math.min(e+m.nodeSize,l.doc.content.size)))),i.dispatch(X(l).scrollIntoView()),!0}var Se=()=>({x:0,y:0,left:0,top:0,right:0,bottom:0,width:0,height:0});function Ee({getView:i,store:n=()=>null,acceptState:t=()=>globalThis.clay?.save?.flush?.(),newId:r=se,transport:s=ye()}={}){let a=()=>{let e=i();return e&&!e.isDestroyed?e:null},v=()=>typeof n=="function"?n():n,h=(e,f)=>{let u=v()?.data?.[e]?.[f];return u===void 0?{}:u},o=new Map,m=e=>Array.isArray(e)?`[${e.map(m).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(u=>`${JSON.stringify(u)}:${m(e[u])}`).join(",")}}`:JSON.stringify(e)??"null";function l(e=null,f=null){let u=a(),g=e||!u?null:Pe(u.state,f),d=null,p=ve({transport:{request:c=>s.request(c,{onStatus:T=>d?.(T)}),cancel:c=>s.cancel(c)}}),b=null,w=null,y=null,M=!1,k=null,O=null,C=()=>{y?.host?.dispose(),y=null},L=()=>{let c=a();return c&&e?ie.get(c)?.get(e)??null:null},j=()=>L()?.suspend(),B=()=>L()?.resume(),q=c=>{M=!1;let T=a();return C(),T&&R(T),B(),{status:"failed",message:c}},ne={aiTarget:!0,label:e?"This tool":"New tool",ref:e?[e]:[],placeholder:e?"What should change?":"Describe the tool",get isConnected(){let c=a();return c?e?!!_(c.state.doc,e):!0:!1},getBoundingClientRect(){let c=a();if(!c)return Se();if(y)return y.dom.getBoundingClientRect();let T=e??g?.hostId,A=T?_(c.state.doc,T):null,E=A?c.nodeDOM(A.at):null;return E&&typeof E.getBoundingClientRect=="function"?E.getBoundingClientRect():Se()},async start(c){w=null,M=!1;let T=a();if(!T)return{status:"refused",code:"gone",message:W};if(!globalThis.window?.clay?.wire)return{status:"refused",code:"no-wire",message:Ie};let A=null,E=null;if(e){let x=_(T.state.doc,e);if(x?.node.type!==N.nodes.tool)return{status:"refused",code:"gone",message:W};k=x.node.attrs.rev,A={toolId:e,rev:k},j(),E={artifact:x.node.attrs.artifact,state:h(e,k)},O=m(E.state)}return b=p.request(c,fe(T.state.doc,T.dom.ownerDocument.title),A,E),{status:"ok",id:b.requestId,send:(x={})=>(d=typeof x.onStatus=="function"?x.onStatus:null,{done:p.wait(b).then(S=>(w={id:e,rev:null,artifact:S.artifact,state:S.state},{state:"done",result:S}),S=>(B(),{state:"error",error:S?.message||S?.code||"the helper reported an error",code:S?.code??null})),cancel:()=>{B(),p.discard(b)}})}},async propose(c){let T=a();if(!T||!c)return{status:"refused",message:W};if(!F(c.artifact).ok)return{status:"refused",message:Q};if(!U(c.state).ok)return{status:"refused",message:Ne};w={id:e,rev:null,artifact:c.artifact,state:c.state};let x=De(T);return x.status!=="ready"&&(w=null),x},async keep(){if(!w||M)return q(be);let c=a();if(!c)return q(W);let T=v();if(!T)return q(Te);let A=()=>e&&O!==null&&m(h(e,k))!==O;if(A())return q(xe);M=!0;let E=w.id??r("b"),x=r("rev"),I={...w,id:E,rev:x};try{await T.set([E,x],I.state)}catch(D){return q(D?.message??Te)}let S=null;try{S=await t()}catch{return q(Ae)}if(S?.ok!==!0&&!["saved","clean"].includes(S?.state))return q(S?.msg??S?.message??Ae);if(e){let D=_(c.state.doc,e);if(D?.node.type!==N.nodes.tool||D.node.attrs.rev!==k)return q(be)}else if(!Z(c.state,g))return q(K);if(A())return q(xe);if(C(),R(c),e){let D=_(c.state.doc,e);c.dispatch(X(c.state.tr.setNodeMarkup(D.at,null,{...D.node.attrs,artifact:I.artifact,rev:I.rev})))}else if(!_e(c,I,g))return q(K);let P=!1;for(let D=0;D<2&&!P;D++)try{P=(await t())?.ok!==!1}catch{P=!1}return P?(o.delete(e??"new"),{status:"kept"}):{status:"failed",message:Re}},discard(){C();let c=a();c&&R(c),p.discard(b),B(),o.delete(e??"new")}};function De(c){C();let T=ue({mode:"view",tables:()=>de(c.state.doc).map(({id:I,cols:S,rows:P})=>({id:I,cols:S,rows:P}))}),A=c.dom.ownerDocument.createElement("div");A.className="blockeditor-ai-preview";let E=null;try{E=T.mount(A,{id:"preview",rev:"preview",artifact:w.artifact,seed:w.state})}catch{return T.dispose(),{status:"refused",message:Q}}if(E.failed)return T.dispose(),{status:"refused",message:Q};if(y={host:T,dom:A},e)return $(c,{ids:[e],dom:A}),{status:"ready"};let x=Z(c.state,g);return x?(x.replace?$(c,{ids:[x.node.attrs.id],dom:A}):ae(c,{at:x.insertAt,dom:A}),{status:"ready"}):(C(),{status:"refused",message:K})}return e&&o.set(e,ne),ne}return{newTool(e=null){return l(null,e)},reviseTool(e){let f=o.get(e);return f?.isConnected?f:(o.delete(e),l(e))}}}var{TextSelection:$e}=V,ze="ai-edit",Le="page area",je="This section is too large for AI editing. Select a smaller part.",Ce="Someone changed this area while AI was working, so nothing was changed.",Ve="This page is not open for editing any more.",Fe="AI editing isn't available on this page right now.",Ue=0;function te(i,n){let t=null;return i.forEach((r,s)=>{r.attrs?.id===n&&(t={node:r,at:s})}),t}var qe=(i,n)=>te(i,n)?.node?.type===N.nodes.tool,ee=(i,n,t)=>i.slice(n,t+1).map(r=>r.node.attrs.id).filter(Boolean),Ge=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,ke=()=>({x:0,y:0,left:0,top:0,right:0,bottom:0,width:0,height:0});function Je(i){if(!i.length)return ke();let n=Math.min(...i.map(a=>a.left)),t=Math.min(...i.map(a=>a.top)),r=Math.max(...i.map(a=>a.right)),s=Math.max(...i.map(a=>a.bottom));return{x:n,y:t,left:n,top:t,right:r,bottom:s,width:r-n,height:s-t}}function We(i,n,t){let r=i.selection;if(!(r instanceof $e)||r.empty)return null;let[s,a]=ce(i.doc,r,n);if(s!==a||t.lo!==s||t.hi!==s)return null;let v=n[s];if(r.from<v.at||r.to>v.end)return null;let h=i.doc.textBetween(r.from,r.to," ");if(!h.trim())return null;let o=i.doc.textBetween(v.at+1,r.from," ").length;return{text:h,start:o,end:o+h.length}}function Tt({getView:i,store:n=()=>null,acceptState:t}={}){let r=()=>{let o=i();return o&&!o.isDestroyed?o:null},s=new Map,a=Ee({getView:r,store:n,acceptState:t}),v=o=>a.reviseTool(o);function h(o,{quote:m=null,label:l=null}={}){for(let[d,p]of s)p.isConnected||s.delete(d);let e=s.get(o.join(","));if(e)return e.quote=m??void 0,e;let f=null,u=null,g={aiTarget:!0,label:l??(o.length===1?"This block":`${o.length} blocks`),ref:[...o],get isConnected(){let d=r();return!!d&&o.some(p=>te(d.state.doc,p))},getBoundingClientRect(){let d=r();if(!d)return ke();let p=d.dom.querySelector(".blockeditor-ai-preview");if(p)return p.getBoundingClientRect();let w=[g.ref[0],g.ref[g.ref.length-1]].map(y=>te(d.state.doc,y)).map(y=>y?d.nodeDOM(y.at):null).filter(y=>y&&typeof y.getBoundingClientRect=="function").map(y=>y.getBoundingClientRect());return Je(w)},async start(d,p){let b=r();if(!b)return{status:"refused",code:"gone",message:Ve};let w=window.clay?.wire;if(!w)return{status:"refused",code:"no-wire",message:Fe};let{captureArea:y,AREA_GUIDE:M}=await import("./c-SFZRY6RT.js"),k=y(b.state.doc,g.ref);if(f=null,u=null,k.status!=="ok")return{status:"refused",code:k.code,message:k.message};let O=p??g.quote,C={id:"req-"+Date.now().toString(36)+"-"+ ++Ue,editId:Le,tag:"div",elementHTML:k.capture.html,comment:d+`
|
|
1
|
+
import{a as me,b as pe,c as he}from"./c-SIM7Z3U7.js";import{a as de,b as fe}from"./c-OYW5MFPZ.js";import{a as F,b as U,c as ue}from"./c-H3FNLBHN.js";import{C as X,E as le,h as z,l as ce,m as Y}from"./c-3Y234AUB.js";import{A as se,d as N,x as oe}from"./c-OH2FPYSY.js";import"./c-VPXCXBDT.js";import{b as $,c as ae,d as R}from"./c-Z6MROEQ4.js";import{b as ie}from"./c-Q26XHBLQ.js";import{a as H,b as V}from"./c-RETTCOWO.js";import{a as re}from"./c-3LDGIBMN.js";import"./c-VHNSBD2M.js";var ge=16384,we=i=>new TextEncoder().encode(JSON.stringify(i)).length,G=class extends Error{constructor(n,t=n){super(t),this.name="ToolRequestError",this.code=n}};function Oe(i){let n=re(i);for(Array.isArray(n.tables)||(n.tables=[]),Array.isArray(n.outline)||(n.outline=[]);we(n)>ge;){let t=[...n.tables].reverse().find(r=>Array.isArray(r.rows)&&r.rows.length);if(t)t.rows.pop();else if(n.outline.length)n.outline.pop();else break}if(we(n)>ge)throw new G("context-too-large");return n}var Me=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;function ve({transport:i,newId:n=Me}){let t=null,r=s=>{!s||s.discarded||s.done||(s.discarded=!0,t===s&&(t=null),i.cancel(s.requestId),s.resolve({requestId:s.requestId,code:"discarded",message:"Candidate discarded"}))};return{request(s,a,v=null,h=null){let o=Oe(a);t&&r(t);let m=n(),l={requestId:m,discarded:!1,done:!1};l.promise=new Promise(u=>{l.resolve=u}),t=l;let e={protocol:"blockeditor-tool/1",requestId:m,prompt:s,context:o,target:v,current:h};l.request=e;let f=u=>{if(!(l.discarded||l.done||u?.requestId!==m))if(l.done=!0,t===l&&(t=null),u?.artifact!==void 0){let g=F(u.artifact),d=U(u.state),p=g.ok?d.ok?null:d:g;l.resolve(p?{requestId:m,code:p.code,message:p.code}:u)}else l.resolve(typeof u?.code=="string"?u:{requestId:m,code:"invalid-result",message:"invalid-result"})};try{let u=g=>f({requestId:m,code:typeof g?.code=="string"?g.code:"transport-error",message:String(g?.message??g)});Promise.resolve(i.request(e)).then(f,u)}catch(u){f({requestId:m,code:typeof u?.code=="string"?u.code:"transport-error",message:String(u?.message??u)})}return l},discard:r,async wait(s,{signal:a}={}){if(a?.aborted)throw new DOMException("Aborted","AbortError");let v,h=await(a?Promise.race([s.promise,new Promise((o,m)=>{v=()=>m(new DOMException("Aborted","AbortError")),a.addEventListener("abort",v,{once:!0})})]).finally(()=>a.removeEventListener("abort",v)):s.promise);if(h?.code)throw new G(h.code,h.message);return h}}}var J=class extends Error{constructor(n){super(n),this.name="ToolTransportError",this.code=n}};function ye({getWire:i=()=>globalThis.window?.clay?.wire??null}={}){let n=new Map;return{request(t,{onStatus:r=null}={}){let s=i();if(!s||typeof s.send!="function")return Promise.reject(new J("no-wire"));let a=t?.requestId,v;try{v=s.send(t,{helper:"blockeditor-tool",document:"none",id:a,onStatus:r})}catch{return Promise.reject(new J("no-wire"))}return n.set(a,v),Promise.resolve(v.done).then(h=>{if(n.get(a)===v&&n.delete(a),h?.state==="done"){let o=h.result??{};return{requestId:typeof o.requestId=="string"?o.requestId:a,artifact:o.artifact,state:o.state,model:o.model}}return{requestId:a,code:h?.errorCode||(h?.state==="cancelled"?"cancelled":"transport-error"),message:h?.error||"the helper reported an error"}},()=>({requestId:a,code:"transport-error",message:"the helper reported an error"}))},cancel(t){let r=n.get(t);n.delete(t),r?.cancel?.()}}}var{Selection:Be}=V,W="This page is not open for editing any more.",Ie="AI tool making isn't available on this page right now.",Te="This document can't save tool data.",K="The place for this tool moved. Close this and run /ai where you want the tool.",be="This tool changed while you were revising, so nothing was replaced. Ask again.",Q="AI did not make a usable tool. Try again.",Ne="The tool data from AI is too large or not usable. Try again.",xe="This tool's data changed while AI was working, so it was not replaced. Ask again to include the latest data.",Ae="The tool could not be saved, so it was not added. Try again.",Re="Your tool is in the document, but saving failed. It will be saved with your next edit.";function _(i,n){let t=null;return i.forEach((r,s,a)=>{r.attrs.id===n&&(t={node:r,at:s,index:a})}),t}function Pe(i,n){let t=i.selection.$head,r=Math.min(Math.max(t.index(0),0),i.doc.childCount-1);return{hostId:i.doc.child(r)?.attrs.id??null,slashText:n?i.doc.textBetween(n.from,n.to):null,slashOffset:n&&t.depth?n.from-t.before(1)-1:null}}function Z(i,n){let t=n?.hostId?_(i.doc,n.hostId):null;if(!t)return null;let r=i.doc.maybeChild(t.index+1),s=t.node.isTextblock&&(t.node.content.size===0||t.node.textContent===n.slashText);return{...t,replace:s,pos:s?t.node.attrs.pos:oe(t.node.attrs.pos,r?.attrs.pos??null),insertAt:s?t.at:t.at+t.node.nodeSize}}function _e(i,n,t){let r=i.state,s=Z(r,t);if(!s)return!1;let{node:a,at:v,insertAt:h,replace:o}=s,m=N.nodes.tool.create({id:n.id,pos:s.pos,parent:a.attrs.parent??null,artifact:n.artifact,rev:n.rev,state:n.state}),l=r.tr;if(!o&&t?.hostId===a.attrs.id&&t.slashText&&t.slashOffset>=0){let f=v+1+t.slashOffset,u=f+t.slashText.length;u<=v+a.nodeSize-1&&r.doc.textBetween(f,u)===t.slashText&&l.delete(f,u)}let e=l.mapping.map(h);return l.replaceWith(e,o?l.mapping.map(v+a.nodeSize):e,m),l.setSelection(Be.near(l.doc.resolve(Math.min(e+m.nodeSize,l.doc.content.size)))),i.dispatch(X(l).scrollIntoView()),!0}var Se=()=>({x:0,y:0,left:0,top:0,right:0,bottom:0,width:0,height:0});function Ee({getView:i,store:n=()=>null,acceptState:t=()=>globalThis.clay?.save?.flush?.(),newId:r=se,transport:s=ye()}={}){let a=()=>{let e=i();return e&&!e.isDestroyed?e:null},v=()=>typeof n=="function"?n():n,h=(e,f)=>{let u=v()?.data?.[e]?.[f];return u===void 0?{}:u},o=new Map,m=e=>Array.isArray(e)?`[${e.map(m).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(u=>`${JSON.stringify(u)}:${m(e[u])}`).join(",")}}`:JSON.stringify(e)??"null";function l(e=null,f=null){let u=a(),g=e||!u?null:Pe(u.state,f),d=null,p=ve({transport:{request:c=>s.request(c,{onStatus:T=>d?.(T)}),cancel:c=>s.cancel(c)}}),b=null,w=null,y=null,M=!1,k=null,O=null,C=()=>{y?.host?.dispose(),y=null},L=()=>{let c=a();return c&&e?ie.get(c)?.get(e)??null:null},j=()=>L()?.suspend(),B=()=>L()?.resume(),q=c=>{M=!1;let T=a();return C(),T&&R(T),B(),{status:"failed",message:c}},ne={aiTarget:!0,label:e?"This tool":"New tool",ref:e?[e]:[],placeholder:e?"What should change?":"Describe the tool",get isConnected(){let c=a();return c?e?!!_(c.state.doc,e):!0:!1},getBoundingClientRect(){let c=a();if(!c)return Se();if(y)return y.dom.getBoundingClientRect();let T=e??g?.hostId,A=T?_(c.state.doc,T):null,E=A?c.nodeDOM(A.at):null;return E&&typeof E.getBoundingClientRect=="function"?E.getBoundingClientRect():Se()},async start(c){w=null,M=!1;let T=a();if(!T)return{status:"refused",code:"gone",message:W};if(!globalThis.window?.clay?.wire)return{status:"refused",code:"no-wire",message:Ie};let A=null,E=null;if(e){let x=_(T.state.doc,e);if(x?.node.type!==N.nodes.tool)return{status:"refused",code:"gone",message:W};k=x.node.attrs.rev,A={toolId:e,rev:k},j(),E={artifact:x.node.attrs.artifact,state:h(e,k)},O=m(E.state)}return b=p.request(c,fe(T.state.doc,T.dom.ownerDocument.title),A,E),{status:"ok",id:b.requestId,send:(x={})=>(d=typeof x.onStatus=="function"?x.onStatus:null,{done:p.wait(b).then(S=>(w={id:e,rev:null,artifact:S.artifact,state:S.state},{state:"done",result:S}),S=>(B(),{state:"error",error:S?.message||S?.code||"the helper reported an error",code:S?.code??null})),cancel:()=>{B(),p.discard(b)}})}},async propose(c){let T=a();if(!T||!c)return{status:"refused",message:W};if(!F(c.artifact).ok)return{status:"refused",message:Q};if(!U(c.state).ok)return{status:"refused",message:Ne};w={id:e,rev:null,artifact:c.artifact,state:c.state};let x=De(T);return x.status!=="ready"&&(w=null),x},async keep(){if(!w||M)return q(be);let c=a();if(!c)return q(W);let T=v();if(!T)return q(Te);let A=()=>e&&O!==null&&m(h(e,k))!==O;if(A())return q(xe);M=!0;let E=w.id??r("b"),x=r("rev"),I={...w,id:E,rev:x};try{await T.set([E,x],I.state)}catch(D){return q(D?.message??Te)}let S=null;try{S=await t()}catch{return q(Ae)}if(S?.ok!==!0&&!["saved","clean"].includes(S?.state))return q(S?.msg??S?.message??Ae);if(e){let D=_(c.state.doc,e);if(D?.node.type!==N.nodes.tool||D.node.attrs.rev!==k)return q(be)}else if(!Z(c.state,g))return q(K);if(A())return q(xe);if(C(),R(c),e){let D=_(c.state.doc,e);c.dispatch(X(c.state.tr.setNodeMarkup(D.at,null,{...D.node.attrs,artifact:I.artifact,rev:I.rev})))}else if(!_e(c,I,g))return q(K);let P=!1;for(let D=0;D<2&&!P;D++)try{P=(await t())?.ok!==!1}catch{P=!1}return P?(o.delete(e??"new"),{status:"kept"}):{status:"failed",message:Re}},discard(){C();let c=a();c&&R(c),p.discard(b),B(),o.delete(e??"new")}};function De(c){C();let T=ue({mode:"view",tables:()=>de(c.state.doc).map(({id:I,cols:S,rows:P})=>({id:I,cols:S,rows:P}))}),A=c.dom.ownerDocument.createElement("div");A.className="blockeditor-ai-preview";let E=null;try{E=T.mount(A,{id:"preview",rev:"preview",artifact:w.artifact,seed:w.state})}catch{return T.dispose(),{status:"refused",message:Q}}if(E.failed)return T.dispose(),{status:"refused",message:Q};if(y={host:T,dom:A},e)return $(c,{ids:[e],dom:A}),{status:"ready"};let x=Z(c.state,g);return x?(x.replace?$(c,{ids:[x.node.attrs.id],dom:A}):ae(c,{at:x.insertAt,dom:A}),{status:"ready"}):(C(),{status:"refused",message:K})}return e&&o.set(e,ne),ne}return{newTool(e=null){return l(null,e)},reviseTool(e){let f=o.get(e);return f?.isConnected?f:(o.delete(e),l(e))}}}var{TextSelection:$e}=V,ze="ai-edit",Le="page area",je="This section is too large for AI editing. Select a smaller part.",Ce="Someone changed this area while AI was working, so nothing was changed.",Ve="This page is not open for editing any more.",Fe="AI editing isn't available on this page right now.",Ue=0;function te(i,n){let t=null;return i.forEach((r,s)=>{r.attrs?.id===n&&(t={node:r,at:s})}),t}var qe=(i,n)=>te(i,n)?.node?.type===N.nodes.tool,ee=(i,n,t)=>i.slice(n,t+1).map(r=>r.node.attrs.id).filter(Boolean),Ge=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,ke=()=>({x:0,y:0,left:0,top:0,right:0,bottom:0,width:0,height:0});function Je(i){if(!i.length)return ke();let n=Math.min(...i.map(a=>a.left)),t=Math.min(...i.map(a=>a.top)),r=Math.max(...i.map(a=>a.right)),s=Math.max(...i.map(a=>a.bottom));return{x:n,y:t,left:n,top:t,right:r,bottom:s,width:r-n,height:s-t}}function We(i,n,t){let r=i.selection;if(!(r instanceof $e)||r.empty)return null;let[s,a]=ce(i.doc,r,n);if(s!==a||t.lo!==s||t.hi!==s)return null;let v=n[s];if(r.from<v.at||r.to>v.end)return null;let h=i.doc.textBetween(r.from,r.to," ");if(!h.trim())return null;let o=i.doc.textBetween(v.at+1,r.from," ").length;return{text:h,start:o,end:o+h.length}}function Tt({getView:i,store:n=()=>null,acceptState:t}={}){let r=()=>{let o=i();return o&&!o.isDestroyed?o:null},s=new Map,a=Ee({getView:r,store:n,acceptState:t}),v=o=>a.reviseTool(o);function h(o,{quote:m=null,label:l=null}={}){for(let[d,p]of s)p.isConnected||s.delete(d);let e=s.get(o.join(","));if(e)return e.quote=m??void 0,e;let f=null,u=null,g={aiTarget:!0,label:l??(o.length===1?"This block":`${o.length} blocks`),ref:[...o],get isConnected(){let d=r();return!!d&&o.some(p=>te(d.state.doc,p))},getBoundingClientRect(){let d=r();if(!d)return ke();let p=d.dom.querySelector(".blockeditor-ai-preview");if(p)return p.getBoundingClientRect();let w=[g.ref[0],g.ref[g.ref.length-1]].map(y=>te(d.state.doc,y)).map(y=>y?d.nodeDOM(y.at):null).filter(y=>y&&typeof y.getBoundingClientRect=="function").map(y=>y.getBoundingClientRect());return Je(w)},async start(d,p){let b=r();if(!b)return{status:"refused",code:"gone",message:Ve};let w=window.clay?.wire;if(!w)return{status:"refused",code:"no-wire",message:Fe};let{captureArea:y,AREA_GUIDE:M}=await import("./c-TWB5ZQU4.js"),k=y(b.state.doc,g.ref);if(f=null,u=null,k.status!=="ok")return{status:"refused",code:k.code,message:k.message};let O=p??g.quote,C={id:"req-"+Date.now().toString(36)+"-"+ ++Ue,editId:Le,tag:"div",elementHTML:k.capture.html,comment:d+`
|
|
2
2
|
|
|
3
|
-
`+M,contextRefs:pe(d)};return O&&(C.quote=O.text,Number.isInteger(O.start)&&(C.selection={start:O.start,end:O.end})),he(d)&&(C.page=!0),new Blob([JSON.stringify(C)]).size>921600?{status:"refused",code:"too-large",message:je}:(f=k.capture,{status:"ok",id:C.id,send:(L={})=>{let j=!0,B=null;return{done:(async()=>(C.page&&await window.clay?.save?.(),j?(B=w.send(C,{helper:ze,onStatus:L.onStatus}),B.done):{state:"cancelled"}))(),cancel(){j=!1,B?.cancel()}}}})},async propose(d){let p=r();if(!p||!f)return{status:"refused",message:"This area is no longer open for AI editing."};let{proposeArea:b}=await import("./c-
|
|
3
|
+
`+M,contextRefs:pe(d)};return O&&(C.quote=O.text,Number.isInteger(O.start)&&(C.selection={start:O.start,end:O.end})),he(d)&&(C.page=!0),new Blob([JSON.stringify(C)]).size>921600?{status:"refused",code:"too-large",message:je}:(f=k.capture,{status:"ok",id:C.id,send:(L={})=>{let j=!0,B=null;return{done:(async()=>(C.page&&await window.clay?.save?.(),j?(B=w.send(C,{helper:ze,onStatus:L.onStatus}),B.done):{state:"cancelled"}))(),cancel(){j=!1,B?.cancel()}}}})},async propose(d){let p=r();if(!p||!f)return{status:"refused",message:"This area is no longer open for AI editing."};let{proposeArea:b}=await import("./c-TWB5ZQU4.js"),w=b(p.state,f,d?.html??"",{seed:Ge()});if(w.status!=="ready")return{status:"refused",message:w.message};u=w;let y=p.dom.ownerDocument.createElement("div");y.className="blockeditor-ai-preview";let M=H.DOMSerializer.fromSchema(N);return y.appendChild(M.serializeFragment(H.Fragment.from(w.nodes),{document:p.dom.ownerDocument})),$(p,{ids:f.ids,dom:y}),{status:"ready"}},async keep(){let d=r();if(!d||!f||!u)return{status:"failed",message:Ce};let{keepAreaTransaction:p}=await import("./c-TWB5ZQU4.js"),b=p(d.state,f,u);if(R(d),b.status!=="ok")return{status:"failed",message:Ce};d.dispatch(b.tr),d.dom.isConnected&&d.focus();try{await window.clay?.save?.flush?.()}catch{return{status:"failed",message:"Your change is in the document, but saving failed. It will be saved with your next edit."}}return{status:"kept"}},discard(){let d=r();d&&(R(d),d.dom.isConnected&&d.focus())}};return g.quote=m??void 0,s.set(o.join(","),g),g}return{active:()=>!!r(),targetFromSelection(){let o=r();if(!o)return null;let m=z(o.state.doc);if(!m.length)return null;let l=le(o.state,m),e=ee(m,l.lo,l.hi);return e.length?e.length===1&&qe(o.state.doc,e[0])?v(e[0]):h(e,{quote:We(o.state,m,l)}):null},targetAt(o,m){let l=r();if(!l)return null;let e=l.posAtCoords({left:o,top:m});if(!e)return null;let f=z(l.state.doc);if(!f.length)return null;let u=e.inside>=0?e.inside:e.pos,g=f.findIndex(y=>y.node.type===N.nodes.tool&&y.end===u),d=g>=0?g:Math.min(Math.max(l.state.doc.resolve(u).index(0),0),f.length-1),{lo:p,hi:b}=Y(f,d,d),w=ee(f,p,b);return w.length?w.length===1&&qe(l.state.doc,w[0])?v(w[0]):h(w):null},between(o,m){let l=r();if(!l)return null;let e=z(l.state.doc),f=[...o?.ref??[],...m?.ref??[]].map(p=>e.findIndex(b=>b.node.attrs.id===p)).filter(p=>p>=0);if(!f.length)return null;let{lo:u,hi:g}=Y(e,Math.min(...f),Math.max(...f)),d=ee(e,u,g);return d.length?h(d):null},wholePage(){let o=r(),m=o?z(o.state.doc).map(l=>l.node.attrs.id).filter(Boolean):[];return h(m,{label:"This page"})},newTool(o){return a.newTool(o??null)},reviseTool(o){return a.reviseTool(o)}}}export{Tt as createPageAi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./c-VHNSBD2M.js";var l=(e,n)=>Object.assign(new Error(`clayjs: ${e}`),{code:n}),u=(e,n)=>!e||n.seq===null||e.seq===null||n.seq>e.seq?n:e;function a({stream:e,apply:n,retire:f,yieldArticle:i=()=>!1,reclaimArticle:s=()=>!1}){let t=null,r=!1;e.adopt({onSnapshot:o=>(t=u(t,o),!0)});let d=()=>{let o=t;return t=null,o};return{get represented(){return e.represented},get held(){return t??e.represented},yieldArticle(){return r||!i()?!1:(r=!0,!0)},reclaimArticle(){return!r||!s()?!1:(r=!1,!0)},reconcile(){let o=d();return o&&!n(o)?Promise.reject(l("the switch could not apply the saved file","load-failed")):Promise.resolve()},resume(){e.adopt({onSnapshot:n});let o=d();o&&n(o)},commit(){if(!r){let o=d();if(o&&!n(o))return!1}return e.represented.bytes===null?!1:(e.stop(),f())}}}async function c({stream:e,options:n,apply:f,retire:i,yieldArticle:s=()=>!1,reclaimArticle:t=()=>!1}){if(e)return a({stream:e,apply:f,retire:i,yieldArticle:s,reclaimArticle:t});let r=await import("./sync/live-sync-
|
|
1
|
+
import"./c-VHNSBD2M.js";var l=(e,n)=>Object.assign(new Error(`clayjs: ${e}`),{code:n}),u=(e,n)=>!e||n.seq===null||e.seq===null||n.seq>e.seq?n:e;function a({stream:e,apply:n,retire:f,yieldArticle:i=()=>!1,reclaimArticle:s=()=>!1}){let t=null,r=!1;e.adopt({onSnapshot:o=>(t=u(t,o),!0)});let d=()=>{let o=t;return t=null,o};return{get represented(){return e.represented},get held(){return t??e.represented},yieldArticle(){return r||!i()?!1:(r=!0,!0)},reclaimArticle(){return!r||!s()?!1:(r=!1,!0)},reconcile(){let o=d();return o&&!n(o)?Promise.reject(l("the switch could not apply the saved file","load-failed")):Promise.resolve()},resume(){e.adopt({onSnapshot:n});let o=d();o&&n(o)},commit(){if(!r){let o=d();if(o&&!n(o))return!1}return e.represented.bytes===null?!1:(e.stop(),f())}}}async function c({stream:e,options:n,apply:f,retire:i,yieldArticle:s=()=>!1,reclaimArticle:t=()=>!1}){if(e)return a({stream:e,apply:f,retire:i,yieldArticle:s,reclaimArticle:t});let r=await import("./sync/live-sync-DX4K5GDB.js").then(({liveSync:d})=>d.prepareHandoff(n));return{get represented(){return r.represented},get held(){return r.held},yieldArticle:s,reclaimArticle:t,reconcile:()=>r.reconcile(),resume:()=>r.resume(),commit:()=>r.commit()&&i()}}async function p(e,{signal:n,deadline:f=15e3}={}){let i=Date.now()+f;for(;e._morphInFlight;){if(n?.aborted)throw e._handoffHeld=!1,l("the switch was cancelled","aborted");if(Date.now()>=i)throw e._handoffHeld=!1,l("the apply did not settle","timeout");await new Promise(t=>setTimeout(t,1))}let s=()=>e._pendingHtml!=null||e._pendingExternal!=null;return{get represented(){return e._represented},get held(){let t=e._represented;return e._pendingHtml!=null&&(t=u(t,{bytes:e._pendingHtml,etag:e._pendingEtag??null,seq:e._pendingSeq??null})),e._pendingExternal&&(t=u(t,{bytes:e._pendingExternal.html,etag:e._pendingExternal.etag??null,seq:e._pendingExternal.seq??null})),t},async reconcile(){if(!(!e._handoff||e.isDestroyed)){for(let t=0;t<8;t++){if(e._morphInFlight){await new Promise(r=>setTimeout(r,1));continue}if(!s())return;await e._runPending()}if(s())throw l("the held frame could not be applied","load-failed")}},resume(){e._handoff&&(e._handoff=null,e._handoffHeld=!1,e._scheduleNextFrame())},commit(){return e._represented.bytes?(e._handoff=null,e._handoffHeld=!1,e.stop(),!0):!1}}}export{p as engineHandoff,c as readerHandoff};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as X,f as G,h as J,i as Q,j as P,k as U}from"./c-NICICT4P.js";import{a as C,f as L}from"./c-VO6RSFCO.js";import"./c-WN3MXOLT.js";import"./c-V2V5FKXX.js";import{a as O,b as N,k as z,l as K,m as j,n as V,v as T}from"./c-WMRJKQ2V.js";import{p as w}from"./c-
|
|
1
|
+
import{e as X,f as G,h as J,i as Q,j as P,k as U}from"./c-NICICT4P.js";import{a as C,f as L}from"./c-VO6RSFCO.js";import"./c-WN3MXOLT.js";import"./c-V2V5FKXX.js";import{a as O,b as N,k as z,l as K,m as j,n as V,v as T}from"./c-WMRJKQ2V.js";import{p as w}from"./c-3Y234AUB.js";import"./c-OH2FPYSY.js";import{b as y,d as H}from"./c-RETTCOWO.js";import{b as W}from"./c-NL4I4KNG.js";import"./c-7SWMYKAI.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import{d as q}from"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var ce=128,D=r=>r.depth?r.node(1).attrs.id:null,Z=r=>!!r.depth&&r.node(1).type.name==="table",ae=(r,t,o,e,n)=>O(K(z(r.flow,J(t,o.holes,e,o.visible),n)));function te({pd:r,w:t,doc:o},e){if(!r||!t||!o||!e)return null;if(e instanceof y.TextSelection){let n=e.$anchor,s=e.$head;if(Z(n)||Z(s)){let a=P(o,n.pos),u=P(o,s.pos);return!a||!u||a.table!==u.table||a.row!==u.row||a.col!==u.col?null:{kind:"cell",block:a.table,row:a.row,col:a.col}}let i=Math.min(e.from,e.to),l=a=>{let u=D(a);return u===null?null:{block:u,rel:ae(r,o,t,a.pos,e.empty||a.pos===i?0:-1)}},c=l(n),m=l(s);return c&&m?{kind:"text",anchor:c,head:m}:null}if(e instanceof w||e instanceof y.NodeSelection){let n=[];if(e instanceof w){let{lo:s,hi:i}=e.span();o.forEach((l,c,m)=>{m>=s&&m<=i&&n.push(l.attrs.id)})}else{let s=o.nodeAt(e.from);s&&n.push(s.attrs.id)}if(!n.length)return null;if(n.length>ce){let s=D(e.$from);return s?{kind:"blocks",ids:[s]}:null}return{kind:"blocks",ids:n}}return null}var ue=(r,t)=>{if(!t||typeof t!="object"||typeof t.block!="string"||!t.block||typeof t.rel!="string"||!t.rel)return null;let o;try{o=j(N(t.rel))}catch{return null}let e;try{e=V(o,r.ydoc)}catch{return null}return!e||e.type!==r.flow?null:e.index},fe=(r,t)=>{let o=0;for(let e=r.flow._start;e;e=e.right){let n=o+e.length;if(t<n)return!e.deleted;o=n}return!1},de=(r,t)=>{for(let o=r.flow._start;o;o=o.right)if(!o.deleted&&o.content instanceof T&&o.content.embed?.b===t)return!0;return!1},me=(r,t)=>{let o=0,e=null,n=0;for(let s=r.flow._start;s;s=s.right)if(s.content instanceof T&&s.content.embed?.b!==void 0&&(e=s.content.embed.b,n=o+s.length),o+=s.length,o>t&&e!==null)return{id:e,offset:t-n};return e===null?null:{id:e,offset:t-n}},pe=(r,t,o)=>{let e=null;return r.forEach((n,s)=>{e===null&&n.attrs.id===t&&n.isTextblock&&(e=s+1+Math.min(Math.max(o,0),n.content.size))}),e},ee=({pd:r,w:t,doc:o},e)=>{let n=ue(r,e);if(n===null)return null;let s=Q(o,t.holes,t.tokens,n,t.visible);if(D(o.resolve(s))===e.block)return s;let i=me(r,n);if(i&&i.id===e.block){let l=pe(o,e.block,i.offset);if(l!==null)return l}return de(r,e.block)||!fe(r,n)||t.holes.some(l=>n>=G(t.holes,l.at)&&n<X(t.holes,l.at))?null:o.resolve(s).parent.inlineContent?s:null};function oe({pd:r,w:t,doc:o},e){if(!r||!t||!o||!e||typeof e!="object")return null;if(e.kind==="text"){let n=ee({pd:r,w:t,doc:o},e.anchor),s=ee({pd:r,w:t,doc:o},e.head);return n===null||s===null?null:{kind:"text",from:Math.min(n,s),to:Math.max(n,s)}}if(e.kind==="cell"){let n=U(o,{table:e.block,row:e.row,col:e.col,offset:0});return n?{kind:"cell",from:n.from,to:n.to,block:n.block,row:n.row,col:n.col}:null}if(e.kind==="blocks"){let n=[],s=[];for(let i of Array.isArray(e.ids)?e.ids:[])o.forEach((l,c)=>{l.attrs.id!==i||n.includes(i)||(n.push(i),s.push({from:c,to:c+l.nodeSize}))});return s.length?{kind:"blocks",ids:n,ranges:s}:null}return null}var{Plugin:be,PluginKey:ge}=y,{Decoration:h,DecorationSet:x}=H,k=new ge("blockeditor-awareness"),ne="blockeditor-awareness-style",he=`
|
|
2
2
|
.blockeditor-remote-selection { background-color: color-mix(in srgb, var(--blockeditor-remote-color, currentColor) 22%, transparent); }
|
|
3
3
|
.blockeditor-remote-caret { position: relative; display: inline-block; width: 0; height: 1.1em; vertical-align: text-bottom; }
|
|
4
4
|
.blockeditor-remote-caret::before { content: ""; position: absolute; inset-inline-start: -1px; top: 0; bottom: 0; width: 2px; background: var(--blockeditor-remote-color, currentColor); }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as ee,D as oe,G as te,H as re,I as ne,i as J}from"./c-TGIMBAWE.js";import"./c-WNOLMHI2.js";import"./c-LS7IVQVW.js";import"./c-NEQRFC4O.js";import{a as X}from"./c-
|
|
1
|
+
import{A as ee,D as oe,G as te,H as re,I as ne,i as J}from"./c-TGIMBAWE.js";import"./c-WNOLMHI2.js";import"./c-LS7IVQVW.js";import"./c-NEQRFC4O.js";import{a as X}from"./c-Y3J5LDKB.js";import"./c-PZ4XEPUP.js";import"./c-JRKY44DK.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{A as Q,F as Z,d as z,y as K}from"./c-OH2FPYSY.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import{b as Y}from"./c-QY7F6EN6.js";import{a as G,b as H}from"./c-RETTCOWO.js";import"./c-RHMPKZZ7.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var le="Work from an earlier session could not be put back. Read it, download it, or recover it as a copy.",pe=`
|
|
2
2
|
:host { font: inherit !important; color: inherit !important; }
|
|
3
3
|
.blockeditor-recovery-root { display: contents; }
|
|
4
4
|
.blockeditor-recovery { position: fixed; right: 16px; bottom: 16px; z-index: 20; min-height: 36px; padding: 0 14px; font: inherit; font-size: 14px; color: var(--blockeditor-ink); background: var(--blockeditor-pop-bg); border: 1px solid var(--blockeditor-chrome-line-rest); border-radius: 999px; cursor: pointer; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as y,c as S}from"./c-6DNRCPNM.js";import{b as C,c as s}from"./c-
|
|
1
|
+
import{b as y,c as S}from"./c-6DNRCPNM.js";import{b as C,c as s}from"./c-YRDKVEGR.js";import{A as d,B as f,C as m,D as p,q as i}from"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";function b(e={}){let t=d({...e,sliced:!0});return Object.freeze({captureId:t.captureId,steps:()=>h(t),drop:()=>p(t)})}function v(e,t){let r=e.querySelector("head");if(!r)return;let n=e.querySelector(`meta[name="${t.name}"]`);if(n){n.getAttribute("content")!==t.content&&n.setAttribute("content",t.content);return}let o=e.ownerDocument.createElement("meta");o.setAttribute("name",t.name),o.setAttribute("content",t.content),r.appendChild(o)}function*g(e,t,r){if(!r.renderer)return t;let n=null;for(;;){let o;try{o=i(r.context,()=>(n||=r.rendererSteps?r.rendererSteps(e,t):!1,n?n.next():{done:!0,value:r.renderer(e,t)}))}catch(c){return console.error("clayjs: save renderer failed, sending the full serialization",c),t}if(o.done)return o.value;yield}}function*h(e){f(e);let t=yield*C(e.clone);yield;let r=e.compareClone?yield*s(e.compareClone):null;yield;let n=e.dirtyClone?yield*s(e.dirtyClone):r;yield,e.pageFormatMarker&&v(e.clone,e.pageFormatMarker);let o=yield*g(e.clone,t,e);return m(e,{forSave:o,forComparison:r,forDirty:n})}var l=()=>globalThis.performance?globalThis.performance.now():Date.now();async function F(e,{budgetMs:t=4,signal:r=null}={}){let n=0,o=l(),c=async()=>{n+=l()-o,await y(),o=l()},a;try{a=await S(e,{budgetMs:t,signal:r,yieldTask:c})}finally{n+=l()-o}let u=a!==null&&typeof a=="object"&&a.aborted===!0;return{result:u?null:a,aborted:u,activeMs:n}}export{b as beginSaveCapture,F as runPreparedSteps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d="#FFFCF6",l=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],y=18,h=3,p=null,f=null;function C(){return f??=Promise.all([import("./c-
|
|
1
|
+
import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d="#FFFCF6",l=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],y=18,h=3,p=null,f=null;function C(){return f??=Promise.all([import("./c-33SS5A4Y.js"),import("./c-46LJAZZJ.js")]).then(([i,e])=>p={RUNTIME_ONLY:i.RUNTIME_ONLY,CHIP_FONT:`600 11px/16px ${e.FONT_MONO}`}).catch(i=>{throw f=null,i}),f}var $=()=>C().then(()=>!0,()=>!1);function a(i){return i.setAttribute("clay",p.RUNTIME_ONLY),i}function A(i){let e=i&&Array.isArray(i.people)?i.people:[],o=[];for(let t of e){if(!t||t.you===!0||typeof t.id!="string"||!t.id||typeof t.editing!="string"||!_.test(t.editing))continue;let n=typeof t.name=="string"&&t.name.trim()?t.name.trim():"Someone";o.push({id:t.id,name:n,path:t.editing})}return o}var m=class{constructor(){this.editors=[],this.root=null,this._gate=null,this._frame=0,this._following=!1,this._onMove=()=>this.schedule()}supported(){return this._gate||(this._gate=b("presence").then(e=>e===!0,()=>!1)),this._gate}async update(e){this.editors=A(e),await this.supported()&&await this.render()}clear(){this.editors=[],this.follow(!1),this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this.root&&this.root.remove(),this.root=null}schedule(){this._frame||(this._frame=requestAnimationFrame(()=>{this._frame=0,this.render()}))}render(){return p?(this.paint(),Promise.resolve()):$().then(e=>{e&&this.paint()})}paint(){let e=new Map;for(let t of this.editors){let n=v(t.path);n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let o=[];for(let[t,n]of e){let r=this.box(t,n);r&&o.push(r)}if(!o.length){this.root&&(this.root.textContent="",u(this.root,"display","none")),this.follow(this.editors.length>0);return}this.build()&&(this.root.textContent="",this.root.append(...o),u(this.root,"display","block"),this.follow(!0))}box(e,o){let t=e.getBoundingClientRect();if(!(t.width||t.height))return null;let n=c(o[0].id),r=a(s("div",[...l,"position:fixed","box-sizing:border-box","pointer-events:none",`top:${Math.round(t.top-h)}px`,`left:${Math.round(t.left-h)}px`,`width:${Math.round(t.width+h*2)}px`,`height:${Math.round(t.height+h*2)}px`,`border:2px solid ${n}`,`box-shadow:0 0 0 1px ${d}, inset 0 0 0 1px ${d}`]));r.setAttribute("data-clay-editing-marker","");let M=t.top-h>=y+2,x=a(s("div",[...l,"position:absolute","left:-2px",M?"bottom:100%":"top:100%","display:flex","gap:2px","pointer-events:none"]));for(let g of o){let w=a(s("span",[...l,"box-sizing:border-box",`height:${y}px`,"padding:1px 6px",`font:${p.CHIP_FONT}`,"letter-spacing:.02em","white-space:nowrap","max-width:180px","overflow:hidden","text-overflow:ellipsis",`background-color:${c(g.id)}`,`color:${d}`,`box-shadow:0 0 0 1px ${d}`],g.name));w.setAttribute("data-clay-editing-chip",""),x.appendChild(w)}return r.appendChild(x),r}build(){return this.root&&this.root.isConnected?!0:typeof document>"u"||!document.body?!1:(this.root=a(s("div",[...l,"position:fixed","top:0","left:0","width:0","height:0","overflow:visible","z-index:2147482999","pointer-events:none","display:none"])),this.root.setAttribute("data-clay-editing",""),document.body.appendChild(this.root),!0)}follow(e){if(typeof window>"u"||!!e===this._following)return;this._following=!!e;let o=e?"addEventListener":"removeEventListener";window[o]("scroll",this._onMove,{capture:!0,passive:!0}),window[o]("resize",this._onMove,{passive:!0}),document[o]("input",this._onMove),document[o]("clay:sync-applied",this._onMove)}},N=new m;var O=N;export{m as EditingMarker,O as default,N as editingMarker};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as U}from"./c-LD6UVV5R.js";import{a as se,g as ae,h as C}from"./c-PGSBXHUE.js";import{a as oe,b as ie,c as j}from"./c-KU3PX7LL.js";import{d as A}from"./c-EQ5NBOGA.js";import{c as Z,e as Q,g as ee}from"./c-IJUK2GPW.js";import{b as k,f as D}from"./c-C7SUMNMI.js";import{c as V}from"./c-BPF2NSPV.js";import{i as q}from"./c-U4TWEIKZ.js";import{a as M,g as te,h as ne,i as re}from"./c-
|
|
1
|
+
import{b as U}from"./c-LD6UVV5R.js";import{a as se,g as ae,h as C}from"./c-PGSBXHUE.js";import{a as oe,b as ie,c as j}from"./c-KU3PX7LL.js";import{d as A}from"./c-EQ5NBOGA.js";import{c as Z,e as Q,g as ee}from"./c-IJUK2GPW.js";import{b as k,f as D}from"./c-C7SUMNMI.js";import{c as V}from"./c-BPF2NSPV.js";import{i as q}from"./c-U4TWEIKZ.js";import{a as M,g as te,h as ne,i as re}from"./c-UW6MMZ4V.js";var F=null,ue=null,T=null;function Te(e){let t=e?.document?.maxBytes;return Number.isSafeInteger(t)&&t>0?t:null}function le(e){return F=Te(e),ue=e?.document?.maxBytesMeasures==="file"?"file":null,F}var be=/<script\b[^>]*\bmerge=(["'])blockeditor\1[^>]*>[\s\S]*?<\/script\s*>/i;function B(e,t=ue){if(t!=="file"||typeof e!="string")return e;let n=be.exec(e);if(!n)return e;let o=n.index,s=o+n[0].length,r=e.lastIndexOf(`
|
|
2
2
|
`,o-1)+1,a=e.indexOf(`
|
|
3
|
-
`,s),c=a===-1?e.length:a+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function H(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function ce(){return F}function L({fresh:e=!1}={}){return e?(T=A({fresh:!0}).then(le),T):(T||(T=A().then(le)),T)}function St({fresh:e=!1}={}){return L({fresh:e}).then(t=>({maxBytes:t}))}async function xt(e){let t=await L();return H(B(e),t)}function fe(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-M7ITYKMF.js").then(n=>n.start(t),()=>{})}var P="/_/clayjs/",Oe=/[\u0000-\u001F\u007F]/,Ee=/^[\t\n\f\r ]|[\t\n\f\r ]$/,$e=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,Re=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,de=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,ke=/%2e|%2f|%5c/i;function Me(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function je(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function Le(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Pe(e){if(e===""||e.includes("\\")||ke.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function b(e,{documentURL:t}={}){if(typeof e!="string"||e===""||Ee.test(e)||Oe.test(e))return null;let{head:n,search:o,hash:s}=Le(e),r=null,a=null,c=null,l=null,i=$e.exec(n);if(i&&(r="rolling",c=i[1],l=i[2]),r||(i=Re.exec(n),i&&(r="exact",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),r||(i=de.exec(n),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),!r){let f=je(t);f&&n.startsWith(`${f}/`)&&(i=de.exec(n.slice(f.length)),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4]))}if(!r)return null;let u=Pe(l);return u===null?null:{kind:r,major:c,version:a,rawPath:l,path:u,search:o,hash:s}}function Ie(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function _e(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function Ne(e,t,n){if(!n)return!0;let o=Ie(n,t);return!!(o&&Object.hasOwn(o,e.path))}function he(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=b(e,{documentURL:o});if(!r||r.kind!=="local")return e;let a=_e(t),c=Me(r.version);for(let l of a){if(l.local!==e||typeof l.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,l.original)&&i[l.original]===r.path)return l.original;let u=b(l.original);if(u&&!(u.kind!=="rolling"&&u.kind!=="exact")&&u.rawPath===r.rawPath&&u.search===r.search&&u.hash===r.hash&&!(u.kind==="rolling"?u.major!==c:u.version!==r.version)&&Ne(r,r.version,n))return u.kind==="exact"?l.original:`https://clayjs.com/v${u.major}/${r.rawPath}${r.search}${r.hash}`}for(let l of a){if(typeof l.original!="string")continue;let i=b(l.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var De=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),z="clay-runtime-map",Ue=new Set(["stylesheet","preload","modulepreload"]),pe=null,J=null;function Ce(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Fe(){if(typeof document>"u")return null;let e=document.getElementById(z);if(!e)return null;let t=e.textContent??"";return t===pe||(pe=t,J=Ce(t)),J}var Be=`script[src*="${P}"], link[href*="${P}"], #${z}`;function me(e){if(e.querySelector(Be))return!0;for(let t of e.querySelectorAll("template"))if(me(t.content))return!0;return!1}function He(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function Je(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>Ue.has(n))?"href":null}function ze(e){if(!e||!me(e))return;let t=[],n=!1;for(let r of He(e)){if(r.getAttribute("id")===z){r.remove();continue}let a=Je(r);a&&(t.push({element:r,name:a}),!n&&(r.getAttribute(a)??"").includes(P)&&(n=!0))}if(!n)return;let o=location.href,s=Fe();for(let{element:r,name:a}of t){let c=r.getAttribute(a),l=b(c,{documentURL:o});!l||l.kind!=="local"||r.setAttribute(a,he(c,{descriptor:s,documentURL:o,aliases:De}))}}re(ze);var x=!1,$=null,ge="/_/save",Ke=12e3,ve=6e4,We=1024*1024,we="text/plain;charset=UTF-8",I=null,R=!1,K=new Map;function Ht(e,t){t==null?K.delete(e):K.set(e,String(t))}var W=new Set;function Jt(e){return W.add(e),()=>W.delete(e)}async function zt(e,t){R=!!e;try{return await t()}finally{R=!1}}function Gt(){return x}function Kt(){return x?null:(x=!0,$={reserved:!0},$)}function Wt(e){!e||$!==e||($=null,x=!1)}function Xt(){return R}var _=[],N=[];function Yt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function Vt(e){return N.push(e),()=>{let t=N.indexOf(e);t>=0&&N.splice(t,1)}}function Xe(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function Ye(e){for(let t of N)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ye(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null,...e.siteData?{siteData:e.siteData}:{}}}var O=[],Ve=8,y=null;function qt(){return y!==null}function Se(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function qe(e){O.push(e),O.length>Ve&&O.shift()}function Ze(e){return typeof e=="string"&&e!==""&&O.includes(e)}function Zt(){O.length=0,y=null}function X(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&y!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function E(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function Qe(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...X(t),sent:!1,size:e}}var w=null;function et(e){return w?null:(w={kind:e},w)}function tt(e){w===e&&(w=null)}function nt(){return w?w.kind:null}function rt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var ot=3,it=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function st(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!it.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var at=/^[0-9a-f]{64}$/,lt=/^[A-Za-z0-9-]{1,64}$/;function ut(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!at.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!lt.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function ct(e,t,n,o,s,r=!1,a=null,c=!0){let l=V(),i=l?`${ge}/${l}`:ge,u={method:"POST",credentials:l?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[se]:String(1)},body:ft(e)};for(let[f,h]of K)u.headers[f]=h;if(c)for(let f of W){let h=null;try{h=f(e)}catch(p){console.error("clayjs: a save header source failed:",p)}if(h)for(let[p,S]of Object.entries(h))u.headers[p]=String(S)}return typeof u.body!="string"&&(u.headers["Content-Type"]=we),a&&(u.headers["Blockeditor-Conversion"]=a),s&&(u.headers["If-Match"]=s),r&&e.length<ve&&new Blob([e]).size<ve&&(u.keepalive=!0),{url:dt(i),options:u}}function ft(e){if(e.length<We)return e;if(I&&I.content===e)return I.blob;let t=new Blob([e],{type:we});return I={content:e,blob:t},t}function xe(){let e=oe();return ie()&&e?e:null}function dt(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function G(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function ht(e,t){let n=q();return n?Promise.resolve().then(()=>n(e,t)).then(()=>G(200,{msg:"Saved in this browser",msgType:"success"}),o=>G(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:o?.code||"draft-storage"})):Promise.resolve(G(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function pt(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[],gateToken:a=null}={}){let c=new AbortController,l=setTimeout(()=>c.abort(),Ke),i=Q(),u=ee(),f=i||u,h=R;R=!1;let{url:p,options:S}=ct(e,f,c.signal,t,n,h,s);return qe(t),k||(r.some(d=>d.saveId===t&&d.etag===(n??null))||r.push({saveId:t,etag:n??null}),Xe({captureId:o,saveId:t,html:e,etag:n??null})),(k?ht(e,a):fetch(p,S)).then(d=>d.text().then(g=>{let m={};if(g)try{m=JSON.parse(g)}catch{if(d.ok)throw new Error("Server sent a response that was not JSON")}if(!d.ok){let v=new Error(m.msg||m.error||`HTTP ${d.status}: ${d.statusText}`);throw v.code=d.status===413?"save-too-large":m.code??null,v.status=d.status,v.changedBy=m.changedBy??null,v.etag=m.etag??null,v.saveId=m.saveId??null,v.reason=typeof m.reason=="string"?m.reason:null,v.saveOutcome=m.saveOutcome??null,v.retryAfter=st(d.headers?.get?.("Retry-After")),v}return j(m.etag??null),y=null,m})).catch(d=>{throw console.error("Failed to save page:",d),d.name==="AbortError"&&(y={saveId:t,etag:n}),f&&Z(),d}).finally(()=>{clearTimeout(l)})}async function mt(){let e=y;if(!e)return{landed:null,resend:!1};let n=(await A({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(j(o),y=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(y=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function gt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[],gateToken:s=null}={}){let r=Se(),a=xe(),c=!1,l=!1,i=0,u=t??M();for(;;)try{return await pt(e,r,a,{captureId:t,conversionHeader:n,attempts:o,gateToken:s})}catch(f){if(c&&(f.hadTimeout=!0),f.name==="AbortError"){if(c)throw f;let{landed:h,resend:p,etag:S}=await mt();if(h)return h;if(!p)throw f;a=S,c=!0;continue}if(f.status===412&&!l&&Ze(f.saveId)){j(f.etag??null),y=null,r=Se(),a=xe(),l=!0;continue}if(f.code==="blockeditor-converting"&&i<ot){if(M()!==u||(i+=1,await new Promise(h=>setTimeout(h,Math.max(0,f.retryAfter??1)*1e3)),M()!==u))throw f;continue}throw f}}function Y(e,t,n,o,s=null,r=0,a=null,c=null){return e=ae(e,Math.max(C(),r)),new Promise(l=>{let i=[],u=te(s),f=()=>a!==null&&$===a,h=()=>{f()||(x=!1)},p=(g,m=!1)=>{m&&U(e,t??null,u),ne(s),Ye({captureId:t??null,result:g,attempts:i,sent:i.length>0}),typeof n=="function"&&n(g),l(g)};if(!D&&!window.clay?.testMode)return p(E("Not in edit mode"));if(x&&!f())return p(E("Save already in progress"));let S=ut(o);if(S.invalid)return p(rt());if(x=!0,window.clay?.testMode){setTimeout(()=>{h(),p(ye({msg:"Test mode: save skipped"}))},0);return}L();let d=H(B(e),ce());if(fe(d),d.state==="over")return h(),p(Qe(d));gt(e,{captureId:t,conversionHeader:S.header,attempts:i,gateToken:c}).then(ye,X).then(g=>{h(),g.code==="save-too-large"&&!g.size&&(g.size=d),g.ok&&U(e,t??null,u,g.siteData??null),p(g)})})}function vt(e,t=()=>{}){return Y(e,null,t,null)}function Qt(e,t,n=()=>{},{conversion:o,capture:s=null,blockeditorFormatFloor:r,lane:a=null,gateToken:c=null}={}){return Y(e,t,n,o,s,r,a,c)}function en({html:e,captureId:t,conversion:n}){return Y(e,t??null,void 0,n)}function tn(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{tt(o),typeof t=="function"&&t(r),n(r)};if(!D)return s(E("Not in edit mode"));if(nt())return s(E("Another document operation is in progress"));if(x)return s(E("Save already in progress"));if(k)return s(!1);o=et("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>vt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(X(r))})})}var Ae=null;function nn(e){Ae=e}function rn(){return Ae}export{L as a,St as b,xt as c,Ht as d,Jt as e,zt as f,Gt as g,Kt as h,Wt as i,Xt as j,Yt as k,Vt as l,qt as m,Se as n,Zt as o,et as p,tt as q,nt as r,ct as s,vt as t,Qt as u,en as v,tn as w,nn as x,rn as y};
|
|
3
|
+
`,s),c=a===-1?e.length:a+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function H(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function ce(){return F}function L({fresh:e=!1}={}){return e?(T=A({fresh:!0}).then(le),T):(T||(T=A().then(le)),T)}function St({fresh:e=!1}={}){return L({fresh:e}).then(t=>({maxBytes:t}))}async function xt(e){let t=await L();return H(B(e),t)}function fe(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-3F3AADKG.js").then(n=>n.start(t),()=>{})}var P="/_/clayjs/",Oe=/[\u0000-\u001F\u007F]/,Ee=/^[\t\n\f\r ]|[\t\n\f\r ]$/,$e=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,Re=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,de=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,ke=/%2e|%2f|%5c/i;function Me(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function je(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function Le(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Pe(e){if(e===""||e.includes("\\")||ke.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function b(e,{documentURL:t}={}){if(typeof e!="string"||e===""||Ee.test(e)||Oe.test(e))return null;let{head:n,search:o,hash:s}=Le(e),r=null,a=null,c=null,l=null,i=$e.exec(n);if(i&&(r="rolling",c=i[1],l=i[2]),r||(i=Re.exec(n),i&&(r="exact",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),r||(i=de.exec(n),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),!r){let f=je(t);f&&n.startsWith(`${f}/`)&&(i=de.exec(n.slice(f.length)),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4]))}if(!r)return null;let u=Pe(l);return u===null?null:{kind:r,major:c,version:a,rawPath:l,path:u,search:o,hash:s}}function Ie(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function _e(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function Ne(e,t,n){if(!n)return!0;let o=Ie(n,t);return!!(o&&Object.hasOwn(o,e.path))}function he(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=b(e,{documentURL:o});if(!r||r.kind!=="local")return e;let a=_e(t),c=Me(r.version);for(let l of a){if(l.local!==e||typeof l.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,l.original)&&i[l.original]===r.path)return l.original;let u=b(l.original);if(u&&!(u.kind!=="rolling"&&u.kind!=="exact")&&u.rawPath===r.rawPath&&u.search===r.search&&u.hash===r.hash&&!(u.kind==="rolling"?u.major!==c:u.version!==r.version)&&Ne(r,r.version,n))return u.kind==="exact"?l.original:`https://clayjs.com/v${u.major}/${r.rawPath}${r.search}${r.hash}`}for(let l of a){if(typeof l.original!="string")continue;let i=b(l.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var De=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),z="clay-runtime-map",Ue=new Set(["stylesheet","preload","modulepreload"]),pe=null,J=null;function Ce(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Fe(){if(typeof document>"u")return null;let e=document.getElementById(z);if(!e)return null;let t=e.textContent??"";return t===pe||(pe=t,J=Ce(t)),J}var Be=`script[src*="${P}"], link[href*="${P}"], #${z}`;function me(e){if(e.querySelector(Be))return!0;for(let t of e.querySelectorAll("template"))if(me(t.content))return!0;return!1}function He(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function Je(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>Ue.has(n))?"href":null}function ze(e){if(!e||!me(e))return;let t=[],n=!1;for(let r of He(e)){if(r.getAttribute("id")===z){r.remove();continue}let a=Je(r);a&&(t.push({element:r,name:a}),!n&&(r.getAttribute(a)??"").includes(P)&&(n=!0))}if(!n)return;let o=location.href,s=Fe();for(let{element:r,name:a}of t){let c=r.getAttribute(a),l=b(c,{documentURL:o});!l||l.kind!=="local"||r.setAttribute(a,he(c,{descriptor:s,documentURL:o,aliases:De}))}}re(ze);var x=!1,$=null,ge="/_/save",Ke=12e3,ve=6e4,We=1024*1024,we="text/plain;charset=UTF-8",I=null,R=!1,K=new Map;function Ht(e,t){t==null?K.delete(e):K.set(e,String(t))}var W=new Set;function Jt(e){return W.add(e),()=>W.delete(e)}async function zt(e,t){R=!!e;try{return await t()}finally{R=!1}}function Gt(){return x}function Kt(){return x?null:(x=!0,$={reserved:!0},$)}function Wt(e){!e||$!==e||($=null,x=!1)}function Xt(){return R}var _=[],N=[];function Yt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function Vt(e){return N.push(e),()=>{let t=N.indexOf(e);t>=0&&N.splice(t,1)}}function Xe(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function Ye(e){for(let t of N)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ye(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null,...e.siteData?{siteData:e.siteData}:{}}}var O=[],Ve=8,y=null;function qt(){return y!==null}function Se(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function qe(e){O.push(e),O.length>Ve&&O.shift()}function Ze(e){return typeof e=="string"&&e!==""&&O.includes(e)}function Zt(){O.length=0,y=null}function X(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&y!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function E(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function Qe(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...X(t),sent:!1,size:e}}var w=null;function et(e){return w?null:(w={kind:e},w)}function tt(e){w===e&&(w=null)}function nt(){return w?w.kind:null}function rt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var ot=3,it=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function st(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!it.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var at=/^[0-9a-f]{64}$/,lt=/^[A-Za-z0-9-]{1,64}$/;function ut(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!at.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!lt.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function ct(e,t,n,o,s,r=!1,a=null,c=!0){let l=V(),i=l?`${ge}/${l}`:ge,u={method:"POST",credentials:l?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[se]:String(1)},body:ft(e)};for(let[f,h]of K)u.headers[f]=h;if(c)for(let f of W){let h=null;try{h=f(e)}catch(p){console.error("clayjs: a save header source failed:",p)}if(h)for(let[p,S]of Object.entries(h))u.headers[p]=String(S)}return typeof u.body!="string"&&(u.headers["Content-Type"]=we),a&&(u.headers["Blockeditor-Conversion"]=a),s&&(u.headers["If-Match"]=s),r&&e.length<ve&&new Blob([e]).size<ve&&(u.keepalive=!0),{url:dt(i),options:u}}function ft(e){if(e.length<We)return e;if(I&&I.content===e)return I.blob;let t=new Blob([e],{type:we});return I={content:e,blob:t},t}function xe(){let e=oe();return ie()&&e?e:null}function dt(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function G(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function ht(e,t){let n=q();return n?Promise.resolve().then(()=>n(e,t)).then(()=>G(200,{msg:"Saved in this browser",msgType:"success"}),o=>G(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:o?.code||"draft-storage"})):Promise.resolve(G(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function pt(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[],gateToken:a=null}={}){let c=new AbortController,l=setTimeout(()=>c.abort(),Ke),i=Q(),u=ee(),f=i||u,h=R;R=!1;let{url:p,options:S}=ct(e,f,c.signal,t,n,h,s);return qe(t),k||(r.some(d=>d.saveId===t&&d.etag===(n??null))||r.push({saveId:t,etag:n??null}),Xe({captureId:o,saveId:t,html:e,etag:n??null})),(k?ht(e,a):fetch(p,S)).then(d=>d.text().then(g=>{let m={};if(g)try{m=JSON.parse(g)}catch{if(d.ok)throw new Error("Server sent a response that was not JSON")}if(!d.ok){let v=new Error(m.msg||m.error||`HTTP ${d.status}: ${d.statusText}`);throw v.code=d.status===413?"save-too-large":m.code??null,v.status=d.status,v.changedBy=m.changedBy??null,v.etag=m.etag??null,v.saveId=m.saveId??null,v.reason=typeof m.reason=="string"?m.reason:null,v.saveOutcome=m.saveOutcome??null,v.retryAfter=st(d.headers?.get?.("Retry-After")),v}return j(m.etag??null),y=null,m})).catch(d=>{throw console.error("Failed to save page:",d),d.name==="AbortError"&&(y={saveId:t,etag:n}),f&&Z(),d}).finally(()=>{clearTimeout(l)})}async function mt(){let e=y;if(!e)return{landed:null,resend:!1};let n=(await A({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(j(o),y=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(y=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function gt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[],gateToken:s=null}={}){let r=Se(),a=xe(),c=!1,l=!1,i=0,u=t??M();for(;;)try{return await pt(e,r,a,{captureId:t,conversionHeader:n,attempts:o,gateToken:s})}catch(f){if(c&&(f.hadTimeout=!0),f.name==="AbortError"){if(c)throw f;let{landed:h,resend:p,etag:S}=await mt();if(h)return h;if(!p)throw f;a=S,c=!0;continue}if(f.status===412&&!l&&Ze(f.saveId)){j(f.etag??null),y=null,r=Se(),a=xe(),l=!0;continue}if(f.code==="blockeditor-converting"&&i<ot){if(M()!==u||(i+=1,await new Promise(h=>setTimeout(h,Math.max(0,f.retryAfter??1)*1e3)),M()!==u))throw f;continue}throw f}}function Y(e,t,n,o,s=null,r=0,a=null,c=null){return e=ae(e,Math.max(C(),r)),new Promise(l=>{let i=[],u=te(s),f=()=>a!==null&&$===a,h=()=>{f()||(x=!1)},p=(g,m=!1)=>{m&&U(e,t??null,u),ne(s),Ye({captureId:t??null,result:g,attempts:i,sent:i.length>0}),typeof n=="function"&&n(g),l(g)};if(!D&&!window.clay?.testMode)return p(E("Not in edit mode"));if(x&&!f())return p(E("Save already in progress"));let S=ut(o);if(S.invalid)return p(rt());if(x=!0,window.clay?.testMode){setTimeout(()=>{h(),p(ye({msg:"Test mode: save skipped"}))},0);return}L();let d=H(B(e),ce());if(fe(d),d.state==="over")return h(),p(Qe(d));gt(e,{captureId:t,conversionHeader:S.header,attempts:i,gateToken:c}).then(ye,X).then(g=>{h(),g.code==="save-too-large"&&!g.size&&(g.size=d),g.ok&&U(e,t??null,u,g.siteData??null),p(g)})})}function vt(e,t=()=>{}){return Y(e,null,t,null)}function Qt(e,t,n=()=>{},{conversion:o,capture:s=null,blockeditorFormatFloor:r,lane:a=null,gateToken:c=null}={}){return Y(e,t,n,o,s,r,a,c)}function en({html:e,captureId:t,conversion:n}){return Y(e,t??null,void 0,n)}function tn(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{tt(o),typeof t=="function"&&t(r),n(r)};if(!D)return s(E("Not in edit mode"));if(nt())return s(E("Another document operation is in progress"));if(x)return s(E("Save already in progress"));if(k)return s(!1);o=et("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>vt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(X(r))})})}var Ae=null;function nn(e){Ae=e}function rn(){return Ae}export{L as a,St as b,xt as c,Ht as d,Jt as e,zt as f,Gt as g,Kt as h,Wt as i,Xt as j,Yt as k,Vt as l,qt as m,Se as n,Zt as o,et as p,tt as q,nt as r,ct as s,vt as t,Qt as u,en as v,tn as w,nn as x,rn as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as B}from"./c-QY7F6EN6.js";import{d as T}from"./c-QHWJ5ZIJ.js";import{b as E,c as I,f as x,g as $,h as N,j as y}from"./c-J2ZW4HMR.js";import{a as g,d as S,e as b,f as w}from"./c-A5LASUEZ.js";import{e as d,f,g as m}from"./c-5RZNFTWD.js";import{b as C}from"./c-PKCCHJ5X.js";import{a as L,b as c}from"./c-NUHP2XDB.js";var h={success:{edge:d.teal,icon:f.toastSuccess},error:{edge:d.ox,icon:f.toastWarning},warning:{edge:d.brass,icon:f.toastWarning},info:{edge:d.brass,icon:f.toastInfo}},R=f.toastClose,_=["opacity:0","transform:translateX(24px)"],P=24,q=10;function U(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches?"none":"opacity .5s ease-in-out, transform .5s ease-in-out"}function X(e){let n=document.querySelector('clay-editor-ui[data-clay-ui="toasts"]')?.shadowRoot.querySelector("[data-clay-toasts]");if(n)return n;let s=x("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"],{theme:e,parts:["toast.stack"]});return s.setAttribute("data-clay-toasts",""),s.setAttribute("aria-live","polite"),B({name:"toasts",content:s}),s}function A(e,n,{detail:s="",actions:t=[]}={},i){let l=h[n],o=N("div",["display:flex","align-items:flex-start",...m.toast,"width:100%",`border-inline-start:3px solid ${l.edge}`,"cursor:pointer","pointer-events:auto",..._,`transition:${U()}`],{theme:i,parts:["toast.panel"]});g(i)&&L(o,[`border-inline-start-color:${l.edge}`,...b(i,["toast.panel"],{})]),o.setAttribute("data-clay-toast",n);let a=x("div",["flex:1 1 auto","min-width:0","display:flex","flex-direction:column","gap:8px"],{theme:i}),r=x("div",["display:flex","align-items:flex-start","gap:8px"],{theme:i}),p=y("span",["display:inline-grid","flex:none","padding-top:1px",`color:${l.edge}`],void 0,{theme:i,parts:["toast.icon"],role:null});p.innerHTML=l.icon,E(p.firstElementChild,16);let O=y("span",["flex:1 1 auto","min-width:120px",...m.toastTitle,"overflow-wrap:anywhere"],e,{theme:i,parts:["toast.text"]});if(r.append(p,O),a.append(r),s&&a.append(y("span",["display:block",`padding-inline-start:${P}px`,`color:${d.muted}`,"overflow-wrap:anywhere"],s,{theme:i,parts:["toast.text"],role:"mutedText"})),t.length){let k=x("div",["display:flex","flex-wrap:wrap","gap:8px",`padding-inline-start:${P-q}px`],{theme:i});for(let{label:D,onClick:H}of t)k.append(I(D,{small:!0,variant:"quiet",onClick:H,extra:["padding:4px 8px"],theme:i}));a.append(k)}return o.append(a),o}function W(e,n){let s=["flex:none","display:inline-grid","place-items:center",...m.toastClose,"cursor:pointer"],t=x("button",s);if(t.type="button",t.setAttribute("aria-label","Dismiss"),t.title="Dismiss",t.innerHTML=R,!g(n)){E(t.firstElementChild,14);let r=p=>{c(t,"color",p?d.ink:d.muted),c(t,"background",p?d.sunk:"transparent")};return t.addEventListener("pointerenter",()=>r(!0)),t.addEventListener("pointerleave",()=>r(!1)),t.addEventListener("focus",()=>{r(!0),c(t,"outline",`2px solid ${d.brass}`),c(t,"outline-offset","1px")}),t.addEventListener("blur",()=>{r(!1),c(t,"outline","none")}),t.addEventListener("click",e),t}let i=["close","toast.close"],l=["icon","toast.closeIcon"];w(t,n,i),w(t.firstElementChild,n,l);let o={hover:!1,focus:!1,pressed:!1},a=()=>{let r={hover:o.hover,active:o.pressed,focus:o.focus},p=t.firstElementChild;p.style.cssText="",E(p,14),L(p,b(n,l,r)),$(t,[...s,...S(n,"close",r),...b(n,i,r)])};return t.addEventListener("pointerenter",()=>{o.hover=!0,a()}),t.addEventListener("pointerleave",()=>{o.hover=!1,o.pressed=!1,a()}),t.addEventListener("pointerdown",r=>{r.button!==void 0&&r.button!==0||(o.pressed=!0,a())}),t.addEventListener("pointerup",()=>{o.pressed=!1,a()}),t.addEventListener("focus",()=>{o.focus=!0,a()}),t.addEventListener("blur",()=>{o.focus=!1,o.pressed=!1,a()}),t.addEventListener("click",e),a(),t}function M(e,n){X(n).append(e),g(n)?c(e,"color-scheme",n.scheme==="light dark"?"light":n.scheme):C(e,{background:d.surface}),setTimeout(()=>{c(e,"opacity","1"),c(e,"transform","none")},10)}function v(e,n){c(e,"opacity","0"),c(e,"transform","translateX(24px)"),setTimeout(()=>{e.remove(),n?.()},500)}function z(e,n="success"){let s=T(),t=A(e,h[n]?n:"success",{},s);t.addEventListener("click",()=>v(t)),M(t,s),setTimeout(()=>v(t),6600)}var u=new Map;function Q(e,n="warning",{detail:s="",actions:t=[]}={}){let i=u.get(e);i&&(v(i),u.delete(e));let l=T(),o=A(e,h[n]?n:"warning",{detail:s,actions:t},l);c(o,"cursor","default");let a=W(r=>{r.stopPropagation(),v(o,()=>{u.get(e)===o&&u.delete(e)})},l);o.append(a),u.set(e,o),M(o,l)}function V(e,{now:n=!1}={}){let s=u.get(e);if(s){if(u.delete(e),n){s.remove();return}v(s)}}var Z=z;export{Q as a,V as b,Z as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h}from"./c-A5LASUEZ.js";import"./c-VHNSBD2M.js";export{g as floorRules,h as heightFloor,f as markParts,e as partRules,b as stateList,a as themed,c as tokenRules,d as tokenRulesFor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Qt}from"./c-4ASQPRQL.js";import{a as Ot}from"./c-GQ6F6IDK.js";import{c as F}from"./c-I2SCCUEW.js";import{b as We}from"./c-5VYOWDTI.js";import{a as Vt,d as $,e as Ge,f as R,h as N}from"./c-P73XPAOA.js";import{a as Ke,b as Yt,c as jt,d as zt}from"./c-ZPI7M5U5.js";import{a as $t}from"./c-UGHH4MB3.js";import{a as kt}from"./c-MZCOGNZL.js";import{a as Rt,f as Ft,g as P,h as Ut,i as qt,j as Bt,m as Ht,u as Gt,w as Wt,x as Kt}from"./c-EHAR4RJJ.js";import{b as Nt,h as He}from"./c-PGSBXHUE.js";import{a as qe,c as It,g as bt,h as Be}from"./c-KU3PX7LL.js";import{a as be,f as Re,h as Q}from"./c-IJUK2GPW.js";import{b as K,e as Pt,f as A}from"./c-C7SUMNMI.js";import{k as Ct,m as Mt,o as xt}from"./c-U4TWEIKZ.js";import{E as Ue,h as Ne,r as Fe,u as Lt,y as V,z as me}from"./c-UW6MMZ4V.js";import{d as Dt}from"./c-MOP5KBWZ.js";import{a as pe}from"./c-2YYDMLNZ.js";import{d as Et,e as wt,g as At,h as Tt}from"./c-HA6INT6J.js";import{k as _t}from"./c-ICMAOOGK.js";var An="clay:debug:autosave";function ve(){try{return localStorage.getItem(An)==="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 Xt(e,t){ve()&&ge().then(n=>n?.logUnloadDiffSync(e,t))}function Jt(){ve()&&ge().then(e=>e?.preloadIfEnabled())}var U=Number.NEGATIVE_INFINITY;function Tn({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 Zt({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 Tn({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}}Fe(e=>{for(let t of Tt)e.removeAttribute(t)},{required:!0});Fe(e=>{for(let t of[...Et,...wt,...At])e.removeAttribute(t)},{required:!0});var x=null;function w(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),Mn(e,r.detail)}var an=Symbol.for("clay.saveFailureClaimed"),Br=e=>{e?.detail&&(e.detail[an]=!0)},Ee=null,un=()=>(Ee??=import("./c-2EFMJYGJ.js").catch(e=>{throw Ee=null,e}),Ee),Cn=()=>{un().then(e=>e.warm(),()=>{})};for(let e of["beforeinput","keydown","pointerdown"])document.addEventListener(e,Cn,{once:!0,capture:!0});function Mn(e,t){if(e==="saved"){Ee?.then(n=>n.clearFailures(),()=>{});return}e!=="error"&&e!=="offline"||t?.[an]||un().then(n=>n.reportFailure(e),n=>{console.error("clayjs: a save failed and the notice for it could not be downloaded",n)})}function ot(){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","offline")}function xn(){x=setTimeout(()=>{w("saving")},500)}window.addEventListener("offline",()=>{ot()});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,we=new Set,D=!1,k=!1,Ae=!1,B=0,je=!1;function Pn(){B++}function ln(){B!==0&&(B--,!(B>0)&&(fe&&(fe=!1,Z=setTimeout(mt,0)),je&&(je=!1,Oe())))}function _n(){return B>0}var Y=0,ne=!1,ae=!1,Te=!1;function de(e=null){return Y===0||dn(e)}function st(){return ne}function Dn(){if(ne)return!0;try{let e=V({flushUndo:!1});return St(e)?!1:e!==C}catch{return!0}}function kn(){let e="idle",t=0;return{get phase(){return e},get open(){return e==="open"},changedWhileClosed(){return e==="quiesced"&&Ge()!==t},start(){e==="idle"&&(e="open")},quiesce(){e==="open"&&(e="quiesced",t=Ge(),Y++)},resume(){e==="quiesced"&&(e="open",Y--,!(Y>0)&&(zn(),on()))},stop(){if(e==="stopped")return;let n=e==="quiesced";(n||e==="open")&&Dn()&&(Te=!0),e="stopped",n&&(Y--,Y===0&&on())}}}var en=!1,oe=null,ze=null,Xe=!1;function Hr(e=b){if(!oe||oe.generation!==e)return null;let{bytes:t,etag:n}=oe;return{bytes:t,etag:n}}function Gr({represented:e}={}){let t=R(),{forComparison:n,forDirty:o}=me(),r=typeof e?.etag=="string"&&e.etag?e.etag:null;return!(Xe&&r!==null&&r!==ze)&&Te&&(n!==L||o!==C)?{ok:!1,code:"pending-input"}:(Te=!1,ue(n,o),W=n,ee=!1,vt=!0,ze=r,Xe=!0,N(t),document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:baseline-settled")),{ok:!0})}var it=Promise.resolve(!1),Ce=!1,Ln=()=>(Ce=!0,bt().catch(()=>!1).then(e=>(Ce=!1,e)));function Wr(){return{id:"clay:save",order:10,prepare(e={}){let t=kn();return e.initial===!0&&t.start(),{enable(){it=Ln();let n=e.represented?.etag;typeof n=="string"&&n&&It(n),e.initial!==!0&&(On(),t.start())},quiesce:()=>t.quiesce(),resume:()=>t.resume(),dispose:()=>t.stop()}}}}function On(){en||(en=!0,Vt(),be(),En(),wn())}var O=0,Je=!1,Me=!1,at="Waiting for the AI edit to be kept or reverted",j=new Map;function Kr(e=at){O++,j.set(e,(j.get(e)||0)+1)}function Qr({replay:e=!0,reason:t=at}={}){let n=j.get(t)||0;if(n===0||(n===1?j.delete(t):j.set(t,n-1),O--,O>0))return;let o=Je,r=Me;Je=!1,Me=!1,e&&(o?I():r&&Oe())}function Vr(){return O>0}function ut(){return O===0?null:j.keys().next().value||at}function fn(e,t){if(O===0)return!1;Je=!0,Q();let n=h(ut());return e(n),t(n),n}var H=!1,se=null;function In(e){se=e??null,!H&&(H=!0,Pn())}function bn(){H&&(H=!1,se=null,ln())}function Ze(){return H}function $r(e){if(!H||se&&e!==se)return;H=!1,se=null,!We()&&$()||(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}})),ln()}function h(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function lt(e){return($()||F())&&(ne=!0),h(e)}function cn(){return{ok:!1,msg:"You are not allowed to save this document.",msgType:"forbidden",code:"forbidden",status:403,sent:!1,etag:null}}function ft(){return Pt()===!1}var ct=new Set,b=0;function Yr(){return b}function jr(e){typeof e=="number"&&(b=e)}function Rn(e=b){let t=Object.freeze({generation:e});return ct.add(t),t}function Nn(e){ct.delete(e)}function dn(e){return!!e&&ct.has(e)&&e.generation===b}function z(e,t){e!=null&&zt({captureId:e,ok:t.ok===!0,etag:t.etag??null})}function Fn(e,t,n,o,r,i=null,a=null,f=!1){if(z(a,e),e.ok)ne=!1,ue(t,n),xe=i,oe={bytes:i,etag:qe(),generation:b},ze=oe.etag,Xe=!0,Te=!1,q=!1,N(r),w("saved",e.msg||"Saved",e.msgType,{etag:e.etag??null,captureId:a}),re(o,`${L.length} chars`),bn();else if(e.msgType==="conflict"){if(f){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","saved");return}In(e.conflictEtag),w("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?w("error",e.msg,e.msgType||"error",u):w("offline",e.msg,e.msgType||"error",u)}}function pn(){if(!(!D&&!k)&&!Ht()){if(D){D=!1,k=!1,I();return}k=!1,nt.request()}}function zr(){return q}function Xr(e){q=e}function Jr(){return L}function dt(){return C}var xe=null;function Zr(){return xe}function ue(e,t){L=e,C=t,ie++}function eo(e){ue(e,e)}var G=()=>typeof performance<"u"&&performance.now?performance.now():Date.now();var Un=4,tn="Save cancelled: the page changed while it prepared",X=null,le=null,Qe=null,mn=!1;function vn(){return Qe||(Qe=import("./c-DYTBSJBI.js").then(e=>(le=e,e),e=>(mn=!0,console.info("clayjs: sliced save off ("+(e&&e.message?e.message:e)+"); saves prepare in one task"),null))),Qe}function qn(){try{return performance.getEntriesByType("navigation")[0]?.decodedBodySize||0}catch{return 0}}var Bn=()=>typeof xe=="string"?xe.length:qn();function Pe(){return mn||document.hidden||Bt()?!1:Bn()>=307200}function nn(e,t,n){return n?"morph":b!==t.generation||!A?"mode":de(e.permit)?ft()?"refused":ie!==t.baselines?"newer save":Math.max(He(),e.blockeditorFormatFloor)>t.floor?"floor":null:"session"}function Hn(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 pt({explicit:e,forced:t=!1,forSave:n,forComparison:o,forDirty:r,captureId:i,gateToken:a,costMs:f,blockeditorFormatFloor: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=!ee||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(_t)||$()&&r===C)}catch(yt){console.error("savePageThrottled: dirty domain check failed",yt)}M&&N(a),nt.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}}}xn();let l={forComparison:o,forDirty:r};return we.add(l),Ae=!0,new Promise(s=>{Gt(n,i,v=>{Ae=!1,we.delete(l);let M=G();Fn(v,l.forComparison,l.forDirty,t?"updated after force save":"updated after save",a,n,i,m),e||nt.noteCost(f+(G()-M)),typeof g=="function"&&g(v),s({result:v,dispatched:!0}),c||pn()},{capture:S,blockeditorFormatFloor:u,lane:p,gateToken:a})})}async function Gn(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=R(),f={generation:b,baselines:ie,floor:Math.max(He(),e.blockeditorFormatFloor)},u=le.beginSaveCapture({requestRefresh:!0,forRequest:!0,pageFormatMarker:f.floor?{name:Nt,content:String(f.floor)}:null});Yt(u.captureId);let m=null,c={get aborted(){let d=nn(e,f,n.over);return d&&(m=d),!!d}},p;try{p=await le.runPreparedSteps(u.steps(),{budgetMs:Un,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 w("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:nn(e,f,n.over);if(!S){let d=p.result;return await pt({explicit:e.explicit,forced:e.forced,forSave:d.forSave,forComparison:d.forComparison,forDirty:d.forDirty,captureId:d.captureId,gateToken:a,costMs:p.activeMs,blockeditorFormatFloor:e.blockeditorFormatFloor,quietConflict:e.quietConflict,laneHeld:!0,lane:t,capture:d,noteRecovery:()=>jt(d.captureId,d.forSave),release:()=>u.drop(),callback:e.callback})}u.drop();let y=h(tn);if(S==="session"&&(ae=!0),z(u.captureId,y),!(S==="floor"&&i===0)){if(S==="morph"&&e.explicit&&i===0){await Hn(),n.over=!1;continue}return typeof e.callback=="function"&&e.callback(y),{result:y,dispatched:!1}}}let r=h(tn);return typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}}finally{document.removeEventListener("clay:sync-applied",o),qt(t)}}function gn(e){let t=Ut();if(!t)return!1;let n=Gn(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 w("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||ke.length)&&pn()}),!0}function Le(e,t=()=>{}){return Ce?it.then(()=>Le(e,t)):te?ce.then(()=>De(e,t)):De(e,t)}function _e(e,t){let n=!1,o=setTimeout(()=>{n=!0,w("saving")},500);return e.then(()=>(clearTimeout(o),t())).then(r=>(n&&!P()&&!$()&&document.documentElement.getAttribute("savestatus")==="saving"&&(document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-status",{detail:{state:"saved"}}))),r))}function De({kind:e,permit:t=null},n=()=>{}){let o=e==="explicit";return new Promise(r=>{if(!A&&!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=lt("Save session is quiesced");return o&&T().forEach(v=>v(s)),n(s),r(s)}if(ft()){o&&Q();let s=cn();return w("error",s.msg,"",{code:s.code,status:s.status,sent:!1}),T().forEach(v=>v(s)),n(s),r(s)}if(o){let s=fn(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){Me=!0;let s=h(ut());return n(s),r(s)}if(P()&&!ee&&Ae){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(!ee&&!$()){let s=h("No changes to save");return n(s),r(s)}}let i=window.clay?.source?.ensureForSave?.();if(i)return r(_e(i,()=>De({kind:e,permit:t},n)));if(Pe()&&!le){r(_e(vn(),()=>De({kind:e,permit:t},n)));return}let a=o?T():[],f=s=>a.forEach(v=>v(s));if(!navigator.onLine&&ot(),Pe()&&gn({explicit:o,forced:!1,permit:t,blockeditorFormatFloor:0,quietConflict:!1,settleSoonQueued:f,callback:n,resolve:r}))return;let m=G(),c,p,S,y,d,g=R();try{c=Ue({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(),w("error",s.message,"error",{sent:!1,code:s.code??null})):w("error",s.message,"error");let v={ok:!1,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;pt({explicit:o,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:l,capture:c,noteRecovery:()=>Ke({captureId:d,html:p}),release:()=>Ne(c),callback:n}).then(s=>{r(s.result),f(s.result)})})}function I(e=()=>{}){return Le({kind:"explicit"},e)}function Wn(e,t=()=>{}){return Le({kind:"explicit",permit:e},t)}function J(e=()=>{},{quietConflict:t=!1,blockeditorFormatFloor:n=0,permit:o=null}={}){return Ce?it.then(()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})):new Promise(r=>{if(!A&&!window.clay?.testMode){let l=h("Not in edit mode");return T().forEach(s=>s(l)),e(l),r(l)}if(!de(o)||o&&!dn(o)){let l=lt("Save session is quiesced");return T().forEach(s=>s(l)),e(l),r(l)}if(ft()){let l=cn();return w("error",l.msg,"",{code:l.code,status:l.status,sent:!1}),T().forEach(s=>s(l)),e(l),r(l)}let i=fn(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 r(_e(a,()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})));if(!navigator.onLine&&ot(),Pe()&&!le){r(_e(vn(),()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})));return}let u=T(),m=l=>u.forEach(s=>s(l));if(Pe()&&gn({explicit:!0,forced:!0,permit:o,blockeditorFormatFloor:n,quietConflict:t,settleSoonQueued:m,callback:e,resolve:r}))return;let c,p,S,y,d,g=R();try{c=Ue({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(l){console.error("savePageForce: captureForSaveAndComparison failed",l),w("error",l.message,"error",{sent:!1,code:l.code??null});let s={ok:!1,msg:l.message,msgType:"error",code:l.code??null,etag:null};typeof e=="function"&&e(s),r(s),m(s);return}pt({explicit:!0,forced:!0,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:0,blockeditorFormatFloor:n,quietConflict:t,capture:c,noteRecovery:()=>Ke({captureId:d,html:p}),release:()=>Ne(c),callback:e}).then(l=>{r(l.result),m(l.result)})})}Kt(e=>J(()=>{},{permit:e}));function Kn(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 Qn(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 to({keepalive:e=!1,timeoutMs:t=15e3,permit:n=null}={}){if(!A)return{state:"view",etag:null};let o=Date.now()+t,r=n||Rn(),i={over:!1},a=null,f=new Promise((u,m)=>{a=setTimeout(()=>m(Object.assign(_("Save timed out.","failed"),{timedOut:!0})),Math.max(0,t))});try{return await Promise.race([Vn(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||Nn(r)}}async function Vn(e,t,n,o={over:!1}){if(hn()||await Qn("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 Kn(t),o.over))return null;if(Ze())throw _("This document has a conflict to resolve.","conflict");let f=R();if(!rt()){if(N(f),F())throw _("This document has unsaved work a save cannot write.","blocked");return ne=!1,{state:r?"saved":"clean",etag:i??qe()}}if(o.over)return null;let u=await Ft(e,()=>Wn(n));if(u.msgType!=="skipped"){if(!u.ok)throw _(u.msg||"Save failed",u.msgType==="conflict"||Ze()?"conflict":"failed");r=!0,i=u.etag??null}}throw _("The document kept changing while saving.","failed")}async function no(e=()=>{}){return await Be({fresh:!0}),J(e)}function ro(e){!A||K||Wt(e,t=>{t.ok?window.location.reload():t.msgType==="skipped"?w("error",t.msg||"Template not saved"):w("error",t.msg||"Failed to save template")})}var $n=Ot(e=>Le({kind:"automatic"},e),1200),Yn=250,jn=1e3,Z=null,rn=0,et=[],ke=[],fe=!1,T=()=>{let e=ke;return ke=[],e};function mt(){if(Z=null,B>0||!de()){fe=!0;return}let e=et;if(et=[],P()){ke.push(...e),I();return}I().then(t=>e.forEach(n=>n(t)))}function oo(){let e=Date.now();return Z===null?rn=e:clearTimeout(Z),new Promise(t=>{et.push(t),Z=setTimeout(mt,Math.max(0,Math.min(Yn,rn+jn-e)))})}function zn(){ae&&(ae=!1,Oe())}function on(){fe&&(fe=!1,Z=setTimeout(mt,0))}var W="",ee=!0,vt=!1;function hn(){return vt}var Ve=!1,Xn=250,Jn=1250,$e=null,Sn="clay:paint-heal:"+location.pathname;function yn(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 Zn(e){try{return localStorage.getItem(Sn)===yn(e)}catch{return!1}}function er(e){try{localStorage.setItem(Sn,yn(e))}catch{}}function tr(){return Dt(Lt({flushUndo:!1}))}function so(e){!A||K||(clearTimeout($e),$e=setTimeout(async()=>{$e=null,te&&await ce;let t=typeof e=="function"?e():e;t==null||!We()||!hn()||Ze()||_n()||V({flushUndo:!1})===C&&t!==tr()&&(Zn(t)||(er(t),J(()=>{},{quietConflict:!0})))},Xn+Math.random()*Jn))}var Se=null,Ye=null,te=0,ce=Promise.resolve(),gt=!1,ht=[];function nr(){return Ye??=import("./c-KNPDOMDY.js").catch(e=>(Ye=null,console.error("style-comparisons failed to load",e),null)),Ye}async function rr(e){try{if(Se||(Se=(await nr())?.styleComparisonStripper??null),!Se)return;let t=Se(e);L=t(L),C=t(C),W=t(W);for(let n of we)n.forComparison=t(n.forComparison),n.forDirty=t(n.forDirty)}catch(t){console.error("style adoption failed",t)}finally{te--,ht.shift()}}var ye=e=>e.replace(/&/g,"&").replace(/"/g,""");function or(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 sr(e){let t=[L,C,W];for(let n of we)t.push(n.forComparison,n.forDirty);return t.some(n=>n&&e.some(o=>o&&n.includes(o)))}function ir(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)}$t(e=>{let t=or(e);sr(t)&&(te||(gt=!1),te++,ht.push({markers:t,tag:e.name!==void 0?"style":"link"}),ce=ce.then(()=>rr(e)))});function io(){return ce}function St(e){return!te||gt||F()||P()||D||k||ne||typeof e!="string"?!1:e===ir(C,ht)}var ar=500,ur=3e3,lr=1e4,tt=null;function fr(){pe.holdSettle=!1,tt&&tt()}function sn(){if(!A)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)||(gt=!0,e||(Ve=!0))};i.forEach(c=>document.addEventListener(c,f,!0));let u=()=>{if(!e){if(e=!0,t&&t(),!Ve&&ie===r){let c=R(),{forComparison:p,forDirty:S}=me();ue(p,S),W=p,N(c),re("settled capture",`${p.length} chars`)}else re("settled skipped",Ve?"user edited":"save occurred during settle");ee=!1,document.documentElement.setAttribute("savestatus","saved"),vt=!0,document.dispatchEvent(new CustomEvent("clay:baseline-settled"))}};tt=u;let m=()=>{pe.holdSettle||u()};t=kt.onAnyChange({debounce:ar,omitChangeDetails:!0,require:"autosave"},m),setTimeout(()=>{e||m()},ur),setTimeout(()=>{!e&&pe.holdSettle&&fr()},lr)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",sn):sn();function Oe(e=()=>{}){if(!A){let t=h("Not in edit mode");return e(t),Promise.resolve(t)}if(O>0){Me=!0;let t=h(ut());return e(t),Promise.resolve(t)}if(!de()){ae=!0;let t=lt("Save session is quiesced");return e(t),Promise.resolve(t)}if(B>0){je=!0;let t=h("Autosave suspended");return e(t),Promise.resolve(t)}if(!ee&&Ae){k=!0;let t=h("Save already in progress");return e(t),Promise.resolve(t)}return $n(e).catch(t=>{let n={ok:!1,msg:t?.message||"Save failed",msgType:"error",code:null,etag:null};return w("error",n.msg),n})}var nt=Zt({now:G,run:()=>Oe()});function En(){document.addEventListener("keydown",function(e){if((window.navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)&&e.keyCode==83){if(!A)return;e.preventDefault(),e.isTrusted&&Re(),I()}})}function wn(){document.addEventListener("click",e=>{e.target.closest("[trigger-save]")&&(e.isTrusted&&Re(),I())})}function cr(){A&&(Be(),Rt(),be(),En(),wn())}cr();var ao=I;var Ie=!1;function go({isCurrent:e,reload:t}){return e()?(Ie=!0,setTimeout(()=>{Ie=!1},1e3),t(),!0):!1}Jt();function dr(){return st()?!0:A?F()?!0:K?Mt()||xt():window.clay?.demo?!1:rt():!1}function rt(){if(!A)return!1;try{let e=V();return St(e)?!1:e!==dt()}catch{return!0}}window.addEventListener("beforeunload",e=>{if(!A&&!st())return;if(Ie){Ie=!1;return}if(!((!K||Ct())&&!dr())&&(e.preventDefault(),e.returnValue="",!window.clay?.demo&&!F()))try{let n=V(),o=dt();n!==o&&Xt(n,o)}catch{}});export{go as a,dr as b,rt as c,Br as d,Pn as e,ln as f,_n as g,de as h,st as i,kn as j,Hr as k,Gr as l,Wr as m,Kr as n,Qr as o,Vr as p,ut as q,Ze as r,$r as s,Yr as t,jr as u,Rn as v,Nn as w,zr as x,Xr as y,Jr as z,dt as A,Zr as B,ue as C,eo as D,I as E,J as F,to as G,no as H,ro as I,oo as J,hn as K,tr as L,so as M,io as N,St as O,fr as P,Oe as Q,nt as R,En as S,wn as T,cr as U,ao as V};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./c-7WZSUTYP.js";import{b as s,d as n,f as l,h as m}from"./c-PGSBXHUE.js";import{f as i}from"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var p="blockeditor-format-activation-failed";function u(){let e=document.querySelector(`meta[name="${s}"]`);return e?l(e.outerHTML):0}var F=async e=>(await import("./core/save-
|
|
1
|
+
import"./c-7WZSUTYP.js";import{b as s,d as n,f as l,h as m}from"./c-PGSBXHUE.js";import{f as i}from"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var p="blockeditor-format-activation-failed";function u(){let e=document.querySelector(`meta[name="${s}"]`);return e?l(e.outerHTML):0}var F=async e=>(await import("./core/save-JZ7R4ET2.js")).savePageForce(()=>{},e),P=4,f=1e4,w=e=>e?.ok===!1&&e?.msgType==="skipped"&&/in progress/i.test(e?.msg??""),A=async()=>{let{isSaveInProgress:e}=await import("./core/save-core-I4N6S4ED.js"),a=Date.now()+f;for(;e()&&Date.now()<a;)await new Promise(c=>setTimeout(c,50))};function k({save:e=F,settles:a=A,supported:c=()=>i().then(o=>o===1)}={}){return{read(){return{floor:Math.max(m(),u()),revision:null}},capabilities(){return[]},supported:c,async activate({floor:o=1}={}){let t;try{t=await e({blockeditorFormatFloor:o});for(let r=1;r<P&&w(t);r+=1)await a(),t=await e({blockeditorFormatFloor:o})}catch(r){return{accepted:!1,code:r?.code??p}}return t?.ok?{accepted:!0,revision:null,receipt:t.receipt??t.etag??null}:t?.code===n?{accepted:!1,code:n}:{accepted:!1,code:t?.code??p}}}}export{k as createFormatHost};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b}from"./c-NEQRFC4O.js";import{a as T,d as h}from"./c-IW6GGOU2.js";import{b as y}from"./c-HAWFNBYG.js";import{n as d}from"./c-GO635CRU.js";import{ea as s,ha as m,ia as p,ja as g}from"./c-OH2FPYSY.js";import{a as c}from"./c-TCCA5BZN.js";import{r as f}from"./c-
|
|
1
|
+
import{b}from"./c-NEQRFC4O.js";import{a as T,d as h}from"./c-IW6GGOU2.js";import{b as y}from"./c-HAWFNBYG.js";import{n as d}from"./c-GO635CRU.js";import{ea as s,ha as m,ia as p,ja as g}from"./c-OH2FPYSY.js";import{a as c}from"./c-TCCA5BZN.js";import{r as f}from"./c-UW6MMZ4V.js";var x="article[data-blockeditor]",S=/^blockeditor(\.[0-9]+)?$/;function k(t){return[...t.querySelectorAll('script[merge][clay~="live"]')].filter(e=>S.test(e.getAttribute("merge")))}var a=null;function v(t){let e=t.join("\0");if(a&&a.key===e)return a;let r=t.map(i=>{try{return c(i)}catch{throw new d("invalid-json","Cannot read the page data as JSON")}}),n=b(r),o=s(n);return a={key:e,html:g(o,{fallbackOf:i=>{let u=n[i]?.artifact?.fallbackHtml;return typeof u=="string"?u:""},clean:p(document)}),rev:m(o),model:o,title:y(o)},a}function O(t){let e=t.querySelector(x);if(!e)return;let r=k(t);if(!r.length)return;let{html:n,rev:o,title:l}=v(r.map(i=>i.textContent));e.innerHTML!==n&&(e.innerHTML=n),e.setAttribute("data-rev",o),T(t)||h(t,l)}function A(t){let e=k(t);if(e.length!==1)return null;let r;try{r=c(e[0].textContent)}catch{return null}let{v:n,g:o,y:l}=r??{};return n!==1||!l||typeof l!="object"||Array.isArray(l)?null:{v:n,g:o,y:{...l}}}function M(t){return v([typeof t=="string"?t:JSON.stringify(t)]).html}function D(t){if(typeof t!="string")return null;try{let e=new DOMParser().parseFromString(t,"text/html"),r=A(e),n=e.querySelector(x);if(!r||!n)return null;let o=e.createElement("article");return o.innerHTML=M(r),n.innerHTML===o.innerHTML?r:null}catch{return null}}f(O,{required:!0});export{x as a,k as b,v as c,A as d,M as e,D as f};
|