@panphora/clayjs 1.20.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/all.js +1 -1
  2. package/dist/clay-dom.js +1 -1
  3. package/dist/clay-events.js +1 -1
  4. package/dist/clay-internals.js +1 -1
  5. package/dist/clay-options.js +1 -1
  6. package/dist/clay-router.js +1 -1
  7. package/dist/clay-ui.js +1 -1
  8. package/dist/clay-utils.js +1 -1
  9. package/dist/clay.js +1 -1
  10. package/dist/clay.standalone.js +7865 -8022
  11. package/dist/m/{c-JOH753EJ.js → c-26KVJS6J.js} +1 -1
  12. package/dist/m/{c-ZE46QDIH.js → c-3TLG3OLG.js} +1 -1
  13. package/dist/m/{c-RT3C74GY.js → c-4OGEVKR3.js} +1 -1
  14. package/dist/m/{c-Y33LUUIQ.js → c-4PHDUV3H.js} +1 -1
  15. package/dist/m/{c-SJPD46ZO.js → c-4RFZROCF.js} +4 -4
  16. package/dist/m/{c-XQSXKIKM.js → c-4TWARTLS.js} +1 -1
  17. package/dist/m/{c-S5IEIZCN.js → c-5AQYL27I.js} +1 -1
  18. package/dist/m/{c-OJYM642Q.js → c-5FKRZNJV.js} +1 -1
  19. package/dist/m/{c-CJFDLD43.js → c-6KBKYLPO.js} +1 -1
  20. package/dist/m/{c-DHXPDLW6.js → c-6PBXRWDX.js} +1 -1
  21. package/dist/m/{c-BRLCTNMC.js → c-6RC66MYY.js} +1 -1
  22. package/dist/m/{c-PIVIYLTY.js → c-6UEFPHHE.js} +1 -1
  23. package/dist/m/{c-YQUJ74R3.js → c-BV6FQQXM.js} +1 -1
  24. package/dist/m/{c-YSB6JKV2.js → c-DEAFCHDO.js} +2 -2
  25. package/dist/m/{c-NLZ5AN4L.js → c-DKFSOJCV.js} +1 -1
  26. package/dist/m/c-DP4X4JID.js +1 -0
  27. package/dist/m/{c-LIBE4HPD.js → c-DZBZ57EE.js} +1 -1
  28. package/dist/m/c-ECY5AZMH.js +1 -0
  29. package/dist/m/{c-VAK7SG37.js → c-EUGJVHDD.js} +1 -1
  30. package/dist/m/{c-GPGYKER7.js → c-F5AER2ID.js} +1 -1
  31. package/dist/m/{c-RG6XUZFA.js → c-FAXQU7MQ.js} +1 -1
  32. package/dist/m/{c-XD5MOROJ.js → c-FLBUYV3P.js} +1 -1
  33. package/dist/m/{c-NFR673TL.js → c-FMCPQ4VT.js} +2 -2
  34. package/dist/m/{c-VBLFAQD2.js → c-FNIGX4FI.js} +1 -1
  35. package/dist/m/{c-BTLFLLML.js → c-FWFJUU3T.js} +1 -1
  36. package/dist/m/{c-2VB555FG.js → c-GPTKI7AQ.js} +1 -1
  37. package/dist/m/{c-EZ7B5AZT.js → c-GY4ODHO2.js} +1 -1
  38. package/dist/m/{c-5734MF2P.js → c-H6DXQEH2.js} +1 -1
  39. package/dist/m/{c-Z32V4MHK.js → c-HAVGDXAL.js} +1 -1
  40. package/dist/m/{c-D3E4WJ4M.js → c-HDWZEJHM.js} +49 -32
  41. package/dist/m/{c-W23KVGUO.js → c-HWR6GMGK.js} +1 -1
  42. package/dist/m/{c-BJ7YQ5QZ.js → c-IHUWUKIU.js} +1 -1
  43. package/dist/m/{c-AL4RBJF2.js → c-ILGQ3UXQ.js} +1 -1
  44. package/dist/m/{c-W3K23S72.js → c-IWTTOC2V.js} +1 -1
  45. package/dist/m/c-JFST6QE7.js +1 -0
  46. package/dist/m/{c-FNVQAACK.js → c-KE33W4RE.js} +1 -1
  47. package/dist/m/c-KV7R47FR.js +1 -0
  48. package/dist/m/{c-LPUJXRXW.js → c-L7K5EXU2.js} +1 -1
  49. package/dist/m/{c-3YH6JSIL.js → c-LF6HNVPU.js} +1 -1
  50. package/dist/m/{c-MIL4B2JQ.js → c-MRURHLKV.js} +1 -1
  51. package/dist/m/{c-LQU7TXIH.js → c-N33TPVTL.js} +1 -1
  52. package/dist/m/{c-EOCZ2YVL.js → c-NBNRLZXO.js} +1 -1
  53. package/dist/m/{c-JUE7B4OX.js → c-NLWEZYKJ.js} +1 -1
  54. package/dist/m/{c-DDDOKPI6.js → c-NNNR7OXA.js} +1 -1
  55. package/dist/m/{c-E4IBSAQM.js → c-OI2BYWVV.js} +1 -1
  56. package/dist/m/{c-SBSMJIPC.js → c-P3WATEDR.js} +1 -1
  57. package/dist/m/{c-ZJLU56DV.js → c-PCEMXY2K.js} +1 -1
  58. package/dist/m/{c-3GJ4XARY.js → c-PWBJVHA4.js} +1 -1
  59. package/dist/m/{c-67ILSNPR.js → c-Q5KAQJAG.js} +1 -1
  60. package/dist/m/{c-U5X57T4L.js → c-QHVCUTJV.js} +1 -1
  61. package/dist/m/{c-GKEATME6.js → c-QJFYVCJO.js} +1 -1
  62. package/dist/m/{c-VY6XRBOW.js → c-QTC6VGA4.js} +1 -1
  63. package/dist/m/{c-44B5ODN7.js → c-TMT5TL65.js} +2 -2
  64. package/dist/m/{c-OABVRYOT.js → c-TV7JHSRL.js} +1 -1
  65. package/dist/m/{c-SO63UGPQ.js → c-UWT4CXQ4.js} +1 -1
  66. package/dist/m/{c-EFD6QNTE.js → c-VFES2BP5.js} +1 -1
  67. package/dist/m/{c-UXEVJ63W.js → c-VIW5X35H.js} +1 -1
  68. package/dist/m/{c-EOCKLMKX.js → c-WWE67K5Y.js} +1 -1
  69. package/dist/m/{c-J3BXFTZS.js → c-XDVAZDUE.js} +1 -1
  70. package/dist/m/{c-K76AUL4I.js → c-XZJ5IK6Q.js} +1 -1
  71. package/dist/m/{c-2ZZBC45O.js → c-Z7RJANGO.js} +1 -1
  72. package/dist/m/{c-I2IFKJX2.js → c-ZAHTFCXQ.js} +1 -1
  73. package/dist/m/{c-GVPNDIKJ.js → c-ZKELCT4T.js} +1 -1
  74. package/dist/m/{c-7SXYQCN4.js → c-ZO6VL2SC.js} +1 -1
  75. package/dist/m/{c-M4FSPNQ2.js → c-ZYEJLZEY.js} +1 -1
  76. package/dist/m/core/{autosave-VPORYJSE.js → autosave-GI3WNJYN.js} +1 -1
  77. package/dist/m/core/{conflict-notice-JMAZLVRX.js → conflict-notice-CEI3XY6A.js} +1 -1
  78. package/dist/m/core/{save-AOJBDSOK.js → save-OJ5NSLS7.js} +1 -1
  79. package/dist/m/core/{save-core-IOCMXO5L.js → save-core-DX3RFVO3.js} +1 -1
  80. package/dist/m/core/{unsaved-warning-U5VUJFOE.js → unsaved-warning-HGYH7O4H.js} +1 -1
  81. package/dist/m/internals/{index-HDRANDWE.js → index-V4WC44FU.js} +1 -1
  82. package/dist/m/loader-V6VI46HU.js +1 -0
  83. package/dist/m/{manifest-3AEF5191.js → manifest-83C18DED.js} +1 -1
  84. package/dist/m/{manifest-edit-29A26F22.js → manifest-edit-B28C1985.js} +1 -1
  85. package/dist/m/manifest.json +567 -567
  86. package/dist/m/page/{editor-EY2WAAGB.js → editor-BQEPCJLG.js} +2 -2
  87. package/dist/m/plugins/ai-edit-45A2J6LC.js +6 -0
  88. package/dist/m/plugins/cms-IFTKWF4S.js +2235 -0
  89. package/dist/m/plugins/{derive-FRE5JJQE.js → derive-QVI3LI3A.js} +1 -1
  90. package/dist/m/plugins/{indicator-4VDXWYTD.js → indicator-IPZJ35K6.js} +1 -1
  91. package/dist/m/plugins/{live-5EZN2EYP.js → live-GPQXSXSM.js} +1 -1
  92. package/dist/m/plugins/menu-UN3KRCOF.js +1 -0
  93. package/dist/m/plugins/{page-LVW5DWA4.js → page-BAVLWCP6.js} +2 -2
  94. package/dist/m/plugins/{page-view-5KQ76IJB.js → page-view-P3UGJFDZ.js} +1 -1
  95. package/dist/m/plugins/{people-C7TVBBMR.js → people-Z4RGVQAV.js} +1 -1
  96. package/dist/m/plugins/{quickcrop-BQ5YYFCH.js → quickcrop-E34PUYA3.js} +2 -2
  97. package/dist/m/plugins/{richclay-KLGETK77.js → richclay-S4NVJYIK.js} +2 -2
  98. package/dist/m/plugins/{source-CCEUM3OR.js → source-KVN6YNTY.js} +1 -1
  99. package/dist/m/plugins/{upgrade-NW556WJD.js → upgrade-KTSICB22.js} +1 -1
  100. package/dist/m/plugins/{wire-VRYPY6EJ.js → wire-SYVIBNSE.js} +1 -1
  101. package/dist/m/{reader-core-2GXY7SHY.js → reader-core-RUIFH32Y.js} +2 -2
  102. package/dist/m/sync/{live-sync-SKPMFYOO.js → live-sync-RGQMMWK2.js} +1 -1
  103. package/dist/m/ui/{index-QNIPDHXQ.js → index-EZGLEM5P.js} +1 -1
  104. package/dist/m/vendor/{sap-core.vendor-RN4ZVY4X.js → sap-core.vendor-OA5SKL7Q.js} +1 -1
  105. package/dist/offline-manifest.json +463 -469
  106. package/docs/guide.md +16 -8
  107. package/entries/sap.js +1 -1
  108. package/package.json +2 -2
  109. package/src/loader-logic.js +4 -1
  110. package/src/plugins/ai-edit.js +6 -17
  111. package/src/plugins/cms.js +3 -6
  112. package/src/plugins/menu/style.js +59 -31
  113. package/src/plugins/menu.js +131 -28
  114. package/src/ui/bevel.js +1 -1
  115. package/src/ui/skins/cms.js +1 -1
  116. package/src/ui/skins/quickcrop.js +1 -1
  117. package/src/ui/skins/richclay.js +1 -1
  118. package/src/vendor/hypercms.vendor.js +16 -69
  119. package/src/vendor/sap-core.vendor.js +1 -1
  120. package/dist/m/c-FSWRGBVQ.js +0 -1
  121. package/dist/m/c-HMYWIHFG.js +0 -1
  122. package/dist/m/c-M6FNQCTQ.js +0 -1
  123. package/dist/m/c-WFMRX5RZ.js +0 -1
  124. package/dist/m/loader-DZZLUBVB.js +0 -1
  125. package/dist/m/plugins/ai-edit-J5VLSW5I.js +0 -6
  126. package/dist/m/plugins/cms-LRAOZHT7.js +0 -2293
  127. package/dist/m/plugins/menu-KGWKT6CS.js +0 -1
  128. package/src/ui/skins/cms-toggle.js +0 -15
  129. /package/dist/m/plugins/{quickcrop-BQ5YYFCH.js.LEGAL.txt → quickcrop-E34PUYA3.js.LEGAL.txt} +0 -0
  130. /package/dist/m/plugins/{richclay-KLGETK77.js.LEGAL.txt → richclay-S4NVJYIK.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{b as M,e as y,g as a,h as g}from"./c-VAK7SG37.js";import{a as x,b as R,c as E}from"./c-NUHP2XDB.js";var V=e=>!!e&&!e.bevel,z=(e,o,t)=>`color-mix(in srgb, ${e}, ${o} ${t}%)`,s=(e,o)=>o?[`${e}:${o}`]:[];function Y({hover:e=!1,active:o=!1,focus:t=!1,disabled:r=!1}={}){let n=["base"];return!r&&e&&n.push("hover"),!r&&o&&n.push("active"),t&&n.push("focus"),r&&n.push("disabled"),n}function N(e,o){return e.background&&e.background!==e.surface?o>8?z(e.background,e.text||"currentColor",6):e.background:e.surface?z(e.surface,e.text||"currentColor",o):e.background}function re(e,o,t){let r=[],n={primary:["accent","accentText"],danger:["danger","dangerText"]}[o];if(t==="base"&&r.push(...s("font-family",e.font),...s("border-radius",e.radius)),t==="base"&&e.buttonHeight&&r.push("height:auto","block-size:auto",`min-height:${e.buttonHeight}`),n){let i=e[n[0]],c=e[n[1]];t==="base"&&r.push(...s("background",i),...s("border-color",i),...s("color",c)),t==="hover"&&i&&c&&r.push(`background:${z(i,c,12)}`),t==="active"&&i&&r.push(`border-color:${i}`,...c?[`background:${z(i,c,20)}`]:[]),t==="disabled"&&i&&r.push("opacity:.55")}else o==="quiet"?(t==="base"&&r.push(...s("color",e.text)),t==="hover"&&r.push(...s("background",N(e,7))),t==="active"&&r.push(...s("background",N(e,12))),t==="disabled"&&r.push(...s("color",e.mutedText))):(t==="base"&&r.push(...s("background",e.surface),...s("color",e.text),...s("border-color",e.border)),t==="hover"&&r.push(...s("background",N(e,7))),t==="active"&&r.push(...s("background",N(e,12)),...s("border-color",e.border)),t==="disabled"&&r.push(...s("color",e.mutedText)));return t==="focus"&&e.accent&&r.push(`outline:2px solid ${e.accent}`),r}var X={input:(e,o)=>o==="base"?[...s("font-family",e.font),...s("color",e.text),...s("background",e.surface),...s("border-color",e.border),...s("border-radius",e.radius)]:o==="hover"?s("border-color",e.mutedText):o==="focus"&&e.accent?[`outline:2px solid ${e.accent}`,`border-color:${e.accent}`]:[],surface:(e,o)=>o==="base"?[...s("background",e.surface),...s("color",e.text),...s("border-color",e.border),...s("box-shadow",e.shadow),...s("border-radius",e.radius),...s("font-family",e.font)]:[],text:(e,o)=>o==="base"?[...s("color",e.text),...s("font-family",e.font)]:[],mutedText:(e,o)=>o==="base"?[...s("color",e.mutedText),...s("font-family",e.font)]:[],heading:(e,o)=>o==="base"?[...s("font-family",e.headingFont||e.font),...s("color",e.text)]:[],code:(e,o)=>o==="base"?s("color",e.text):[],well:(e,o)=>o==="base"?[...s("background",e.background),...e.border?[`border:1px solid ${e.border}`]:[],...s("border-radius",e.radius)]:[],overlay:(e,o)=>o==="base"?s("background",e.overlay):[],close:(e,o)=>o==="base"?[...s("background",e.surface),...s("color",e.mutedText),...s("border-color",e.border)]:o==="hover"?s("background",N(e,7)):o==="focus"&&e.accent?[`outline:2px solid ${e.accent}`]:[]};function ne(e,o,t="base"){return V(e)?o.startsWith("button.")?re(e.tokens,o.slice(7),t):X[o]?X[o](e.tokens,t):[]:[]}function C(e,o,t){return Y(t).flatMap(r=>ne(e,o,r))}function $(e,o,t){if(!V(e)||!o?.length)return[];let r=Y(t),n=[];for(let i of o){let c=e.parts[i];if(c)for(let d of r)for(let[b,L]of Object.entries(c[d]||{}))n.push(`${b}:${L}`)}return n}function w(e,o,t){V(o)&&t?.length&&e.setAttribute("data-clay-part",t.join(" "))}function O(e,o,t){if(!t)return[];let r=[...e].reverse().find(c=>c.startsWith(`${o}:`)),n=r?r.slice(o.length+1).trim():"",i=[`${o}:${t}px`];return n&&n!==`${t}px`&&i.push(`${o}:max(${t}px, ${n})`),i}var ie="no-save no-watch no-snapshot",m=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],J={normal:[`font:500 14px/1.45 ${M}`,"padding:4px 12px"],small:[`font:500 12.5px/1.45 ${M}`,"padding:1px 8px"]},P={default:{rest:a.button,hover:a.buttonHover,active:a.buttonActive},primary:{rest:a.buttonPrimary,hover:[...a.buttonPrimaryHoverBase,...a.buttonPrimaryHover],active:a.buttonPrimaryActive},quiet:{rest:[...a.button,...a.buttonQuiet],hover:[...a.buttonHover,...a.buttonQuietHover],active:[...a.buttonActive,...a.buttonQuietActive]},danger:{rest:a.buttonDanger,hover:a.buttonDangerHover,active:a.buttonDangerActive}},S=e=>typeof matchMedia=="function"&&matchMedia(e).matches,F=!1,_=new Set;typeof document<"u"&&(document.addEventListener("keydown",()=>{F=!0;for(let e of _)e()},!0),document.addEventListener("pointerdown",()=>{F=!1},!0));function A(e){return e.setAttribute("clay",ie),e}function B(e,o){e.style.cssText="",x(e,o)}var se="http://www.w3.org/2000/svg",ue=new Set(["path","circle","rect","line","polyline","polygon","ellipse","g"]);function ee(e,o){if(!(!e||e.namespaceURI!==se)){A(e),x(e,[...m,"color:inherit","display:block",`width:${o}px`,`height:${o}px`,"overflow:visible","visibility:visible","opacity:1","transform:none","pointer-events:none"]);for(let t of e.querySelectorAll("*")){if(!ue.has(t.localName))continue;let r=(i,c)=>t.getAttribute(i)??c,n=["visibility:visible","opacity:1","transform:none","display:inline",`fill:${r("fill",e.getAttribute("fill")??"currentColor")}`,`stroke:${r("stroke",e.getAttribute("stroke")??"none")}`];for(let i of["stroke-width","stroke-linecap","stroke-linejoin"]){let c=t.getAttribute(i)??e.getAttribute(i);c!==null&&n.push(`${i}:${c}`)}t.localName==="path"&&t.hasAttribute("d")&&n.push(`d:path("${t.getAttribute("d")}")`),x(t,n)}}}function oe(e,{variant:o="default",small:t=!1,onClick:r=null,extra:n=[],labelExtra:i=[],onState:c=null,theme:d=null,parts:b=[],labelParts:L=[]}={}){let h=P[o]||P.default,I=t?J.small:J.normal,j=S("(prefers-reduced-motion: reduce)"),q=S("(forced-colors: active)"),Z=S("(pointer: coarse)"),Q=S("(max-width: 760px)"),u={hovered:!1,pressed:!1,focusVisible:!1,disabled:!1},U=new Map,v=A(E("button",[]));v.type="button";let T=A(E("span",[]));T.textContent=e,v.append(T);let W=P[o]?o:"default",G=["button",`button.${W}`,...b],K=["buttonLabel",...L];w(v,d,G),w(T,d,K);function f(){let l=[...m,"box-sizing:border-box",...h.rest,...I];if(u.disabled?l.push(...a.buttonDisabled):(u.hovered&&l.push(...h.hover),u.pressed&&l.push(...h.active)),u.focusVisible&&l.push(...a.focus),q&&l.push(...g.forcedColors),Z&&l.push(...g.coarseButton),Q&&l.push("min-height:44px"),l.push(...n),V(d)){let k={hover:u.hovered,active:u.pressed,focus:u.focusVisible,disabled:u.disabled};l.push(...C(d,`button.${W}`,k),...$(d,G,k)),q&&l.push(...g.forcedColors),l.push(...O(l,"min-height",Q?44:Z?40:0))}for(let[k,te]of U)l.push(`${k}:${te}`);B(v,l);let p=[...m,"font:inherit","color:inherit",...a.buttonLabel];if(u.disabled?p.push(...a.buttonDisabledLabel):u.pressed&&p.push(...j?g.reducedMotion:a.buttonActiveLabel),p.push(...i),V(d)){let k={hover:u.hovered,active:u.pressed,focus:u.focusVisible,disabled:u.disabled};p.push(...$(d,K,k)),u.pressed&&!u.disabled&&j&&p.push(...g.reducedMotion)}B(T,p),c?.({...u})}function D(){let l;try{l=v.matches(":focus-visible")}catch{l=!1}let p=l||F;p!==u.focusVisible&&(u.focusVisible=p,f())}let H=(l,p)=>v.addEventListener(l,p);return H("pointerenter",()=>{u.hovered=!0,f()}),H("pointerleave",()=>{u.hovered=!1,u.pressed=!1,f()}),H("pointercancel",()=>{u.pressed=!1,f()}),H("pointerdown",l=>{l.button!==void 0&&l.button!==0||u.disabled||(u.pressed=!0,f())}),H("pointerup",()=>{u.pressed=!1,f()}),H("keydown",l=>{(l.key===" "||l.key==="Enter")&&!u.disabled&&(u.pressed=!0,f())}),H("keyup",()=>{u.pressed&&(u.pressed=!1,f())}),H("focus",()=>{_.add(D),u.focusVisible=!1,D(),f()}),H("blur",()=>{_.delete(D),u.focusVisible=!1,u.pressed=!1,f()}),H("click",l=>{if(u.pressed&&(u.pressed=!1,f()),u.disabled){l.preventDefault(),l.stopImmediatePropagation();return}r&&r(l)}),v.setLabel=l=>{T.textContent=l},v.setDisabled=l=>{u.disabled=!!l,u.disabled?v.setAttribute("aria-disabled","true"):v.removeAttribute("aria-disabled"),f()},v.isDisabled=()=>u.disabled,v.pin=l=>{for(let[p,k]of Object.entries(l))U.set(p,k);f()},f(),v}function ge(e,{label:o,onClick:t=null}){let r=oe("",{small:!0,onClick:t,extra:["width:26px","height:26px","padding:0","display:inline-grid","place-items:center"],labelExtra:["display:inline-grid","width:12px","height:12px"]});return r.firstChild.innerHTML=e,ee(r.firstChild.firstElementChild,12),r.setAttribute("aria-label",o),r.title=o,r}var le=["position:absolute","top:-1px","right:-1px","z-index:2","display:block","width:68px","height:68px","padding:0","margin:0","border:0","outline:none","background:transparent","clip-path:polygon(0 4%, 0 0, 100% 0, 100% 100%, 94% 100%)"],ce="M132 132.5 1 1.5h131v131Z",ae="M0 0h3v1.5h1.5V3H6v1.5h1.5V6H9v1.5h1.5V9H12v1.5h1.5V12H15v1.5h1.5V15H18v1.5h1.5V18H21v1.5h1.5V21H24v1.5h1.5V24H27v1.5h1.5V27H30v1.5h1.5V30H33v1.5h1.5V33H36v1.5h1.5V36H39v1.5h1.5V39H42v1.5h1.5V42H45v1.5h1.5V45H48v1.5h1.5V48H51v1.5h1.5V51H54v1.5h1.5V54H57v1.5h1.5V57H60v1.5h1.5V60H63v1.5h1.5V63H66v1.5h1.5V66H69v1.5h1.5V69H72v1.5h1.5V72H75v1.5h1.5V75H78v1.5h1.5V78H81v1.5h1.5V81H84v1.5h1.5V84H87v1.5h1.5V87H90v1.5h1.5V90H93v1.5h1.5V93H96v1.5h1.5V96H99v1.5h1.5V99h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v3h-3V132H129v-1.5h-1.5V129H126v-1.5h-1.5V126H123v-1.5h-1.5V123H120v-1.5h-1.5V120H117v-1.5h-1.5V117H114v-1.5h-1.5V114H111v-1.5h-1.5V111H108v-1.5h-1.5V108H105v-1.5h-1.5V105H102v-1.5h-1.5V102H99v-1.5h-1.5V99H96v-1.5h-1.5V96H93v-1.5h-1.5V93H90v-1.5h-1.5V90H87v-1.5h-1.5V87H84v-1.5h-1.5V84H81v-1.5h-1.5V81H78v-1.5h-1.5V78H75v-1.5h-1.5V75H72v-1.5h-1.5V72H69v-1.5h-1.5V69H66v-1.5h-1.5V66H63v-1.5h-1.5V63H60v-1.5h-1.5V60H57v-1.5h-1.5V57H54v-1.5h-1.5V54H51v-1.5h-1.5V51H48v-1.5h-1.5V48H45v-1.5h-1.5V45H42v-1.5h-1.5V42H39v-1.5h-1.5V39H36v-1.5h-1.5V36H33v-1.5h-1.5V33H30v-1.5h-1.5V30H27v-1.5h-1.5V27H24v-1.5h-1.5V24H21v-1.5h-1.5V21H18v-1.5h-1.5V18H15v-1.5h-1.5V15H12v-1.5h-1.5V12H9v-1.5H7.5V9H6V7.5H4.5V6H3V4.5H1.5V3H0V0ZM108.8 22h5.2v5.1h-2.6v2.6H109v2.6h-2.6v2.6h-2.6v2.5h-2.6v5.2h2.6V45h2.6v2.6h2.6v2.6h2.5v2.6h2.6V58h-5.1v-2.6h-2.6V53h-2.6v-2.6h-2.6v-2.6h-2.5v-2.6h-5.2v2.6H91v2.6h-2.6v2.6h-2.6v2.5h-2.6V58H78v-5.1h2.6v-2.6H83v-2.6h2.6v-2.6h2.6v-2.5h2.6v-5.2h-2.6V35h-2.6v-2.6h-2.6v-2.6h-2.5v-2.6H78V22h5.2v2.6h2.5V27h2.6v2.6h2.6v2.6h2.5v2.6h5.2v-2.6h2.5v-2.6h2.6v-2.6h2.6v-2.5h2.5V22Z";function me({label:e="Close",onClick:o=null}={}){let t=null,r=null,n=({hovered:d,focusVisible:b})=>{t&&(R(t,"fill",b?y.brass:d?y.face:y.sunk),R(r,"fill",b?y.face:y.ink))},i=oe("",{variant:"quiet",onClick:o,extra:le,labelExtra:["display:block","width:100%","height:100%"],onState:n});i.setAttribute("aria-label",e),i.firstChild.innerHTML=`<svg viewBox="0 0 134 134" xmlns="http://www.w3.org/2000/svg"><path d="${ce}"/><path fill-rule="evenodd" clip-rule="evenodd" d="${ae}"/></svg>`;let c=i.firstChild.firstElementChild;return ee(c,68),[t,r]=c.children,R(r,"fill-rule","evenodd"),R(r,"clip-rule","evenodd"),n({hovered:!1,focusVisible:!1}),i}function ke(e,o=[],{theme:t=null,parts:r=[],role:n=null}={}){let i=A(E(e,[...m,"box-sizing:border-box",...o]));if(V(t)){n&&x(i,C(t,n,{}));let c=[...["text","mutedText","well"].includes(n)?[n]:[],...r];x(i,$(t,c,{})),w(i,t,c)}return i}function ye(e,o){B(e,[...m,"box-sizing:border-box",...o])}function $e(e,o=[],{theme:t=null,parts:r=[],role:n="surface"}={}){let i=A(E(e,[...m,"box-sizing:border-box",...a.surface,`font:14px/1.5 ${M}`,...o]));return V(t)&&(n&&x(i,C(t,n,{})),x(i,$(t,r,{})),w(i,t,r)),i}function we(e=[],{theme:o=null,parts:t=[],role:r="well"}={}){let n=A(E("div",[...m,"display:block","box-sizing:border-box",`font:14px/1.5 ${M}`,`color:${y.ink}`,...a.recess,...e]));if(V(o)){r&&x(n,C(o,r,{}));let i=[...["text","mutedText","well"].includes(r)?[r]:[],...t];x(n,$(o,i,{})),w(n,o,i)}return n}function Ae(e,o=[],t,{theme:r=null,parts:n=[],role:i="text"}={}){let c=A(E(e,[...m,"font:inherit",`color:${y.ink}`,...o]));if(t!=null&&(c.textContent=t),V(r)){i&&x(c,C(r,i,{}));let d=[...["text","mutedText","well"].includes(i)?[i]:[],...n];x(c,$(r,d,{})),w(c,r,d)}return c}function de(e,{rules:o=[],theme:t=null,parts:r=[]}={}){let n={hovered:!1,focused:!1},i=S("(forced-colors: active)"),c=S("(pointer: coarse)");A(e);let d=["input",...r];w(e,t,d);function b(){let L=e.localName==="textarea"?e.style.getPropertyValue("height"):"",h=[...m,"box-sizing:border-box",...a.input];if(n.hovered&&h.push(...a.inputHover),n.focused&&h.push(...a.inputFocus),i&&h.push(...g.forcedColors),h.push(...o),c&&h.push(...g.coarseInput),V(t)){let I={hover:n.hovered&&!e.disabled,focus:n.focused,disabled:!!e.disabled};h.push(...C(t,"input",I),...$(t,d,I)),i&&h.push(...g.forcedColors),c&&h.push(...O(h,"font-size",16))}L&&h.push(`height:${L}`),B(e,h)}return e.addEventListener("pointerenter",()=>{n.hovered=!0,b()}),e.addEventListener("pointerleave",()=>{n.hovered=!1,b()}),e.addEventListener("focus",()=>{n.focused=!0,b()}),e.addEventListener("blur",()=>{n.focused=!1,b()}),b(),e}function Ee(e="input",o={}){let t=document.createElement(e);return e==="input"&&(t.type="text"),de(t,o)}function Ce(e,o,t="block"){e.hidden=!o,e.pin?e.pin({display:o?t:"none"}):R(e,"display",o?t:"none")}export{V as a,C as b,$ as c,w as d,ie as e,ee as f,oe as g,ge as h,me as i,ke as j,ye as k,$e as l,we as m,Ae as n,de as o,Ee as p,Ce as q};
1
+ import{b as M,e as y,g as a,h as g}from"./c-EUGJVHDD.js";import{a as x,b as R,c as E}from"./c-NUHP2XDB.js";var V=e=>!!e&&!e.bevel,z=(e,o,t)=>`color-mix(in srgb, ${e}, ${o} ${t}%)`,s=(e,o)=>o?[`${e}:${o}`]:[];function Y({hover:e=!1,active:o=!1,focus:t=!1,disabled:r=!1}={}){let n=["base"];return!r&&e&&n.push("hover"),!r&&o&&n.push("active"),t&&n.push("focus"),r&&n.push("disabled"),n}function N(e,o){return e.background&&e.background!==e.surface?o>8?z(e.background,e.text||"currentColor",6):e.background:e.surface?z(e.surface,e.text||"currentColor",o):e.background}function re(e,o,t){let r=[],n={primary:["accent","accentText"],danger:["danger","dangerText"]}[o];if(t==="base"&&r.push(...s("font-family",e.font),...s("border-radius",e.radius)),t==="base"&&e.buttonHeight&&r.push("height:auto","block-size:auto",`min-height:${e.buttonHeight}`),n){let i=e[n[0]],c=e[n[1]];t==="base"&&r.push(...s("background",i),...s("border-color",i),...s("color",c)),t==="hover"&&i&&c&&r.push(`background:${z(i,c,12)}`),t==="active"&&i&&r.push(`border-color:${i}`,...c?[`background:${z(i,c,20)}`]:[]),t==="disabled"&&i&&r.push("opacity:.55")}else o==="quiet"?(t==="base"&&r.push(...s("color",e.text)),t==="hover"&&r.push(...s("background",N(e,7))),t==="active"&&r.push(...s("background",N(e,12))),t==="disabled"&&r.push(...s("color",e.mutedText))):(t==="base"&&r.push(...s("background",e.surface),...s("color",e.text),...s("border-color",e.border)),t==="hover"&&r.push(...s("background",N(e,7))),t==="active"&&r.push(...s("background",N(e,12)),...s("border-color",e.border)),t==="disabled"&&r.push(...s("color",e.mutedText)));return t==="focus"&&e.accent&&r.push(`outline:2px solid ${e.accent}`),r}var X={input:(e,o)=>o==="base"?[...s("font-family",e.font),...s("color",e.text),...s("background",e.surface),...s("border-color",e.border),...s("border-radius",e.radius)]:o==="hover"?s("border-color",e.mutedText):o==="focus"&&e.accent?[`outline:2px solid ${e.accent}`,`border-color:${e.accent}`]:[],surface:(e,o)=>o==="base"?[...s("background",e.surface),...s("color",e.text),...s("border-color",e.border),...s("box-shadow",e.shadow),...s("border-radius",e.radius),...s("font-family",e.font)]:[],text:(e,o)=>o==="base"?[...s("color",e.text),...s("font-family",e.font)]:[],mutedText:(e,o)=>o==="base"?[...s("color",e.mutedText),...s("font-family",e.font)]:[],heading:(e,o)=>o==="base"?[...s("font-family",e.headingFont||e.font),...s("color",e.text)]:[],code:(e,o)=>o==="base"?s("color",e.text):[],well:(e,o)=>o==="base"?[...s("background",e.background),...e.border?[`border:1px solid ${e.border}`]:[],...s("border-radius",e.radius)]:[],overlay:(e,o)=>o==="base"?s("background",e.overlay):[],close:(e,o)=>o==="base"?[...s("background",e.surface),...s("color",e.mutedText),...s("border-color",e.border)]:o==="hover"?s("background",N(e,7)):o==="focus"&&e.accent?[`outline:2px solid ${e.accent}`]:[]};function ne(e,o,t="base"){return V(e)?o.startsWith("button.")?re(e.tokens,o.slice(7),t):X[o]?X[o](e.tokens,t):[]:[]}function C(e,o,t){return Y(t).flatMap(r=>ne(e,o,r))}function $(e,o,t){if(!V(e)||!o?.length)return[];let r=Y(t),n=[];for(let i of o){let c=e.parts[i];if(c)for(let d of r)for(let[b,L]of Object.entries(c[d]||{}))n.push(`${b}:${L}`)}return n}function w(e,o,t){V(o)&&t?.length&&e.setAttribute("data-clay-part",t.join(" "))}function O(e,o,t){if(!t)return[];let r=[...e].reverse().find(c=>c.startsWith(`${o}:`)),n=r?r.slice(o.length+1).trim():"",i=[`${o}:${t}px`];return n&&n!==`${t}px`&&i.push(`${o}:max(${t}px, ${n})`),i}var ie="no-save no-watch no-snapshot",m=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],J={normal:[`font:500 14px/1.45 ${M}`,"padding:4px 12px"],small:[`font:500 12.5px/1.45 ${M}`,"padding:1px 8px"]},P={default:{rest:a.button,hover:a.buttonHover,active:a.buttonActive},primary:{rest:a.buttonPrimary,hover:[...a.buttonPrimaryHoverBase,...a.buttonPrimaryHover],active:a.buttonPrimaryActive},quiet:{rest:[...a.button,...a.buttonQuiet],hover:[...a.buttonHover,...a.buttonQuietHover],active:[...a.buttonActive,...a.buttonQuietActive]},danger:{rest:a.buttonDanger,hover:a.buttonDangerHover,active:a.buttonDangerActive}},S=e=>typeof matchMedia=="function"&&matchMedia(e).matches,F=!1,_=new Set;typeof document<"u"&&(document.addEventListener("keydown",()=>{F=!0;for(let e of _)e()},!0),document.addEventListener("pointerdown",()=>{F=!1},!0));function A(e){return e.setAttribute("clay",ie),e}function B(e,o){e.style.cssText="",x(e,o)}var se="http://www.w3.org/2000/svg",ue=new Set(["path","circle","rect","line","polyline","polygon","ellipse","g"]);function ee(e,o){if(!(!e||e.namespaceURI!==se)){A(e),x(e,[...m,"color:inherit","display:block",`width:${o}px`,`height:${o}px`,"overflow:visible","visibility:visible","opacity:1","transform:none","pointer-events:none"]);for(let t of e.querySelectorAll("*")){if(!ue.has(t.localName))continue;let r=(i,c)=>t.getAttribute(i)??c,n=["visibility:visible","opacity:1","transform:none","display:inline",`fill:${r("fill",e.getAttribute("fill")??"currentColor")}`,`stroke:${r("stroke",e.getAttribute("stroke")??"none")}`];for(let i of["stroke-width","stroke-linecap","stroke-linejoin"]){let c=t.getAttribute(i)??e.getAttribute(i);c!==null&&n.push(`${i}:${c}`)}t.localName==="path"&&t.hasAttribute("d")&&n.push(`d:path("${t.getAttribute("d")}")`),x(t,n)}}}function oe(e,{variant:o="default",small:t=!1,onClick:r=null,extra:n=[],labelExtra:i=[],onState:c=null,theme:d=null,parts:b=[],labelParts:L=[]}={}){let h=P[o]||P.default,I=t?J.small:J.normal,j=S("(prefers-reduced-motion: reduce)"),q=S("(forced-colors: active)"),Z=S("(pointer: coarse)"),Q=S("(max-width: 760px)"),u={hovered:!1,pressed:!1,focusVisible:!1,disabled:!1},U=new Map,v=A(E("button",[]));v.type="button";let T=A(E("span",[]));T.textContent=e,v.append(T);let W=P[o]?o:"default",G=["button",`button.${W}`,...b],K=["buttonLabel",...L];w(v,d,G),w(T,d,K);function f(){let l=[...m,"box-sizing:border-box",...h.rest,...I];if(u.disabled?l.push(...a.buttonDisabled):(u.hovered&&l.push(...h.hover),u.pressed&&l.push(...h.active)),u.focusVisible&&l.push(...a.focus),q&&l.push(...g.forcedColors),Z&&l.push(...g.coarseButton),Q&&l.push("min-height:44px"),l.push(...n),V(d)){let k={hover:u.hovered,active:u.pressed,focus:u.focusVisible,disabled:u.disabled};l.push(...C(d,`button.${W}`,k),...$(d,G,k)),q&&l.push(...g.forcedColors),l.push(...O(l,"min-height",Q?44:Z?40:0))}for(let[k,te]of U)l.push(`${k}:${te}`);B(v,l);let p=[...m,"font:inherit","color:inherit",...a.buttonLabel];if(u.disabled?p.push(...a.buttonDisabledLabel):u.pressed&&p.push(...j?g.reducedMotion:a.buttonActiveLabel),p.push(...i),V(d)){let k={hover:u.hovered,active:u.pressed,focus:u.focusVisible,disabled:u.disabled};p.push(...$(d,K,k)),u.pressed&&!u.disabled&&j&&p.push(...g.reducedMotion)}B(T,p),c?.({...u})}function D(){let l;try{l=v.matches(":focus-visible")}catch{l=!1}let p=l||F;p!==u.focusVisible&&(u.focusVisible=p,f())}let H=(l,p)=>v.addEventListener(l,p);return H("pointerenter",()=>{u.hovered=!0,f()}),H("pointerleave",()=>{u.hovered=!1,u.pressed=!1,f()}),H("pointercancel",()=>{u.pressed=!1,f()}),H("pointerdown",l=>{l.button!==void 0&&l.button!==0||u.disabled||(u.pressed=!0,f())}),H("pointerup",()=>{u.pressed=!1,f()}),H("keydown",l=>{(l.key===" "||l.key==="Enter")&&!u.disabled&&(u.pressed=!0,f())}),H("keyup",()=>{u.pressed&&(u.pressed=!1,f())}),H("focus",()=>{_.add(D),u.focusVisible=!1,D(),f()}),H("blur",()=>{_.delete(D),u.focusVisible=!1,u.pressed=!1,f()}),H("click",l=>{if(u.pressed&&(u.pressed=!1,f()),u.disabled){l.preventDefault(),l.stopImmediatePropagation();return}r&&r(l)}),v.setLabel=l=>{T.textContent=l},v.setDisabled=l=>{u.disabled=!!l,u.disabled?v.setAttribute("aria-disabled","true"):v.removeAttribute("aria-disabled"),f()},v.isDisabled=()=>u.disabled,v.pin=l=>{for(let[p,k]of Object.entries(l))U.set(p,k);f()},f(),v}function ge(e,{label:o,onClick:t=null}){let r=oe("",{small:!0,onClick:t,extra:["width:26px","height:26px","padding:0","display:inline-grid","place-items:center"],labelExtra:["display:inline-grid","width:12px","height:12px"]});return r.firstChild.innerHTML=e,ee(r.firstChild.firstElementChild,12),r.setAttribute("aria-label",o),r.title=o,r}var le=["position:absolute","top:-1px","right:-1px","z-index:2","display:block","width:68px","height:68px","padding:0","margin:0","border:0","outline:none","background:transparent","clip-path:polygon(0 4%, 0 0, 100% 0, 100% 100%, 94% 100%)"],ce="M132 132.5 1 1.5h131v131Z",ae="M0 0h3v1.5h1.5V3H6v1.5h1.5V6H9v1.5h1.5V9H12v1.5h1.5V12H15v1.5h1.5V15H18v1.5h1.5V18H21v1.5h1.5V21H24v1.5h1.5V24H27v1.5h1.5V27H30v1.5h1.5V30H33v1.5h1.5V33H36v1.5h1.5V36H39v1.5h1.5V39H42v1.5h1.5V42H45v1.5h1.5V45H48v1.5h1.5V48H51v1.5h1.5V51H54v1.5h1.5V54H57v1.5h1.5V57H60v1.5h1.5V60H63v1.5h1.5V63H66v1.5h1.5V66H69v1.5h1.5V69H72v1.5h1.5V72H75v1.5h1.5V75H78v1.5h1.5V78H81v1.5h1.5V81H84v1.5h1.5V84H87v1.5h1.5V87H90v1.5h1.5V90H93v1.5h1.5V93H96v1.5h1.5V96H99v1.5h1.5V99h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v3h-3V132H129v-1.5h-1.5V129H126v-1.5h-1.5V126H123v-1.5h-1.5V123H120v-1.5h-1.5V120H117v-1.5h-1.5V117H114v-1.5h-1.5V114H111v-1.5h-1.5V111H108v-1.5h-1.5V108H105v-1.5h-1.5V105H102v-1.5h-1.5V102H99v-1.5h-1.5V99H96v-1.5h-1.5V96H93v-1.5h-1.5V93H90v-1.5h-1.5V90H87v-1.5h-1.5V87H84v-1.5h-1.5V84H81v-1.5h-1.5V81H78v-1.5h-1.5V78H75v-1.5h-1.5V75H72v-1.5h-1.5V72H69v-1.5h-1.5V69H66v-1.5h-1.5V66H63v-1.5h-1.5V63H60v-1.5h-1.5V60H57v-1.5h-1.5V57H54v-1.5h-1.5V54H51v-1.5h-1.5V51H48v-1.5h-1.5V48H45v-1.5h-1.5V45H42v-1.5h-1.5V42H39v-1.5h-1.5V39H36v-1.5h-1.5V36H33v-1.5h-1.5V33H30v-1.5h-1.5V30H27v-1.5h-1.5V27H24v-1.5h-1.5V24H21v-1.5h-1.5V21H18v-1.5h-1.5V18H15v-1.5h-1.5V15H12v-1.5h-1.5V12H9v-1.5H7.5V9H6V7.5H4.5V6H3V4.5H1.5V3H0V0ZM108.8 22h5.2v5.1h-2.6v2.6H109v2.6h-2.6v2.6h-2.6v2.5h-2.6v5.2h2.6V45h2.6v2.6h2.6v2.6h2.5v2.6h2.6V58h-5.1v-2.6h-2.6V53h-2.6v-2.6h-2.6v-2.6h-2.5v-2.6h-5.2v2.6H91v2.6h-2.6v2.6h-2.6v2.5h-2.6V58H78v-5.1h2.6v-2.6H83v-2.6h2.6v-2.6h2.6v-2.5h2.6v-5.2h-2.6V35h-2.6v-2.6h-2.6v-2.6h-2.5v-2.6H78V22h5.2v2.6h2.5V27h2.6v2.6h2.6v2.6h2.5v2.6h5.2v-2.6h2.5v-2.6h2.6v-2.6h2.6v-2.5h2.5V22Z";function me({label:e="Close",onClick:o=null}={}){let t=null,r=null,n=({hovered:d,focusVisible:b})=>{t&&(R(t,"fill",b?y.brass:d?y.face:y.sunk),R(r,"fill",b?y.face:y.ink))},i=oe("",{variant:"quiet",onClick:o,extra:le,labelExtra:["display:block","width:100%","height:100%"],onState:n});i.setAttribute("aria-label",e),i.firstChild.innerHTML=`<svg viewBox="0 0 134 134" xmlns="http://www.w3.org/2000/svg"><path d="${ce}"/><path fill-rule="evenodd" clip-rule="evenodd" d="${ae}"/></svg>`;let c=i.firstChild.firstElementChild;return ee(c,68),[t,r]=c.children,R(r,"fill-rule","evenodd"),R(r,"clip-rule","evenodd"),n({hovered:!1,focusVisible:!1}),i}function ke(e,o=[],{theme:t=null,parts:r=[],role:n=null}={}){let i=A(E(e,[...m,"box-sizing:border-box",...o]));if(V(t)){n&&x(i,C(t,n,{}));let c=[...["text","mutedText","well"].includes(n)?[n]:[],...r];x(i,$(t,c,{})),w(i,t,c)}return i}function ye(e,o){B(e,[...m,"box-sizing:border-box",...o])}function $e(e,o=[],{theme:t=null,parts:r=[],role:n="surface"}={}){let i=A(E(e,[...m,"box-sizing:border-box",...a.surface,`font:14px/1.5 ${M}`,...o]));return V(t)&&(n&&x(i,C(t,n,{})),x(i,$(t,r,{})),w(i,t,r)),i}function we(e=[],{theme:o=null,parts:t=[],role:r="well"}={}){let n=A(E("div",[...m,"display:block","box-sizing:border-box",`font:14px/1.5 ${M}`,`color:${y.ink}`,...a.recess,...e]));if(V(o)){r&&x(n,C(o,r,{}));let i=[...["text","mutedText","well"].includes(r)?[r]:[],...t];x(n,$(o,i,{})),w(n,o,i)}return n}function Ae(e,o=[],t,{theme:r=null,parts:n=[],role:i="text"}={}){let c=A(E(e,[...m,"font:inherit",`color:${y.ink}`,...o]));if(t!=null&&(c.textContent=t),V(r)){i&&x(c,C(r,i,{}));let d=[...["text","mutedText","well"].includes(i)?[i]:[],...n];x(c,$(r,d,{})),w(c,r,d)}return c}function de(e,{rules:o=[],theme:t=null,parts:r=[]}={}){let n={hovered:!1,focused:!1},i=S("(forced-colors: active)"),c=S("(pointer: coarse)");A(e);let d=["input",...r];w(e,t,d);function b(){let L=e.localName==="textarea"?e.style.getPropertyValue("height"):"",h=[...m,"box-sizing:border-box",...a.input];if(n.hovered&&h.push(...a.inputHover),n.focused&&h.push(...a.inputFocus),i&&h.push(...g.forcedColors),h.push(...o),c&&h.push(...g.coarseInput),V(t)){let I={hover:n.hovered&&!e.disabled,focus:n.focused,disabled:!!e.disabled};h.push(...C(t,"input",I),...$(t,d,I)),i&&h.push(...g.forcedColors),c&&h.push(...O(h,"font-size",16))}L&&h.push(`height:${L}`),B(e,h)}return e.addEventListener("pointerenter",()=>{n.hovered=!0,b()}),e.addEventListener("pointerleave",()=>{n.hovered=!1,b()}),e.addEventListener("focus",()=>{n.focused=!0,b()}),e.addEventListener("blur",()=>{n.focused=!1,b()}),b(),e}function Ee(e="input",o={}){let t=document.createElement(e);return e==="input"&&(t.type="text"),de(t,o)}function Ce(e,o,t="block"){e.hidden=!o,e.pin?e.pin({display:o?t:"none"}):R(e,"display",o?t:"none")}export{V as a,C as b,$ as c,w as d,ie as e,ee as f,oe as g,ge as h,me as i,ke as j,ye as k,$e as l,we as m,Ae as n,de as o,Ee as p,Ce as q};
@@ -1 +1 @@
1
- import{a as Xe,b as ce,d as de,e as ue,f as et}from"./c-DHXPDLW6.js";import{a as Ke,b as Qe,c as he,d as Ze}from"./c-LZJPNR2W.js";import{a as R,b as Y}from"./c-FILLTJA7.js";import{b as Ve}from"./c-5VYOWDTI.js";import{b as le,c as oe,d as x,f as ae,g as Ye,h as Je}from"./c-GSRLXYWL.js";import{a as q}from"./c-LA2BW7UY.js";import{a as Ne}from"./c-ATKAOH23.js";import{a as $e,f as je,g as ze,h as We}from"./c-EK63G3CG.js";import{a as ie,b as Ge,c as M,d as se,e as re,h as Ue}from"./c-NQJRVJ56.js";import{e as Oe}from"./c-XGH4GS2T.js";import{d as qe}from"./c-IJUK2GPW.js";import{f as $,j as ee}from"./c-3O7OBDCM.js";import{a as Ie}from"./c-BPF2NSPV.js";import{D as W,E as Me,G as T,H as Be,b as D,j as ne,s as P,y as Pe}from"./c-EGTIAL6P.js";import{a as Fe,b as Re,c as He,e as j,g as z,h as te}from"./c-VG5XIN4T.js";import{m as be,n as De}from"./c-HA6INT6J.js";import{a as Te,b as Le,l as Ce,m as Ae}from"./c-ICMAOOGK.js";function tt(s){let e=new WeakMap,t=0,i=r=>e.get(r)||null,n=r=>{let l=e.get(r);return l||(l=`${s}:${++t}`,e.set(r,l)),l};return{idOf:i,ensure:n,adopt:(r,l)=>{r&&typeof l=="string"&&l&&e.set(r,l)},exportMap:(r,l)=>{let o={},a=[],h=[],c=(d,_)=>{let g=l(d);g&&(o[_]=n(g));let E=d.children;a.push(E.length),h.push(d.tagName.toLowerCase());for(let f=0;f<E.length;f++)c(E[f],_===""?String(f):`${_}.${f}`)};return c(r,""),o["~"]=a.join(","),o["^"]=h.join(","),o}}}function nt(s,e){let t=new WeakMap;if(!s||!e||typeof e!="object"||Array.isArray(e))return t;let i=e["~"],n=typeof i=="string"?i.split(",").map(Number):null,r=n&&typeof e["^"]=="string"?e["^"].split(","):null,l=d=>Number.isInteger(d)&&d>=0,o=0,a=!1,h=d=>{let _=d;for(;_>0;){let g=n[o++];if(o>n.length||!l(g))return!1;_+=g-1}return!0},c=(d,_)=>{if(a)return;if(n){let f=o++,u=n[f];if(f>=n.length||!l(u)){a=!0;return}let S=!r||r[f]===d.tagName.toLowerCase();if(!S||u!==d.children.length){let w=S&&e[_];typeof w=="string"&&w&&t.set(d,w),h(u)||(a=!0);return}}let g=e[_];typeof g=="string"&&g&&t.set(d,g);let E=d.children;for(let f=0;f<E.length;f++)c(E[f],_===""?String(f):`${_}.${f}`)};return c(s,""),t}function yt(s){return e=>{for(let t of s){let i=t(e);if(typeof i=="string"&&i!=="")return i}return null}}var Pt=yt([s=>s.getAttribute("data-id"),s=>s.getAttribute("id")]);var mt=/^page(\.[0-9]+)?$/,it=s=>[...s.querySelectorAll('script[merge][clay~="live"]')].filter(e=>mt.test(e.getAttribute("merge")));function st(s,e,t){if(!s.html.includes("data-page"))return s;let i=u=>new DOMParser().parseFromString(u,"text/html"),n=i(s.html),r=n.querySelector("article[data-page]");if(!r)return s;let l=i(e),o=l.querySelector("article[data-page]");if(!o)return null;let a=nt(n.documentElement,s.identityMap),h=(u,S)=>{let w=n.importNode(S,!0),b=a.get(u);return b&&a.set(w,b),u.replaceWith(w),w},c=h(r,o),d=new Map(it(n).map(u=>[u.getAttribute("merge"),u]));for(let u of it(l)){let S=u.getAttribute("merge"),w=d.get(S);w?h(w,u):c.before(n.importNode(u,!0)),d.delete(S)}for(let u of d.values())u.remove();let _=n.querySelector("head > title"),g=l.querySelector("head > title");_&&g?h(_,g):g?n.head.append(n.importNode(g,!0)):_?.remove();let E=n.documentElement,f=t.exportMap(E,u=>{let S=a.get(u);return S?(t.adopt(u,S),u):null});return{...s,html:T(E),identityMap:f}}var vt={"merge-tokens":"tokens","merge-max":"max"};function rt(s,e){if(!e.startsWith("data-")||e==="data-id"||!s?.closest)return null;for(let[t,i]of Object.entries(vt)){let n=s.closest(`[${t}]`);if(n&&n.getAttribute(t).split(/\s+/).includes(e))return i}return null}var m=null,lt=null,B=new Map;function J(){return lt??=Promise.all([import("./c-CAWNFER6.js"),import("./c-EJTGYSLN.js")]).then(([s,e])=>{m={...s,beginLineageCapture:e.beginLineageCapture};for(let t of[...B.keys()])B.set(t,s.registerContext(t));return m}),lt}var ot=()=>m,I={get size(){return m?m.conflicts.size:0},list(){return m?m.conflicts.list():[]},get(s){return m?m.conflicts.get(s):null},acknowledge(s,e={}){if(m)return m.conflicts.acknowledge(s,e);if(!Array.isArray(s))throw new TypeError("clay.conflicts.acknowledge needs an array of ids");return{removedIds:[],remainingIds:[]}},claim(s,e={}){if(m)return m.conflicts.claim(s,e);if(!e.owner)throw new TypeError("clay.conflicts.claim needs an owner");return{release(){}}},registerContext(s){if(m)return m.conflicts.registerContext(s);if(typeof s!="function")throw new TypeError("clay.conflicts.registerContext needs a resolver function");return B.set(s,null),()=>{let e=B.get(s);B.delete(s),e&&e()}},contextFor(s,e){return m?m.conflicts.contextFor(s,e):null},recoveryOf(s){return m?m.conflicts.recoveryOf(s):null},hasPendingApply(){return m?m.conflicts.hasPendingApply():!1}};var y=null,fe=null;function H(){return fe??=new Promise(s=>setTimeout(s,0)).then(()=>import("./c-FNVQAACK.js")).then(s=>y=s).catch(s=>{throw fe=null,s}),fe}var ye=null,pe=null;function Et(){return pe??=import("./c-FTWGYI5E.js").then(s=>ye=s.presence).catch(s=>{throw pe=null,s}),pe}var ct=ee().phase==="entering";$&&!ct&&H().catch(()=>{});$&&J().catch(()=>{});var L=null,_e=null,K=[];function dt(s){L.presence.update(s),L.editingMarker.update(s)}function wt(){return _e??=Promise.all([import("./c-ZJLU56DV.js"),import("./c-JUE7B4OX.js")]).then(([s,e])=>{L={presence:s.presence,editingMarker:e.editingMarker};let t=K;K=[];for(let i of t)dt(i);return L}).catch(s=>{throw _e=null,s}),_e}function kt(s){if(L){dt(s);return}K.push(s),wt().catch(()=>{})}var at=Object.freeze({bytes:null,etag:null,seq:null}),xt=()=>({msg:"Not in edit mode",msgType:"skipped",code:null,etag:null}),ut=["[editor-ui]",'[clay~="editor-ui"]',"[save-ignore]","[snapshot-remove]","[no-snapshot]","[no-save]","[save-remove]","[freeze] *","[save-freeze] *",'[clay~="no-save"]','[clay~="no-snapshot"]','[clay~="freeze"] *',Ce,Te].join(","),ft='[clay~="freeze"], [freeze], [save-freeze]';function V(s){for(let e of s.querySelectorAll(ft))e.replaceChildren();return z()&&He(s),s}function ht(s){if(s==null)return s;let e=typeof s=="string"?new DOMParser().parseFromString(s,"text/html"):s;return ne(e),V(e),e}var bt=[Ae,'[clay~="no-watch"]',"[no-watch]","[mutations-ignore]"].join(","),Dt=(s,e,t)=>be(s,e,t)||Le.test(e.toLowerCase()),pt=s=>s.getAttribute("data-id")||s.getAttribute("id")||null;function It(s){let e=new Map,t=n=>{if(n.matches(ut))return;let r=pt(n);r&&e.set(r,(e.get(r)||0)+1);let l=n.localName==="template"&&n.content?n.content.children:n.children;for(let o of l)t(o)},i=s.nodeType===9?[s.documentElement]:s.nodeType===11?s.children:[s];for(let n of i)n&&n.nodeType===1&&t(n);return e}var Tt=s=>e=>{let t=pt(e);if(!t)return null;let i=e.getRootNode(),n=s.get(i);return n||s.set(i,n=It(i)),n.get(t)===1?t:null},ge=s=>!!s&&typeof s=="object"&&!Array.isArray(s);function Lt(s){return typeof s!="string"||s===""?null:new DOMParser().parseFromString(s,"text/html").documentElement?.getAttribute("documentetag")||null}function Ct(s,e){e!=="live"||!s||!y||(y.enableContentEditable(s),y.enableOnClick(s),y.enableAdminInputs(s),y.enableAdminResources(s))}function At(){let{forComparison:s,forDirty:e}=Pe({flushUndo:!1});return[s,e]}var Ft=1024*1024;function Rt(s,e,t,i,n){let r={sender:t,identityMap:i,...n?{etag:n}:{}};return e.length<Ft?JSON.stringify({[s.snapshotKey]:e,...r}):new Blob([`{${JSON.stringify(s.snapshotKey)}:`,JSON.stringify(e),`,${JSON.stringify(r).slice(1)}`],{type:"application/json"})}var me=class{constructor(){this.sse=null,this.currentFile=null,this.lastHtml=null,this._diskBase=null,this._diskBaseTicket=0,this._agreeSeq=0,this._saveTicket=0,this._peerBaseTicket=0,this._acceptedSaveTicket=0,this._morphTicket=0,this.clientId=this.generateClientId(),this.resumeId=null,this._savedSnapshot?.abort?.abort(),this._savedSnapshot=null,this._sendInFlight=!1,this._queuedSend=null,this._profile=null,this._profilePromise=null,this._sharedData=!1,this._sharedSync=!1,this._liveData=!1,this._editing=null,this._presenceLease=null,this._presenceQuiesced=!1,this._ready=null,this._startGen=0,this.isPaused=!1,this.isDestroyed=!1,this.debug=!1,this._lane=$?"live":"saved",this._laneChosen=!1,this._snapshotHandler=null,this.lastSeenSeq=0,this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,this._morphInFlight=!1,this._rafHandle=null,this._represented=at,this._handoff=null,this._handoffHeld=!1,this._pendingExternal=null,this._lastExternalSeq=0,this._saveEpoch=0,this._saveSavedHandler=null,this._saveConflictHandler=null,this._settledHandler=null,this._lastIdentityMap=null,this._applyGen=0,this._holdRetryPeer=null,this._holdRetryExt=null,this._servedFetchId=0,this._startupRetry=null,this._engineRetry=null,this._heldLive=!1,this._heldExt=!1,this.identity=tt(this.clientId),this.onConnect=null,this.onDisconnect=null,this.onUpdate=null,this.onError=null,this.onNotification=null}get unresolvedConflicts(){return I.list().filter(e=>e.kind!=="apply-incomplete")}_log(e,t=null){if(!this.debug)return;let i=`[LiveSync ${new Date().toISOString()}]`;t!==null?console.log(i,e,t):console.log(i,e)}generateClientId(){return Math.random().toString(36).slice(2,11)+Date.now().toString(36)}generateResumeId(){try{let e=new Uint8Array(16);return(globalThis.crypto||window.crypto).getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}catch{return Math.random().toString(36).slice(2)+Date.now().toString(36)}}_seedBases(){if(x())return;let e=P({flushUndo:!1});this._setPeerBase(T(e),this.identity.exportMap(e,D),this._ticket()),this._setDiskBase(W({emitForSync:!1}).forSave,this._ticket())}get lane(){return this._lane}set lane(e){this._lane=e,this._laneChosen=!0}start(e=null,{lane:t,represented:i}={}){if(this.isDestroyed=!1,(this.sse||this._snapshotHandler)&&this.cleanup(),this.currentFile=e||this.detectCurrentFile(),!this.currentFile){console.warn("[LiveSync] No file detected");return}let n=ee().mode==="edit"?"live":"saved",r=this.lane==="live";this._lane=t||(this._laneChosen?this._lane:n),this.lastHtml=null,this._lastIdentityMap=null,this._peerBaseTicket=this._ticket(),this._diskBase=null,this._diskBaseTicket=this._ticket(),this._saveTicket=0,this._savedSnapshot?.abort?.abort(),this._savedSnapshot=null,this._applyGen++,this.lastSeenSeq=0,this._lastExternalSeq=0,this._represented=i?Object.freeze({bytes:i.bytes??null,etag:i.etag??null,seq:i.seq??null}):at,this._acquireEmptySaved=r&&this.lane==="saved"&&this._represented.bytes===null,this._pendingExternal=null,this.resumeId=this.generateResumeId(),this.lane==="live"&&this._seedBases(),this.lane==="live"&&J().catch(()=>{}),console.log(`[LiveSync] Starting for: ${this.currentFile} (lane=${this.lane})`);let l=++this._startGen;if(this.lane==="live"&&!(y&&y.baselineSettled())){let o=this._applyGen,a=this._morphTicket,h=this._saveEpoch,c=this.lastHtml,d=this._diskBaseTicket,_=this._diskBase!==null;this._settledHandler=()=>{if(this._settledHandler=null,!(this.isDestroyed||this._startGen!==l)&&!qe()&&!x()&&this._saveTicket===0&&this._morphTicket===a){if(c!==null&&this._applyGen===o&&this._saveEpoch===h&&this.lastHtml===c){let g=P({flushUndo:!1});this._setPeerBase(T(g),this.identity.exportMap(g,D),this._ticket())}_&&this._diskBaseTicket===d&&this._setDiskBase(W({emitForSync:!1}).forSave,this._ticket())}},document.addEventListener("clay:baseline-settled",this._settledHandler,{once:!0})}this._ready=Promise.all([this.lane==="live"?H():null,this._resolveProfile()]).then(()=>{this.isDestroyed||this._startGen!==l||this.connect()}),this.lane==="live"&&(this.listenForSnapshots(),Et().then(o=>this._startPresence(o,l),()=>{}),this._saveSavedHandler=o=>{this._saveEpoch++;let a=this._saveTicket||this._ticket();this._saveTicket=0,a>this._acceptedSaveTicket&&(this._acceptedSaveTicket=a);let h=y?y.getLastSavedBytes():null;h!=null&&this._setDiskBase(h,a),this._relayCommit(o?.detail?.captureId,h)},document.addEventListener("clay:save-saved",this._saveSavedHandler),this._saveConflictHandler=o=>{let a=o.detail&&o.detail.etag;a&&queueMicrotask(()=>{this.isDestroyed||a===ie()&&(y?.conflictResolvedBySync(a),this._saveAfterMerge(x(),!1))})},document.addEventListener("clay:save-conflict",this._saveConflictHandler))}cleanup(){if(this.sse&&(this.sse.close(),this.sse=null),he(),K=[],L&&(L.presence.clear(),L.editingMarker.clear()),this._editing&&(this._editing.stop(),this._editing=null),this._presenceLease){let e=this._presenceLease;this._presenceLease=null,typeof e.stop=="function"?e.stop():e.detach()}this._lastRoster=null,this._snapshotHandler&&(document.removeEventListener("clay:snapshot-ready",this._snapshotHandler),this._snapshotHandler=null),this._saveSavedHandler&&(document.removeEventListener("clay:save-saved",this._saveSavedHandler),this._saveSavedHandler=null),this._saveConflictHandler&&(document.removeEventListener("clay:save-conflict",this._saveConflictHandler),this._saveConflictHandler=null),this._settledHandler&&(document.removeEventListener("clay:baseline-settled",this._settledHandler),this._settledHandler=null),this._queuedSend=null,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingBy=null,this._pendingExternal=null,this._handoff=null,this._handoffHeld=!1,clearTimeout(this._holdRetryPeer),clearTimeout(this._holdRetryExt),this._holdRetryPeer=null,this._holdRetryExt=null,clearTimeout(this._startupRetry),this._startupRetry=null,clearTimeout(this._engineRetry),this._engineRetry=null,this._servedFetchId++}detectCurrentFile(){let e=window.location.pathname;if(e==="/")return"index.html";e=e.replace(/^\//,"");let t=e.match(/^(.*?\.html(?:clay)?)/);return t?t[1]:e}_resolveProfile(){return this._profilePromise||(this._profilePromise=et().then(e=>(this._sharedData=e.sharedData,this._sharedSync=e.sharedSync,this._liveData=e.liveData,this._profile=e.profile,this._log(`Wire profile: ${e.profile.name}`),e.profile))),this._profilePromise}_setHeld(e,t,i){let n=e==="live"?"_heldLive":"_heldExt";this[n]!==t&&(this[n]=t,!t&&!this._heldLive&&!this._heldExt&&Ue({fresh:!0,clearIfMissing:!1}),document.dispatchEvent(new CustomEvent(t?"clay:sync-held":"clay:sync-resumed",{detail:{lane:e,el:i||null}})))}_applyEtagFrame(e){return typeof e.etag!="string"||typeof e.html=="string"?!1:(this._log("Dropping a stamp that arrived with no document: nothing proves this tab holds those bytes"),!0)}connect(){if(this.isDestroyed)return;let t=(this._profile||ue.legacy).streamPath(window.location.href,this.lane,this.resumeId,this.clientId);this.sse=new Xe(new URL(t,window.location.origin).href,{shared:this._sharedSync,sharedData:this._sharedData,documentURL:window.location.href,lane:this.lane,clientId:this.clientId,keepAliveWhenHidden:this._liveData&&this.lane==="live",startupCheck:!!Ie}),this._acquireEmptySaved&&(this._acquireEmptySaved=!1,this._fetchServedDocument(void 0,{repair:!0})),this.sse.onopen=()=>{console.log("[LiveSync] Connected"),this._editing&&this._editing.reconnected(),ye&&ye.reconnect(),this.onConnect&&this.onConnect()},this.sse.addEventListener("open",()=>Qe({clientId:this.clientId,lane:this.lane})),this.sse.addEventListener("error",()=>he());for(let i of Ke)this.sse.addEventListener(i,n=>{let r;try{r=JSON.parse(n.data)}catch{return}Ze(i,r)});this.sse.addEventListener("cursor",i=>{let n;try{n=JSON.parse(i.data)}catch{return}if(!n||n.resync!==!0&&n.startup!==!0)return;let r=n.resync===!0,l=n.startup===!0&&!r;console.log(r?"[LiveSync] Server could not replay everything; refetching the document":"[LiveSync] Checking the served document against the version this tab was served"),this._fetchServedDocument(typeof n.seq=="number"?n.seq:void 0,{repair:r,startup:l})}),this.sse.addEventListener("presence",i=>{let n;try{n=JSON.parse(i.data)}catch{return}kt(n),this._lastRoster=n,this._editing&&this._editing.roster(n)}),this.sse.onmessage=i=>{let n=JSON.parse(i.data),{seq:r}=n;if(typeof r=="number"&&r<=this.lastSeenSeq){this._log(`Dropping stale message: seq=${r}, lastSeen=${this.lastSeenSeq}`);return}if(typeof r=="number"&&(this.lastSeenSeq=r),n.type==="notification"){if(this._maybeAcceptExternalChange(n))return;this.handleNotification(n);return}if(n.error){console.error("[LiveSync] Server error:",n.error),this.onError&&this.onError(new Error(n.error));return}if(this._applyEtagFrame(n))return;let{html:l,sender:o,identityMap:a}=n;if(o===this.clientId){this._log("Ignoring own message (sender matches clientId)");return}if(typeof l!="string"){console.error("[LiveSync] Received invalid html, ignoring");return}let h=typeof n.etag=="string"&&n.etag?n.etag:null;if(this.lane==="live"&&!h&&Ge()){this._log(`Dropping an unstamped live frame on a stamping host (seq=${r})`);return}if(this.lane==="saved"&&l===this._represented.bytes){this._represented=Object.freeze({bytes:l,etag:h||null,seq:r??null}),M(h);return}if(h&&l===this.lastHtml){this._log(`Taking the stamp from a peer save of content already applied (seq=${r})`),M(h),y&&y.isSaveConflicted()&&(y.conflictResolvedBySync(h),this._saveAfterMerge(x(),!1));return}this._log(`Received update from: ${o} (my clientId: ${this.clientId}, seq=${r})`),this.applyUpdate(l,r,a,h,n.by),this.onUpdate&&this.onUpdate({html:l,sender:o,seq:r,identityMap:a,etag:h})},this.sse.onerror=()=>{this.sse.readyState===EventSource.CONNECTING?console.log("[LiveSync] Reconnecting..."):this.sse.readyState===EventSource.CLOSED&&(console.log("[LiveSync] Connection closed"),this.onError&&this.onError(new Error("Connection closed"))),this.onDisconnect&&this.onDisconnect()}}listenForSnapshots(){this._snapshotHandler=e=>{if(!e.detail||e.detail.forSave!==!0)return;this._saveTicket=this._ticket();let{documentElement:t}=e.detail;if(!t)return;this._log("snapshot-ready received, preparing to send");let i=this.identity.exportMap(t,D);this._savedSnapshot?.abort?.abort();let n={html:null,steps:null,copy:null,abort:null,identityMap:i,ticket:this._saveTicket,captureId:e.detail.captureId??null};if(e.detail.sliced){n.copy=Be(t),n.abort=new AbortController;let{signal:r}=n.abort;Promise.all([import("./c-MEWUGR4D.js"),import("./c-ZWBI4HYK.js")]).then(([{serializeForSyncSteps:l},{runSliced:o}])=>{if(r.aborted||typeof n.html=="string")return;let a=(function*(){let h=yield*l(n.copy);n.html=h,n.steps=null})();return n.steps=a,o(a,{signal:r})}).catch(()=>{})}else n.html=T(t);this._savedSnapshot=n},document.addEventListener("clay:snapshot-ready",this._snapshotHandler)}_enqueueSend(e,t,i=null){if(!this._profile){this._queuedSend={html:e,identityMap:t,etag:i},this._resolveProfile().then(()=>this._flushQueuedSend());return}if(this._sendInFlight){this._queuedSend={html:e,identityMap:t,etag:i};return}this._postUpdate(e,t,i)}_flushQueuedSend(){if(this.isDestroyed||this._sendInFlight)return;let e=this._queuedSend;e&&(this._queuedSend=null,this._postUpdate(e.html,e.identityMap,e.etag))}_relayCommit(e=null,t=null){if(this.isDestroyed)return;let i=ie(),n=this._savedSnapshot;if(n&&(n.captureId??null)!==(e??null)){this._log("Skipping send - snapshot belongs to a different capture");return}let r=n;if(this._savedSnapshot=null,r?.copy&&typeof r.html!="string")if(r.abort?.abort(),r.steps)for(let c=r.steps.next();!c.done;c=r.steps.next());else r.html=T(r.copy);if(!r||typeof r.html!="string")return;let l=r;if(typeof t=="string"){try{l=st(r,t,this.identity)}catch(c){this._log(`Skipping send - page relay failed: ${c&&c.message}`);return}if(!l){this._log("Skipping send - accepted capture has no page article");return}}let o=Ht(e)??t,a=typeof o=="string"?je(o):0;l={...l,html:qt(ze(l.html,Math.max(We(),a)),o)};let h=!i&&l.html===this.lastHtml;if(this._setPeerBase(l.html,l.identityMap,l.ticket),h){this._log("Skipping send - HTML unchanged");return}this._enqueueSend(l.html,l.identityMap,i||null)}_postUpdate(e,t,i=null,n=0){this._log(`Sending update (HTML length: ${e.length})`),this._sendInFlight=!0;let r=!1,l=this._profile||ue.legacy;fetch(new URL(l.relayPath,window.location.origin).href,{method:"POST",headers:{"Content-Type":"application/json",[l.documentHeader]:window.location.href,[$e]:String(1)},body:Rt(l,e,this.clientId,t,i)}).then(o=>{o.ok||(console.warn("[LiveSync] Save returned status:",o.status),r=o.status>=500||o.status===408||o.status===429)}).catch(o=>{console.error("[LiveSync] Save failed:",o),this.onError&&this.onError(o),r=!0}).finally(()=>{this._sendInFlight=!1;let o=this._queuedSend;if(this._queuedSend=null,o){this._postUpdate(o.html,o.identityMap,o.etag);return}!r||!i||n>=3||this.isDestroyed||(this._sendInFlight=!0,setTimeout(()=>{if(this._sendInFlight=!1,this.isDestroyed)return;let a=this._queuedSend;this._queuedSend=null,a?this._postUpdate(a.html,a.identityMap,a.etag):this._postUpdate(e,t,i,n+1)},500*2**n))})}_startPresence(e,t){return this.isDestroyed||this._startGen!==t||this._presenceLease?null:e.connect({send:i=>this._postPresence(i)}).then(i=>this.isDestroyed||this._startGen!==t?(typeof i?.stop=="function"?i.stop():i?.detach(),null):(this._presenceLease=i||null,Oe("presence-editing")),()=>!1).then(i=>{if(!(!i||this.isDestroyed||this._startGen!==t||this._editing))return H().then(n=>{this.isDestroyed||this._startGen!==t||this._editing||(this._editing=new n.EditingSender({}),this._presenceQuiesced?this._editing.stop():(this._editing.start(),this._editing.roster(this._lastRoster)))})})}_postPresence(e){let t=new URL("/_/presence",window.location.origin);return t.searchParams.set("client-id",this.clientId),fetch(t.href,{method:"POST",headers:{"Content-Type":"application/json","Document-URL":window.location.href},body:JSON.stringify(e)}).then(i=>i.ok,()=>!1)}_maybeAcceptExternalChange(e){if(this.lane!=="live")return!1;let t=e.data;return t&&t.kind==="external-change"?(typeof t.html=="string"?this._enqueueExternal(t.html,e.seq,t.etag,t.by):this._fetchExternalChange(e.seq),!0):typeof e.msg=="string"&&e.msg.endsWith("changed on disk outside this tab")?(this._fetchExternalChange(e.seq),!0):!1}_enqueueExternal(e,t,i,n){if(typeof t=="number"){if(t<=this._lastExternalSeq){this._log(`Dropping replayed external change: seq=${t}`);return}this._lastExternalSeq=t}this._pendingExternal={html:e,seq:t,saveEpoch:this._saveEpoch,etag:typeof i=="string"&&i?i:null,by:n??null},this._scheduleNextFrame()}_fetchExternalChange(e){if(typeof e=="number"){if(e<=this._lastExternalSeq)return;this._lastExternalSeq=e}this._fetchServedDocument(e)}_fetchServedDocument(e,{attempt:t=0,repair:i=!1,startup:n=!1}={}){if(n&&(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null)){this._retryStartup(t);return}let r=this._saveEpoch,l=this._startGen,o=this.lastSeenSeq,a=this._applyGen,h=++this._servedFetchId;i&&typeof e!="number"&&(e=this._lastExternalSeq),fetch(new URL(window.location.href),{cache:"no-store"}).then(c=>c.ok?c.text():null).then(c=>{if(this.isDestroyed||c==null||this._startGen!==l)return;let d=Lt(c),_=n||i&&!!d;if(_){if(h!==this._servedFetchId){i&&this._retryStartup(t+1,{repair:i,startup:n},typeof e=="number"?Math.max(e,this._lastExternalSeq):e);return}if(r!==this._saveEpoch||o!==this.lastSeenSeq||a!==this._applyGen||this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(t+1,{repair:i,startup:n},e);return}if(d){if(d===se()){(i||n)&&this.lane==="saved"&&(this._represented=Object.freeze({bytes:c,etag:d,seq:e??null}));return}}else if(!i)return}else if(typeof e=="number"&&e<this._lastExternalSeq){i&&t<3&&this._fetchServedDocument(this._lastExternalSeq,{attempt:t+1,repair:i,startup:n});return}else if(this._saveEpoch>r){t<3&&(console.log("[LiveSync] Refetching external change: own save landed mid-fetch"),this._fetchServedDocument(e,{attempt:t+1,repair:i,startup:n}));return}this._pendingExternal={html:c,seq:e,saveEpoch:r,etag:d,by:null,fetchOptions:{repair:i,startup:n,attempt:t,versionCheck:_},startGen:l,seenSeq:o,applyGen:a,fetchId:h},this._scheduleNextFrame()}).catch(c=>{this._log("External-change fetch failed",c),typeof e=="number"&&this._lastExternalSeq===e&&(this._lastExternalSeq=e-1)})}_retryStartup(e=0,t={startup:!0},i){this.isDestroyed||e>3||(clearTimeout(this._startupRetry),this._startupRetry=setTimeout(()=>{if(this._startupRetry=null,!this.isDestroyed){if(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(e,t,i);return}this._fetchServedDocument(i,{...t,attempt:e})}},16))}applyUpdate(e,t,i,n,r){this.isDestroyed||(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=i,this._pendingEtag=n??null,this._pendingBy=r??null,this._scheduleNextFrame())}prepareHandoff(e={}){return this._handoff?Promise.resolve(this._handoff):this.isDestroyed?Promise.reject(new Error("LiveSync: stopped")):(this._handoffHeld=!0,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),import("./c-Y33LUUIQ.js").then(({engineHandoff:t})=>t(this,e)).then(t=>this._handoff=t))}_scheduleNextFrame(){this.isDestroyed||this._handoffHeld||this._rafHandle==null&&(this._morphInFlight||(this._rafHandle=this._requestFrame(()=>this._runPending())))}async _runPending(){if(this._rafHandle=null,this.isDestroyed)return;if(!R()){this._morphInFlight=!0;try{await Y()}catch(r){this._log("Merge engine failed to load",r),this._engineRetry=setTimeout(()=>this._scheduleNextFrame(),2e3);return}finally{this._morphInFlight=!1}if(this.isDestroyed)return}let e=this._pendingExternal,t=e?.fetchOptions||null,i=!!(t?.startup||t?.versionCheck),n=!1;if(e!=null&&(i&&this._pendingHtml!=null?n=!1:this._pendingHtml==null?n=!0:n=!(typeof e.seq=="number"&&typeof this._pendingSeq=="number"&&this._pendingSeq<e.seq)),n)if(this._pendingExternal=null,typeof e.seq=="number"&&e.seq<this._lastExternalSeq)i&&t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded external change at drain");else if(i&&e.startGen!==this._startGen)this._log("Dropping superseded startup check at drain");else if(i&&e.fetchId!==this._servedFetchId)t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded startup check at drain");else if(i&&(e.saveEpoch!==this._saveEpoch||e.seenSeq!==this.lastSeenSeq||e.applyGen!==this._applyGen))this._retryStartup((t.attempt||0)+1,t,e.seq);else if(i&&e.etag!=null&&e.etag===se())this._log("Startup check found the same version: nothing to apply");else if(!i&&e.saveEpoch!==this._saveEpoch)console.log("[LiveSync] Refetching external change: own save landed after queue"),this._fetchServedDocument(e.seq,t||{});else{this._morphInFlight=!0;try{await this._doApplyExternal(e.html,e.seq,e.etag,e.by,t)}catch(r){console.error("[LiveSync] applyExternal failed:",r)}finally{this._morphInFlight=!1}}else{let r=this._pendingHtml,l=this._pendingSeq,o=this._pendingIdentityMap,a=this._pendingEtag,h=this._pendingBy;if(this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,r==null)return;this._morphInFlight=!0;try{await this._doApplyUpdate(r,l,o,a,h)}catch(c){console.error("[LiveSync] applyUpdate failed:",c)}finally{this._morphInFlight=!1}}!this.isDestroyed&&(this._pendingHtml!=null||this._pendingExternal!=null)&&this._scheduleNextFrame()}_ticket(){return++this._agreeSeq}_setDiskBase(e,t){t<=this._diskBaseTicket||(this._diskBase=e,this._diskBaseTicket=t)}_setPeerBase(e,t,i){return i<this._peerBaseTicket?!1:(this._peerBaseTicket=i,this.lastHtml=e,this._lastIdentityMap=t&&typeof t=="object"&&!Array.isArray(t)?t:null,!0)}_requestFrame(e){return typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(e):setTimeout(e,16)}_cancelFrame(e){if(typeof window<"u"&&typeof window.cancelAnimationFrame=="function"){window.cancelAnimationFrame(e);return}clearTimeout(e)}async _mergeIncoming(e,t,{base:i,baseIdentityMap:n=null,captureLocal:r,synthetic:l,source:o="peer",seq:a=null,etag:h=null,extra:c={}}){R()||await Y();let{beginApply:d,completeApply:_,failApply:g,beginLineageCapture:E}=ot()||await J(),f,u=p=>{f=E(I.list());try{let v=R().HyperMorph.mergeDocument({...p,lineage:f.lineage});return f.returned(),v}catch(v){throw f.invalidate(I.list()),f.finish(I.list()),v}},S=this.identity,w=De,b=Tt(new WeakMap),N=p=>ge(p)?{first:b,map:p,then:b}:b,O=l?p=>b(p)||S.idOf(D(p)||p)||null:b,C=e,Se=new Map;if(ge(t)){C=new DOMParser().parseFromString(e,"text/html"),ne(C);let p=R().HyperMorph.importMap(C.documentElement,t);for(let v of C.querySelectorAll("[data-id], [id]")){let k=b(v),xe=k&&p.get(v);xe&&Se.set(k,xe)}}C=ht(C);let Q={live:document,remote:C,ignore:p=>p.matches(ut),opaque:p=>p.matches(ft)||z()&&Re(p),remoteWins:p=>p.matches(bt),ignoreAttribute:(p,v,k)=>Dt(p,v,k)||z()&&Fe(k||p,v),attributeMerge:rt,protectFocusedValue:!0,restoreFocus:document.activeElement?.localName!=="clay-editor-ui",keepLiveOnly:o==="peer",scripts:{mergeTags:R().mergeTagRecognizers},hooks:{beforeAttributeUpdated:w},...c},Ee=this.lane==="live"&&x(),we=ae(),G,Z=null,F=null;if(i==null)G=u({...Q,base:null,local:{root:V(r()),toLive:D},identity:{local:O,remote:N(t)}});else if(Ee){let p=r(),v=p.cloneNode(!0);Z=V(p),F=d({source:o,seq:a,etag:h,root:Z,recoveryRoot:v,domain:o==="disk"?"save":"sync"});try{G=u({...Q,base:ht(i),local:{root:Z,toLive:D},identity:{base:N(n),local:O,remote:N(t)}})}catch(k){throw g(F,k),k}}else{let p=V(r()),v=p.ownerDocument;v.documentElement!==p&&v.replaceChild(p,v.documentElement),G=u({...Q,base:v,local:{root:p,toLive:D},fastPath:!0,identity:{base:O,local:O,remote:N(t)}})}let U=this._ticket();this._morphTicket=U;let A;try{A=await G}catch(p){f.invalidate(I.list());try{F&&g(F,p,{ticket:U})}finally{f.finish(I.list())}throw p}let _t=ae().gen!==we.gen,ke;try{f.prepareComplete(A,I.list()),ke=F?_(F,A.conflicts,{ticket:U}):[]}finally{f.finish(I.list())}this.lane==="live"&&A.localDiverged?Ye():Ee&&!A.localDiverged&&Je(we);let gt=new Set(ge(t)?Object.values(t):[]);for(let[p,v]of A.identities){let k=gt.has(v)?v:Se.get(v);k&&S.adopt(p,k)}return{report:A,ticket:U,typedDuringWait:_t,conflictIds:ke}}_saveAfterMerge(e,t){(e||t)&&Ve()&&(y?y.savePageThrottled():xt())}async _doApplyUpdate(e,t,i,n,r=null){if(ce(e)){await de();return}this.lane==="live"&&!y&&await H(),this._log("applyUpdate - pausing mutations and morphing"),this.isPaused=!0;let l=window.scrollX,o=window.scrollY;q.pause(),le();let a=!1,h=!1,c=!1;try{if(this.lane==="live"&&x()&&this.lastHtml===null){console.log("[LiveSync] Holding incoming update: unsaved local edits and no baseline to merge against"),this._setHeld("live",!0,null);let f=this._saveEpoch,u=this.lastSeenSeq;clearTimeout(this._holdRetryPeer),this._holdRetryPeer=setTimeout(()=>{this._holdRetryPeer=null,!(this.isDestroyed||this._pendingHtml!=null)&&this._saveEpoch===f&&this.lastSeenSeq===u&&(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=i,this._pendingBy=r,this._scheduleNextFrame())},3e3);return}this._setHeld("live",!1);let{report:d,ticket:_,typedDuringWait:g,conflictIds:E}=await this._mergeIncoming(e,i,{base:this.lastHtml,baseIdentityMap:this._lastIdentityMap,captureLocal:()=>P({flushUndo:!1}),synthetic:!0,source:"peer",seq:t,etag:n});if(a=d.localDiverged,h=g,te(),window.scrollTo(l,o),this._setPeerBase(e,i,_),this._applyGen++,this._acceptedSaveTicket>_||(typeof n=="string"&&n?(M(n),c=!0):re()),this.lane==="live"&&!a&&!x()){let{forSave:f,forComparison:u,forDirty:S}=W({emitForSync:!1,flushUndo:!1});y.setLastSavedBaselines(u,S),this._setDiskBase(f,this._ticket())}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:n||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:this.lane==="saved"?"disk":"peer",lane:this.lane,by:r||null,html:e,report:d,unresolved:this.unresolvedConflicts,conflictIds:E}}))}finally{this._log("applyUpdate - morph complete, resuming mutations"),q.resume(),oe(),await new Promise(d=>setTimeout(d,0)),this.isPaused=!1}c&&y?.conflictResolvedBySync(n),this._saveAfterMerge(a,h)}async _doApplyExternal(e,t,i=null,n=null,r=null){if(ce(e)){await de();return}this.lane==="live"&&!y&&await H();let l=this._diskBase;this._log(`applyExternal - external disk change (seq=${t})`),this.isPaused=!0;let o=window.scrollX,a=window.scrollY;q.pause(),le();let h=!1,c=!1,d=!1;try{if(this.lane==="live"&&x()&&this._diskBase===null){if(console.log("[LiveSync] Holding external change: unsaved local edits and no baseline to merge against"),this._setHeld("external",!0,null),r?.startup||r?.versionCheck){clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{if(this._holdRetryExt=null,this.isDestroyed)return;let S=typeof t=="number"?Math.max(t,this._lastExternalSeq):t;this._retryStartup(0,r,S)},3e3);return}let u=this._saveEpoch;clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{this._holdRetryExt=null,!(this.isDestroyed||this._pendingExternal!=null)&&(this._pendingExternal={html:e,seq:t,saveEpoch:u,etag:i,by:n},this._scheduleNextFrame())},3e3);return}this._setHeld("external",!1);let{report:_,ticket:g,typedDuringWait:E,conflictIds:f}=await this._mergeIncoming(e,null,{base:this._diskBase,captureLocal:()=>Me().saveClone,synthetic:!1,source:"disk",seq:t,etag:i,extra:{beforeApply:u=>Ct(u.documentElement,this.lane)}});if(h=_.localDiverged,c=E,te(),this._setDiskBase(e,g),window.scrollTo(o,a),this._acceptedSaveTicket>g||(typeof i=="string"&&i?(M(i),d=!0):re()),this.lane==="live"&&!h&&!x()){y.setLastSavedBaselines(...At()),y.setUnsavedChanges(!1);let u=P({flushUndo:!1});this._setPeerBase(T(u),this.identity.exportMap(u,D),g),this._applyGen++}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:i||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:"disk",etag:typeof i=="string"&&i?i:null,by:n||null,html:e,report:_,conflictIds:f,unresolved:this.unresolvedConflicts}}))}finally{this._log("applyExternal - morph complete, resuming mutations"),q.resume(),oe(),await new Promise(_=>setTimeout(_,0)),this.isPaused=!1}d&&y?.conflictResolvedBySync(i),this._saveAfterMerge(h,c),l!=null&&j(l)===j(e)&&y&&y.schedulePaintHeal(()=>this._diskBase==null?null:j(this._diskBase))}handleNotification({msgType:e,msg:t,action:i,persistent:n,data:r}){this._log(`Notification received: ${e} - ${t}`),e==="data-loss"||(n&&window.toastPersistent?window.toastPersistent(t,e):window.toast?window.toast(t,e):console.log(`[LiveSync] Notification: ${t}`)),document.dispatchEvent(new CustomEvent("clay:notification",{detail:{msgType:e,msg:t,action:i,persistent:n,data:r}})),this.onNotification&&this.onNotification({msgType:e,msg:t,action:i,persistent:n,data:r})}stop(){this.cleanup(),this.isDestroyed=!0,console.log("[LiveSync] Stopped")}editParticipant(){return H().then(e=>e.syncParticipant(this))}},X=null;Ne((s,e)=>{X=typeof s=="string"?{html:s,captureId:e?.captureId??null}:null});var Ht=s=>X&&(X.captureId??null)===(s??null)?X.html:null;function qt(s,e){if(typeof e!="string"||e===s)return s;let t=i=>new DOMParser().parseFromString(i,"text/html").documentElement;return t(s).isEqualNode(t(e))?e:s}var ve=new me;typeof window<"u"&&!ct&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>ve.start()):ve.start());var _n=(s,e,t)=>Y().then(({morph:i})=>i(s,e,t));var gn=ve;export{I as a,ut as b,bt as c,me as d,ve as e,_n as f,gn as g};
1
+ import{a as Xe,b as ce,d as de,e as ue,f as et}from"./c-6PBXRWDX.js";import{a as Ke,b as Qe,c as he,d as Ze}from"./c-LZJPNR2W.js";import{a as R,b as Y}from"./c-FILLTJA7.js";import{b as Ve}from"./c-5VYOWDTI.js";import{b as le,c as oe,d as x,f as ae,g as Ye,h as Je}from"./c-GSRLXYWL.js";import{a as q}from"./c-LA2BW7UY.js";import{a as Ne}from"./c-ATKAOH23.js";import{a as $e,f as je,g as ze,h as We}from"./c-EK63G3CG.js";import{a as ie,b as Ge,c as M,d as se,e as re,h as Ue}from"./c-NQJRVJ56.js";import{e as Oe}from"./c-XGH4GS2T.js";import{d as qe}from"./c-IJUK2GPW.js";import{f as $,j as ee}from"./c-3O7OBDCM.js";import{a as Ie}from"./c-BPF2NSPV.js";import{D as W,E as Me,G as T,H as Be,b as D,j as ne,s as P,y as Pe}from"./c-EGTIAL6P.js";import{a as Fe,b as Re,c as He,e as j,g as z,h as te}from"./c-VG5XIN4T.js";import{m as be,n as De}from"./c-HA6INT6J.js";import{a as Te,b as Le,l as Ce,m as Ae}from"./c-ICMAOOGK.js";function tt(s){let e=new WeakMap,t=0,i=r=>e.get(r)||null,n=r=>{let l=e.get(r);return l||(l=`${s}:${++t}`,e.set(r,l)),l};return{idOf:i,ensure:n,adopt:(r,l)=>{r&&typeof l=="string"&&l&&e.set(r,l)},exportMap:(r,l)=>{let o={},a=[],h=[],c=(d,_)=>{let g=l(d);g&&(o[_]=n(g));let E=d.children;a.push(E.length),h.push(d.tagName.toLowerCase());for(let f=0;f<E.length;f++)c(E[f],_===""?String(f):`${_}.${f}`)};return c(r,""),o["~"]=a.join(","),o["^"]=h.join(","),o}}}function nt(s,e){let t=new WeakMap;if(!s||!e||typeof e!="object"||Array.isArray(e))return t;let i=e["~"],n=typeof i=="string"?i.split(",").map(Number):null,r=n&&typeof e["^"]=="string"?e["^"].split(","):null,l=d=>Number.isInteger(d)&&d>=0,o=0,a=!1,h=d=>{let _=d;for(;_>0;){let g=n[o++];if(o>n.length||!l(g))return!1;_+=g-1}return!0},c=(d,_)=>{if(a)return;if(n){let f=o++,u=n[f];if(f>=n.length||!l(u)){a=!0;return}let S=!r||r[f]===d.tagName.toLowerCase();if(!S||u!==d.children.length){let w=S&&e[_];typeof w=="string"&&w&&t.set(d,w),h(u)||(a=!0);return}}let g=e[_];typeof g=="string"&&g&&t.set(d,g);let E=d.children;for(let f=0;f<E.length;f++)c(E[f],_===""?String(f):`${_}.${f}`)};return c(s,""),t}function yt(s){return e=>{for(let t of s){let i=t(e);if(typeof i=="string"&&i!=="")return i}return null}}var Pt=yt([s=>s.getAttribute("data-id"),s=>s.getAttribute("id")]);var mt=/^page(\.[0-9]+)?$/,it=s=>[...s.querySelectorAll('script[merge][clay~="live"]')].filter(e=>mt.test(e.getAttribute("merge")));function st(s,e,t){if(!s.html.includes("data-page"))return s;let i=u=>new DOMParser().parseFromString(u,"text/html"),n=i(s.html),r=n.querySelector("article[data-page]");if(!r)return s;let l=i(e),o=l.querySelector("article[data-page]");if(!o)return null;let a=nt(n.documentElement,s.identityMap),h=(u,S)=>{let w=n.importNode(S,!0),b=a.get(u);return b&&a.set(w,b),u.replaceWith(w),w},c=h(r,o),d=new Map(it(n).map(u=>[u.getAttribute("merge"),u]));for(let u of it(l)){let S=u.getAttribute("merge"),w=d.get(S);w?h(w,u):c.before(n.importNode(u,!0)),d.delete(S)}for(let u of d.values())u.remove();let _=n.querySelector("head > title"),g=l.querySelector("head > title");_&&g?h(_,g):g?n.head.append(n.importNode(g,!0)):_?.remove();let E=n.documentElement,f=t.exportMap(E,u=>{let S=a.get(u);return S?(t.adopt(u,S),u):null});return{...s,html:T(E),identityMap:f}}var vt={"merge-tokens":"tokens","merge-max":"max"};function rt(s,e){if(!e.startsWith("data-")||e==="data-id"||!s?.closest)return null;for(let[t,i]of Object.entries(vt)){let n=s.closest(`[${t}]`);if(n&&n.getAttribute(t).split(/\s+/).includes(e))return i}return null}var m=null,lt=null,B=new Map;function J(){return lt??=Promise.all([import("./c-CAWNFER6.js"),import("./c-EJTGYSLN.js")]).then(([s,e])=>{m={...s,beginLineageCapture:e.beginLineageCapture};for(let t of[...B.keys()])B.set(t,s.registerContext(t));return m}),lt}var ot=()=>m,I={get size(){return m?m.conflicts.size:0},list(){return m?m.conflicts.list():[]},get(s){return m?m.conflicts.get(s):null},acknowledge(s,e={}){if(m)return m.conflicts.acknowledge(s,e);if(!Array.isArray(s))throw new TypeError("clay.conflicts.acknowledge needs an array of ids");return{removedIds:[],remainingIds:[]}},claim(s,e={}){if(m)return m.conflicts.claim(s,e);if(!e.owner)throw new TypeError("clay.conflicts.claim needs an owner");return{release(){}}},registerContext(s){if(m)return m.conflicts.registerContext(s);if(typeof s!="function")throw new TypeError("clay.conflicts.registerContext needs a resolver function");return B.set(s,null),()=>{let e=B.get(s);B.delete(s),e&&e()}},contextFor(s,e){return m?m.conflicts.contextFor(s,e):null},recoveryOf(s){return m?m.conflicts.recoveryOf(s):null},hasPendingApply(){return m?m.conflicts.hasPendingApply():!1}};var y=null,fe=null;function H(){return fe??=new Promise(s=>setTimeout(s,0)).then(()=>import("./c-KE33W4RE.js")).then(s=>y=s).catch(s=>{throw fe=null,s}),fe}var ye=null,pe=null;function Et(){return pe??=import("./c-FTWGYI5E.js").then(s=>ye=s.presence).catch(s=>{throw pe=null,s}),pe}var ct=ee().phase==="entering";$&&!ct&&H().catch(()=>{});$&&J().catch(()=>{});var L=null,_e=null,K=[];function dt(s){L.presence.update(s),L.editingMarker.update(s)}function wt(){return _e??=Promise.all([import("./c-PCEMXY2K.js"),import("./c-NLWEZYKJ.js")]).then(([s,e])=>{L={presence:s.presence,editingMarker:e.editingMarker};let t=K;K=[];for(let i of t)dt(i);return L}).catch(s=>{throw _e=null,s}),_e}function kt(s){if(L){dt(s);return}K.push(s),wt().catch(()=>{})}var at=Object.freeze({bytes:null,etag:null,seq:null}),xt=()=>({msg:"Not in edit mode",msgType:"skipped",code:null,etag:null}),ut=["[editor-ui]",'[clay~="editor-ui"]',"[save-ignore]","[snapshot-remove]","[no-snapshot]","[no-save]","[save-remove]","[freeze] *","[save-freeze] *",'[clay~="no-save"]','[clay~="no-snapshot"]','[clay~="freeze"] *',Ce,Te].join(","),ft='[clay~="freeze"], [freeze], [save-freeze]';function V(s){for(let e of s.querySelectorAll(ft))e.replaceChildren();return z()&&He(s),s}function ht(s){if(s==null)return s;let e=typeof s=="string"?new DOMParser().parseFromString(s,"text/html"):s;return ne(e),V(e),e}var bt=[Ae,'[clay~="no-watch"]',"[no-watch]","[mutations-ignore]"].join(","),Dt=(s,e,t)=>be(s,e,t)||Le.test(e.toLowerCase()),pt=s=>s.getAttribute("data-id")||s.getAttribute("id")||null;function It(s){let e=new Map,t=n=>{if(n.matches(ut))return;let r=pt(n);r&&e.set(r,(e.get(r)||0)+1);let l=n.localName==="template"&&n.content?n.content.children:n.children;for(let o of l)t(o)},i=s.nodeType===9?[s.documentElement]:s.nodeType===11?s.children:[s];for(let n of i)n&&n.nodeType===1&&t(n);return e}var Tt=s=>e=>{let t=pt(e);if(!t)return null;let i=e.getRootNode(),n=s.get(i);return n||s.set(i,n=It(i)),n.get(t)===1?t:null},ge=s=>!!s&&typeof s=="object"&&!Array.isArray(s);function Lt(s){return typeof s!="string"||s===""?null:new DOMParser().parseFromString(s,"text/html").documentElement?.getAttribute("documentetag")||null}function Ct(s,e){e!=="live"||!s||!y||(y.enableContentEditable(s),y.enableOnClick(s),y.enableAdminInputs(s),y.enableAdminResources(s))}function At(){let{forComparison:s,forDirty:e}=Pe({flushUndo:!1});return[s,e]}var Ft=1024*1024;function Rt(s,e,t,i,n){let r={sender:t,identityMap:i,...n?{etag:n}:{}};return e.length<Ft?JSON.stringify({[s.snapshotKey]:e,...r}):new Blob([`{${JSON.stringify(s.snapshotKey)}:`,JSON.stringify(e),`,${JSON.stringify(r).slice(1)}`],{type:"application/json"})}var me=class{constructor(){this.sse=null,this.currentFile=null,this.lastHtml=null,this._diskBase=null,this._diskBaseTicket=0,this._agreeSeq=0,this._saveTicket=0,this._peerBaseTicket=0,this._acceptedSaveTicket=0,this._morphTicket=0,this.clientId=this.generateClientId(),this.resumeId=null,this._savedSnapshot?.abort?.abort(),this._savedSnapshot=null,this._sendInFlight=!1,this._queuedSend=null,this._profile=null,this._profilePromise=null,this._sharedData=!1,this._sharedSync=!1,this._liveData=!1,this._editing=null,this._presenceLease=null,this._presenceQuiesced=!1,this._ready=null,this._startGen=0,this.isPaused=!1,this.isDestroyed=!1,this.debug=!1,this._lane=$?"live":"saved",this._laneChosen=!1,this._snapshotHandler=null,this.lastSeenSeq=0,this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,this._morphInFlight=!1,this._rafHandle=null,this._represented=at,this._handoff=null,this._handoffHeld=!1,this._pendingExternal=null,this._lastExternalSeq=0,this._saveEpoch=0,this._saveSavedHandler=null,this._saveConflictHandler=null,this._settledHandler=null,this._lastIdentityMap=null,this._applyGen=0,this._holdRetryPeer=null,this._holdRetryExt=null,this._servedFetchId=0,this._startupRetry=null,this._engineRetry=null,this._heldLive=!1,this._heldExt=!1,this.identity=tt(this.clientId),this.onConnect=null,this.onDisconnect=null,this.onUpdate=null,this.onError=null,this.onNotification=null}get unresolvedConflicts(){return I.list().filter(e=>e.kind!=="apply-incomplete")}_log(e,t=null){if(!this.debug)return;let i=`[LiveSync ${new Date().toISOString()}]`;t!==null?console.log(i,e,t):console.log(i,e)}generateClientId(){return Math.random().toString(36).slice(2,11)+Date.now().toString(36)}generateResumeId(){try{let e=new Uint8Array(16);return(globalThis.crypto||window.crypto).getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}catch{return Math.random().toString(36).slice(2)+Date.now().toString(36)}}_seedBases(){if(x())return;let e=P({flushUndo:!1});this._setPeerBase(T(e),this.identity.exportMap(e,D),this._ticket()),this._setDiskBase(W({emitForSync:!1}).forSave,this._ticket())}get lane(){return this._lane}set lane(e){this._lane=e,this._laneChosen=!0}start(e=null,{lane:t,represented:i}={}){if(this.isDestroyed=!1,(this.sse||this._snapshotHandler)&&this.cleanup(),this.currentFile=e||this.detectCurrentFile(),!this.currentFile){console.warn("[LiveSync] No file detected");return}let n=ee().mode==="edit"?"live":"saved",r=this.lane==="live";this._lane=t||(this._laneChosen?this._lane:n),this.lastHtml=null,this._lastIdentityMap=null,this._peerBaseTicket=this._ticket(),this._diskBase=null,this._diskBaseTicket=this._ticket(),this._saveTicket=0,this._savedSnapshot?.abort?.abort(),this._savedSnapshot=null,this._applyGen++,this.lastSeenSeq=0,this._lastExternalSeq=0,this._represented=i?Object.freeze({bytes:i.bytes??null,etag:i.etag??null,seq:i.seq??null}):at,this._acquireEmptySaved=r&&this.lane==="saved"&&this._represented.bytes===null,this._pendingExternal=null,this.resumeId=this.generateResumeId(),this.lane==="live"&&this._seedBases(),this.lane==="live"&&J().catch(()=>{}),console.log(`[LiveSync] Starting for: ${this.currentFile} (lane=${this.lane})`);let l=++this._startGen;if(this.lane==="live"&&!(y&&y.baselineSettled())){let o=this._applyGen,a=this._morphTicket,h=this._saveEpoch,c=this.lastHtml,d=this._diskBaseTicket,_=this._diskBase!==null;this._settledHandler=()=>{if(this._settledHandler=null,!(this.isDestroyed||this._startGen!==l)&&!qe()&&!x()&&this._saveTicket===0&&this._morphTicket===a){if(c!==null&&this._applyGen===o&&this._saveEpoch===h&&this.lastHtml===c){let g=P({flushUndo:!1});this._setPeerBase(T(g),this.identity.exportMap(g,D),this._ticket())}_&&this._diskBaseTicket===d&&this._setDiskBase(W({emitForSync:!1}).forSave,this._ticket())}},document.addEventListener("clay:baseline-settled",this._settledHandler,{once:!0})}this._ready=Promise.all([this.lane==="live"?H():null,this._resolveProfile()]).then(()=>{this.isDestroyed||this._startGen!==l||this.connect()}),this.lane==="live"&&(this.listenForSnapshots(),Et().then(o=>this._startPresence(o,l),()=>{}),this._saveSavedHandler=o=>{this._saveEpoch++;let a=this._saveTicket||this._ticket();this._saveTicket=0,a>this._acceptedSaveTicket&&(this._acceptedSaveTicket=a);let h=y?y.getLastSavedBytes():null;h!=null&&this._setDiskBase(h,a),this._relayCommit(o?.detail?.captureId,h)},document.addEventListener("clay:save-saved",this._saveSavedHandler),this._saveConflictHandler=o=>{let a=o.detail&&o.detail.etag;a&&queueMicrotask(()=>{this.isDestroyed||a===ie()&&(y?.conflictResolvedBySync(a),this._saveAfterMerge(x(),!1))})},document.addEventListener("clay:save-conflict",this._saveConflictHandler))}cleanup(){if(this.sse&&(this.sse.close(),this.sse=null),he(),K=[],L&&(L.presence.clear(),L.editingMarker.clear()),this._editing&&(this._editing.stop(),this._editing=null),this._presenceLease){let e=this._presenceLease;this._presenceLease=null,typeof e.stop=="function"?e.stop():e.detach()}this._lastRoster=null,this._snapshotHandler&&(document.removeEventListener("clay:snapshot-ready",this._snapshotHandler),this._snapshotHandler=null),this._saveSavedHandler&&(document.removeEventListener("clay:save-saved",this._saveSavedHandler),this._saveSavedHandler=null),this._saveConflictHandler&&(document.removeEventListener("clay:save-conflict",this._saveConflictHandler),this._saveConflictHandler=null),this._settledHandler&&(document.removeEventListener("clay:baseline-settled",this._settledHandler),this._settledHandler=null),this._queuedSend=null,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingBy=null,this._pendingExternal=null,this._handoff=null,this._handoffHeld=!1,clearTimeout(this._holdRetryPeer),clearTimeout(this._holdRetryExt),this._holdRetryPeer=null,this._holdRetryExt=null,clearTimeout(this._startupRetry),this._startupRetry=null,clearTimeout(this._engineRetry),this._engineRetry=null,this._servedFetchId++}detectCurrentFile(){let e=window.location.pathname;if(e==="/")return"index.html";e=e.replace(/^\//,"");let t=e.match(/^(.*?\.html(?:clay)?)/);return t?t[1]:e}_resolveProfile(){return this._profilePromise||(this._profilePromise=et().then(e=>(this._sharedData=e.sharedData,this._sharedSync=e.sharedSync,this._liveData=e.liveData,this._profile=e.profile,this._log(`Wire profile: ${e.profile.name}`),e.profile))),this._profilePromise}_setHeld(e,t,i){let n=e==="live"?"_heldLive":"_heldExt";this[n]!==t&&(this[n]=t,!t&&!this._heldLive&&!this._heldExt&&Ue({fresh:!0,clearIfMissing:!1}),document.dispatchEvent(new CustomEvent(t?"clay:sync-held":"clay:sync-resumed",{detail:{lane:e,el:i||null}})))}_applyEtagFrame(e){return typeof e.etag!="string"||typeof e.html=="string"?!1:(this._log("Dropping a stamp that arrived with no document: nothing proves this tab holds those bytes"),!0)}connect(){if(this.isDestroyed)return;let t=(this._profile||ue.legacy).streamPath(window.location.href,this.lane,this.resumeId,this.clientId);this.sse=new Xe(new URL(t,window.location.origin).href,{shared:this._sharedSync,sharedData:this._sharedData,documentURL:window.location.href,lane:this.lane,clientId:this.clientId,keepAliveWhenHidden:this._liveData&&this.lane==="live",startupCheck:!!Ie}),this._acquireEmptySaved&&(this._acquireEmptySaved=!1,this._fetchServedDocument(void 0,{repair:!0})),this.sse.onopen=()=>{console.log("[LiveSync] Connected"),this._editing&&this._editing.reconnected(),ye&&ye.reconnect(),this.onConnect&&this.onConnect()},this.sse.addEventListener("open",()=>Qe({clientId:this.clientId,lane:this.lane})),this.sse.addEventListener("error",()=>he());for(let i of Ke)this.sse.addEventListener(i,n=>{let r;try{r=JSON.parse(n.data)}catch{return}Ze(i,r)});this.sse.addEventListener("cursor",i=>{let n;try{n=JSON.parse(i.data)}catch{return}if(!n||n.resync!==!0&&n.startup!==!0)return;let r=n.resync===!0,l=n.startup===!0&&!r;console.log(r?"[LiveSync] Server could not replay everything; refetching the document":"[LiveSync] Checking the served document against the version this tab was served"),this._fetchServedDocument(typeof n.seq=="number"?n.seq:void 0,{repair:r,startup:l})}),this.sse.addEventListener("presence",i=>{let n;try{n=JSON.parse(i.data)}catch{return}kt(n),this._lastRoster=n,this._editing&&this._editing.roster(n)}),this.sse.onmessage=i=>{let n=JSON.parse(i.data),{seq:r}=n;if(typeof r=="number"&&r<=this.lastSeenSeq){this._log(`Dropping stale message: seq=${r}, lastSeen=${this.lastSeenSeq}`);return}if(typeof r=="number"&&(this.lastSeenSeq=r),n.type==="notification"){if(this._maybeAcceptExternalChange(n))return;this.handleNotification(n);return}if(n.error){console.error("[LiveSync] Server error:",n.error),this.onError&&this.onError(new Error(n.error));return}if(this._applyEtagFrame(n))return;let{html:l,sender:o,identityMap:a}=n;if(o===this.clientId){this._log("Ignoring own message (sender matches clientId)");return}if(typeof l!="string"){console.error("[LiveSync] Received invalid html, ignoring");return}let h=typeof n.etag=="string"&&n.etag?n.etag:null;if(this.lane==="live"&&!h&&Ge()){this._log(`Dropping an unstamped live frame on a stamping host (seq=${r})`);return}if(this.lane==="saved"&&l===this._represented.bytes){this._represented=Object.freeze({bytes:l,etag:h||null,seq:r??null}),M(h);return}if(h&&l===this.lastHtml){this._log(`Taking the stamp from a peer save of content already applied (seq=${r})`),M(h),y&&y.isSaveConflicted()&&(y.conflictResolvedBySync(h),this._saveAfterMerge(x(),!1));return}this._log(`Received update from: ${o} (my clientId: ${this.clientId}, seq=${r})`),this.applyUpdate(l,r,a,h,n.by),this.onUpdate&&this.onUpdate({html:l,sender:o,seq:r,identityMap:a,etag:h})},this.sse.onerror=()=>{this.sse.readyState===EventSource.CONNECTING?console.log("[LiveSync] Reconnecting..."):this.sse.readyState===EventSource.CLOSED&&(console.log("[LiveSync] Connection closed"),this.onError&&this.onError(new Error("Connection closed"))),this.onDisconnect&&this.onDisconnect()}}listenForSnapshots(){this._snapshotHandler=e=>{if(!e.detail||e.detail.forSave!==!0)return;this._saveTicket=this._ticket();let{documentElement:t}=e.detail;if(!t)return;this._log("snapshot-ready received, preparing to send");let i=this.identity.exportMap(t,D);this._savedSnapshot?.abort?.abort();let n={html:null,steps:null,copy:null,abort:null,identityMap:i,ticket:this._saveTicket,captureId:e.detail.captureId??null};if(e.detail.sliced){n.copy=Be(t),n.abort=new AbortController;let{signal:r}=n.abort;Promise.all([import("./c-MEWUGR4D.js"),import("./c-ZWBI4HYK.js")]).then(([{serializeForSyncSteps:l},{runSliced:o}])=>{if(r.aborted||typeof n.html=="string")return;let a=(function*(){let h=yield*l(n.copy);n.html=h,n.steps=null})();return n.steps=a,o(a,{signal:r})}).catch(()=>{})}else n.html=T(t);this._savedSnapshot=n},document.addEventListener("clay:snapshot-ready",this._snapshotHandler)}_enqueueSend(e,t,i=null){if(!this._profile){this._queuedSend={html:e,identityMap:t,etag:i},this._resolveProfile().then(()=>this._flushQueuedSend());return}if(this._sendInFlight){this._queuedSend={html:e,identityMap:t,etag:i};return}this._postUpdate(e,t,i)}_flushQueuedSend(){if(this.isDestroyed||this._sendInFlight)return;let e=this._queuedSend;e&&(this._queuedSend=null,this._postUpdate(e.html,e.identityMap,e.etag))}_relayCommit(e=null,t=null){if(this.isDestroyed)return;let i=ie(),n=this._savedSnapshot;if(n&&(n.captureId??null)!==(e??null)){this._log("Skipping send - snapshot belongs to a different capture");return}let r=n;if(this._savedSnapshot=null,r?.copy&&typeof r.html!="string")if(r.abort?.abort(),r.steps)for(let c=r.steps.next();!c.done;c=r.steps.next());else r.html=T(r.copy);if(!r||typeof r.html!="string")return;let l=r;if(typeof t=="string"){try{l=st(r,t,this.identity)}catch(c){this._log(`Skipping send - page relay failed: ${c&&c.message}`);return}if(!l){this._log("Skipping send - accepted capture has no page article");return}}let o=Ht(e)??t,a=typeof o=="string"?je(o):0;l={...l,html:qt(ze(l.html,Math.max(We(),a)),o)};let h=!i&&l.html===this.lastHtml;if(this._setPeerBase(l.html,l.identityMap,l.ticket),h){this._log("Skipping send - HTML unchanged");return}this._enqueueSend(l.html,l.identityMap,i||null)}_postUpdate(e,t,i=null,n=0){this._log(`Sending update (HTML length: ${e.length})`),this._sendInFlight=!0;let r=!1,l=this._profile||ue.legacy;fetch(new URL(l.relayPath,window.location.origin).href,{method:"POST",headers:{"Content-Type":"application/json",[l.documentHeader]:window.location.href,[$e]:String(1)},body:Rt(l,e,this.clientId,t,i)}).then(o=>{o.ok||(console.warn("[LiveSync] Save returned status:",o.status),r=o.status>=500||o.status===408||o.status===429)}).catch(o=>{console.error("[LiveSync] Save failed:",o),this.onError&&this.onError(o),r=!0}).finally(()=>{this._sendInFlight=!1;let o=this._queuedSend;if(this._queuedSend=null,o){this._postUpdate(o.html,o.identityMap,o.etag);return}!r||!i||n>=3||this.isDestroyed||(this._sendInFlight=!0,setTimeout(()=>{if(this._sendInFlight=!1,this.isDestroyed)return;let a=this._queuedSend;this._queuedSend=null,a?this._postUpdate(a.html,a.identityMap,a.etag):this._postUpdate(e,t,i,n+1)},500*2**n))})}_startPresence(e,t){return this.isDestroyed||this._startGen!==t||this._presenceLease?null:e.connect({send:i=>this._postPresence(i)}).then(i=>this.isDestroyed||this._startGen!==t?(typeof i?.stop=="function"?i.stop():i?.detach(),null):(this._presenceLease=i||null,Oe("presence-editing")),()=>!1).then(i=>{if(!(!i||this.isDestroyed||this._startGen!==t||this._editing))return H().then(n=>{this.isDestroyed||this._startGen!==t||this._editing||(this._editing=new n.EditingSender({}),this._presenceQuiesced?this._editing.stop():(this._editing.start(),this._editing.roster(this._lastRoster)))})})}_postPresence(e){let t=new URL("/_/presence",window.location.origin);return t.searchParams.set("client-id",this.clientId),fetch(t.href,{method:"POST",headers:{"Content-Type":"application/json","Document-URL":window.location.href},body:JSON.stringify(e)}).then(i=>i.ok,()=>!1)}_maybeAcceptExternalChange(e){if(this.lane!=="live")return!1;let t=e.data;return t&&t.kind==="external-change"?(typeof t.html=="string"?this._enqueueExternal(t.html,e.seq,t.etag,t.by):this._fetchExternalChange(e.seq),!0):typeof e.msg=="string"&&e.msg.endsWith("changed on disk outside this tab")?(this._fetchExternalChange(e.seq),!0):!1}_enqueueExternal(e,t,i,n){if(typeof t=="number"){if(t<=this._lastExternalSeq){this._log(`Dropping replayed external change: seq=${t}`);return}this._lastExternalSeq=t}this._pendingExternal={html:e,seq:t,saveEpoch:this._saveEpoch,etag:typeof i=="string"&&i?i:null,by:n??null},this._scheduleNextFrame()}_fetchExternalChange(e){if(typeof e=="number"){if(e<=this._lastExternalSeq)return;this._lastExternalSeq=e}this._fetchServedDocument(e)}_fetchServedDocument(e,{attempt:t=0,repair:i=!1,startup:n=!1}={}){if(n&&(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null)){this._retryStartup(t);return}let r=this._saveEpoch,l=this._startGen,o=this.lastSeenSeq,a=this._applyGen,h=++this._servedFetchId;i&&typeof e!="number"&&(e=this._lastExternalSeq),fetch(new URL(window.location.href),{cache:"no-store"}).then(c=>c.ok?c.text():null).then(c=>{if(this.isDestroyed||c==null||this._startGen!==l)return;let d=Lt(c),_=n||i&&!!d;if(_){if(h!==this._servedFetchId){i&&this._retryStartup(t+1,{repair:i,startup:n},typeof e=="number"?Math.max(e,this._lastExternalSeq):e);return}if(r!==this._saveEpoch||o!==this.lastSeenSeq||a!==this._applyGen||this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(t+1,{repair:i,startup:n},e);return}if(d){if(d===se()){(i||n)&&this.lane==="saved"&&(this._represented=Object.freeze({bytes:c,etag:d,seq:e??null}));return}}else if(!i)return}else if(typeof e=="number"&&e<this._lastExternalSeq){i&&t<3&&this._fetchServedDocument(this._lastExternalSeq,{attempt:t+1,repair:i,startup:n});return}else if(this._saveEpoch>r){t<3&&(console.log("[LiveSync] Refetching external change: own save landed mid-fetch"),this._fetchServedDocument(e,{attempt:t+1,repair:i,startup:n}));return}this._pendingExternal={html:c,seq:e,saveEpoch:r,etag:d,by:null,fetchOptions:{repair:i,startup:n,attempt:t,versionCheck:_},startGen:l,seenSeq:o,applyGen:a,fetchId:h},this._scheduleNextFrame()}).catch(c=>{this._log("External-change fetch failed",c),typeof e=="number"&&this._lastExternalSeq===e&&(this._lastExternalSeq=e-1)})}_retryStartup(e=0,t={startup:!0},i){this.isDestroyed||e>3||(clearTimeout(this._startupRetry),this._startupRetry=setTimeout(()=>{if(this._startupRetry=null,!this.isDestroyed){if(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(e,t,i);return}this._fetchServedDocument(i,{...t,attempt:e})}},16))}applyUpdate(e,t,i,n,r){this.isDestroyed||(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=i,this._pendingEtag=n??null,this._pendingBy=r??null,this._scheduleNextFrame())}prepareHandoff(e={}){return this._handoff?Promise.resolve(this._handoff):this.isDestroyed?Promise.reject(new Error("LiveSync: stopped")):(this._handoffHeld=!0,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),import("./c-4PHDUV3H.js").then(({engineHandoff:t})=>t(this,e)).then(t=>this._handoff=t))}_scheduleNextFrame(){this.isDestroyed||this._handoffHeld||this._rafHandle==null&&(this._morphInFlight||(this._rafHandle=this._requestFrame(()=>this._runPending())))}async _runPending(){if(this._rafHandle=null,this.isDestroyed)return;if(!R()){this._morphInFlight=!0;try{await Y()}catch(r){this._log("Merge engine failed to load",r),this._engineRetry=setTimeout(()=>this._scheduleNextFrame(),2e3);return}finally{this._morphInFlight=!1}if(this.isDestroyed)return}let e=this._pendingExternal,t=e?.fetchOptions||null,i=!!(t?.startup||t?.versionCheck),n=!1;if(e!=null&&(i&&this._pendingHtml!=null?n=!1:this._pendingHtml==null?n=!0:n=!(typeof e.seq=="number"&&typeof this._pendingSeq=="number"&&this._pendingSeq<e.seq)),n)if(this._pendingExternal=null,typeof e.seq=="number"&&e.seq<this._lastExternalSeq)i&&t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded external change at drain");else if(i&&e.startGen!==this._startGen)this._log("Dropping superseded startup check at drain");else if(i&&e.fetchId!==this._servedFetchId)t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded startup check at drain");else if(i&&(e.saveEpoch!==this._saveEpoch||e.seenSeq!==this.lastSeenSeq||e.applyGen!==this._applyGen))this._retryStartup((t.attempt||0)+1,t,e.seq);else if(i&&e.etag!=null&&e.etag===se())this._log("Startup check found the same version: nothing to apply");else if(!i&&e.saveEpoch!==this._saveEpoch)console.log("[LiveSync] Refetching external change: own save landed after queue"),this._fetchServedDocument(e.seq,t||{});else{this._morphInFlight=!0;try{await this._doApplyExternal(e.html,e.seq,e.etag,e.by,t)}catch(r){console.error("[LiveSync] applyExternal failed:",r)}finally{this._morphInFlight=!1}}else{let r=this._pendingHtml,l=this._pendingSeq,o=this._pendingIdentityMap,a=this._pendingEtag,h=this._pendingBy;if(this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,r==null)return;this._morphInFlight=!0;try{await this._doApplyUpdate(r,l,o,a,h)}catch(c){console.error("[LiveSync] applyUpdate failed:",c)}finally{this._morphInFlight=!1}}!this.isDestroyed&&(this._pendingHtml!=null||this._pendingExternal!=null)&&this._scheduleNextFrame()}_ticket(){return++this._agreeSeq}_setDiskBase(e,t){t<=this._diskBaseTicket||(this._diskBase=e,this._diskBaseTicket=t)}_setPeerBase(e,t,i){return i<this._peerBaseTicket?!1:(this._peerBaseTicket=i,this.lastHtml=e,this._lastIdentityMap=t&&typeof t=="object"&&!Array.isArray(t)?t:null,!0)}_requestFrame(e){return typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(e):setTimeout(e,16)}_cancelFrame(e){if(typeof window<"u"&&typeof window.cancelAnimationFrame=="function"){window.cancelAnimationFrame(e);return}clearTimeout(e)}async _mergeIncoming(e,t,{base:i,baseIdentityMap:n=null,captureLocal:r,synthetic:l,source:o="peer",seq:a=null,etag:h=null,extra:c={}}){R()||await Y();let{beginApply:d,completeApply:_,failApply:g,beginLineageCapture:E}=ot()||await J(),f,u=p=>{f=E(I.list());try{let v=R().HyperMorph.mergeDocument({...p,lineage:f.lineage});return f.returned(),v}catch(v){throw f.invalidate(I.list()),f.finish(I.list()),v}},S=this.identity,w=De,b=Tt(new WeakMap),N=p=>ge(p)?{first:b,map:p,then:b}:b,O=l?p=>b(p)||S.idOf(D(p)||p)||null:b,C=e,Se=new Map;if(ge(t)){C=new DOMParser().parseFromString(e,"text/html"),ne(C);let p=R().HyperMorph.importMap(C.documentElement,t);for(let v of C.querySelectorAll("[data-id], [id]")){let k=b(v),xe=k&&p.get(v);xe&&Se.set(k,xe)}}C=ht(C);let Q={live:document,remote:C,ignore:p=>p.matches(ut),opaque:p=>p.matches(ft)||z()&&Re(p),remoteWins:p=>p.matches(bt),ignoreAttribute:(p,v,k)=>Dt(p,v,k)||z()&&Fe(k||p,v),attributeMerge:rt,protectFocusedValue:!0,restoreFocus:document.activeElement?.localName!=="clay-editor-ui",keepLiveOnly:o==="peer",scripts:{mergeTags:R().mergeTagRecognizers},hooks:{beforeAttributeUpdated:w},...c},Ee=this.lane==="live"&&x(),we=ae(),G,Z=null,F=null;if(i==null)G=u({...Q,base:null,local:{root:V(r()),toLive:D},identity:{local:O,remote:N(t)}});else if(Ee){let p=r(),v=p.cloneNode(!0);Z=V(p),F=d({source:o,seq:a,etag:h,root:Z,recoveryRoot:v,domain:o==="disk"?"save":"sync"});try{G=u({...Q,base:ht(i),local:{root:Z,toLive:D},identity:{base:N(n),local:O,remote:N(t)}})}catch(k){throw g(F,k),k}}else{let p=V(r()),v=p.ownerDocument;v.documentElement!==p&&v.replaceChild(p,v.documentElement),G=u({...Q,base:v,local:{root:p,toLive:D},fastPath:!0,identity:{base:O,local:O,remote:N(t)}})}let U=this._ticket();this._morphTicket=U;let A;try{A=await G}catch(p){f.invalidate(I.list());try{F&&g(F,p,{ticket:U})}finally{f.finish(I.list())}throw p}let _t=ae().gen!==we.gen,ke;try{f.prepareComplete(A,I.list()),ke=F?_(F,A.conflicts,{ticket:U}):[]}finally{f.finish(I.list())}this.lane==="live"&&A.localDiverged?Ye():Ee&&!A.localDiverged&&Je(we);let gt=new Set(ge(t)?Object.values(t):[]);for(let[p,v]of A.identities){let k=gt.has(v)?v:Se.get(v);k&&S.adopt(p,k)}return{report:A,ticket:U,typedDuringWait:_t,conflictIds:ke}}_saveAfterMerge(e,t){(e||t)&&Ve()&&(y?y.savePageThrottled():xt())}async _doApplyUpdate(e,t,i,n,r=null){if(ce(e)){await de();return}this.lane==="live"&&!y&&await H(),this._log("applyUpdate - pausing mutations and morphing"),this.isPaused=!0;let l=window.scrollX,o=window.scrollY;q.pause(),le();let a=!1,h=!1,c=!1;try{if(this.lane==="live"&&x()&&this.lastHtml===null){console.log("[LiveSync] Holding incoming update: unsaved local edits and no baseline to merge against"),this._setHeld("live",!0,null);let f=this._saveEpoch,u=this.lastSeenSeq;clearTimeout(this._holdRetryPeer),this._holdRetryPeer=setTimeout(()=>{this._holdRetryPeer=null,!(this.isDestroyed||this._pendingHtml!=null)&&this._saveEpoch===f&&this.lastSeenSeq===u&&(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=i,this._pendingBy=r,this._scheduleNextFrame())},3e3);return}this._setHeld("live",!1);let{report:d,ticket:_,typedDuringWait:g,conflictIds:E}=await this._mergeIncoming(e,i,{base:this.lastHtml,baseIdentityMap:this._lastIdentityMap,captureLocal:()=>P({flushUndo:!1}),synthetic:!0,source:"peer",seq:t,etag:n});if(a=d.localDiverged,h=g,te(),window.scrollTo(l,o),this._setPeerBase(e,i,_),this._applyGen++,this._acceptedSaveTicket>_||(typeof n=="string"&&n?(M(n),c=!0):re()),this.lane==="live"&&!a&&!x()){let{forSave:f,forComparison:u,forDirty:S}=W({emitForSync:!1,flushUndo:!1});y.setLastSavedBaselines(u,S),this._setDiskBase(f,this._ticket())}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:n||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:this.lane==="saved"?"disk":"peer",lane:this.lane,by:r||null,html:e,report:d,unresolved:this.unresolvedConflicts,conflictIds:E}}))}finally{this._log("applyUpdate - morph complete, resuming mutations"),q.resume(),oe(),await new Promise(d=>setTimeout(d,0)),this.isPaused=!1}c&&y?.conflictResolvedBySync(n),this._saveAfterMerge(a,h)}async _doApplyExternal(e,t,i=null,n=null,r=null){if(ce(e)){await de();return}this.lane==="live"&&!y&&await H();let l=this._diskBase;this._log(`applyExternal - external disk change (seq=${t})`),this.isPaused=!0;let o=window.scrollX,a=window.scrollY;q.pause(),le();let h=!1,c=!1,d=!1;try{if(this.lane==="live"&&x()&&this._diskBase===null){if(console.log("[LiveSync] Holding external change: unsaved local edits and no baseline to merge against"),this._setHeld("external",!0,null),r?.startup||r?.versionCheck){clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{if(this._holdRetryExt=null,this.isDestroyed)return;let S=typeof t=="number"?Math.max(t,this._lastExternalSeq):t;this._retryStartup(0,r,S)},3e3);return}let u=this._saveEpoch;clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{this._holdRetryExt=null,!(this.isDestroyed||this._pendingExternal!=null)&&(this._pendingExternal={html:e,seq:t,saveEpoch:u,etag:i,by:n},this._scheduleNextFrame())},3e3);return}this._setHeld("external",!1);let{report:_,ticket:g,typedDuringWait:E,conflictIds:f}=await this._mergeIncoming(e,null,{base:this._diskBase,captureLocal:()=>Me().saveClone,synthetic:!1,source:"disk",seq:t,etag:i,extra:{beforeApply:u=>Ct(u.documentElement,this.lane)}});if(h=_.localDiverged,c=E,te(),this._setDiskBase(e,g),window.scrollTo(o,a),this._acceptedSaveTicket>g||(typeof i=="string"&&i?(M(i),d=!0):re()),this.lane==="live"&&!h&&!x()){y.setLastSavedBaselines(...At()),y.setUnsavedChanges(!1);let u=P({flushUndo:!1});this._setPeerBase(T(u),this.identity.exportMap(u,D),g),this._applyGen++}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:i||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:"disk",etag:typeof i=="string"&&i?i:null,by:n||null,html:e,report:_,conflictIds:f,unresolved:this.unresolvedConflicts}}))}finally{this._log("applyExternal - morph complete, resuming mutations"),q.resume(),oe(),await new Promise(_=>setTimeout(_,0)),this.isPaused=!1}d&&y?.conflictResolvedBySync(i),this._saveAfterMerge(h,c),l!=null&&j(l)===j(e)&&y&&y.schedulePaintHeal(()=>this._diskBase==null?null:j(this._diskBase))}handleNotification({msgType:e,msg:t,action:i,persistent:n,data:r}){this._log(`Notification received: ${e} - ${t}`),e==="data-loss"||(n&&window.toastPersistent?window.toastPersistent(t,e):window.toast?window.toast(t,e):console.log(`[LiveSync] Notification: ${t}`)),document.dispatchEvent(new CustomEvent("clay:notification",{detail:{msgType:e,msg:t,action:i,persistent:n,data:r}})),this.onNotification&&this.onNotification({msgType:e,msg:t,action:i,persistent:n,data:r})}stop(){this.cleanup(),this.isDestroyed=!0,console.log("[LiveSync] Stopped")}editParticipant(){return H().then(e=>e.syncParticipant(this))}},X=null;Ne((s,e)=>{X=typeof s=="string"?{html:s,captureId:e?.captureId??null}:null});var Ht=s=>X&&(X.captureId??null)===(s??null)?X.html:null;function qt(s,e){if(typeof e!="string"||e===s)return s;let t=i=>new DOMParser().parseFromString(i,"text/html").documentElement;return t(s).isEqualNode(t(e))?e:s}var ve=new me;typeof window<"u"&&!ct&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>ve.start()):ve.start());var _n=(s,e,t)=>Y().then(({morph:i})=>i(s,e,t));var gn=ve;export{I as a,ut as b,bt as c,me as d,ve as e,_n as f,gn as g};
@@ -1 +1 @@
1
- import{a as ae}from"./c-LKSL4AUJ.js";import{i as ne,j as re}from"./c-SJPD46ZO.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-XQSXKIKM.js";import"./c-67ILSNPR.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as se}from"./c-44B5ODN7.js";import{A as J,H as D,I as Z,J as N,O as ee,b as Y,j as U,k as G,m as K,na as te,ra as oe,x as Q}from"./c-QIXT3Q7C.js";import"./c-E4IBSAQM.js";import"./c-57XDY6HC.js";import{a as W}from"./c-I2SCCUEW.js";import"./c-EK63G3CG.js";import"./c-VHNSBD2M.js";var be="iframe, frame, frameset, object, embed, applet, meta, base, link, form, style, animate, set, animateMotion, animateTransform, portal",ye=/^(srcdoc|data|formaction|codebase|archive|ping|background|poster|lowsrc|dynsrc)$/i,we=/^\s*(javascript|vbscript|data):/i;function xe(o){let l=document.createElement("template");l.innerHTML=o;for(let a of l.content.querySelectorAll(be))a.remove();for(let a of l.content.querySelectorAll("*"))for(let{name:i,value:h}of[...a.attributes])(ye.test(i)||we.test(h.replace(/[\u0000-\u0020]/g,"")))&&a.removeAttribute(i);return l.innerHTML}var F=2*1024*1024,ce=32,le=1e4,P=class extends Error{constructor(l,a){super(a),this.name="MarkdownImportError",this.code=l}},pe="\uFFFC",de={type:"hard_break"},ue=new Set(["paragraph","heading","list","blockquote","code","table","hr","html","def","space"]),Me=new TextEncoder,ie=K.marks,fe=o=>o.slice().sort((l,a)=>l.type.rank-a.type.rank);function j(o,l,a){return o.some(i=>i.type===ie[l])?o:fe([...o,ie[l].create(a)])}function Se(o,{images:l=!0,refused:a=[],unsupported:i=[]}={}){let h=[],k="",z=[],S=()=>{k&&h.push({c:k,m:z}),k="",z=[]},O=(A,g)=>{let p=String(A??"");if(!p)return;let C=Q(fe(g));k+=p;for(let b=0;b<p.length;b++)z.push(C)},$=A=>{k+=pe,z.push("@"+JSON.stringify(A))},E=(A,g)=>{for(let p of A??[]){let C=p?.type;if(typeof C!="string")throw new P("malformed-input","A Markdown token has no type.");switch(C){case"text":Array.isArray(p.tokens)?E(p.tokens.filter(b=>typeof b?.type=="string"&&!ue.has(b.type)),g):O(p.text,g);break;case"escape":O(p.text,g);break;case"strong":E(p.tokens,j(g,"strong"));break;case"em":E(p.tokens,j(g,"em"));break;case"del":case"strike":E(p.tokens,j(g,"strike"));break;case"codespan":O(p.text,j(g,"code"));break;case"br":$(de);break;case"link":{let b=U(p.href);b?E(p.tokens,j(g,"link",{href:b})):(a.push({type:"link",href:String(p.href??"")}),E(p.tokens,g));break}case"image":{let b={src:String(p.href??""),alt:String(p.text??""),title:p.title??""};if(!l){O(b.alt,g);break}S(),h.push({image:b});break}case"html":O(p.text??p.raw,g);break;case"checkbox":break;default:i.push({type:C,text:String(p.raw??p.text??"")}),O(p.raw??p.text,g);break}}};return E(o,[]),S(),{parts:h}}function me(o){if(!Array.isArray(o))throw new P("malformed-input","Markdown import needs the lexer's token list.");let l=0;for(let e of o){if(!e||typeof e!="object"||typeof e.type!="string")throw new P("malformed-input","A Markdown token has no type.");l+=Me.encode(String(e.raw??"")).length}if(l>F)throw new P("input-too-large",`Markdown import is limited to ${F} bytes; this file is ${l}.`);let a=[],i=[],h=[],k=new Set,z=e=>{let t=N(e);for(;k.has(t);)t=N(e);return k.add(t),t},S=e=>{if(a.length+1>le)throw new P("too-many-blocks",`Markdown import is limited to ${le} blocks.`);a.push(e)},O=e=>{let t=e.depth+1;if(t>ce)throw new P("nesting-too-deep",`Markdown import is limited to ${ce} levels of nesting.`);return t},$=(e,t,{c:n,m:u})=>{let r={t:e,...t,c:n};return u.some(Boolean)&&(r.m=J(u)),r},E=e=>{let t=G(e.src);return t?{t:"image",src:t,...e.alt?{alt:e.alt}:{},...e.title?{caption:e.title}:{}}:(h.push({type:"image",href:e.src}),e.alt?$("paragraph",{},{c:e.alt,m:[]}):null)},A=(e,t,n)=>{for(let u of n.parts){if(!u.image){S($(e,t,u));continue}let r=E(u.image);r&&S(r)}},g=(e,t)=>A(t.quote?"quote":"paragraph",{},e),p=(e,t={})=>Se(e,{refused:h,unsupported:i,...t}),C=e=>{let t=String(e.raw??e.text??"");i.push({type:e.type,text:t}),S({t:"code_block",lang:"markdown",c:t})},b=(e,t)=>{for(let n of e??[]){let u=n?.type;if(typeof u!="string")throw new P("malformed-input","A Markdown token has no type.");switch(u){case"space":break;case"heading":{let r=Math.min(6,Math.max(1,Number.parseInt(n.depth,10)||1));A("heading",r===2?{}:{level:r},p(n.tokens,{images:!1}));break}case"paragraph":case"text":g(p(n.tokens??[n]),t);break;case"hr":S({t:"divider"});break;case"code":S({t:"code_block",...n.lang?{lang:String(n.lang)}:{},c:String(n.text??"")});break;case"html":{let r=String(n.text??n.raw??"");i.push({type:"HTML block cleaned",text:r}),S({t:"preserved",html:xe(oe(document).fallback(r))});break}case"blockquote":{let r=O(t);b(n.tokens,{...t,depth:r,quote:!0});break}case"list":{let r=O(t),s=t.indent??0,f=n.ordered?"ordered":"bullet";for(let c of n.items??[]){let m={c:"",m:[]},d=[];for(let y of c?.tokens??[]){let M=y?.type;if(!(M==="checkbox"||M==="space"))if(M==="text"||M==="paragraph"){m.c&&(m={c:m.c+pe,m:[...m.m,"@"+JSON.stringify(de)]});let v=M==="paragraph"?y.tokens??[]:[y];for(let x of p(v,{images:!1}).parts)m={c:m.c+x.c,m:[...m.m,...x.m]};d.push(...(y.tokens??[]).filter(x=>typeof x?.type=="string"&&ue.has(x.type)&&x.type!=="space"))}else d.push(y)}let w=c?.task?"check":f,B={...w==="bullet"?{}:{kind:w},...s?{indent:s}:{},...c?.task&&c.checked?{checked:!0}:{}};S($("list_item",B,m)),d.length&&b(d,{...t,depth:r,indent:s+1,quote:!1})}break}case"table":{let r=n.header??[];if(!r.length){C(n);break}let s=y=>p(y,{images:!1}).parts[0]??{c:"",m:[]},f=r.map(()=>z("c")),c=D(null,null,r.length),m=Object.fromEntries(f.map((y,M)=>[y,{pos:c[M],name:s(r[M]?.tokens).c}])),d=n.rows?.length?n.rows:[[]],w=D(null,null,d.length),B=d.map(y=>Object.fromEntries(f.map((M,v)=>{let x=s(y?.[v]?.tokens);return[M,x.m.some(Boolean)?{c:x.c,m:J(x.m)}:x.c]})));S({t:"table",cols:m,rows:Object.fromEntries(B.map((y,M)=>[z("r"),{pos:w[M],cells:y}]))});break}default:C(n);break}}};b(o,{depth:0,indent:0,quote:!1});let _=D(null,null,a.length),R={};return a.forEach((e,t)=>{R[z("b")]={...e,pos:_[t]}}),{blocks:R,unsupported:i,refused:h}}var Ee="markdown-import-preview",Te=new TextEncoder,Ae=o=>{let l=String(o??"").replace(/\s+/g," ").trim();return l.length>60?`${l.slice(0,60)}\u2026`:l},Oe=o=>typeof o.text=="function"?o.text():new Promise((l,a)=>{let i=new FileReader;i.onload=()=>l(i.result),i.onerror=()=>a(i.error),i.readAsText(o)}),ze=()=>globalThis.clay?.assets?.load?.("marked")??import("./c-XN6MBKI6.js"),$e=(o,l)=>{let a=-1;return o.forEach((i,h,k)=>{a<0&&i.attrs.id===l&&(a=k)}),a};function Ce(o){let l=o.selection.$from;if(l.depth>=1)return{node:l.node(1),at:l.before(1),textblock:l.parent.isTextblock};let a=Math.min(l.index(0),Math.max(0,o.doc.childCount-1)),i=0;for(let h=0;h<a;h++)i+=o.doc.child(h).nodeSize;return{node:o.doc.child(a),at:i,textblock:!1}}function ve(o){let{node:l,at:a,textblock:i}=Ce(o),h=o.selection,k=i?Math.max(0,h.from-a-1):0;return{id:l.attrs.id,textblock:i,size:l.isTextblock?l.content.size:0,fromOff:k,toOff:i?Math.max(k,h.to-a-1):0}}var Pe=o=>{try{return ae(te(o))>0}catch{return!0}},Be=o=>o?.code==="page-format-upgrade-required"?"This document needs a newer page format before Markdown can be added. The preview stays open.":o?.code==="page-format-unsupported"?"This host cannot record the newer page format this file needs. The preview stays open.":o?.code==="stale-target"?"The place this import was started from changed. The preview stays open.":o?.code==="empty-import"?"This file holds nothing that can be inserted.":"The Markdown could not be inserted. The preview stays open.";function Ue({view:o=null,load:l=ze}={}){if(!o)return{run:()=>Promise.resolve({ok:!1,code:"not-editing"}),dispose(){}};let a=o.dom.ownerDocument,i=null,h=null,k=!1,z=W({id:Ee,isPending:()=>i!==null}),S=()=>h??=Promise.resolve().then(l).catch(e=>{throw h=null,e});function O(){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},t=o.coordsAtPos(Math.min(o.state.selection.from,o.state.doc.content.size));return{x:Math.max(8,t.left-e.left),y:t.bottom+6-e.top}}catch{return null}}function $(){let e=i;if(!e)return!1;i=null;for(let[t,n,u,r]of e.listen)t.removeEventListener(n,u,r);return e.panel.remove(),!0}function E(){return $()?(o.focus?.(),{ok:!0,cancelled:!0}):{ok:!1,code:"cancelled"}}function A(e){let t=[],n=(c,m)=>{let d=a.createElement("div");return d.className=c,d.textContent=m,d};if(t.push(n("page-menu-title",e.error?"Couldn't read that Markdown":`Import ${e.name}`)),!e.error){let c=[`${e.count} block${e.count===1?"":"s"}`];e.unsupported.length&&c.push(`${e.unsupported.length} kept as written`),e.refused.length&&c.push(`${e.refused.length} address${e.refused.length===1?"":"es"} left out`),t.push(n("page-menu-title page-import-summary",c.join(" \xB7 ")))}let u=(c,m)=>{let d=a.createElement("div");return d.className=c,d.replaceChildren(...m.map(w=>n("page-import-row",w))),d};e.unsupported.length&&t.push(u("page-import-unsupported",e.unsupported.map(c=>`${c.type}: ${Ae(c.text)}`))),e.refused.length&&t.push(u("page-import-refused",e.refused.map(c=>`${c.type}: ${c.href}`)));let r=e.error??e.notice??null;if(r){let c=a.createElement("p");c.className="page-import-error",c.setAttribute("role","alert"),c.textContent=r,t.push(c)}let s=(c,m)=>{let d=a.createElement("button");return d.type="button",d.className="page-menu-item",d.dataset.import=c,d.textContent=m,d.addEventListener("mousedown",w=>w.preventDefault()),d.addEventListener("click",()=>c==="insert"?p():E()),d},f=s("insert","Insert at the selection");f.disabled=!!e.error,t.push(f,s("cancel","Cancel")),e.panel.replaceChildren(...t)}function g(e,t){let n=o.state,u=n.doc,r=$e(u,e.id);if(r<0)return{ok:!1,code:"stale-target"};let s=u.child(r);if(e.textblock?!s.isTextblock||s.content.size!==e.size:s.isTextblock)return{ok:!1,code:"stale-target"};let f=Z(t).map(T=>ee(K,T,{...t[T],pos:null,parent:null}));if(!f.length)return{ok:!1,code:"empty-import"};let c=0;for(let T=0;T<r;T++)c+=u.child(T).nodeSize;let m=u.maybeChild(r+1),d=s.type.name==="toggle",w=e.textblock&&!d&&s.content.size>0,B=w||e.textblock&&!d&&s.content.size===0,y=w?Math.min(e.fromOff,s.content.size):0,M=w?Math.min(Math.max(y,e.toOff),s.content.size):0,v=w&&y>0?s.type.create({...s.attrs},s.content.cut(0,y)):null,x=w?s.content.cut(M):null,I=x&&x.size?s.type.create({...s.attrs,id:N(),pos:null},x):null,he=w&&!v?r>0?u.child(r-1).attrs.pos:null:s.attrs.pos,V=D(he,m?.attrs.pos??null,f.length+(I?1:0)),ke=d?s.attrs.id:s.attrs.parent??null,L=f.map((T,ge)=>T.type.create({...T.attrs,pos:V[ge],parent:ke},T.content,T.marks)),H=I?I.type.create({...I.attrs,pos:V[f.length]},I.content,I.marks):null,q=n.tr;B?q.replaceWith(c,c+s.nodeSize,[...v?[v]:[],...L,...H?[H]:[]]):q.insert(c+s.nodeSize,L),d&&!s.attrs.open&&L.length>0&&q.setNodeMarkup(c,null,{...s.attrs,open:!0});let X=c+(B?v?v.nodeSize:0:s.nodeSize);for(let T of L)X+=T.nodeSize;return q.setSelection(Y.TextSelection.near(q.doc.resolve(H?X:Math.max(0,X-1)),H?1:-1)),o.dispatch(se(q).scrollIntoView()),o.focus?.(),{ok:!0,blocks:L.length}}async function p(){let e=i;if(!e||e.error)return e?{ok:!1,code:"no-import"}:{ok:!1,code:"not-editing"};e.notice&&(e.notice=null,A(e));let t=()=>g(e.target,e.blocks),n=e.floor?await ne(o,t):t();return n?.ok?($(),n):(i===e&&(e.notice=Be(n),A(e)),n??{ok:!1,code:"import-failed"})}function C(e){!i||re(e,o)||(e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),E()):e.key==="Enter"&&!e.target?.closest?.("[data-import]")&&(e.preventDefault(),e.stopPropagation(),p()))}function b(){return new Promise(e=>{let t=a.createElement("input");t.type="file",t.accept=".md,.markdown,text/markdown,text/plain",t.hidden=!0,t.className="page-markdown-input";let n=u=>{t.remove(),e(u)};t.addEventListener("change",()=>n(t.files?.[0]??null)),t.addEventListener("cancel",()=>n(null)),(o.dom.parentElement??a.body).appendChild(t),t.click()})}async function _(e,t=null){e.error=t;let n=a.createElement("div");n.className="page-menu page-import-preview",n.setAttribute("role","dialog"),n.setAttribute("aria-label","Import Markdown"),e.panel=n,i=e;let u=(f,c,m,d)=>{f.addEventListener(c,m,d),e.listen.push([f,c,m,d])};u(a,"keydown",f=>C(f),!0),u(a,"mousedown",f=>{e.panel.contains(f.target)||E()},!0),(o.dom.parentElement??a.body).appendChild(n),A(e);let r=O();r&&(n.style.setProperty("--page-pop-x",`${r.x}px`),n.style.setProperty("--page-pop-y",`${r.y}px`));let s=n.querySelector('[data-import="insert"]');return s&&!s.disabled&&s.focus?.(),{ok:!0,preview:!0}}async function R(e={}){if(k||o.isDestroyed)return{ok:!1,code:"not-editing"};$();let t=ve(o.state),n=e?.file??await b();if(!n)return{ok:!1,code:"cancelled"};if(typeof n.size=="number"&&n.size>F)return{ok:!1,code:"input-too-large"};let u;try{u=await Oe(n)}catch(f){return{ok:!1,code:"unreadable",error:f}}if(k||o.isDestroyed)return{ok:!1,code:"not-editing"};if(Te.encode(u).length>F)return{ok:!1,code:"input-too-large"};let r={target:t,name:String(n.name??"Markdown"),blocks:{},count:0,unsupported:[],refused:[],floor:0,panel:null,error:null,notice:null,listen:[]},s;try{let f=await S();s=me(new f.Marked().lexer(u))}catch(f){return k||o.isDestroyed?{ok:!1,code:"not-editing"}:_(r,String(f?.message??"The Markdown could not be read."))}return k||o.isDestroyed?{ok:!1,code:"not-editing"}:(r.blocks=s.blocks,r.count=Object.keys(s.blocks).length,r.unsupported=s.unsupported,r.refused=s.refused,r.floor=Pe(s.blocks)?1:0,_(r))}return{async run(e){return R(e)},dispose(){k=!0,$(),z.dispose()}}}export{Ue as createFeature};
1
+ import{a as ae}from"./c-LKSL4AUJ.js";import{i as ne,j as re}from"./c-4RFZROCF.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-4TWARTLS.js";import"./c-Q5KAQJAG.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as se}from"./c-TMT5TL65.js";import{A as J,H as D,I as Z,J as N,O as ee,b as Y,j as U,k as G,m as K,na as te,ra as oe,x as Q}from"./c-QIXT3Q7C.js";import"./c-OI2BYWVV.js";import"./c-57XDY6HC.js";import{a as W}from"./c-I2SCCUEW.js";import"./c-EK63G3CG.js";import"./c-VHNSBD2M.js";var be="iframe, frame, frameset, object, embed, applet, meta, base, link, form, style, animate, set, animateMotion, animateTransform, portal",ye=/^(srcdoc|data|formaction|codebase|archive|ping|background|poster|lowsrc|dynsrc)$/i,we=/^\s*(javascript|vbscript|data):/i;function xe(o){let l=document.createElement("template");l.innerHTML=o;for(let a of l.content.querySelectorAll(be))a.remove();for(let a of l.content.querySelectorAll("*"))for(let{name:i,value:h}of[...a.attributes])(ye.test(i)||we.test(h.replace(/[\u0000-\u0020]/g,"")))&&a.removeAttribute(i);return l.innerHTML}var F=2*1024*1024,ce=32,le=1e4,P=class extends Error{constructor(l,a){super(a),this.name="MarkdownImportError",this.code=l}},pe="\uFFFC",de={type:"hard_break"},ue=new Set(["paragraph","heading","list","blockquote","code","table","hr","html","def","space"]),Me=new TextEncoder,ie=K.marks,fe=o=>o.slice().sort((l,a)=>l.type.rank-a.type.rank);function j(o,l,a){return o.some(i=>i.type===ie[l])?o:fe([...o,ie[l].create(a)])}function Se(o,{images:l=!0,refused:a=[],unsupported:i=[]}={}){let h=[],k="",z=[],S=()=>{k&&h.push({c:k,m:z}),k="",z=[]},O=(A,g)=>{let p=String(A??"");if(!p)return;let C=Q(fe(g));k+=p;for(let b=0;b<p.length;b++)z.push(C)},$=A=>{k+=pe,z.push("@"+JSON.stringify(A))},E=(A,g)=>{for(let p of A??[]){let C=p?.type;if(typeof C!="string")throw new P("malformed-input","A Markdown token has no type.");switch(C){case"text":Array.isArray(p.tokens)?E(p.tokens.filter(b=>typeof b?.type=="string"&&!ue.has(b.type)),g):O(p.text,g);break;case"escape":O(p.text,g);break;case"strong":E(p.tokens,j(g,"strong"));break;case"em":E(p.tokens,j(g,"em"));break;case"del":case"strike":E(p.tokens,j(g,"strike"));break;case"codespan":O(p.text,j(g,"code"));break;case"br":$(de);break;case"link":{let b=U(p.href);b?E(p.tokens,j(g,"link",{href:b})):(a.push({type:"link",href:String(p.href??"")}),E(p.tokens,g));break}case"image":{let b={src:String(p.href??""),alt:String(p.text??""),title:p.title??""};if(!l){O(b.alt,g);break}S(),h.push({image:b});break}case"html":O(p.text??p.raw,g);break;case"checkbox":break;default:i.push({type:C,text:String(p.raw??p.text??"")}),O(p.raw??p.text,g);break}}};return E(o,[]),S(),{parts:h}}function me(o){if(!Array.isArray(o))throw new P("malformed-input","Markdown import needs the lexer's token list.");let l=0;for(let e of o){if(!e||typeof e!="object"||typeof e.type!="string")throw new P("malformed-input","A Markdown token has no type.");l+=Me.encode(String(e.raw??"")).length}if(l>F)throw new P("input-too-large",`Markdown import is limited to ${F} bytes; this file is ${l}.`);let a=[],i=[],h=[],k=new Set,z=e=>{let t=N(e);for(;k.has(t);)t=N(e);return k.add(t),t},S=e=>{if(a.length+1>le)throw new P("too-many-blocks",`Markdown import is limited to ${le} blocks.`);a.push(e)},O=e=>{let t=e.depth+1;if(t>ce)throw new P("nesting-too-deep",`Markdown import is limited to ${ce} levels of nesting.`);return t},$=(e,t,{c:n,m:u})=>{let r={t:e,...t,c:n};return u.some(Boolean)&&(r.m=J(u)),r},E=e=>{let t=G(e.src);return t?{t:"image",src:t,...e.alt?{alt:e.alt}:{},...e.title?{caption:e.title}:{}}:(h.push({type:"image",href:e.src}),e.alt?$("paragraph",{},{c:e.alt,m:[]}):null)},A=(e,t,n)=>{for(let u of n.parts){if(!u.image){S($(e,t,u));continue}let r=E(u.image);r&&S(r)}},g=(e,t)=>A(t.quote?"quote":"paragraph",{},e),p=(e,t={})=>Se(e,{refused:h,unsupported:i,...t}),C=e=>{let t=String(e.raw??e.text??"");i.push({type:e.type,text:t}),S({t:"code_block",lang:"markdown",c:t})},b=(e,t)=>{for(let n of e??[]){let u=n?.type;if(typeof u!="string")throw new P("malformed-input","A Markdown token has no type.");switch(u){case"space":break;case"heading":{let r=Math.min(6,Math.max(1,Number.parseInt(n.depth,10)||1));A("heading",r===2?{}:{level:r},p(n.tokens,{images:!1}));break}case"paragraph":case"text":g(p(n.tokens??[n]),t);break;case"hr":S({t:"divider"});break;case"code":S({t:"code_block",...n.lang?{lang:String(n.lang)}:{},c:String(n.text??"")});break;case"html":{let r=String(n.text??n.raw??"");i.push({type:"HTML block cleaned",text:r}),S({t:"preserved",html:xe(oe(document).fallback(r))});break}case"blockquote":{let r=O(t);b(n.tokens,{...t,depth:r,quote:!0});break}case"list":{let r=O(t),s=t.indent??0,f=n.ordered?"ordered":"bullet";for(let c of n.items??[]){let m={c:"",m:[]},d=[];for(let y of c?.tokens??[]){let M=y?.type;if(!(M==="checkbox"||M==="space"))if(M==="text"||M==="paragraph"){m.c&&(m={c:m.c+pe,m:[...m.m,"@"+JSON.stringify(de)]});let v=M==="paragraph"?y.tokens??[]:[y];for(let x of p(v,{images:!1}).parts)m={c:m.c+x.c,m:[...m.m,...x.m]};d.push(...(y.tokens??[]).filter(x=>typeof x?.type=="string"&&ue.has(x.type)&&x.type!=="space"))}else d.push(y)}let w=c?.task?"check":f,B={...w==="bullet"?{}:{kind:w},...s?{indent:s}:{},...c?.task&&c.checked?{checked:!0}:{}};S($("list_item",B,m)),d.length&&b(d,{...t,depth:r,indent:s+1,quote:!1})}break}case"table":{let r=n.header??[];if(!r.length){C(n);break}let s=y=>p(y,{images:!1}).parts[0]??{c:"",m:[]},f=r.map(()=>z("c")),c=D(null,null,r.length),m=Object.fromEntries(f.map((y,M)=>[y,{pos:c[M],name:s(r[M]?.tokens).c}])),d=n.rows?.length?n.rows:[[]],w=D(null,null,d.length),B=d.map(y=>Object.fromEntries(f.map((M,v)=>{let x=s(y?.[v]?.tokens);return[M,x.m.some(Boolean)?{c:x.c,m:J(x.m)}:x.c]})));S({t:"table",cols:m,rows:Object.fromEntries(B.map((y,M)=>[z("r"),{pos:w[M],cells:y}]))});break}default:C(n);break}}};b(o,{depth:0,indent:0,quote:!1});let _=D(null,null,a.length),R={};return a.forEach((e,t)=>{R[z("b")]={...e,pos:_[t]}}),{blocks:R,unsupported:i,refused:h}}var Ee="markdown-import-preview",Te=new TextEncoder,Ae=o=>{let l=String(o??"").replace(/\s+/g," ").trim();return l.length>60?`${l.slice(0,60)}\u2026`:l},Oe=o=>typeof o.text=="function"?o.text():new Promise((l,a)=>{let i=new FileReader;i.onload=()=>l(i.result),i.onerror=()=>a(i.error),i.readAsText(o)}),ze=()=>globalThis.clay?.assets?.load?.("marked")??import("./c-XN6MBKI6.js"),$e=(o,l)=>{let a=-1;return o.forEach((i,h,k)=>{a<0&&i.attrs.id===l&&(a=k)}),a};function Ce(o){let l=o.selection.$from;if(l.depth>=1)return{node:l.node(1),at:l.before(1),textblock:l.parent.isTextblock};let a=Math.min(l.index(0),Math.max(0,o.doc.childCount-1)),i=0;for(let h=0;h<a;h++)i+=o.doc.child(h).nodeSize;return{node:o.doc.child(a),at:i,textblock:!1}}function ve(o){let{node:l,at:a,textblock:i}=Ce(o),h=o.selection,k=i?Math.max(0,h.from-a-1):0;return{id:l.attrs.id,textblock:i,size:l.isTextblock?l.content.size:0,fromOff:k,toOff:i?Math.max(k,h.to-a-1):0}}var Pe=o=>{try{return ae(te(o))>0}catch{return!0}},Be=o=>o?.code==="page-format-upgrade-required"?"This document needs a newer page format before Markdown can be added. The preview stays open.":o?.code==="page-format-unsupported"?"This host cannot record the newer page format this file needs. The preview stays open.":o?.code==="stale-target"?"The place this import was started from changed. The preview stays open.":o?.code==="empty-import"?"This file holds nothing that can be inserted.":"The Markdown could not be inserted. The preview stays open.";function Ue({view:o=null,load:l=ze}={}){if(!o)return{run:()=>Promise.resolve({ok:!1,code:"not-editing"}),dispose(){}};let a=o.dom.ownerDocument,i=null,h=null,k=!1,z=W({id:Ee,isPending:()=>i!==null}),S=()=>h??=Promise.resolve().then(l).catch(e=>{throw h=null,e});function O(){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},t=o.coordsAtPos(Math.min(o.state.selection.from,o.state.doc.content.size));return{x:Math.max(8,t.left-e.left),y:t.bottom+6-e.top}}catch{return null}}function $(){let e=i;if(!e)return!1;i=null;for(let[t,n,u,r]of e.listen)t.removeEventListener(n,u,r);return e.panel.remove(),!0}function E(){return $()?(o.focus?.(),{ok:!0,cancelled:!0}):{ok:!1,code:"cancelled"}}function A(e){let t=[],n=(c,m)=>{let d=a.createElement("div");return d.className=c,d.textContent=m,d};if(t.push(n("page-menu-title",e.error?"Couldn't read that Markdown":`Import ${e.name}`)),!e.error){let c=[`${e.count} block${e.count===1?"":"s"}`];e.unsupported.length&&c.push(`${e.unsupported.length} kept as written`),e.refused.length&&c.push(`${e.refused.length} address${e.refused.length===1?"":"es"} left out`),t.push(n("page-menu-title page-import-summary",c.join(" \xB7 ")))}let u=(c,m)=>{let d=a.createElement("div");return d.className=c,d.replaceChildren(...m.map(w=>n("page-import-row",w))),d};e.unsupported.length&&t.push(u("page-import-unsupported",e.unsupported.map(c=>`${c.type}: ${Ae(c.text)}`))),e.refused.length&&t.push(u("page-import-refused",e.refused.map(c=>`${c.type}: ${c.href}`)));let r=e.error??e.notice??null;if(r){let c=a.createElement("p");c.className="page-import-error",c.setAttribute("role","alert"),c.textContent=r,t.push(c)}let s=(c,m)=>{let d=a.createElement("button");return d.type="button",d.className="page-menu-item",d.dataset.import=c,d.textContent=m,d.addEventListener("mousedown",w=>w.preventDefault()),d.addEventListener("click",()=>c==="insert"?p():E()),d},f=s("insert","Insert at the selection");f.disabled=!!e.error,t.push(f,s("cancel","Cancel")),e.panel.replaceChildren(...t)}function g(e,t){let n=o.state,u=n.doc,r=$e(u,e.id);if(r<0)return{ok:!1,code:"stale-target"};let s=u.child(r);if(e.textblock?!s.isTextblock||s.content.size!==e.size:s.isTextblock)return{ok:!1,code:"stale-target"};let f=Z(t).map(T=>ee(K,T,{...t[T],pos:null,parent:null}));if(!f.length)return{ok:!1,code:"empty-import"};let c=0;for(let T=0;T<r;T++)c+=u.child(T).nodeSize;let m=u.maybeChild(r+1),d=s.type.name==="toggle",w=e.textblock&&!d&&s.content.size>0,B=w||e.textblock&&!d&&s.content.size===0,y=w?Math.min(e.fromOff,s.content.size):0,M=w?Math.min(Math.max(y,e.toOff),s.content.size):0,v=w&&y>0?s.type.create({...s.attrs},s.content.cut(0,y)):null,x=w?s.content.cut(M):null,I=x&&x.size?s.type.create({...s.attrs,id:N(),pos:null},x):null,he=w&&!v?r>0?u.child(r-1).attrs.pos:null:s.attrs.pos,V=D(he,m?.attrs.pos??null,f.length+(I?1:0)),ke=d?s.attrs.id:s.attrs.parent??null,L=f.map((T,ge)=>T.type.create({...T.attrs,pos:V[ge],parent:ke},T.content,T.marks)),H=I?I.type.create({...I.attrs,pos:V[f.length]},I.content,I.marks):null,q=n.tr;B?q.replaceWith(c,c+s.nodeSize,[...v?[v]:[],...L,...H?[H]:[]]):q.insert(c+s.nodeSize,L),d&&!s.attrs.open&&L.length>0&&q.setNodeMarkup(c,null,{...s.attrs,open:!0});let X=c+(B?v?v.nodeSize:0:s.nodeSize);for(let T of L)X+=T.nodeSize;return q.setSelection(Y.TextSelection.near(q.doc.resolve(H?X:Math.max(0,X-1)),H?1:-1)),o.dispatch(se(q).scrollIntoView()),o.focus?.(),{ok:!0,blocks:L.length}}async function p(){let e=i;if(!e||e.error)return e?{ok:!1,code:"no-import"}:{ok:!1,code:"not-editing"};e.notice&&(e.notice=null,A(e));let t=()=>g(e.target,e.blocks),n=e.floor?await ne(o,t):t();return n?.ok?($(),n):(i===e&&(e.notice=Be(n),A(e)),n??{ok:!1,code:"import-failed"})}function C(e){!i||re(e,o)||(e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),E()):e.key==="Enter"&&!e.target?.closest?.("[data-import]")&&(e.preventDefault(),e.stopPropagation(),p()))}function b(){return new Promise(e=>{let t=a.createElement("input");t.type="file",t.accept=".md,.markdown,text/markdown,text/plain",t.hidden=!0,t.className="page-markdown-input";let n=u=>{t.remove(),e(u)};t.addEventListener("change",()=>n(t.files?.[0]??null)),t.addEventListener("cancel",()=>n(null)),(o.dom.parentElement??a.body).appendChild(t),t.click()})}async function _(e,t=null){e.error=t;let n=a.createElement("div");n.className="page-menu page-import-preview",n.setAttribute("role","dialog"),n.setAttribute("aria-label","Import Markdown"),e.panel=n,i=e;let u=(f,c,m,d)=>{f.addEventListener(c,m,d),e.listen.push([f,c,m,d])};u(a,"keydown",f=>C(f),!0),u(a,"mousedown",f=>{e.panel.contains(f.target)||E()},!0),(o.dom.parentElement??a.body).appendChild(n),A(e);let r=O();r&&(n.style.setProperty("--page-pop-x",`${r.x}px`),n.style.setProperty("--page-pop-y",`${r.y}px`));let s=n.querySelector('[data-import="insert"]');return s&&!s.disabled&&s.focus?.(),{ok:!0,preview:!0}}async function R(e={}){if(k||o.isDestroyed)return{ok:!1,code:"not-editing"};$();let t=ve(o.state),n=e?.file??await b();if(!n)return{ok:!1,code:"cancelled"};if(typeof n.size=="number"&&n.size>F)return{ok:!1,code:"input-too-large"};let u;try{u=await Oe(n)}catch(f){return{ok:!1,code:"unreadable",error:f}}if(k||o.isDestroyed)return{ok:!1,code:"not-editing"};if(Te.encode(u).length>F)return{ok:!1,code:"input-too-large"};let r={target:t,name:String(n.name??"Markdown"),blocks:{},count:0,unsupported:[],refused:[],floor:0,panel:null,error:null,notice:null,listen:[]},s;try{let f=await S();s=me(new f.Marked().lexer(u))}catch(f){return k||o.isDestroyed?{ok:!1,code:"not-editing"}:_(r,String(f?.message??"The Markdown could not be read."))}return k||o.isDestroyed?{ok:!1,code:"not-editing"}:(r.blocks=s.blocks,r.count=Object.keys(s.blocks).length,r.unsupported=s.unsupported,r.refused=s.refused,r.floor=Pe(s.blocks)?1:0,_(r))}return{async run(e){return R(e)},dispose(){k=!0,$(),z.dispose()}}}export{Ue as createFeature};
@@ -0,0 +1 @@
1
+ import{a as b,b as c,c as d,d as e,e as f}from"./c-WWE67K5Y.js";import{g as a}from"./c-4RFZROCF.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-4TWARTLS.js";import"./c-Q5KAQJAG.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-TMT5TL65.js";import"./c-QIXT3Q7C.js";import"./c-OI2BYWVV.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";export{e as ChartView,d as chartFromSlash,a as chartTables,b as insertChartAfterTable,f as refreshCharts,c as tableLabel};
@@ -1 +1 @@
1
- import{a as u}from"./c-LV5MABYD.js";import{f as n}from"./c-RQRMPZXD.js";import{b as h,c as a}from"./c-WN3MXOLT.js";import"./c-N326R2JD.js";import{b as T,g as _}from"./c-N7Y52HJH.js";import{b as p}from"./c-ZSCBEB7I.js";import{b}from"./c-TUGVINJR.js";import"./c-TWCXBWS3.js";import"./c-VKEDWYDF.js";import{A as v,B as g,J as k,L as E,P as w,q as f,r as m,x as y}from"./c-NLZ5AN4L.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-GSRLXYWL.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import"./c-GVPNDIKJ.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=250,A=2e3,c=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=t=>n.setGeneric(t),o=class{constructor({send:e=S,now:i=()=>Date.now()}){this.send=e,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=s=>{s.type==="clay:workspace-background"&&(this.background=!0),s.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let e of c)document.addEventListener(e,this._onEvent)}resume(){this.stopped&&(this.start(),this.sent=null,this.schedule())}stop(){this.stopped=!0;for(let e of c)document.removeEventListener(e,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(e){let s=(e&&Array.isArray(e.people)?e.people:[]).some(r=>r&&r.you!==!0);s!==this.others&&(this.others=s,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let e=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},e)}flush(){if(this.inflight)return;let e=this.wanted();if(e===this.sent)return;this.sent=e,this.lastAt=this.now(),this.inflight=!0;let i=s=>{if(this.inflight=!1,!this.stopped){if(s)clearTimeout(this.retry),this.retry=null;else if(this.sent===e){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(e)).then(s=>i(!!s),()=>i(!1))}};function P(t){let e=()=>(t._presenceQuiesced=!0,t._editing?.stop(),n.setGeneric(null),n.releaseTarget(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-quiesce")),t.lane==="live"&&t._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>{t._presenceQuiesced=!1,t._editing?.resume(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))},s=()=>{t._presenceQuiesced=!1,t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))};return{id:"clay:sync",order:50,async prepare(r){if(await u(),r?.initial)return{quiesce:e,resume:i,dispose:s};let l=!1;return{quiesce:e,resume:i,enable(){let d=t.currentFile;t.stop(),t.start(d,{lane:"live"}),l=!0},dispose:()=>{t._presenceQuiesced=!1,l&&t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))}}}}}export{o as EditingSender,k as baselineSettled,m as conflictResolvedBySync,_ as enableAdminInputs,p as enableAdminResources,b as enableContentEditable,T as enableOnClick,v as getLastSavedBytes,f as isSaveConflicted,w as savePageThrottled,E as schedulePaintHeal,g as setLastSavedBaselines,y as setUnsavedChanges,P as syncParticipant};
1
+ import{a as u}from"./c-LV5MABYD.js";import{f as n}from"./c-RQRMPZXD.js";import{b as h,c as a}from"./c-WN3MXOLT.js";import"./c-N326R2JD.js";import{b as T,g as _}from"./c-N7Y52HJH.js";import{b as p}from"./c-ZSCBEB7I.js";import{b}from"./c-TUGVINJR.js";import"./c-TWCXBWS3.js";import"./c-VKEDWYDF.js";import{A as v,B as g,J as k,L as E,P as w,q as f,r as m,x as y}from"./c-DKFSOJCV.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-GSRLXYWL.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import"./c-ZKELCT4T.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=250,A=2e3,c=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=t=>n.setGeneric(t),o=class{constructor({send:e=S,now:i=()=>Date.now()}){this.send=e,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=s=>{s.type==="clay:workspace-background"&&(this.background=!0),s.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let e of c)document.addEventListener(e,this._onEvent)}resume(){this.stopped&&(this.start(),this.sent=null,this.schedule())}stop(){this.stopped=!0;for(let e of c)document.removeEventListener(e,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(e){let s=(e&&Array.isArray(e.people)?e.people:[]).some(r=>r&&r.you!==!0);s!==this.others&&(this.others=s,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let e=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},e)}flush(){if(this.inflight)return;let e=this.wanted();if(e===this.sent)return;this.sent=e,this.lastAt=this.now(),this.inflight=!0;let i=s=>{if(this.inflight=!1,!this.stopped){if(s)clearTimeout(this.retry),this.retry=null;else if(this.sent===e){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(e)).then(s=>i(!!s),()=>i(!1))}};function P(t){let e=()=>(t._presenceQuiesced=!0,t._editing?.stop(),n.setGeneric(null),n.releaseTarget(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-quiesce")),t.lane==="live"&&t._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>{t._presenceQuiesced=!1,t._editing?.resume(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))},s=()=>{t._presenceQuiesced=!1,t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))};return{id:"clay:sync",order:50,async prepare(r){if(await u(),r?.initial)return{quiesce:e,resume:i,dispose:s};let l=!1;return{quiesce:e,resume:i,enable(){let d=t.currentFile;t.stop(),t.start(d,{lane:"live"}),l=!0},dispose:()=>{t._presenceQuiesced=!1,l&&t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))}}}}}export{o as EditingSender,k as baselineSettled,m as conflictResolvedBySync,_ as enableAdminInputs,p as enableAdminResources,b as enableContentEditable,T as enableOnClick,v as getLastSavedBytes,f as isSaveConflicted,w as savePageThrottled,E as schedulePaintHeal,g as setLastSavedBaselines,y as setUnsavedChanges,P as syncParticipant};
@@ -0,0 +1 @@
1
+ import{a,b,c}from"./c-6KBKYLPO.js";import"./c-IHUWUKIU.js";import"./c-4JZDZFF6.js";import"./c-EUGJVHDD.js";import"./c-MHI3GYKF.js";import"./c-NUHP2XDB.js";import"./c-VHNSBD2M.js";export{c as bevelDialog,a as dismissOf,b as keepFocusIn};
@@ -1 +1 @@
1
- var o={table:{types:["table"],views:["table","table_cell"],module:"page/features/table.js",load:()=>import("./c-LQU7TXIH.js")},board:{types:["board"],module:"page/features/board.js",load:()=>import("./c-7SXYQCN4.js")},chart:{types:["chart"],views:["chart"],module:"page/features/chart.js",load:()=>import("./c-VY6XRBOW.js")},checklist:{types:[],views:[],match:e=>e.type.name==="list_item"&&e.attrs.kind==="check",module:"page/features/checklist.js",load:()=>import("./c-SBSMJIPC.js")},code:{types:["code_block"],module:"page/features/code.js",load:()=>import("./c-OABVRYOT.js")},toc:{types:["toc"],module:"page/features/toc.js",load:()=>import("./c-M4FSPNQ2.js")},titleIcon:{types:[],views:["heading"],match:e=>e.attrs.pageIcon!=null||e.attrs.pageCoverSrc!=null,module:"page/features/title-icon.js",load:()=>import("./c-NFR673TL.js")},media:{types:["image","file"],module:"page/features/media.js",load:()=>import("./c-2VB555FG.js")},tool:{types:["tool"],module:"page/features/tool.js",boot:["page/tools.js","page/tool-data.js"],load:()=>import("./c-GKEATME6.js")}},r=e=>Object.keys(o).find(t=>o[t].types.includes(e))??null,s=e=>{for(let t of Object.keys(o)){let a=o[t];if(a.match?a.match(e):a.types.includes(e.type.name))return t}return null},l={mentions:{module:"page/features/mentions.js",load:()=>import("./c-XD5MOROJ.js")},dates:{module:"page/features/dates.js",load:()=>import("./c-3GJ4XARY.js")},emoji:{module:"page/features/emoji.js",load:()=>import("./c-EOCZ2YVL.js")},titleIcon:{module:"page/features/title-icon.js",load:()=>import("./c-NFR673TL.js")},titleCover:{module:"page/features/title-cover.js",load:()=>import("./c-GPGYKER7.js")},exportHtml:{module:"page/features/export-html.js",load:()=>import("./c-ZQXNHZZT.js")},importMarkdown:{module:"page/features/import-markdown.js",load:()=>import("./c-W3K23S72.js")},exportMarkdown:{module:"page/features/export-markdown.js",load:()=>import("./c-VQCEOGKH.js")}};export{o as a,r as b,s as c,l as d};
1
+ var o={table:{types:["table"],views:["table","table_cell"],module:"page/features/table.js",load:()=>import("./c-N33TPVTL.js")},board:{types:["board"],module:"page/features/board.js",load:()=>import("./c-ZO6VL2SC.js")},chart:{types:["chart"],views:["chart"],module:"page/features/chart.js",load:()=>import("./c-QTC6VGA4.js")},checklist:{types:[],views:[],match:e=>e.type.name==="list_item"&&e.attrs.kind==="check",module:"page/features/checklist.js",load:()=>import("./c-P3WATEDR.js")},code:{types:["code_block"],module:"page/features/code.js",load:()=>import("./c-TV7JHSRL.js")},toc:{types:["toc"],module:"page/features/toc.js",load:()=>import("./c-ZYEJLZEY.js")},titleIcon:{types:[],views:["heading"],match:e=>e.attrs.pageIcon!=null||e.attrs.pageCoverSrc!=null,module:"page/features/title-icon.js",load:()=>import("./c-FMCPQ4VT.js")},media:{types:["image","file"],module:"page/features/media.js",load:()=>import("./c-GPTKI7AQ.js")},tool:{types:["tool"],module:"page/features/tool.js",boot:["page/tools.js","page/tool-data.js"],load:()=>import("./c-QJFYVCJO.js")}},r=e=>Object.keys(o).find(t=>o[t].types.includes(e))??null,s=e=>{for(let t of Object.keys(o)){let a=o[t];if(a.match?a.match(e):a.types.includes(e.type.name))return t}return null},l={mentions:{module:"page/features/mentions.js",load:()=>import("./c-FLBUYV3P.js")},dates:{module:"page/features/dates.js",load:()=>import("./c-PWBJVHA4.js")},emoji:{module:"page/features/emoji.js",load:()=>import("./c-NBNRLZXO.js")},titleIcon:{module:"page/features/title-icon.js",load:()=>import("./c-FMCPQ4VT.js")},titleCover:{module:"page/features/title-cover.js",load:()=>import("./c-F5AER2ID.js")},exportHtml:{module:"page/features/export-html.js",load:()=>import("./c-ZQXNHZZT.js")},importMarkdown:{module:"page/features/import-markdown.js",load:()=>import("./c-IWTTOC2V.js")},exportMarkdown:{module:"page/features/export-markdown.js",load:()=>import("./c-VQCEOGKH.js")}};export{o as a,r as b,s as c,l as d};
@@ -1 +1 @@
1
- import{F as x,c as b,q as f,s as p,u as h,v as k}from"./c-NLZ5AN4L.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import{b as c,d as S}from"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-GSRLXYWL.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import{l as s,o as D,p as y,q as E}from"./c-GVPNDIKJ.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var A=15e3,M=Symbol("the barrier deadline passed"),I=2,e=(i,r={})=>({ok:!1,code:i,...r});async function O(i,r){let u=null,l=new Promise(a=>{u=setTimeout(()=>a(M),Math.max(0,r-Date.now()))});try{return await Promise.race([Promise.resolve(i),l])}finally{clearTimeout(u)}}async function _({generation:i=p(),keepalive:r=!1,timeoutMs:u=A,operation:l=null}={}){let a=l?null:D("mode");if(!l&&!a)return e("busy");let n=Date.now()+u,d=h(i),m=new AbortController;try{for(let g=0;;g++){if(i!==p())return e("stale-document");if(Date.now()>=n)return e("timeout");let P={permit:d,deadline:n,keepalive:r,signal:m.signal,timeoutMs:Math.max(0,n-Date.now())},t=await O(S(P),n);if(t===M)return e("timeout",{pending:c()});if(!t.ok)return f()?e("conflict",{pending:t.pending}):s()?e("save-unknown",{pending:t.pending}):e("pending-input",{pending:t.pending});if(t.pending.length)return e("pending-input",{pending:t.pending});if(f())return e("conflict");if(s())return e("save-unknown");let o;try{o=await x({keepalive:r,timeoutMs:Math.max(0,n-Date.now()),permit:d})}catch(v){return v?.state==="conflict"?e("conflict"):v?.state==="blocked"?e("pending-input",{pending:c()}):s()?e("save-unknown"):Date.now()>=n?e("timeout"):e("save-failed")}if(o.state!=="clean"&&o.state!=="saved")return e("save-failed");if(f())return e("conflict");if(s())return e("save-unknown");let w=c();if(w.length)return e("pending-input",{pending:w});if(b()){if(g+1<I&&Date.now()<n)continue;return e("pending-input")}return{ok:!0,state:o.state,etag:o.etag??null}}}finally{m.abort(),k(d),a&&y(a)}}export{D as claimOperation,E as operationKind,y as releaseOperation,_ as runSaveBarrier};
1
+ import{F as x,c as b,q as f,s as p,u as h,v as k}from"./c-DKFSOJCV.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import{b as c,d as S}from"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-GSRLXYWL.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import{l as s,o as D,p as y,q as E}from"./c-ZKELCT4T.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var A=15e3,M=Symbol("the barrier deadline passed"),I=2,e=(i,r={})=>({ok:!1,code:i,...r});async function O(i,r){let u=null,l=new Promise(a=>{u=setTimeout(()=>a(M),Math.max(0,r-Date.now()))});try{return await Promise.race([Promise.resolve(i),l])}finally{clearTimeout(u)}}async function _({generation:i=p(),keepalive:r=!1,timeoutMs:u=A,operation:l=null}={}){let a=l?null:D("mode");if(!l&&!a)return e("busy");let n=Date.now()+u,d=h(i),m=new AbortController;try{for(let g=0;;g++){if(i!==p())return e("stale-document");if(Date.now()>=n)return e("timeout");let P={permit:d,deadline:n,keepalive:r,signal:m.signal,timeoutMs:Math.max(0,n-Date.now())},t=await O(S(P),n);if(t===M)return e("timeout",{pending:c()});if(!t.ok)return f()?e("conflict",{pending:t.pending}):s()?e("save-unknown",{pending:t.pending}):e("pending-input",{pending:t.pending});if(t.pending.length)return e("pending-input",{pending:t.pending});if(f())return e("conflict");if(s())return e("save-unknown");let o;try{o=await x({keepalive:r,timeoutMs:Math.max(0,n-Date.now()),permit:d})}catch(v){return v?.state==="conflict"?e("conflict"):v?.state==="blocked"?e("pending-input",{pending:c()}):s()?e("save-unknown"):Date.now()>=n?e("timeout"):e("save-failed")}if(o.state!=="clean"&&o.state!=="saved")return e("save-failed");if(f())return e("conflict");if(s())return e("save-unknown");let w=c();if(w.length)return e("pending-input",{pending:w});if(b()){if(g+1<I&&Date.now()<n)continue;return e("pending-input")}return{ok:!0,state:o.state,etag:o.etag??null}}}finally{m.abort(),k(d),a&&y(a)}}export{D as claimOperation,E as operationKind,y as releaseOperation,_ as runSaveBarrier};
@@ -1 +1 @@
1
- import{a,b,c}from"./c-RG6XUZFA.js";import"./c-QY7F6EN6.js";import"./c-BJ7YQ5QZ.js";import"./c-4JZDZFF6.js";import"./c-VAK7SG37.js";import"./c-MHI3GYKF.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
+ import{a,b,c}from"./c-FAXQU7MQ.js";import"./c-QY7F6EN6.js";import"./c-IHUWUKIU.js";import"./c-4JZDZFF6.js";import"./c-EUGJVHDD.js";import"./c-MHI3GYKF.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,4 +1,4 @@
1
- import{A as v,B as P,C as x,D as T,E as A,F as k,G as E,H as z,I as C,J as O,K as tt,L as et,M as nt,N as B,O as D,R as it,S as K,c as M,d as L,e as f,n as J,s as $,w as g,x as Q,z as Z}from"./c-SJPD46ZO.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-XQSXKIKM.js";import"./c-67ILSNPR.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as Y,d as N}from"./c-44B5ODN7.js";import{I as X,W as G,m as V}from"./c-QIXT3Q7C.js";import"./c-E4IBSAQM.js";import"./c-57XDY6HC.js";import{a as j}from"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";var ot=`
1
+ import{A as v,B as P,C as x,D as T,E as A,F as k,G as E,H as z,I as C,J as O,K as tt,L as et,M as nt,N as B,O as D,R as it,S as K,c as M,d as L,e as f,n as J,s as $,w as g,x as Q,z as Z}from"./c-4RFZROCF.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-4TWARTLS.js";import"./c-Q5KAQJAG.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as Y,d as N}from"./c-TMT5TL65.js";import{I as X,W as G,m as V}from"./c-QIXT3Q7C.js";import"./c-OI2BYWVV.js";import"./c-57XDY6HC.js";import{a as j}from"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";var ot=`
2
2
  .page-editor .page-table { position: relative; }
3
3
  .page-table td { position: relative; }
4
4
  .page-table th { position: relative; }
@@ -1 +1 @@
1
- import{c as A}from"./c-KBS3UV6B.js";import{j as b}from"./c-SJPD46ZO.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-XQSXKIKM.js";import"./c-67ILSNPR.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as x}from"./c-44B5ODN7.js";import{b as h}from"./c-QIXT3Q7C.js";import"./c-E4IBSAQM.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";function S(o){let s=String(o??""),n=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter("en",{granularity:"grapheme"}):null;return n?[...n.segment(s)].map(a=>a.segment):[...s]}var I=o=>S(o).length===1&&!/^\s*$/.test(String(o??""));function L(o){let s=[];for(let[n,a]of Object.entries(o??{}))for(let u of Array.isArray(a)?a:[]){let[f,m,d=""]=u??[];typeof f!="string"||typeof m!="string"||s.push({id:`${n}:${m}`,char:f,name:`${f} ${m}`,keywords:`${m} ${d}`})}return s}var P=(o,s)=>{let n=String(s??"").trim().toLowerCase();return n?o.filter(a=>a.char===n||a.keywords.toLowerCase().includes(n)):o};function T(o=()=>import("./c-SZGYW5HT.js")){let s=null;return()=>(s??=Promise.resolve().then(()=>o()).then(n=>L(n.EMOJI)).catch(n=>{throw s=null,n}),s)}function w({view:o=null,load:s=()=>import("./c-SZGYW5HT.js")}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let n=o.dom.ownerDocument,a=T(s),u=null;function f(t){let e=o.state,r=e.selection;if(r.from!==t.from||r.to!==t.to||t.from<0||t.to>e.doc.content.size)return null;let c=e.doc.resolve(t.from),i=e.doc.resolve(t.to);return!c.parent.isTextblock||c.parent!==i.parent?null:{from:t.from,to:t.to}}function m(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function d(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function l(){let t=u;if(t){u=null;for(let[e,r,c,i]of t.listen)e.removeEventListener(r,c,i);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function j(t,e){let r=o.state.tr.insertText(e,t.from,t.to);return r.setSelection(h.TextSelection.create(r.doc,t.from+e.length)),o.dispatch(x(r)),o.focus(),{ok:!0,emoji:e}}function p(t){let e=u;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),c=f(e);return!r||c===null||!I(r.char)?(l(),r?c===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-emoji"}:{ok:!1,code:"no-emoji"}):(l(),j(c,r.char))}function E(t){let e=u;if(!e||b(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),d(e)):t.key==="Enter"?(r(),p(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),l())}async function $(t={}){l();let e={from:o.state.selection.from,to:o.state.selection.to,picker:null,listen:[]};e.picker=A({document:n,label:"Insert an emoji",empty:"No emoji found",onPick:i=>p(i)}),u=e;let r=(i,k,g,y)=>{i.addEventListener(k,g,y),e.listen.push([i,k,g,y])};r(n,"keydown",i=>E(i),!0),r(o.dom,"input",()=>l()),r(n,"mousedown",i=>{e.picker.el.contains(i.target)||l()},!0),(o.dom.parentElement??n.body).appendChild(e.picker.el);let c;try{c=await a()}catch(i){return l(),{ok:!1,code:"unavailable",error:i}}return u!==e?{ok:!1,code:"not-editing"}:f(e)===null?(l(),{ok:!1,code:"stale-target"}):(e.picker.show(P(c,t?.query),m(e)),d(e),{ok:!0,picker:!0})}return{async run(t){return $(t)},dispose(){l()}}}export{w as createFeature,L as emojiEntries,T as emojiLibrary,P as filterEmoji,S as graphemes,I as isEmojiText};
1
+ import{c as A}from"./c-KBS3UV6B.js";import{j as b}from"./c-4RFZROCF.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-4TWARTLS.js";import"./c-Q5KAQJAG.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as x}from"./c-TMT5TL65.js";import{b as h}from"./c-QIXT3Q7C.js";import"./c-OI2BYWVV.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";function S(o){let s=String(o??""),n=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter("en",{granularity:"grapheme"}):null;return n?[...n.segment(s)].map(a=>a.segment):[...s]}var I=o=>S(o).length===1&&!/^\s*$/.test(String(o??""));function L(o){let s=[];for(let[n,a]of Object.entries(o??{}))for(let u of Array.isArray(a)?a:[]){let[f,m,d=""]=u??[];typeof f!="string"||typeof m!="string"||s.push({id:`${n}:${m}`,char:f,name:`${f} ${m}`,keywords:`${m} ${d}`})}return s}var P=(o,s)=>{let n=String(s??"").trim().toLowerCase();return n?o.filter(a=>a.char===n||a.keywords.toLowerCase().includes(n)):o};function T(o=()=>import("./c-SZGYW5HT.js")){let s=null;return()=>(s??=Promise.resolve().then(()=>o()).then(n=>L(n.EMOJI)).catch(n=>{throw s=null,n}),s)}function w({view:o=null,load:s=()=>import("./c-SZGYW5HT.js")}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let n=o.dom.ownerDocument,a=T(s),u=null;function f(t){let e=o.state,r=e.selection;if(r.from!==t.from||r.to!==t.to||t.from<0||t.to>e.doc.content.size)return null;let c=e.doc.resolve(t.from),i=e.doc.resolve(t.to);return!c.parent.isTextblock||c.parent!==i.parent?null:{from:t.from,to:t.to}}function m(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function d(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function l(){let t=u;if(t){u=null;for(let[e,r,c,i]of t.listen)e.removeEventListener(r,c,i);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function j(t,e){let r=o.state.tr.insertText(e,t.from,t.to);return r.setSelection(h.TextSelection.create(r.doc,t.from+e.length)),o.dispatch(x(r)),o.focus(),{ok:!0,emoji:e}}function p(t){let e=u;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),c=f(e);return!r||c===null||!I(r.char)?(l(),r?c===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-emoji"}:{ok:!1,code:"no-emoji"}):(l(),j(c,r.char))}function E(t){let e=u;if(!e||b(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),d(e)):t.key==="Enter"?(r(),p(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),l())}async function $(t={}){l();let e={from:o.state.selection.from,to:o.state.selection.to,picker:null,listen:[]};e.picker=A({document:n,label:"Insert an emoji",empty:"No emoji found",onPick:i=>p(i)}),u=e;let r=(i,k,g,y)=>{i.addEventListener(k,g,y),e.listen.push([i,k,g,y])};r(n,"keydown",i=>E(i),!0),r(o.dom,"input",()=>l()),r(n,"mousedown",i=>{e.picker.el.contains(i.target)||l()},!0),(o.dom.parentElement??n.body).appendChild(e.picker.el);let c;try{c=await a()}catch(i){return l(),{ok:!1,code:"unavailable",error:i}}return u!==e?{ok:!1,code:"not-editing"}:f(e)===null?(l(),{ok:!1,code:"stale-target"}):(e.picker.show(P(c,t?.query),m(e)),d(e),{ok:!0,picker:!0})}return{async run(t){return $(t)},dispose(){l()}}}export{w as createFeature,L as emojiEntries,T as emojiLibrary,P as filterEmoji,S as graphemes,I as isEmojiText};
@@ -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-XGH4GS2T.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.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-2ZZBC45O.js"),import("./c-ZE46QDIH.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
+ 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-XGH4GS2T.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.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-Z7RJANGO.js"),import("./c-3TLG3OLG.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};