@panphora/clayjs 1.19.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) 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 +8349 -8125
  11. package/dist/m/attrs/{refetch-on-save-ZUE7PSCI.js → refetch-on-save-DPGJJMGN.js} +1 -1
  12. package/dist/m/attrs/save-freeze-MTFVVYV5.js +1 -0
  13. package/dist/m/{c-DHUCEMXE.js → c-2VB555FG.js} +1 -1
  14. package/dist/m/{c-KGHVFRR3.js → c-3AXJDL2P.js} +1 -1
  15. package/dist/m/{c-FOOE4GML.js → c-3GJ4XARY.js} +1 -1
  16. package/dist/m/c-3TWCKFOP.js +1 -0
  17. package/dist/m/{c-LPCZOYTX.js → c-3YH6JSIL.js} +1 -1
  18. package/dist/m/{c-AIWN4QN4.js → c-44B5ODN7.js} +2 -2
  19. package/dist/m/{c-WQWIRWO3.js → c-5FEU5MMY.js} +1 -1
  20. package/dist/m/{c-S2U6NJU4.js → c-62HZW5DH.js} +1 -1
  21. package/dist/m/{c-ZGDYHKG3.js → c-67ILSNPR.js} +1 -1
  22. package/dist/m/c-67LGZ52V.js +20 -0
  23. package/dist/m/{c-ZRUQ5FSU.js → c-7SXYQCN4.js} +1 -1
  24. package/dist/m/{c-LACAAQFB.js → c-AL4RBJF2.js} +1 -1
  25. package/dist/m/{c-L42OLXWM.js → c-ANNFZFLN.js} +1 -1
  26. package/dist/m/{c-QO4HNGCQ.js → c-B4VYNXTQ.js} +1 -1
  27. package/dist/m/{c-7PRJCA3E.js → c-BJPZCWAV.js} +1 -1
  28. package/dist/m/{c-V52FE5FI.js → c-BTLFLLML.js} +1 -1
  29. package/dist/m/c-C4IIQZGJ.js +1 -0
  30. package/dist/m/{c-5T6NZHNM.js → c-CAWNFER6.js} +1 -1
  31. package/dist/m/c-CSNE5EIF.js +1 -0
  32. package/dist/m/{c-DVYGFTSK.js → c-DDDOKPI6.js} +2 -2
  33. package/dist/m/{c-2RARVIAK.js → c-DHXPDLW6.js} +1 -1
  34. package/dist/m/{c-WCXLG3MV.js → c-E4IBSAQM.js} +1 -1
  35. package/dist/m/{c-IVTRVENZ.js → c-EDSPKYMA.js} +1 -1
  36. package/dist/m/{c-2Y4DOHSY.js → c-EFD6QNTE.js} +1 -1
  37. package/dist/m/{c-7MG5RU63.js → c-EGTIAL6P.js} +1 -1
  38. package/dist/m/{c-FCNAO2MI.js → c-EOCKLMKX.js} +1 -1
  39. package/dist/m/{c-UXFUJEZO.js → c-EOCZ2YVL.js} +1 -1
  40. package/dist/m/{c-K72SY2TL.js → c-EZ7B5AZT.js} +1 -1
  41. package/dist/m/{c-UPD33ZPE.js → c-FDAXZ2PM.js} +1 -1
  42. package/dist/m/{c-P3CK66NT.js → c-FNVQAACK.js} +1 -1
  43. package/dist/m/c-FSWRGBVQ.js +1 -0
  44. package/dist/m/c-FTWGYI5E.js +1 -0
  45. package/dist/m/{c-WKNRJX3C.js → c-GKEATME6.js} +1 -1
  46. package/dist/m/{c-QINHDETP.js → c-GPGYKER7.js} +1 -1
  47. package/dist/m/{c-FWKHM4E7.js → c-GSRLXYWL.js} +1 -1
  48. package/dist/m/{c-B7J4K2AE.js → c-GVPNDIKJ.js} +2 -2
  49. package/dist/m/{c-D3E4WJ4M.js → c-HDWZEJHM.js} +49 -32
  50. package/dist/m/{c-FTQKI7SP.js → c-I2IFKJX2.js} +1 -1
  51. package/dist/m/c-ICMAOOGK.js +1 -0
  52. package/dist/m/{c-HUISJXHF.js → c-J3BXFTZS.js} +1 -1
  53. package/dist/m/{c-BIJALSRD.js → c-JDZDF2QM.js} +1 -1
  54. package/dist/m/{c-UDHIVLYH.js → c-JH5FF4NL.js} +1 -1
  55. package/dist/m/{c-OYRZ7XG2.js → c-JHJR5BQX.js} +1 -1
  56. package/dist/m/{c-V44KWI2L.js → c-JOH753EJ.js} +2 -2
  57. package/dist/m/{c-P3OFYUMA.js → c-JUE7B4OX.js} +1 -1
  58. package/dist/m/c-K76AUL4I.js +7 -0
  59. package/dist/m/{c-ZWIOJGMT.js → c-LA2BW7UY.js} +1 -1
  60. package/dist/m/{c-ICJYHABF.js → c-LDUNOR57.js} +1 -1
  61. package/dist/m/{c-XSZKP646.js → c-LIBE4HPD.js} +1 -1
  62. package/dist/m/c-LPUJXRXW.js +1 -0
  63. package/dist/m/{c-JK3PHE7J.js → c-LQU7TXIH.js} +1 -1
  64. package/dist/m/{c-5ZQV7KC4.js → c-LV5MABYD.js} +1 -1
  65. package/dist/m/{c-GWNC3UGL.js → c-M4FSPNQ2.js} +1 -1
  66. package/dist/m/{c-2KIEGNC4.js → c-MEWUGR4D.js} +1 -1
  67. package/dist/m/c-MIL4B2JQ.js +1 -0
  68. package/dist/m/{c-IVMD3FEM.js → c-N7Y52HJH.js} +1 -1
  69. package/dist/m/{c-O4JMKN6U.js → c-NFR673TL.js} +2 -2
  70. package/dist/m/{c-ZKNBMNN3.js → c-NLZ5AN4L.js} +1 -1
  71. package/dist/m/{c-RRZJWFLE.js → c-OABVRYOT.js} +1 -1
  72. package/dist/m/c-PIVIYLTY.js +1 -0
  73. package/dist/m/{c-L7JL5TL3.js → c-QY7F6EN6.js} +1 -1
  74. package/dist/m/{c-UY4QX42B.js → c-RG6XUZFA.js} +1 -1
  75. package/dist/m/c-RHMPKZZ7.js +1 -0
  76. package/dist/m/{c-TJAXGIRV.js → c-RQRMPZXD.js} +1 -1
  77. package/dist/m/{c-GY422N3Q.js → c-RS77ODLY.js} +1 -1
  78. package/dist/m/{c-BAUBNYXK.js → c-RT3C74GY.js} +1 -1
  79. package/dist/m/{c-CAS3NND4.js → c-S5IEIZCN.js} +1 -1
  80. package/dist/m/{c-HXPHZN7Q.js → c-SBSMJIPC.js} +1 -1
  81. package/dist/m/c-SFKI6OLM.js +2 -0
  82. package/dist/m/{c-4FJTBE6I.js → c-SJPD46ZO.js} +4 -4
  83. package/dist/m/{c-JCP3XDSJ.js → c-SO63UGPQ.js} +1 -1
  84. package/dist/m/{c-PLP4JKFC.js → c-TUGVINJR.js} +1 -1
  85. package/dist/m/{c-Q26MME6N.js → c-TWCXBWS3.js} +1 -1
  86. package/dist/m/{c-GNDL3TKB.js → c-U5X57T4L.js} +1 -1
  87. package/dist/m/{c-ZS4US2XV.js → c-UXEVJ63W.js} +1 -1
  88. package/dist/m/{c-KJJPV77R.js → c-V2J5C5MT.js} +1 -1
  89. package/dist/m/{c-7PYNAULW.js → c-VBLFAQD2.js} +1 -1
  90. package/dist/m/{c-ERQSNR6K.js → c-VQCEOGKH.js} +2 -2
  91. package/dist/m/{c-YVZ2L7CE.js → c-VSPAFOKU.js} +1 -1
  92. package/dist/m/{c-L6FLIUXP.js → c-VY6XRBOW.js} +1 -1
  93. package/dist/m/{c-2KL3BD52.js → c-W23KVGUO.js} +1 -1
  94. package/dist/m/{c-AXGY2WTB.js → c-W3K23S72.js} +1 -1
  95. package/dist/m/c-WFMRX5RZ.js +1 -0
  96. package/dist/m/{c-BWFVSBDF.js → c-WN3MXOLT.js} +1 -1
  97. package/dist/m/{c-MIKZEG5I.js → c-XD5MOROJ.js} +1 -1
  98. package/dist/m/{c-CQQDL6O4.js → c-XQSXKIKM.js} +1 -1
  99. package/dist/m/{c-I4MQHOEY.js → c-Y33LUUIQ.js} +1 -1
  100. package/dist/m/{c-JDARJDOT.js → c-YQUJ74R3.js} +1 -1
  101. package/dist/m/{c-F6G2OGYG.js → c-YSB6JKV2.js} +2 -2
  102. package/dist/m/{c-BHZYSHW4.js → c-ZJLU56DV.js} +1 -1
  103. package/dist/m/{c-DKLS74XB.js → c-ZQXNHZZT.js} +2 -2
  104. package/dist/m/{c-TNEM3RNM.js → c-ZSCBEB7I.js} +1 -1
  105. package/dist/m/core/{admin-attrs-YY7T5FGU.js → admin-attrs-ZG7R5V3E.js} +1 -1
  106. package/dist/m/core/{autosave-RVJPYLRT.js → autosave-VPORYJSE.js} +1 -1
  107. package/dist/m/core/{conflict-notice-2WGT52LH.js → conflict-notice-JMAZLVRX.js} +1 -1
  108. package/dist/m/core/{persist-UKXV5KLA.js → persist-3OPWJKZS.js} +1 -1
  109. package/dist/m/core/{recovery-ZOUOJVIX.js → recovery-DRFZRJED.js} +1 -1
  110. package/dist/m/core/{save-A5JXV6ME.js → save-AOJBDSOK.js} +1 -1
  111. package/dist/m/core/{save-core-MKRPSEEO.js → save-core-IOCMXO5L.js} +1 -1
  112. package/dist/m/core/{snapshot-NU3YM6GR.js → snapshot-O7II2AGG.js} +1 -1
  113. package/dist/m/core/unsaved-warning-U5VUJFOE.js +1 -0
  114. package/dist/m/events/{index-RN2JNGBV.js → index-B6TGDYMG.js} +1 -1
  115. package/dist/m/internals/{index-TGLQINN3.js → index-HDRANDWE.js} +1 -1
  116. package/dist/m/lib/{cache-bust-MUMFXZK6.js → cache-bust-NH7VBWHO.js} +1 -1
  117. package/dist/m/lib/{region-policy-SB2AWVG5.js → region-policy-KWBPROWF.js} +1 -1
  118. package/dist/m/{loader-34YPFKOH.js → loader-ZVPK4ZN3.js} +1 -1
  119. package/dist/m/manifest-5498AFD3.js +1 -0
  120. package/dist/m/manifest-edit-62A5A00F.js +1 -0
  121. package/dist/m/manifest.json +1215 -1171
  122. package/dist/m/options/{options-EJMS3K24.js → options-55LQHSJ4.js} +1 -1
  123. package/dist/m/page/{editor-WRQGHDSG.js → editor-EY2WAAGB.js} +2 -2
  124. package/dist/m/plugins/{ai-edit-X2L2KIEP.js → ai-edit-J5VLSW5I.js} +1 -1
  125. package/dist/m/plugins/{demo-OYO5GCAO.js → demo-42BSYQ7T.js} +1 -1
  126. package/dist/m/plugins/{derive-FRE5JJQE.js → derive-QVI3LI3A.js} +1 -1
  127. package/dist/m/plugins/{live-7C36XEI2.js → live-5EZN2EYP.js} +1 -1
  128. package/dist/m/plugins/menu-DM2JHPSR.js +1 -0
  129. package/dist/m/plugins/{page-BSW6MGDO.js → page-LVW5DWA4.js} +2 -2
  130. package/dist/m/plugins/{page-view-WFZVTPQK.js → page-view-5KQ76IJB.js} +1 -1
  131. package/dist/m/plugins/{sortable-4S6SQC3D.js → sortable-WJZZBM7R.js} +1 -1
  132. package/dist/m/plugins/{source-TJXOIOYY.js → source-CCEUM3OR.js} +1 -1
  133. package/dist/m/plugins/{undo-NLPGCJQY.js → undo-3JEYK5QY.js} +1 -1
  134. package/dist/m/plugins/{upgrade-HSUNDNJD.js → upgrade-NW556WJD.js} +1 -1
  135. package/dist/m/plugins/{upload-NHGJXZK2.js → upload-TTCQRIM5.js} +1 -1
  136. package/dist/m/plugins/{visitor-drafts-BW43DGY3.js → visitor-drafts-2AWNT23K.js} +2 -2
  137. package/dist/m/plugins/{visitor-drafts-owner-7ODQG7JX.js → visitor-drafts-owner-MZP45XSG.js} +1 -1
  138. package/dist/m/plugins/{wire-6OSIL3I7.js → wire-VRYPY6EJ.js} +1 -1
  139. package/dist/m/{reader-core-PLZYLYLT.js → reader-core-2GXY7SHY.js} +2 -2
  140. package/dist/m/sync/{live-sync-UXNI6ZF6.js → live-sync-SKPMFYOO.js} +1 -1
  141. package/dist/m/ui/{index-IVWN2QC4.js → index-QNIPDHXQ.js} +1 -1
  142. package/dist/m/vendor/{sap-core.vendor-RN4ZVY4X.js → sap-core.vendor-OA5SKL7Q.js} +1 -1
  143. package/dist/offline-manifest.json +650 -626
  144. package/docs/guide.md +38 -14
  145. package/entries/sap.js +1 -1
  146. package/package.json +3 -2
  147. package/src/core/conflict-download.js +8 -7
  148. package/src/core/conflict-notice-ui.js +4 -4
  149. package/src/core/copy-content.js +103 -0
  150. package/src/core/download.js +14 -2
  151. package/src/core/save-size-notice.js +2 -2
  152. package/src/core/upgrade-run.js +5 -1
  153. package/src/lib/region-policy.js +1 -1
  154. package/src/page/features/export-html.js +4 -4
  155. package/src/page/features/export-markdown.js +2 -2
  156. package/src/page/recovery-ui.js +2 -2
  157. package/src/page/save-states.js +4 -4
  158. package/src/plugins/menu/actions.js +1 -1
  159. package/src/plugins/menu/style.js +59 -31
  160. package/src/plugins/menu.js +131 -28
  161. package/src/plugins/page.js +4 -4
  162. package/src/plugins/visitor-drafts/prompt.js +12 -12
  163. package/src/plugins/wire.js +3 -1
  164. package/src/vendor/sap-core.vendor.js +1 -1
  165. package/dist/m/attrs/save-freeze-LWGF6XUN.js +0 -1
  166. package/dist/m/c-DCFSEJZG.js +0 -1
  167. package/dist/m/c-EXEDYU4H.js +0 -1
  168. package/dist/m/c-GRXHHFPO.js +0 -1
  169. package/dist/m/c-HT2DKBV2.js +0 -1
  170. package/dist/m/c-MCOOHCSG.js +0 -1
  171. package/dist/m/c-MMXKAX2W.js +0 -1
  172. package/dist/m/c-VE7RKNKZ.js +0 -7
  173. package/dist/m/c-VR2BJ4AN.js +0 -1
  174. package/dist/m/c-WGW764WX.js +0 -1
  175. package/dist/m/c-WNTYKCDG.js +0 -1
  176. package/dist/m/c-YBSS55KU.js +0 -20
  177. package/dist/m/core/unsaved-warning-4ZPEV7BF.js +0 -1
  178. package/dist/m/manifest-0D166F4F.js +0 -1
  179. package/dist/m/manifest-edit-3877153E.js +0 -1
  180. package/dist/m/plugins/menu-MFC4DI5E.js +0 -1
  181. /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
  182. /package/dist/m/{c-5JLFROUB.js → c-X5LNHET5.js} +0 -0
  183. /package/dist/m/plugins/{people-JCHVPF7P.js → people-C7TVBBMR.js} +0 -0
@@ -1 +1 @@
1
- import{b as $}from"./c-R2XUODVY.js";import{a as k,b as B,c as L}from"./c-GBKB5WDL.js";import{B as M}from"./c-AIWN4QN4.js";import{G as P,J as R,b as O,m as q}from"./c-QIXT3Q7C.js";import"./c-3GJ4SDE2.js";import{a as N}from"./c-3LDGIBMN.js";import"./c-VHNSBD2M.js";var K=16384,G=p=>new TextEncoder().encode(JSON.stringify(p)).length,I=class extends Error{constructor(s,n=s){super(n),this.name="ToolRequestError",this.code=s}};function V(p){let s=N(p);for(Array.isArray(s.tables)||(s.tables=[]),Array.isArray(s.outline)||(s.outline=[]);G(s)>K;){let n=[...s.tables].reverse().find(i=>Array.isArray(i.rows)&&i.rows.length);if(n)n.rows.pop();else if(s.outline.length)s.outline.pop();else break}if(G(s)>K)throw new I("context-too-large");return s}function J({transport:p,newId:s}){let n=null,i=a=>{!a||a.discarded||a.done||(a.discarded=!0,n===a&&(n=null),p.cancel(a.requestId),a.resolve({requestId:a.requestId,code:"discarded",message:"Candidate discarded"}))};return{request(a,r,t=null){let m=V(r);n&&i(n);let c=s(),l={requestId:c,discarded:!1,done:!1};l.promise=new Promise(o=>{l.resolve=o}),n=l;let y={protocol:"page-tool/1",requestId:c,prompt:a,context:m,target:t};l.request=y;let v=o=>{if(!(l.discarded||l.done||o?.requestId!==c))if(l.done=!0,n===l&&(n=null),o?.artifact!==void 0){let d=k(o.artifact),C=B(o.state),w=d.ok?C.ok?null:C:d;l.resolve(w?{requestId:c,code:w.code,message:w.code}:o)}else l.resolve(typeof o?.code=="string"?o:{requestId:c,code:"invalid-result",message:"invalid-result"})};try{Promise.resolve(p.request(y)).then(v,o=>v({requestId:c,code:"transport-error",message:String(o?.message??o)}))}catch(o){v({requestId:c,code:"transport-error",message:String(o?.message??o)})}return l},discard:i,async wait(a,{signal:r}={}){if(r?.aborted)throw new DOMException("Aborted","AbortError");let t,m=await(r?Promise.race([a.promise,new Promise((c,l)=>{t=()=>l(new DOMException("Aborted","AbortError")),r.addEventListener("abort",t,{once:!0})})]).finally(()=>r.removeEventListener("abort",t)):a.promise);if(m?.code)throw new I(m.code,m.message);return m}}}var{Selection:X}=O;function W(p,s){let n=null;return p.forEach((i,a,r)=>{i.attrs.id===s&&(n={node:i,at:a,index:r})}),n}function j(p,s,n){let i=p.state,a=W(i.doc,n?.hostId)??(()=>{let w=Math.min(i.selection.$head.index(0),i.doc.childCount-1),f=0;for(let g=0;g<w;g++)f+=i.doc.child(g).nodeSize;return{node:i.doc.child(w),at:f,index:w}})(),{node:r,at:t,index:m}=a,c=i.doc.maybeChild(m+1),l=r.isTextblock&&(r.content.size===0||n?.hostId===r.attrs.id&&r.textContent===n.slashText),y=l?r.attrs.pos:P(r.attrs.pos,c?.attrs.pos??null),v=q.nodes.tool.create({id:s.id,pos:y,parent:r.attrs.parent??null,artifact:s.artifact,rev:s.rev,state:s.state}),o=l?t:t+r.nodeSize,d=i.tr;if(!l&&n?.hostId===r.attrs.id&&n.slashText&&n.slashOffset>=0){let w=t+1+n.slashOffset,f=w+n.slashText.length;f<=t+r.nodeSize-1&&i.doc.textBetween(w,f)===n.slashText&&d.delete(w,f)}let C=d.mapping.map(o);d.replaceWith(C,l?d.mapping.map(t+r.nodeSize):C,v),d.setSelection(X.near(d.doc.resolve(Math.min(C+v.nodeSize,d.doc.content.size)))),p.dispatch(M(d).scrollIntoView())}function ie({getView:p,store:s,transport:n,acceptState:i=()=>globalThis.clay?.save?.flush?.(),newId:a=R}){let r=n?J({transport:n,newId:()=>a("request")}):null,t=null,m=0,c=()=>{m++,t&&(r?.discard(t.pending),t.preview?.dispose(),t.previewHost?.dispose(),t.element.remove(),t=null)};return{open:({target:y=null,remove:v=null}={})=>{c();let o=p();if(!o)return;let d=o.state.selection,w={hostId:o.state.doc.child(Math.min(d.$head.index(0),o.state.doc.childCount-1))?.attrs.id,slashText:v?o.state.doc.textBetween(v.from,v.to):null,slashOffset:v&&d.$head.depth?v.from-d.$head.before(1)-1:null},f=o.dom.ownerDocument,g=f.createElement("section");g.className="page-ai-panel",g.contentEditable="false",g.setAttribute("role","dialog"),g.setAttribute("aria-label",y?"Revise tool":"Make a tool with AI");let E=f.createElement("textarea");E.setAttribute("aria-label","Describe the tool"),E.placeholder=y?"What should change?":"Describe the tool you want";let A=f.createElement("p");A.className="page-ai-status";let S=f.createElement("div");S.className="page-ai-preview";let T=f.createElement("div");T.className="page-ai-actions",g.append(E,A,S,T),o.dom.parentElement.append(g),t={element:g,input:E,status:A,previewRoot:S,actions:T,target:y,bookmark:w,candidate:null,pending:null,preview:null,previewHost:null,kept:!1,busy:!1};let x=(e,u)=>{let h=f.createElement("button");h.type="button",h.textContent=e,h.addEventListener("click",u),T.append(h)},z=()=>{t&&(t.preview?.dispose(),t.previewHost?.dispose(),t.preview=null,t.previewHost=null,t.previewRoot.replaceChildren(),t.input.hidden=!1,t.actions.replaceChildren(),x("Generate",D),x("Cancel",c),t.input.focus())},_=()=>{let e=t;e.input.hidden=!0,e.status.textContent="",e.previewHost=L({mode:"view"}),e.preview=e.previewHost.mount(e.previewRoot,{id:"preview",rev:"preview",artifact:e.candidate.artifact,seed:e.candidate.state}),e.actions.replaceChildren(),x("Keep",H),x("Revise",z),x("Discard",c)},D=async()=>{let e=t;if(!e||e.busy||!e.input.value.trim())return;if(!r){e.status.textContent="Tool generation is unavailable";return}e.busy=!0,e.status.textContent="Making your tool\u2026",e.actions.replaceChildren(),x("Cancel",c);let u=++m,h=r.request(e.input.value.trim(),$(o.state.doc,f.title),e.target);e.pending=h;try{let b=await r.wait(h);if(t!==e||u!==m)return;e.candidate={artifact:b.artifact,state:b.state,id:null,rev:null},_()}catch(b){if(t!==e||u!==m)return;e.status.textContent=b.message,e.actions.replaceChildren(),x("Generate",D),x("Cancel",c)}finally{e.busy=!1}},H=async()=>{let e=t;if(!e?.candidate||e.busy||e.kept)return;e.busy=!0;let u=e.candidate;u.id??=e.target?.toolId??a("b"),u.rev??=a("rev");try{if(!s)throw new Error("This document can't save tool state");await s.set([u.id,u.rev],u.state);let h=await i();if(h?.ok!==!0&&!["saved","clean"].includes(h?.state))throw new Error(h?.msg??h?.message??"Tool state was not saved");if(t!==e||e.kept)return;if(e.target){let b=W(o.state.doc,e.target.toolId);if(b?.node.type!==q.nodes.tool||b.node.attrs.rev!==e.target.rev){e.status.textContent="This tool changed while you were revising. Keep as a new tool, or discard.",e.target=null,u.id=null,u.rev=null,e.actions.replaceChildren(),x("Keep as new tool",H),x("Discard",c);return}o.dispatch(M(o.state.tr.setNodeMarkup(b.at,null,{...b.node.attrs,artifact:u.artifact,rev:u.rev})))}else j(o,u,e.bookmark);e.kept=!0,c()}catch(h){t===e&&(e.status.textContent=h.message)}finally{e.busy=!1}};return z(),g},dispose:c}}export{ie as createAiTool};
1
+ import{b as $}from"./c-R2XUODVY.js";import{a as k,b as B,c as L}from"./c-GBKB5WDL.js";import{B as M}from"./c-44B5ODN7.js";import{G as P,J as R,b as O,m as q}from"./c-QIXT3Q7C.js";import"./c-3GJ4SDE2.js";import{a as N}from"./c-3LDGIBMN.js";import"./c-VHNSBD2M.js";var K=16384,G=p=>new TextEncoder().encode(JSON.stringify(p)).length,I=class extends Error{constructor(s,n=s){super(n),this.name="ToolRequestError",this.code=s}};function V(p){let s=N(p);for(Array.isArray(s.tables)||(s.tables=[]),Array.isArray(s.outline)||(s.outline=[]);G(s)>K;){let n=[...s.tables].reverse().find(i=>Array.isArray(i.rows)&&i.rows.length);if(n)n.rows.pop();else if(s.outline.length)s.outline.pop();else break}if(G(s)>K)throw new I("context-too-large");return s}function J({transport:p,newId:s}){let n=null,i=a=>{!a||a.discarded||a.done||(a.discarded=!0,n===a&&(n=null),p.cancel(a.requestId),a.resolve({requestId:a.requestId,code:"discarded",message:"Candidate discarded"}))};return{request(a,r,t=null){let m=V(r);n&&i(n);let c=s(),l={requestId:c,discarded:!1,done:!1};l.promise=new Promise(o=>{l.resolve=o}),n=l;let y={protocol:"page-tool/1",requestId:c,prompt:a,context:m,target:t};l.request=y;let v=o=>{if(!(l.discarded||l.done||o?.requestId!==c))if(l.done=!0,n===l&&(n=null),o?.artifact!==void 0){let d=k(o.artifact),C=B(o.state),w=d.ok?C.ok?null:C:d;l.resolve(w?{requestId:c,code:w.code,message:w.code}:o)}else l.resolve(typeof o?.code=="string"?o:{requestId:c,code:"invalid-result",message:"invalid-result"})};try{Promise.resolve(p.request(y)).then(v,o=>v({requestId:c,code:"transport-error",message:String(o?.message??o)}))}catch(o){v({requestId:c,code:"transport-error",message:String(o?.message??o)})}return l},discard:i,async wait(a,{signal:r}={}){if(r?.aborted)throw new DOMException("Aborted","AbortError");let t,m=await(r?Promise.race([a.promise,new Promise((c,l)=>{t=()=>l(new DOMException("Aborted","AbortError")),r.addEventListener("abort",t,{once:!0})})]).finally(()=>r.removeEventListener("abort",t)):a.promise);if(m?.code)throw new I(m.code,m.message);return m}}}var{Selection:X}=O;function W(p,s){let n=null;return p.forEach((i,a,r)=>{i.attrs.id===s&&(n={node:i,at:a,index:r})}),n}function j(p,s,n){let i=p.state,a=W(i.doc,n?.hostId)??(()=>{let w=Math.min(i.selection.$head.index(0),i.doc.childCount-1),f=0;for(let g=0;g<w;g++)f+=i.doc.child(g).nodeSize;return{node:i.doc.child(w),at:f,index:w}})(),{node:r,at:t,index:m}=a,c=i.doc.maybeChild(m+1),l=r.isTextblock&&(r.content.size===0||n?.hostId===r.attrs.id&&r.textContent===n.slashText),y=l?r.attrs.pos:P(r.attrs.pos,c?.attrs.pos??null),v=q.nodes.tool.create({id:s.id,pos:y,parent:r.attrs.parent??null,artifact:s.artifact,rev:s.rev,state:s.state}),o=l?t:t+r.nodeSize,d=i.tr;if(!l&&n?.hostId===r.attrs.id&&n.slashText&&n.slashOffset>=0){let w=t+1+n.slashOffset,f=w+n.slashText.length;f<=t+r.nodeSize-1&&i.doc.textBetween(w,f)===n.slashText&&d.delete(w,f)}let C=d.mapping.map(o);d.replaceWith(C,l?d.mapping.map(t+r.nodeSize):C,v),d.setSelection(X.near(d.doc.resolve(Math.min(C+v.nodeSize,d.doc.content.size)))),p.dispatch(M(d).scrollIntoView())}function ie({getView:p,store:s,transport:n,acceptState:i=()=>globalThis.clay?.save?.flush?.(),newId:a=R}){let r=n?J({transport:n,newId:()=>a("request")}):null,t=null,m=0,c=()=>{m++,t&&(r?.discard(t.pending),t.preview?.dispose(),t.previewHost?.dispose(),t.element.remove(),t=null)};return{open:({target:y=null,remove:v=null}={})=>{c();let o=p();if(!o)return;let d=o.state.selection,w={hostId:o.state.doc.child(Math.min(d.$head.index(0),o.state.doc.childCount-1))?.attrs.id,slashText:v?o.state.doc.textBetween(v.from,v.to):null,slashOffset:v&&d.$head.depth?v.from-d.$head.before(1)-1:null},f=o.dom.ownerDocument,g=f.createElement("section");g.className="page-ai-panel",g.contentEditable="false",g.setAttribute("role","dialog"),g.setAttribute("aria-label",y?"Revise tool":"Make a tool with AI");let E=f.createElement("textarea");E.setAttribute("aria-label","Describe the tool"),E.placeholder=y?"What should change?":"Describe the tool you want";let A=f.createElement("p");A.className="page-ai-status";let S=f.createElement("div");S.className="page-ai-preview";let T=f.createElement("div");T.className="page-ai-actions",g.append(E,A,S,T),o.dom.parentElement.append(g),t={element:g,input:E,status:A,previewRoot:S,actions:T,target:y,bookmark:w,candidate:null,pending:null,preview:null,previewHost:null,kept:!1,busy:!1};let x=(e,u)=>{let h=f.createElement("button");h.type="button",h.textContent=e,h.addEventListener("click",u),T.append(h)},z=()=>{t&&(t.preview?.dispose(),t.previewHost?.dispose(),t.preview=null,t.previewHost=null,t.previewRoot.replaceChildren(),t.input.hidden=!1,t.actions.replaceChildren(),x("Generate",D),x("Cancel",c),t.input.focus())},_=()=>{let e=t;e.input.hidden=!0,e.status.textContent="",e.previewHost=L({mode:"view"}),e.preview=e.previewHost.mount(e.previewRoot,{id:"preview",rev:"preview",artifact:e.candidate.artifact,seed:e.candidate.state}),e.actions.replaceChildren(),x("Keep",H),x("Revise",z),x("Discard",c)},D=async()=>{let e=t;if(!e||e.busy||!e.input.value.trim())return;if(!r){e.status.textContent="Tool generation is unavailable";return}e.busy=!0,e.status.textContent="Making your tool\u2026",e.actions.replaceChildren(),x("Cancel",c);let u=++m,h=r.request(e.input.value.trim(),$(o.state.doc,f.title),e.target);e.pending=h;try{let b=await r.wait(h);if(t!==e||u!==m)return;e.candidate={artifact:b.artifact,state:b.state,id:null,rev:null},_()}catch(b){if(t!==e||u!==m)return;e.status.textContent=b.message,e.actions.replaceChildren(),x("Generate",D),x("Cancel",c)}finally{e.busy=!1}},H=async()=>{let e=t;if(!e?.candidate||e.busy||e.kept)return;e.busy=!0;let u=e.candidate;u.id??=e.target?.toolId??a("b"),u.rev??=a("rev");try{if(!s)throw new Error("This document can't save tool state");await s.set([u.id,u.rev],u.state);let h=await i();if(h?.ok!==!0&&!["saved","clean"].includes(h?.state))throw new Error(h?.msg??h?.message??"Tool state was not saved");if(t!==e||e.kept)return;if(e.target){let b=W(o.state.doc,e.target.toolId);if(b?.node.type!==q.nodes.tool||b.node.attrs.rev!==e.target.rev){e.status.textContent="This tool changed while you were revising. Keep as a new tool, or discard.",e.target=null,u.id=null,u.rev=null,e.actions.replaceChildren(),x("Keep as new tool",H),x("Discard",c);return}o.dispatch(M(o.state.tr.setNodeMarkup(b.at,null,{...b.node.attrs,artifact:u.artifact,rev:u.rev})))}else j(o,u,e.bookmark);e.kept=!0,c()}catch(h){t===e&&(e.status.textContent=h.message)}finally{e.busy=!1}};return z(),g},dispose:c}}export{ie as createAiTool};
@@ -1 +1 @@
1
- import{a as $}from"./c-XQXZAO7N.js";import{e as Y}from"./c-S7LK4KUE.js";import{c as z}from"./c-VG5XIN4T.js";import{b as H,i as I,o as N}from"./c-HA6INT6J.js";import{c as D,h as A,j as T,k,n as C,o as L}from"./c-DCFSEJZG.js";var K=[],i=[],g=new WeakMap,w=null,B=null,b=0;function de(){return b}function V(e){return g.get(e)||null}var M=new WeakMap,v=null;function he(){return v}function me(e){v&&e&&(v.artifact=e)}var R=null,x=new Map;function ye(e){R=e}function ve(e){return e==null?null:x.get(e)??null}function Se(e){return e&&M.get(e)||null}function j(e){e&&(M.delete(e),x.delete(e.captureId))}function W(e){let t=o=>{if(o.hasAttribute("onbeforesave")||o.hasAttribute("onbeforesnapshot"))return!0;let r=o.localName==="template"&&o.content?o.content:o;for(let n of r.children)if(t(n))return!0;return!1};return e.nodeType===1?t(e):!1}function l(e){for(let t of e.querySelectorAll(L))t.remove()}function h(e,t){for(let o of e.querySelectorAll(`[${t}]`))if(l(e),!(o!==e&&!e.contains(o)))try{new Function(o.getAttribute(t)).call(o)}catch(r){console.error(`[${t}] handler failed:`,r)}}var O=null;function Ce(e){O=e}function xe(e){return O?.(e),e}function Ae(e){K.push(e)}function Te(e,{steps:t=null}={}){w=e,B=t}var G="http://www.w3.org/1999/xhtml";function P(e){let t=X(e);if(!t.length)return"<!DOCTYPE html>"+e.outerHTML;let o=J(t),r;try{r="<!DOCTYPE html>"+e.outerHTML}finally{for(let[n,c]of t)n.replaceChildren(...c)}for(let[n,c]of o)r=r.split(n).join(c);return r}function X(e){let t=[],o=r=>{for(let n of r.childNodes)if(n.nodeType===1){if(n.localName==="noscript"&&n.namespaceURI===G){let c=Array.from(n.childNodes);c.length&&c.every(a=>a.nodeType===3)&&t.push([n,c]);continue}o(n.localName==="template"&&n.content?n.content:n)}};return o(e),t}function J(e){let t=Math.random().toString(36).slice(2);return e.map(([o,r],n)=>{let c=`\uE000clay-noscript-${t}-${n}\uE000`;return o.replaceChildren(o.ownerDocument.createTextNode(c)),[c,r.map(a=>a.data).join("")]})}function U(e,t){let o=v;v=e;try{return t()}finally{v=o}}function q(e,t=null){if(t&&R){let r=null;try{r=R(e)}catch{}r&&x.set(t.captureId,r)}let o=P(e);if(!w)return o;try{return U(t,()=>w(e,o))}catch(r){return console.error("clayjs: save renderer failed, sending the full serialization",r),o}}function ge(e){i.push(e)}function d(e,t=!0){let o=window.__preventOnclone;window.__preventOnclone=!0;try{return e.cloneNode(t)}finally{window.__preventOnclone=o}}function E(e,t){let o=g.get(e);o&&g.set(t,o);let r=e.children,n=t.children;for(let c=0;c<r.length;c++)E(r[c],n[c])}function f({flushUndo:e=!0,authored:t=!0,forSave:o=!1,requestRefresh:r=!1,context:n=null}={}){e&&typeof window<"u"&&window.clay?.undo?.flush&&window.clay.undo.flush();let a=$(document.documentElement,{capability:"snapshot",provenance:g}).root;for(let m of K)l(a),m(a,{original:V,forSave:o,requestRefresh:r});return Y(a),O?.(a),l(a),n&&(n.authoredHandlers=W(a)),t&&h(a,"onbeforesnapshot"),l(a),D(a),N(a),H(a),a}function _(e,{authored:t=!0}={}){l(e),t&&h(e,"onbeforesave");for(let o of i)l(e),o(e);l(e);for(let o of e.querySelectorAll(A))o.remove();return F(e),e}function F(e){for(let t of e.querySelectorAll("[sap-error]"))t.removeAttribute("sap-error")}function Q({flushUndo:e=!0,authored:t=!0}={}){return _(f({flushUndo:e,authored:t}),{authored:t})}var Z=["style","class"];function ee(e){z(e);for(let t of Z){e.getAttribute(t)===""&&e.removeAttribute(t);for(let o of e.querySelectorAll(`[${t}=""]`))o.removeAttribute(t)}}function S(e){return ee(e),"<!DOCTYPE html>"+e.outerHTML}function we({flushUndo:e=!0}={}){let t=f({flushUndo:e});h(t,"onbeforesave");for(let o of t.querySelectorAll(T))o.remove();for(let o of i)l(t),o(t);return l(t),S(t)}function Re({flushUndo:e=!0}={}){let t=f({flushUndo:e});h(t,"onbeforesave");for(let o of t.querySelectorAll(C))o.remove();for(let o of i)l(t),o(t);return l(t),S(t)}function Ee({flushUndo:e=!0}={}){let t=f({flushUndo:e});h(t,"onbeforesave");let o=t.querySelector(k)?d(t):null;o&&E(t,o);for(let c of t.querySelectorAll(T))c.remove();for(let c of i)l(t),c(t);l(t);let r=S(t),n=r;if(o){for(let c of o.querySelectorAll(C))c.remove();for(let c of i)l(o),c(o);l(o),n=S(o)}return{forComparison:r,forDirty:n}}function te({emitForSync:e=!0,flushUndo:t=!0,requestRefresh:o=!1,forRequest:r=!1,pageFormatMarker:n=null,sliced:c=!1}={}){if(!Number.isSafeInteger(b+1))throw new Error("Save capture identity exhausted");let a=++b,m=r?{captureId:a,authoredHandlers:!1,artifact:null}:null,u=f({flushUndo:t,forSave:e,requestRefresh:o,context:m});e&&document.dispatchEvent(new CustomEvent("clay:snapshot-ready",{detail:{documentElement:u,forSave:!0,captureId:a,sliced:c}})),h(u,"onbeforesave");let y=d(u);E(u,y);let p=u.querySelector(k)?d(u):null;p&&E(u,p);for(let s of i)l(u),s(u);l(u);for(let s of u.querySelectorAll(A))s.remove();F(u);for(let s of y.querySelectorAll(T))s.remove();for(let s of i)l(y),s(y);if(l(y),p){for(let s of p.querySelectorAll(C))s.remove();for(let s of i)l(p),s(p);l(p)}return{captureId:a,context:m,pageFormatMarker:n,clone:u,compareClone:y,dirtyClone:p,renderer:w,rendererSteps:B,pageStateReader:R,result:null}}function oe(e){if(!e.context||!e.pageStateReader)return;let t=null;try{t=e.pageStateReader(e.clone)}catch{}t&&x.set(e.captureId,t)}function re(e,{forSave:t,forComparison:o,forDirty:r}){let n={forSave:t,forComparison:o,forDirty:r,captureId:e.captureId};return e.context&&e.context.artifact&&M.set(n,e.context.artifact),e.result=n,n}function ne(e){j(e.result),x.delete(e.captureId),e.context&&(e.context.artifact=null),e.clone=e.compareClone=e.dirtyClone=null,e.result=null}function _e(e={}){let t=te(e);try{oe(t);let o=P(t.clone),r=t.compareClone?S(t.compareClone):null,n=t.dirtyClone?S(t.dirtyClone):r,c=t.renderer?U(t.context,()=>t.renderer(t.clone,o)):o;return re(t,{forSave:c,forComparison:r,forDirty:n})}catch(o){throw ne(t),o}}function ke(){let e=f({flushUndo:!1});h(e,"onbeforesave");let t=d(e),o=new WeakMap;(function r(n,c){o.set(n,c);let a=n.children,m=c.children;for(let u=0;u<a.length;u++)r(a[u],m[u])})(t,e);for(let r of i)l(e),r(e);l(e);for(let r of e.querySelectorAll(A))r.remove();F(e);for(let r of t.querySelectorAll(C))r.remove();for(let r of i)l(t),r(t);return l(t),{saveClone:e,compareClone:t,pairMap:o}}function ce({emitForSync:e=!0}={}){let t=f();return e&&document.dispatchEvent(new CustomEvent("clay:snapshot-ready",{detail:{documentElement:t}})),q(_(t))}function be(e){let t=d(e,!1);for(let n of I)t.removeAttribute(n);let o=t.outerHTML,r=`</${t.localName}>`;return"<!DOCTYPE html>"+o.slice(0,o.length-r.length)+e.innerHTML+r}function Me(e){return d(e)}function Oe(){return f().querySelector("body").innerHTML}function Pe({transform:e=null,flushUndo:t=!0}={}){if(!e&&t)return ce({emitForSync:!1});let o=f({flushUndo:t});if(e){let r=e(o);if(r&&typeof r.then=="function")throw new TypeError("getHTML: the transform must be synchronous")}return q(_(o))}function qe(e,{prepared:t=!1}={}){let o=d(e);return P(t?o:_(o,{authored:!1}))}function Fe(){return q(Q({flushUndo:!1,authored:!1}))}export{de as a,V as b,he as c,me as d,ye as e,ve as f,Se as g,j as h,Ce as i,xe as j,Ae as k,Te as l,P as m,X as n,J as o,U as p,ge as q,d as r,f as s,Q as t,ee as u,S as v,we as w,Re as x,Ee as y,te as z,oe as A,re as B,ne as C,_e as D,ke as E,ce as F,be as G,Me as H,Oe as I,Pe as J,qe as K,Fe as L};
1
+ import{a as $}from"./c-XQXZAO7N.js";import{e as Y}from"./c-S7LK4KUE.js";import{c as z}from"./c-VG5XIN4T.js";import{b as H,i as I,o as N}from"./c-HA6INT6J.js";import{c as D,h as A,j as T,k,n as C,o as L}from"./c-ICMAOOGK.js";var K=[],i=[],g=new WeakMap,w=null,B=null,b=0;function de(){return b}function V(e){return g.get(e)||null}var M=new WeakMap,v=null;function he(){return v}function me(e){v&&e&&(v.artifact=e)}var R=null,x=new Map;function ye(e){R=e}function ve(e){return e==null?null:x.get(e)??null}function Se(e){return e&&M.get(e)||null}function j(e){e&&(M.delete(e),x.delete(e.captureId))}function W(e){let t=o=>{if(o.hasAttribute("onbeforesave")||o.hasAttribute("onbeforesnapshot"))return!0;let r=o.localName==="template"&&o.content?o.content:o;for(let n of r.children)if(t(n))return!0;return!1};return e.nodeType===1?t(e):!1}function l(e){for(let t of e.querySelectorAll(L))t.remove()}function h(e,t){for(let o of e.querySelectorAll(`[${t}]`))if(l(e),!(o!==e&&!e.contains(o)))try{new Function(o.getAttribute(t)).call(o)}catch(r){console.error(`[${t}] handler failed:`,r)}}var O=null;function Ce(e){O=e}function xe(e){return O?.(e),e}function Ae(e){K.push(e)}function Te(e,{steps:t=null}={}){w=e,B=t}var G="http://www.w3.org/1999/xhtml";function P(e){let t=X(e);if(!t.length)return"<!DOCTYPE html>"+e.outerHTML;let o=J(t),r;try{r="<!DOCTYPE html>"+e.outerHTML}finally{for(let[n,c]of t)n.replaceChildren(...c)}for(let[n,c]of o)r=r.split(n).join(c);return r}function X(e){let t=[],o=r=>{for(let n of r.childNodes)if(n.nodeType===1){if(n.localName==="noscript"&&n.namespaceURI===G){let c=Array.from(n.childNodes);c.length&&c.every(a=>a.nodeType===3)&&t.push([n,c]);continue}o(n.localName==="template"&&n.content?n.content:n)}};return o(e),t}function J(e){let t=Math.random().toString(36).slice(2);return e.map(([o,r],n)=>{let c=`\uE000clay-noscript-${t}-${n}\uE000`;return o.replaceChildren(o.ownerDocument.createTextNode(c)),[c,r.map(a=>a.data).join("")]})}function U(e,t){let o=v;v=e;try{return t()}finally{v=o}}function q(e,t=null){if(t&&R){let r=null;try{r=R(e)}catch{}r&&x.set(t.captureId,r)}let o=P(e);if(!w)return o;try{return U(t,()=>w(e,o))}catch(r){return console.error("clayjs: save renderer failed, sending the full serialization",r),o}}function ge(e){i.push(e)}function d(e,t=!0){let o=window.__preventOnclone;window.__preventOnclone=!0;try{return e.cloneNode(t)}finally{window.__preventOnclone=o}}function E(e,t){let o=g.get(e);o&&g.set(t,o);let r=e.children,n=t.children;for(let c=0;c<r.length;c++)E(r[c],n[c])}function f({flushUndo:e=!0,authored:t=!0,forSave:o=!1,requestRefresh:r=!1,context:n=null}={}){e&&typeof window<"u"&&window.clay?.undo?.flush&&window.clay.undo.flush();let a=$(document.documentElement,{capability:"snapshot",provenance:g}).root;for(let m of K)l(a),m(a,{original:V,forSave:o,requestRefresh:r});return Y(a),O?.(a),l(a),n&&(n.authoredHandlers=W(a)),t&&h(a,"onbeforesnapshot"),l(a),D(a),N(a),H(a),a}function _(e,{authored:t=!0}={}){l(e),t&&h(e,"onbeforesave");for(let o of i)l(e),o(e);l(e);for(let o of e.querySelectorAll(A))o.remove();return F(e),e}function F(e){for(let t of e.querySelectorAll("[sap-error]"))t.removeAttribute("sap-error")}function Q({flushUndo:e=!0,authored:t=!0}={}){return _(f({flushUndo:e,authored:t}),{authored:t})}var Z=["style","class"];function ee(e){z(e);for(let t of Z){e.getAttribute(t)===""&&e.removeAttribute(t);for(let o of e.querySelectorAll(`[${t}=""]`))o.removeAttribute(t)}}function S(e){return ee(e),"<!DOCTYPE html>"+e.outerHTML}function we({flushUndo:e=!0}={}){let t=f({flushUndo:e});h(t,"onbeforesave");for(let o of t.querySelectorAll(T))o.remove();for(let o of i)l(t),o(t);return l(t),S(t)}function Re({flushUndo:e=!0}={}){let t=f({flushUndo:e});h(t,"onbeforesave");for(let o of t.querySelectorAll(C))o.remove();for(let o of i)l(t),o(t);return l(t),S(t)}function Ee({flushUndo:e=!0}={}){let t=f({flushUndo:e});h(t,"onbeforesave");let o=t.querySelector(k)?d(t):null;o&&E(t,o);for(let c of t.querySelectorAll(T))c.remove();for(let c of i)l(t),c(t);l(t);let r=S(t),n=r;if(o){for(let c of o.querySelectorAll(C))c.remove();for(let c of i)l(o),c(o);l(o),n=S(o)}return{forComparison:r,forDirty:n}}function te({emitForSync:e=!0,flushUndo:t=!0,requestRefresh:o=!1,forRequest:r=!1,pageFormatMarker:n=null,sliced:c=!1}={}){if(!Number.isSafeInteger(b+1))throw new Error("Save capture identity exhausted");let a=++b,m=r?{captureId:a,authoredHandlers:!1,artifact:null}:null,u=f({flushUndo:t,forSave:e,requestRefresh:o,context:m});e&&document.dispatchEvent(new CustomEvent("clay:snapshot-ready",{detail:{documentElement:u,forSave:!0,captureId:a,sliced:c}})),h(u,"onbeforesave");let y=d(u);E(u,y);let p=u.querySelector(k)?d(u):null;p&&E(u,p);for(let s of i)l(u),s(u);l(u);for(let s of u.querySelectorAll(A))s.remove();F(u);for(let s of y.querySelectorAll(T))s.remove();for(let s of i)l(y),s(y);if(l(y),p){for(let s of p.querySelectorAll(C))s.remove();for(let s of i)l(p),s(p);l(p)}return{captureId:a,context:m,pageFormatMarker:n,clone:u,compareClone:y,dirtyClone:p,renderer:w,rendererSteps:B,pageStateReader:R,result:null}}function oe(e){if(!e.context||!e.pageStateReader)return;let t=null;try{t=e.pageStateReader(e.clone)}catch{}t&&x.set(e.captureId,t)}function re(e,{forSave:t,forComparison:o,forDirty:r}){let n={forSave:t,forComparison:o,forDirty:r,captureId:e.captureId};return e.context&&e.context.artifact&&M.set(n,e.context.artifact),e.result=n,n}function ne(e){j(e.result),x.delete(e.captureId),e.context&&(e.context.artifact=null),e.clone=e.compareClone=e.dirtyClone=null,e.result=null}function _e(e={}){let t=te(e);try{oe(t);let o=P(t.clone),r=t.compareClone?S(t.compareClone):null,n=t.dirtyClone?S(t.dirtyClone):r,c=t.renderer?U(t.context,()=>t.renderer(t.clone,o)):o;return re(t,{forSave:c,forComparison:r,forDirty:n})}catch(o){throw ne(t),o}}function ke(){let e=f({flushUndo:!1});h(e,"onbeforesave");let t=d(e),o=new WeakMap;(function r(n,c){o.set(n,c);let a=n.children,m=c.children;for(let u=0;u<a.length;u++)r(a[u],m[u])})(t,e);for(let r of i)l(e),r(e);l(e);for(let r of e.querySelectorAll(A))r.remove();F(e);for(let r of t.querySelectorAll(C))r.remove();for(let r of i)l(t),r(t);return l(t),{saveClone:e,compareClone:t,pairMap:o}}function ce({emitForSync:e=!0}={}){let t=f();return e&&document.dispatchEvent(new CustomEvent("clay:snapshot-ready",{detail:{documentElement:t}})),q(_(t))}function be(e){let t=d(e,!1);for(let n of I)t.removeAttribute(n);let o=t.outerHTML,r=`</${t.localName}>`;return"<!DOCTYPE html>"+o.slice(0,o.length-r.length)+e.innerHTML+r}function Me(e){return d(e)}function Oe(){return f().querySelector("body").innerHTML}function Pe({transform:e=null,flushUndo:t=!0}={}){if(!e&&t)return ce({emitForSync:!1});let o=f({flushUndo:t});if(e){let r=e(o);if(r&&typeof r.then=="function")throw new TypeError("getHTML: the transform must be synchronous")}return q(_(o))}function qe(e,{prepared:t=!1}={}){let o=d(e);return P(t?o:_(o,{authored:!1}))}function Fe(){return q(Q({flushUndo:!1,authored:!1}))}export{de as a,V as b,he as c,me as d,ye as e,ve as f,Se as g,j as h,Ce as i,xe as j,Ae as k,Te as l,P as m,X as n,J as o,U as p,ge as q,d as r,f as s,Q as t,ee as u,S as v,we as w,Re as x,Ee as y,te as z,oe as A,re as B,ne as C,_e as D,ke as E,ce as F,be as G,Me as H,Oe as I,Pe as J,qe as K,Fe as L};
@@ -1 +1 @@
1
- import{c as M,g as _,h as A,w as q}from"./c-4FJTBE6I.js";import{B as G}from"./c-AIWN4QN4.js";import{D as O,G as $,I as y,J as B,M as R,Z as j,_ as U,b as z,m as p,na as F}from"./c-QIXT3Q7C.js";import{a as x}from"./c-WCXLG3MV.js";import{a as K}from"./c-I2SCCUEW.js";var{TextSelection:J}=z,S=new WeakMap,D=new Set;function g(n,t){let e=null;return n.forEach(s=>{s.type===p.nodes.table&&s.attrs.id===t&&(e=s)}),e}function N(n){return n?F({[n.attrs.id]:R(n)})[0]:null}function Q(n,t,e){let s=y(n.attrs.cols);if(!s.length)return null;let i=M(n),a=s.filter(r=>r!==s[0]&&i[r]==="number");return a.length?{id:B(),pos:t,parent:e,source:n.attrs.id,kind:"bar",x:s[0],series:a,title:"",highlight:null}:null}function wt(n,t){let e=n.state.doc,s=e.nodeAt(t);if(s?.type!==p.nodes.table)return!1;let i=t+s.nodeSize,a=e.maybeChild(e.resolve(i).index(0)),r=Q(s,$(s.attrs.pos,a?.attrs.pos??null),s.attrs.parent);return r?(D.add(r.id),n.dispatch(n.state.tr.insert(i,p.nodes.chart.create(r))),!0):(x("This table has no number column to chart yet."),!0)}function W(n,t,e,s){let i=n.state.tr;if(s&&i.delete(s.from,s.to),!g(i.doc,e.attrs.id)||t>=i.doc.childCount)return!1;let a=0;for(let m=0;m<t;m++)a+=i.doc.child(m).nodeSize;let r=i.doc.child(t),c=r.isTextblock&&r.content.size===0,h=i.doc.maybeChild(t+1),f=c?r.attrs.pos:$(r.attrs.pos,h?.attrs.pos??null),d=Q(e,f,r.attrs.parent??null);if(!d)return s&&n.dispatch(n.state.tr.delete(s.from,s.to)),x("This table has no number column to chart yet."),!0;let w=p.nodes.chart.create(d);return i=c?i.replaceWith(a,a+r.nodeSize,w):i.insert(a+r.nodeSize,w),D.add(d.id),n.dispatch(i.scrollIntoView()),!0}var X=n=>y(n.attrs.cols).map(t=>n.attrs.cols[t].name||"Untitled").join(", ");function kt(n,t,e=null){let s=_(n.state.doc);if(!s.length)return e&&n.dispatch(n.state.tr.delete(e.from,e.to)),x("Add a table first: a chart plots the numbers in a table on this page."),!0;if(s.length===1)return W(n,t,s[0],e);let i=n.state.doc,a=n.nodeDOM(i.resolve(n.state.selection.head).before(1))??n.dom;return q(n,a,s.map(r=>({label:A(i,r.attrs.id)??"",description:`${r.childCount} ${r.childCount===1?"row":"rows"} \xB7 ${X(r)}`,icon:"\u25A6",run:()=>W(n,t,r,e)})))}var V=n=>`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,Z=V('<rect x="2.5" y="3" width="11" height="10" rx="1.5"/><path d="M2.5 6.5h11M6 6.5V13"/>'),tt=V('<g transform="scale(0.6667)" stroke-width="2.25"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></g>'),et=V('<path d="M2.75 4.5h10.5M6.25 4.5V2.75h3.5V4.5M4.25 4.5l.6 8.75h6.3l.6-8.75"/>'),st=[["bar","Bar"],["line","Line"],["pie","Pie"]],it="Untitled chart";function nt(n,t){let e=null;return n.forEach((s,i)=>{e===null&&s.type===p.nodes.table&&s.attrs.id===t&&(e=i)}),e}function E(n){let t=[];return n.forEach(e=>{e.type===p.nodes.table&&y(e.attrs.cols).length>1&&t.push(e)}),t.map(e=>({id:e.attrs.id,name:A(n,e.attrs.id),rows:e.childCount}))}function at(n){let t=y(n.attrs.cols);if(!t.length)return null;let e=M(n),s=t.find(a=>e[a]!=="number")??t[0],i=t.filter(a=>a!==s&&e[a]==="number");return{x:s,series:i.length?i:t.filter(a=>a!==s).slice(0,1)}}function l(n,t,e,s=null){let i=n.createElement(t);return e&&(i.className=e),s!==null&&(i.textContent=s),i}function C(n,t,e,s=!1){let i=l(n,"option","",e);return i.value=t,i.selected=s,i}function T(n,t,e){let s=l(n,"select","page-chart-select");return s.dataset.field=t,s.setAttribute("aria-label",e),s}var Y=class{constructor(t,e,s){this.node=t,this.view=e,this.getPos=s,this.source=void 0,this.tables=null,this.frame=null,this.unsaved=null,this.titleInput=null;let i=e.dom.ownerDocument;this.doc=i,this.dom=i.createElement("figure"),this.dom.className="page-chart",this.dom.dataset.id=t.attrs.id??"",this.dom.dataset.type="chart",this.head=l(i,"div","page-chart-head"),this.head.contentEditable="false",this.title=l(i,"span","page-chart-title"),this.chip=l(i,"button","page-chart-source"),this.chip.type="button",this.chip.contentEditable="false",this.chip.setAttribute("aria-label","Go to source table"),this.chip.innerHTML=Z,this.chipName=l(i,"span","page-chart-source-name"),this.chip.append(this.chipName),this.chip.addEventListener("click",()=>this.goToSource()),this.edit=l(i,"button","page-chart-edit"),this.edit.type="button",this.edit.contentEditable="false",this.edit.setAttribute("aria-haspopup","dialog"),this.edit.setAttribute("aria-expanded","false"),this.edit.innerHTML=tt,this.edit.append("Edit chart"),this.edit.addEventListener("click",()=>this.panel.isConnected?this.closePanel(!0):this.openPanel()),this.head.append(this.title,this.chip,this.edit),this.plot=l(i,"div","page-chart-plot"),this.broken=l(i,"div","page-chart-broken"),this.broken.hidden=!0,this.broken.contentEditable="false",this.brokenKey=null,this.brokenSelect=null,this.broken.addEventListener("click",a=>this.brokenClick(a)),this.panel=l(i,"div","page-chart-panel"),this.panel.tabIndex=-1,this.panel.contentEditable="false",this.panel.setAttribute("role","dialog"),this.panel.setAttribute("aria-label","Chart settings"),this.panel.addEventListener("click",a=>this.panelClick(a)),this.panel.addEventListener("change",a=>this.panelChange(a)),this.panel.addEventListener("mousedown",a=>{a.target.closest?.("button")&&a.preventDefault()}),this.outside=a=>{!this.panel.isConnected||this.dom.contains(a.target)||(this.commitTitle(),this.closePanel())},this.escape=a=>{!this.panel.isConnected||a.key!=="Escape"||(a.preventDefault(),a.stopPropagation(),this.closePanel(!0))},i.addEventListener("mousedown",this.outside,!0),i.addEventListener("keydown",this.escape,!0),this.dom.append(this.head,this.plot,this.broken),S.has(e)||S.set(e,new Set),S.get(e).add(this),this.refresh(),D.delete(t.attrs.id)&&this.openSoon()}refresh(){this.renderHead(),this.panel.isConnected&&this.panelKey()!==this.renderedKey&&this.redrawPanel();let t=this.view.state.doc,e=g(t,this.node.attrs.source),s=E(t).map(i=>`${i.id}:${i.name}:${i.rows}`).join("|");e===this.source&&s===this.tables||(this.source=e,this.tables=s,this.schedule())}schedule(){if(this.frame!==null)return;let t=this.dom.ownerDocument.defaultView,e=t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0));this.frame=e(()=>{this.frame=null,this.draw()})}draw(){let t=this.node.attrs,e=j({id:t.id,type:t.kind,x:t.x,series:t.series,title:t.title,highlight:t.highlight},N(this.source));this.plot.innerHTML=U(e,{width:640,height:320,narrow:this.dom.getBoundingClientRect().width<480}),this.renderBroken(e)}renderBroken(t){let e=t.state==="missing"&&t.reason==="table";if(this.plot.hidden=e,this.broken.hidden=!e,!e){this.brokenKey!==null&&(this.broken.textContent="",this.brokenKey=null,this.brokenSelect=null);return}let s=E(this.view.state.doc),i=s.map(h=>`${h.id}:${h.name}:${h.rows}`).join("|");if(this.brokenKey===i)return;this.brokenKey=i,this.brokenSelect=null;let a=this.doc;this.broken.textContent="",this.broken.append(l(a,"div","page-chart-broken-head","This chart's table was deleted"),l(a,"p","page-chart-broken-text","Pick another table in this document, or delete the chart. Undo brings the table back."));let r=l(a,"div","page-chart-broken-actions");if(s.length){let h=T(a,"rescue","Source table");for(let d of s)h.append(C(a,d.id,`${d.name} (${d.rows} ${d.rows===1?"row":"rows"})`));this.brokenSelect=h;let f=l(a,"button","page-chart-use","Use this table");f.type="button",f.dataset.action="use",r.append(h,f)}let c=l(a,"button","page-chart-delete","Delete chart");c.type="button",c.dataset.action="delete",r.append(c),this.broken.append(r)}brokenClick(t){let e=t.target.closest?.("button[data-action]");e&&(e.dataset.action==="delete"?this.removeChart():e.dataset.action==="use"&&this.switchSource(this.brokenSelect?.value??""))}openSoon(){let t=this.dom.ownerDocument.defaultView;(t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0)))(()=>{!this.view.isDestroyed&&this.dom.isConnected&&this.openPanel()})}renderHead(){let t=this.node.attrs,e=A(this.view.state.doc,t.source),s=!g(this.view.state.doc,t.source);this.title.textContent=t.title||it,this.title.classList.toggle("is-empty",!t.title),this.chipName.textContent=s?"No table":e??"",this.chip.disabled=s}setAttrs(t){let e=this.getPos();if(e==null)return;let s=this.view.state.doc.nodeAt(e);s?.type===p.nodes.chart&&this.view.dispatch(this.view.state.tr.setNodeMarkup(e,null,{...s.attrs,...t}))}row(t,...e){let s=l(this.doc,"div","page-chart-row");return t&&s.append(l(this.doc,"span","page-chart-label",t)),s.append(...e),s}panelKey(){let t=this.view.state.doc,e=E(t).map(s=>`${s.id}:${s.name}:${s.rows}`).join("|");return JSON.stringify([this.node.attrs,e,N(g(t,this.node.attrs.source))])}redrawPanel(){let t=this.doc.activeElement,e=t&&this.panel.contains(t)?t.dataset??{}:null,s=this.titleInput,i=s&&s.value!==this.renderedTitle?{value:s.value,start:s.selectionStart,end:s.selectionEnd}:null;if(this.renderPanel(),i&&this.titleInput&&(this.titleInput.value=i.value),!e)return;let a=[...this.panel.querySelectorAll("button, input, select")].find(r=>["field","kind","col","action"].every(c=>r.dataset[c]===e[c]));if(!a)return this.panel.focus();a.focus(),i&&a===this.titleInput&&a.setSelectionRange?.(i.start,i.end)}renderPanel(){let t=this.doc;this.renderedKey=this.panelKey(),this.renderedTitle=this.node.attrs.title??"";let e=this.node.attrs,s=N(this.source),i=s?.cols??[],a=s?.rows??[],r=e.kind==="pie";this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.textContent="";let c=l(t,"div","page-chart-types");for(let[o,P]of st){let b=l(t,"button","page-chart-type",P);b.type="button",b.dataset.kind=o,b.setAttribute("aria-pressed",String(e.kind===o)),c.append(b)}this.panel.append(this.row("Chart type",c));let h=T(t,"source","Source table");for(let o of E(this.view.state.doc))h.append(C(t,o.id,`${o.name} (${o.rows} ${o.rows===1?"row":"rows"})`,o.id===e.source));this.panel.append(this.row("Source table",h));let f=T(t,"labels","Labels column");for(let o of i)f.append(C(t,o.id,o.name||o.id,o.id===e.x));this.panel.append(this.row("Labels column",f));let d=l(t,"div","page-chart-values");i.filter(o=>o.id!==e.x).forEach((o,P)=>{let b=l(t,"label","page-chart-value"),v=l(t,"input");v.type="checkbox",v.dataset.field="series",v.dataset.col=o.id,v.checked=e.series.includes(o.id);let I=l(t,"span","page-chart-swatch");I.style.background=`var(--chart-${P%6+1})`,I.setAttribute("aria-hidden","true"),b.append(v,I,l(t,"span","page-chart-value-name",o.name||o.id)),d.append(b)});let w=this.row(r?"Value column":"Value columns",d);r&&w.append(l(t,"span","page-chart-hint","Pie charts plot the first value column across rows.")),this.panel.append(w);let m=T(t,"highlight","Highlight row");m.append(C(t,"","None",!e.highlight));for(let o of a)m.append(C(t,o.id,O(o.cells?.[e.x])||o.id,o.id===e.highlight));this.panel.append(this.row("Highlight row",m));let u=l(t,"input","page-chart-title-input");u.type="text",u.dataset.field="title",u.setAttribute("aria-label","Chart title"),u.value=e.title??"",u.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||o.key==="Enter"&&(o.preventDefault(),o.stopPropagation(),this.commitTitle())}),u.addEventListener("change",()=>this.commitTitle()),u.addEventListener("blur",()=>this.commitTitle()),this.titleInput=u,this.panel.append(this.row("Chart title",u));let H=l(t,"div","page-chart-foot"),k=l(t,"button","page-chart-remove");k.type="button",k.dataset.action="remove",k.innerHTML=et,k.append("Remove");let L=l(t,"button","page-chart-done","Done");L.type="button",L.dataset.action="done",H.append(k,L),this.panel.append(H),this.unsaved=K({id:"chart-title",isPending:()=>u.isConnected&&u.value!==(this.node.attrs.title??"")})}openPanel(){this.panel.isConnected||(this.renderPanel(),this.dom.append(this.panel),this.edit.setAttribute("aria-expanded","true"),this.panel.focus())}closePanel(t=!1){this.panel.isConnected&&(this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.remove(),this.edit.setAttribute("aria-expanded","false"),t&&this.edit.focus())}panelClick(t){let e=t.target.closest?.("button");e&&(e.dataset.action==="done"?(this.commitTitle(),this.closePanel(!0)):e.dataset.action==="remove"?this.removeChart():e.dataset.kind&&this.setAttrs({kind:e.dataset.kind}))}panelChange(t){let e=t.target;if(e?.dataset){if(e.dataset.field==="source")this.switchSource(e.value);else if(e.dataset.field==="labels")this.setAttrs({x:e.value,series:this.node.attrs.series.filter(s=>s!==e.value)});else if(e.dataset.field==="highlight")this.setAttrs({highlight:e.value||null});else if(e.dataset.field==="series"){let s=this.node.attrs.series.filter(i=>i!==e.dataset.col);this.setAttrs({series:e.checked?[...s,e.dataset.col]:s})}}}switchSource(t){let e=g(this.view.state.doc,t),s=e?at(e):null;s&&this.setAttrs({source:t,x:s.x,series:s.series})}commitTitle(){let t=this.titleInput;!t||t.value===(this.node.attrs.title??"")||this.setAttrs({title:t.value})}goToSource(){let t=this.view.state.doc,e=nt(t,this.node.attrs.source),s=e===null?null:t.nodeAt(e);if(!s?.childCount||!s.child(0).childCount)return;let i=e+3;this.view.dispatch(this.view.state.tr.setSelection(J.create(t,i)).scrollIntoView()),this.view.focus?.()}removeChart(){let t=this.getPos();if(t==null)return;let e=this.view.state.doc.nodeAt(t);if(e?.type!==p.nodes.chart)return;this.closePanel();let s=this.view.state.tr.delete(t,t+e.nodeSize);s.setSelection(J.near(s.doc.resolve(Math.min(t,s.doc.content.size)),-1)),this.view.dispatch(G(s).scrollIntoView())}update(t){if(t.type!==p.nodes.chart)return!1;let e=!t.sameMarkup(this.node);return this.node=t,this.dom.dataset.id=t.attrs.id??"",e&&(this.source=g(this.view.state.doc,t.attrs.source),this.renderHead(),this.schedule()),!0}stopEvent(t){return!!t.target.closest?.(".page-chart-head, .page-chart-panel")}destroy(){if(this.unsaved?.dispose(),this.unsaved=null,this.doc.removeEventListener("mousedown",this.outside,!0),this.doc.removeEventListener("keydown",this.escape,!0),S.get(this.view)?.delete(this),this.frame!==null){let t=this.dom.ownerDocument.defaultView;t.cancelAnimationFrame?t.cancelAnimationFrame(this.frame):t.clearTimeout(this.frame)}}};function vt(n){for(let t of S.get(n)??[])t.refresh()}export{wt as a,X as b,kt as c,Y as d,vt as e};
1
+ import{c as M,g as _,h as A,w as q}from"./c-SJPD46ZO.js";import{B as G}from"./c-44B5ODN7.js";import{D as O,G as $,I as y,J as B,M as R,Z as j,_ as U,b as z,m as p,na as F}from"./c-QIXT3Q7C.js";import{a as x}from"./c-E4IBSAQM.js";import{a as K}from"./c-I2SCCUEW.js";var{TextSelection:J}=z,S=new WeakMap,D=new Set;function g(n,t){let e=null;return n.forEach(s=>{s.type===p.nodes.table&&s.attrs.id===t&&(e=s)}),e}function N(n){return n?F({[n.attrs.id]:R(n)})[0]:null}function Q(n,t,e){let s=y(n.attrs.cols);if(!s.length)return null;let i=M(n),a=s.filter(r=>r!==s[0]&&i[r]==="number");return a.length?{id:B(),pos:t,parent:e,source:n.attrs.id,kind:"bar",x:s[0],series:a,title:"",highlight:null}:null}function wt(n,t){let e=n.state.doc,s=e.nodeAt(t);if(s?.type!==p.nodes.table)return!1;let i=t+s.nodeSize,a=e.maybeChild(e.resolve(i).index(0)),r=Q(s,$(s.attrs.pos,a?.attrs.pos??null),s.attrs.parent);return r?(D.add(r.id),n.dispatch(n.state.tr.insert(i,p.nodes.chart.create(r))),!0):(x("This table has no number column to chart yet."),!0)}function W(n,t,e,s){let i=n.state.tr;if(s&&i.delete(s.from,s.to),!g(i.doc,e.attrs.id)||t>=i.doc.childCount)return!1;let a=0;for(let m=0;m<t;m++)a+=i.doc.child(m).nodeSize;let r=i.doc.child(t),c=r.isTextblock&&r.content.size===0,h=i.doc.maybeChild(t+1),f=c?r.attrs.pos:$(r.attrs.pos,h?.attrs.pos??null),d=Q(e,f,r.attrs.parent??null);if(!d)return s&&n.dispatch(n.state.tr.delete(s.from,s.to)),x("This table has no number column to chart yet."),!0;let w=p.nodes.chart.create(d);return i=c?i.replaceWith(a,a+r.nodeSize,w):i.insert(a+r.nodeSize,w),D.add(d.id),n.dispatch(i.scrollIntoView()),!0}var X=n=>y(n.attrs.cols).map(t=>n.attrs.cols[t].name||"Untitled").join(", ");function kt(n,t,e=null){let s=_(n.state.doc);if(!s.length)return e&&n.dispatch(n.state.tr.delete(e.from,e.to)),x("Add a table first: a chart plots the numbers in a table on this page."),!0;if(s.length===1)return W(n,t,s[0],e);let i=n.state.doc,a=n.nodeDOM(i.resolve(n.state.selection.head).before(1))??n.dom;return q(n,a,s.map(r=>({label:A(i,r.attrs.id)??"",description:`${r.childCount} ${r.childCount===1?"row":"rows"} \xB7 ${X(r)}`,icon:"\u25A6",run:()=>W(n,t,r,e)})))}var V=n=>`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,Z=V('<rect x="2.5" y="3" width="11" height="10" rx="1.5"/><path d="M2.5 6.5h11M6 6.5V13"/>'),tt=V('<g transform="scale(0.6667)" stroke-width="2.25"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></g>'),et=V('<path d="M2.75 4.5h10.5M6.25 4.5V2.75h3.5V4.5M4.25 4.5l.6 8.75h6.3l.6-8.75"/>'),st=[["bar","Bar"],["line","Line"],["pie","Pie"]],it="Untitled chart";function nt(n,t){let e=null;return n.forEach((s,i)=>{e===null&&s.type===p.nodes.table&&s.attrs.id===t&&(e=i)}),e}function E(n){let t=[];return n.forEach(e=>{e.type===p.nodes.table&&y(e.attrs.cols).length>1&&t.push(e)}),t.map(e=>({id:e.attrs.id,name:A(n,e.attrs.id),rows:e.childCount}))}function at(n){let t=y(n.attrs.cols);if(!t.length)return null;let e=M(n),s=t.find(a=>e[a]!=="number")??t[0],i=t.filter(a=>a!==s&&e[a]==="number");return{x:s,series:i.length?i:t.filter(a=>a!==s).slice(0,1)}}function l(n,t,e,s=null){let i=n.createElement(t);return e&&(i.className=e),s!==null&&(i.textContent=s),i}function C(n,t,e,s=!1){let i=l(n,"option","",e);return i.value=t,i.selected=s,i}function T(n,t,e){let s=l(n,"select","page-chart-select");return s.dataset.field=t,s.setAttribute("aria-label",e),s}var Y=class{constructor(t,e,s){this.node=t,this.view=e,this.getPos=s,this.source=void 0,this.tables=null,this.frame=null,this.unsaved=null,this.titleInput=null;let i=e.dom.ownerDocument;this.doc=i,this.dom=i.createElement("figure"),this.dom.className="page-chart",this.dom.dataset.id=t.attrs.id??"",this.dom.dataset.type="chart",this.head=l(i,"div","page-chart-head"),this.head.contentEditable="false",this.title=l(i,"span","page-chart-title"),this.chip=l(i,"button","page-chart-source"),this.chip.type="button",this.chip.contentEditable="false",this.chip.setAttribute("aria-label","Go to source table"),this.chip.innerHTML=Z,this.chipName=l(i,"span","page-chart-source-name"),this.chip.append(this.chipName),this.chip.addEventListener("click",()=>this.goToSource()),this.edit=l(i,"button","page-chart-edit"),this.edit.type="button",this.edit.contentEditable="false",this.edit.setAttribute("aria-haspopup","dialog"),this.edit.setAttribute("aria-expanded","false"),this.edit.innerHTML=tt,this.edit.append("Edit chart"),this.edit.addEventListener("click",()=>this.panel.isConnected?this.closePanel(!0):this.openPanel()),this.head.append(this.title,this.chip,this.edit),this.plot=l(i,"div","page-chart-plot"),this.broken=l(i,"div","page-chart-broken"),this.broken.hidden=!0,this.broken.contentEditable="false",this.brokenKey=null,this.brokenSelect=null,this.broken.addEventListener("click",a=>this.brokenClick(a)),this.panel=l(i,"div","page-chart-panel"),this.panel.tabIndex=-1,this.panel.contentEditable="false",this.panel.setAttribute("role","dialog"),this.panel.setAttribute("aria-label","Chart settings"),this.panel.addEventListener("click",a=>this.panelClick(a)),this.panel.addEventListener("change",a=>this.panelChange(a)),this.panel.addEventListener("mousedown",a=>{a.target.closest?.("button")&&a.preventDefault()}),this.outside=a=>{!this.panel.isConnected||this.dom.contains(a.target)||(this.commitTitle(),this.closePanel())},this.escape=a=>{!this.panel.isConnected||a.key!=="Escape"||(a.preventDefault(),a.stopPropagation(),this.closePanel(!0))},i.addEventListener("mousedown",this.outside,!0),i.addEventListener("keydown",this.escape,!0),this.dom.append(this.head,this.plot,this.broken),S.has(e)||S.set(e,new Set),S.get(e).add(this),this.refresh(),D.delete(t.attrs.id)&&this.openSoon()}refresh(){this.renderHead(),this.panel.isConnected&&this.panelKey()!==this.renderedKey&&this.redrawPanel();let t=this.view.state.doc,e=g(t,this.node.attrs.source),s=E(t).map(i=>`${i.id}:${i.name}:${i.rows}`).join("|");e===this.source&&s===this.tables||(this.source=e,this.tables=s,this.schedule())}schedule(){if(this.frame!==null)return;let t=this.dom.ownerDocument.defaultView,e=t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0));this.frame=e(()=>{this.frame=null,this.draw()})}draw(){let t=this.node.attrs,e=j({id:t.id,type:t.kind,x:t.x,series:t.series,title:t.title,highlight:t.highlight},N(this.source));this.plot.innerHTML=U(e,{width:640,height:320,narrow:this.dom.getBoundingClientRect().width<480}),this.renderBroken(e)}renderBroken(t){let e=t.state==="missing"&&t.reason==="table";if(this.plot.hidden=e,this.broken.hidden=!e,!e){this.brokenKey!==null&&(this.broken.textContent="",this.brokenKey=null,this.brokenSelect=null);return}let s=E(this.view.state.doc),i=s.map(h=>`${h.id}:${h.name}:${h.rows}`).join("|");if(this.brokenKey===i)return;this.brokenKey=i,this.brokenSelect=null;let a=this.doc;this.broken.textContent="",this.broken.append(l(a,"div","page-chart-broken-head","This chart's table was deleted"),l(a,"p","page-chart-broken-text","Pick another table in this document, or delete the chart. Undo brings the table back."));let r=l(a,"div","page-chart-broken-actions");if(s.length){let h=T(a,"rescue","Source table");for(let d of s)h.append(C(a,d.id,`${d.name} (${d.rows} ${d.rows===1?"row":"rows"})`));this.brokenSelect=h;let f=l(a,"button","page-chart-use","Use this table");f.type="button",f.dataset.action="use",r.append(h,f)}let c=l(a,"button","page-chart-delete","Delete chart");c.type="button",c.dataset.action="delete",r.append(c),this.broken.append(r)}brokenClick(t){let e=t.target.closest?.("button[data-action]");e&&(e.dataset.action==="delete"?this.removeChart():e.dataset.action==="use"&&this.switchSource(this.brokenSelect?.value??""))}openSoon(){let t=this.dom.ownerDocument.defaultView;(t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0)))(()=>{!this.view.isDestroyed&&this.dom.isConnected&&this.openPanel()})}renderHead(){let t=this.node.attrs,e=A(this.view.state.doc,t.source),s=!g(this.view.state.doc,t.source);this.title.textContent=t.title||it,this.title.classList.toggle("is-empty",!t.title),this.chipName.textContent=s?"No table":e??"",this.chip.disabled=s}setAttrs(t){let e=this.getPos();if(e==null)return;let s=this.view.state.doc.nodeAt(e);s?.type===p.nodes.chart&&this.view.dispatch(this.view.state.tr.setNodeMarkup(e,null,{...s.attrs,...t}))}row(t,...e){let s=l(this.doc,"div","page-chart-row");return t&&s.append(l(this.doc,"span","page-chart-label",t)),s.append(...e),s}panelKey(){let t=this.view.state.doc,e=E(t).map(s=>`${s.id}:${s.name}:${s.rows}`).join("|");return JSON.stringify([this.node.attrs,e,N(g(t,this.node.attrs.source))])}redrawPanel(){let t=this.doc.activeElement,e=t&&this.panel.contains(t)?t.dataset??{}:null,s=this.titleInput,i=s&&s.value!==this.renderedTitle?{value:s.value,start:s.selectionStart,end:s.selectionEnd}:null;if(this.renderPanel(),i&&this.titleInput&&(this.titleInput.value=i.value),!e)return;let a=[...this.panel.querySelectorAll("button, input, select")].find(r=>["field","kind","col","action"].every(c=>r.dataset[c]===e[c]));if(!a)return this.panel.focus();a.focus(),i&&a===this.titleInput&&a.setSelectionRange?.(i.start,i.end)}renderPanel(){let t=this.doc;this.renderedKey=this.panelKey(),this.renderedTitle=this.node.attrs.title??"";let e=this.node.attrs,s=N(this.source),i=s?.cols??[],a=s?.rows??[],r=e.kind==="pie";this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.textContent="";let c=l(t,"div","page-chart-types");for(let[o,P]of st){let b=l(t,"button","page-chart-type",P);b.type="button",b.dataset.kind=o,b.setAttribute("aria-pressed",String(e.kind===o)),c.append(b)}this.panel.append(this.row("Chart type",c));let h=T(t,"source","Source table");for(let o of E(this.view.state.doc))h.append(C(t,o.id,`${o.name} (${o.rows} ${o.rows===1?"row":"rows"})`,o.id===e.source));this.panel.append(this.row("Source table",h));let f=T(t,"labels","Labels column");for(let o of i)f.append(C(t,o.id,o.name||o.id,o.id===e.x));this.panel.append(this.row("Labels column",f));let d=l(t,"div","page-chart-values");i.filter(o=>o.id!==e.x).forEach((o,P)=>{let b=l(t,"label","page-chart-value"),v=l(t,"input");v.type="checkbox",v.dataset.field="series",v.dataset.col=o.id,v.checked=e.series.includes(o.id);let I=l(t,"span","page-chart-swatch");I.style.background=`var(--chart-${P%6+1})`,I.setAttribute("aria-hidden","true"),b.append(v,I,l(t,"span","page-chart-value-name",o.name||o.id)),d.append(b)});let w=this.row(r?"Value column":"Value columns",d);r&&w.append(l(t,"span","page-chart-hint","Pie charts plot the first value column across rows.")),this.panel.append(w);let m=T(t,"highlight","Highlight row");m.append(C(t,"","None",!e.highlight));for(let o of a)m.append(C(t,o.id,O(o.cells?.[e.x])||o.id,o.id===e.highlight));this.panel.append(this.row("Highlight row",m));let u=l(t,"input","page-chart-title-input");u.type="text",u.dataset.field="title",u.setAttribute("aria-label","Chart title"),u.value=e.title??"",u.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||o.key==="Enter"&&(o.preventDefault(),o.stopPropagation(),this.commitTitle())}),u.addEventListener("change",()=>this.commitTitle()),u.addEventListener("blur",()=>this.commitTitle()),this.titleInput=u,this.panel.append(this.row("Chart title",u));let H=l(t,"div","page-chart-foot"),k=l(t,"button","page-chart-remove");k.type="button",k.dataset.action="remove",k.innerHTML=et,k.append("Remove");let L=l(t,"button","page-chart-done","Done");L.type="button",L.dataset.action="done",H.append(k,L),this.panel.append(H),this.unsaved=K({id:"chart-title",isPending:()=>u.isConnected&&u.value!==(this.node.attrs.title??"")})}openPanel(){this.panel.isConnected||(this.renderPanel(),this.dom.append(this.panel),this.edit.setAttribute("aria-expanded","true"),this.panel.focus())}closePanel(t=!1){this.panel.isConnected&&(this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.remove(),this.edit.setAttribute("aria-expanded","false"),t&&this.edit.focus())}panelClick(t){let e=t.target.closest?.("button");e&&(e.dataset.action==="done"?(this.commitTitle(),this.closePanel(!0)):e.dataset.action==="remove"?this.removeChart():e.dataset.kind&&this.setAttrs({kind:e.dataset.kind}))}panelChange(t){let e=t.target;if(e?.dataset){if(e.dataset.field==="source")this.switchSource(e.value);else if(e.dataset.field==="labels")this.setAttrs({x:e.value,series:this.node.attrs.series.filter(s=>s!==e.value)});else if(e.dataset.field==="highlight")this.setAttrs({highlight:e.value||null});else if(e.dataset.field==="series"){let s=this.node.attrs.series.filter(i=>i!==e.dataset.col);this.setAttrs({series:e.checked?[...s,e.dataset.col]:s})}}}switchSource(t){let e=g(this.view.state.doc,t),s=e?at(e):null;s&&this.setAttrs({source:t,x:s.x,series:s.series})}commitTitle(){let t=this.titleInput;!t||t.value===(this.node.attrs.title??"")||this.setAttrs({title:t.value})}goToSource(){let t=this.view.state.doc,e=nt(t,this.node.attrs.source),s=e===null?null:t.nodeAt(e);if(!s?.childCount||!s.child(0).childCount)return;let i=e+3;this.view.dispatch(this.view.state.tr.setSelection(J.create(t,i)).scrollIntoView()),this.view.focus?.()}removeChart(){let t=this.getPos();if(t==null)return;let e=this.view.state.doc.nodeAt(t);if(e?.type!==p.nodes.chart)return;this.closePanel();let s=this.view.state.tr.delete(t,t+e.nodeSize);s.setSelection(J.near(s.doc.resolve(Math.min(t,s.doc.content.size)),-1)),this.view.dispatch(G(s).scrollIntoView())}update(t){if(t.type!==p.nodes.chart)return!1;let e=!t.sameMarkup(this.node);return this.node=t,this.dom.dataset.id=t.attrs.id??"",e&&(this.source=g(this.view.state.doc,t.attrs.source),this.renderHead(),this.schedule()),!0}stopEvent(t){return!!t.target.closest?.(".page-chart-head, .page-chart-panel")}destroy(){if(this.unsaved?.dispose(),this.unsaved=null,this.doc.removeEventListener("mousedown",this.outside,!0),this.doc.removeEventListener("keydown",this.escape,!0),S.get(this.view)?.delete(this),this.frame!==null){let t=this.dom.ownerDocument.defaultView;t.cancelAnimationFrame?t.cancelAnimationFrame(this.frame):t.clearTimeout(this.frame)}}};function vt(n){for(let t of S.get(n)??[])t.refresh()}export{wt as a,X as b,kt as c,Y as d,vt as e};
@@ -1 +1 @@
1
- import{c as A}from"./c-KBS3UV6B.js";import{j as b}from"./c-4FJTBE6I.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-CQQDL6O4.js";import"./c-ZGDYHKG3.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as x}from"./c-AIWN4QN4.js";import{b as h}from"./c-QIXT3Q7C.js";import"./c-WCXLG3MV.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-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 +1 @@
1
- import"./c-LKSL4AUJ.js";import{b as s,d as c,f as p,h as l}from"./c-EK63G3CG.js";import{f as i}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-WRBKEJD4.js";import"./c-VHNSBD2M.js";var u="page-format-activation-failed";function d(){let e=document.querySelector(`meta[name="${s}"]`);return e?p(e.outerHTML):0}var F=async e=>(await import("./core/save-A5JXV6ME.js")).savePageForce(()=>{},e),P=4,g=1e4,f=e=>e?.ok===!1&&e?.msgType==="skipped"&&/in progress/i.test(e?.msg??""),w=async()=>{let{isSaveInProgress:e}=await import("./core/save-core-MKRPSEEO.js"),r=Date.now()+g;for(;e()&&Date.now()<r;)await new Promise(n=>setTimeout(n,50))};function v({save:e=F,settles:r=w,supported:n=()=>i().then(a=>a===1)}={}){return{read(){return{floor:Math.max(l(),d()),revision:null}},capabilities(){return[]},supported:n,async activate({floor:a=1}={}){let t;try{t=await e({pageFormatFloor:a});for(let o=1;o<P&&f(t);o+=1)await r(),t=await e({pageFormatFloor:a})}catch(o){return{accepted:!1,code:o?.code??u}}return t?.ok?{accepted:!0,revision:null,receipt:t.receipt??t.etag??null}:t?.code===c?{accepted:!1,code:c}:{accepted:!1,code:t?.code??u}}}}export{v as createFormatHost};
1
+ import"./c-LKSL4AUJ.js";import{b as s,d as c,f as p,h as l}from"./c-EK63G3CG.js";import{f as i}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-WRBKEJD4.js";import"./c-VHNSBD2M.js";var u="page-format-activation-failed";function d(){let e=document.querySelector(`meta[name="${s}"]`);return e?p(e.outerHTML):0}var F=async e=>(await import("./core/save-AOJBDSOK.js")).savePageForce(()=>{},e),P=4,g=1e4,f=e=>e?.ok===!1&&e?.msgType==="skipped"&&/in progress/i.test(e?.msg??""),w=async()=>{let{isSaveInProgress:e}=await import("./core/save-core-IOCMXO5L.js"),r=Date.now()+g;for(;e()&&Date.now()<r;)await new Promise(n=>setTimeout(n,50))};function v({save:e=F,settles:r=w,supported:n=()=>i().then(a=>a===1)}={}){return{read(){return{floor:Math.max(l(),d()),revision:null}},capabilities(){return[]},supported:n,async activate({floor:a=1}={}){let t;try{t=await e({pageFormatFloor:a});for(let o=1;o<P&&f(t);o+=1)await r(),t=await e({pageFormatFloor:a})}catch(o){return{accepted:!1,code:o?.code??u}}return t?.ok?{accepted:!0,revision:null,receipt:t.receipt??t.etag??null}:t?.code===c?{accepted:!1,code:c}:{accepted:!1,code:t?.code??u}}}}export{v as createFormatHost};
@@ -1 +1 @@
1
- import{b as x}from"./c-L3F5ZLIV.js";import{a as T,d as h}from"./c-IW6GGOU2.js";import{b as y}from"./c-HAWFNBYG.js";import{n as d}from"./c-EXKHPOVC.js";import{na as s,qa as m,ra as p,sa as g}from"./c-QIXT3Q7C.js";import{a as c}from"./c-TCCA5BZN.js";import{q as f}from"./c-7MG5RU63.js";var v="article[data-page]",O=/^page(\.[0-9]+)?$/;function S(t){return[...t.querySelectorAll('script[merge][clay~="live"]')].filter(e=>O.test(e.getAttribute("merge")))}var i=null;function b(t){let e=t.join("\0");if(i&&i.key===e)return i;let r=t.map(l=>{try{return c(l)}catch{throw new d("invalid-json","Cannot read the page data as JSON")}}),n=x(r),o=s(n);return i={key:e,html:g(o,{fallbackOf:l=>{let u=n[l]?.artifact?.fallbackHtml;return typeof u=="string"?u:""},clean:p(document)}),rev:m(o),model:o,title:y(o)},i}function k(t){let e=t.querySelector(v);if(!e)return;let r=S(t);if(!r.length)return;let{html:n,rev:o,title:a}=b(r.map(l=>l.textContent));e.innerHTML!==n&&(e.innerHTML=n),e.setAttribute("data-rev",o),T(t)||h(t,a)}function A(t){let e=S(t);if(e.length!==1)return null;let r;try{r=c(e[0].textContent)}catch{return null}let{v:n,g:o,y:a}=r??{};return n!==1||!a||typeof a!="object"||Array.isArray(a)?null:{v:n,g:o,y:{...a}}}function M(t){return b([typeof t=="string"?t:JSON.stringify(t)]).html}function D(t){if(typeof t!="string")return null;try{let e=new DOMParser().parseFromString(t,"text/html"),r=A(e),n=e.querySelector(v);if(!r||!n)return null;let o=e.createElement("article");return o.innerHTML=M(r),n.innerHTML===o.innerHTML?r:null}catch{return null}}f(k);export{v as a,S as b,b as c,A as d,M as e,D as f};
1
+ import{b as x}from"./c-L3F5ZLIV.js";import{a as T,d as h}from"./c-IW6GGOU2.js";import{b as y}from"./c-HAWFNBYG.js";import{n as d}from"./c-EXKHPOVC.js";import{na as s,qa as m,ra as p,sa as g}from"./c-QIXT3Q7C.js";import{a as c}from"./c-TCCA5BZN.js";import{q as f}from"./c-EGTIAL6P.js";var v="article[data-page]",O=/^page(\.[0-9]+)?$/;function S(t){return[...t.querySelectorAll('script[merge][clay~="live"]')].filter(e=>O.test(e.getAttribute("merge")))}var i=null;function b(t){let e=t.join("\0");if(i&&i.key===e)return i;let r=t.map(l=>{try{return c(l)}catch{throw new d("invalid-json","Cannot read the page data as JSON")}}),n=x(r),o=s(n);return i={key:e,html:g(o,{fallbackOf:l=>{let u=n[l]?.artifact?.fallbackHtml;return typeof u=="string"?u:""},clean:p(document)}),rev:m(o),model:o,title:y(o)},i}function k(t){let e=t.querySelector(v);if(!e)return;let r=S(t);if(!r.length)return;let{html:n,rev:o,title:a}=b(r.map(l=>l.textContent));e.innerHTML!==n&&(e.innerHTML=n),e.setAttribute("data-rev",o),T(t)||h(t,a)}function A(t){let e=S(t);if(e.length!==1)return null;let r;try{r=c(e[0].textContent)}catch{return null}let{v:n,g:o,y:a}=r??{};return n!==1||!a||typeof a!="object"||Array.isArray(a)?null:{v:n,g:o,y:{...a}}}function M(t){return b([typeof t=="string"?t:JSON.stringify(t)]).html}function D(t){if(typeof t!="string")return null;try{let e=new DOMParser().parseFromString(t,"text/html"),r=A(e),n=e.querySelector(v);if(!r||!n)return null;let o=e.createElement("article");return o.innerHTML=M(r),n.innerHTML===o.innerHTML?r:null}catch{return null}}f(k);export{v as a,S as b,b as c,A as d,M as e,D as f};
@@ -1 +1 @@
1
- import{f as n}from"./c-TJAXGIRV.js";import{b as h,c as a}from"./c-BWFVSBDF.js";import{a as u}from"./c-5ZQV7KC4.js";import"./c-N326R2JD.js";import{b as T,g as _}from"./c-IVMD3FEM.js";import{b as p}from"./c-TNEM3RNM.js";import{b}from"./c-PLP4JKFC.js";import"./c-Q26MME6N.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-ZKNBMNN3.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-FWKHM4E7.js";import"./c-5JLFROUB.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import"./c-B7J4K2AE.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-7MG5RU63.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.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-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};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"./c-W23KVGUO.js";import"./c-BRLCTNMC.js";import"./c-QHWJ5ZIJ.js";import"./c-RG6XUZFA.js";import"./c-UL2YUY52.js";import"./c-QY7F6EN6.js";import"./c-CJFDLD43.js";import"./c-BJ7YQ5QZ.js";import"./c-4JZDZFF6.js";import"./c-VAK7SG37.js";import"./c-MHI3GYKF.js";import"./c-46XYM55L.js";import"./c-NUHP2XDB.js";import"./c-VKEDWYDF.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as ask,b as consent,e as init,d as snippet,c as tell};
@@ -0,0 +1 @@
1
+ import{e as a,f as b,g as c}from"./c-RQRMPZXD.js";import"./c-WN3MXOLT.js";import"./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";export{a as PresenceStore,c as default,b as presence};
@@ -1,4 +1,4 @@
1
- import{c as h}from"./c-GBKB5WDL.js";import{w as d}from"./c-4FJTBE6I.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-CQQDL6O4.js";import"./c-ZGDYHKG3.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-AIWN4QN4.js";import{m as p}from"./c-QIXT3Q7C.js";import{a as s}from"./c-BYTKL6UX.js";import"./c-WCXLG3MV.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var c=`
1
+ import{c as h}from"./c-GBKB5WDL.js";import{w as d}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"./c-44B5ODN7.js";import{m as p}from"./c-QIXT3Q7C.js";import{a as s}from"./c-BYTKL6UX.js";import"./c-E4IBSAQM.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var c=`
2
2
  .page-tool-block { position: relative; min-height: 48px; border: 1px solid var(--page-rule); border-radius: 8px; padding: 12px; }
3
3
  .page-tool-settings { position: absolute; top: 4px; inset-inline-end: 4px; border: 0; border-radius: 5px; background: var(--page-pop-bg); color: var(--page-ink-soft); font: 12px var(--page-font); padding: 5px 8px; cursor: pointer; opacity: 0; }
4
4
  .page-tool-block:hover .page-tool-settings, .page-tool-block:focus-within .page-tool-settings { opacity: 1; }
@@ -1,4 +1,4 @@
1
- import{b as F,c as M}from"./c-CQQDL6O4.js";import{B as N,d as $}from"./c-AIWN4QN4.js";import{G as U,J as A,k as X,l as Y,m as w}from"./c-QIXT3Q7C.js";import{b as P}from"./c-L7JL5TL3.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var k=5;function v(n){let u=0;for(let s=0;s<n.childCount;s++){let i=n.child(s);if(i.type===w.nodes.heading&&i.attrs.level===1&&i.attrs.parent==null)return{index:s,at:u,node:i};u+=i.nodeSize}return null}var O=`
1
+ import{b as F,c as M}from"./c-XQSXKIKM.js";import{B as N,d as $}from"./c-44B5ODN7.js";import{G as U,J as A,k as X,l as Y,m as w}from"./c-QIXT3Q7C.js";import{b as P}from"./c-QY7F6EN6.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var k=5;function v(n){let u=0;for(let s=0;s<n.childCount;s++){let i=n.child(s);if(i.type===w.nodes.heading&&i.attrs.level===1&&i.attrs.parent==null)return{index:s,at:u,node:i};u+=i.nodeSize}return null}var O=`
2
2
  :host{font:inherit !important;color:inherit !important}
3
3
  .page-cover-panel{display:flex;align-items:center;gap:8px;margin:8px 0;padding:6px 10px;border:1px solid var(--page-pop-line);border-radius:8px;background:var(--page-pop-bg);color:var(--page-pop-ink);box-shadow:var(--page-pop-shadow);font-size:.88em}
4
4
  .page-cover-msg{max-width:34ch}
@@ -1 +1 @@
1
- import{a as r}from"./c-WYFDLITL.js";import{a as p}from"./c-ZWIOJGMT.js";import{f as u}from"./c-3O7OBDCM.js";import{n as d,o as l}from"./c-DCFSEJZG.js";var n=0,g=0,c=!1,m=!1,y=!1,i=!1;function o(){!u||i||(i=!0,queueMicrotask(()=>{if(i=!1,typeof document>"u")return;let e=C();if(e===y)return;y=e;let t=document.documentElement;e?t.setAttribute("unsaved","true"):t.removeAttribute("unsaved"),document.dispatchEvent(new CustomEvent(e?"clay:dirty":"clay:clean"))}))}var T=`input${r}, textarea${r}, select${r}`,h=`${d}, ${l}`,a=new WeakMap;function v(){let e=[];for(let t of document.querySelectorAll(T))t.closest(h)||e.push(t);return e}function E(e){let t=e.target;!t||t.nodeType!==1||(t.matches("input, textarea, select")||t.isContentEditable)&&(t.closest(h)||(n++,o()))}function x(){m||(m=!0,p.onAnyChange({omitChangeDetails:!0,require:"dirty"},()=>{c||(n++,o())}),document.addEventListener("input",E,!0),document.addEventListener("change",E,!0))}function L(){c=!0}function k(){c=!1}function f(e){return e instanceof HTMLSelectElement?Array.from(e.selectedOptions,t=>t.value).join("\0"):e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?e.checked?"1":"0":e.value}function M(e){return e instanceof HTMLSelectElement?Array.from(e.options).every(t=>t.selected===t.defaultSelected):e instanceof HTMLInputElement?e.type==="checkbox"||e.type==="radio"?e.checked===e.defaultChecked:e.value===e.defaultValue:e instanceof HTMLTextAreaElement?e.hasAttribute("data-value")?e.value===e.getAttribute("data-value"):e.value===e.defaultValue:!0}function S(){for(let e of v()){let t=f(e);if(a.get(e)!==t){if(M(e)){a.set(e,t);continue}return!0}}return!1}function C(){return n>g||S()}function D(){return n}function O(){let e=[];for(let t of v())e.push([t,f(t)]);return{gen:n,probe:e}}function b(){n++,o()}function H(e){if(e){n===e.gen&&(g=e.gen);for(let[t,s]of e.probe)f(t)===s&&a.set(t,s);o()}}typeof document<"u"&&u&&x();typeof window<"u"&&(window.clay=window.clay||{},window.clay.markDirty=b);export{x as a,L as b,k as c,C as d,D as e,O as f,b as g,H as h};
1
+ import{a as r}from"./c-WYFDLITL.js";import{a as p}from"./c-LA2BW7UY.js";import{f as u}from"./c-3O7OBDCM.js";import{n as d,o as l}from"./c-ICMAOOGK.js";var n=0,g=0,c=!1,m=!1,y=!1,i=!1;function o(){!u||i||(i=!0,queueMicrotask(()=>{if(i=!1,typeof document>"u")return;let e=C();if(e===y)return;y=e;let t=document.documentElement;e?t.setAttribute("unsaved","true"):t.removeAttribute("unsaved"),document.dispatchEvent(new CustomEvent(e?"clay:dirty":"clay:clean"))}))}var T=`input${r}, textarea${r}, select${r}`,h=`${d}, ${l}`,a=new WeakMap;function v(){let e=[];for(let t of document.querySelectorAll(T))t.closest(h)||e.push(t);return e}function E(e){let t=e.target;!t||t.nodeType!==1||(t.matches("input, textarea, select")||t.isContentEditable)&&(t.closest(h)||(n++,o()))}function x(){m||(m=!0,p.onAnyChange({omitChangeDetails:!0,require:"dirty"},()=>{c||(n++,o())}),document.addEventListener("input",E,!0),document.addEventListener("change",E,!0))}function L(){c=!0}function k(){c=!1}function f(e){return e instanceof HTMLSelectElement?Array.from(e.selectedOptions,t=>t.value).join("\0"):e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?e.checked?"1":"0":e.value}function M(e){return e instanceof HTMLSelectElement?Array.from(e.options).every(t=>t.selected===t.defaultSelected):e instanceof HTMLInputElement?e.type==="checkbox"||e.type==="radio"?e.checked===e.defaultChecked:e.value===e.defaultValue:e instanceof HTMLTextAreaElement?e.hasAttribute("data-value")?e.value===e.getAttribute("data-value"):e.value===e.defaultValue:!0}function S(){for(let e of v()){let t=f(e);if(a.get(e)!==t){if(M(e)){a.set(e,t);continue}return!0}}return!1}function C(){return n>g||S()}function D(){return n}function O(){let e=[];for(let t of v())e.push([t,f(t)]);return{gen:n,probe:e}}function b(){n++,o()}function H(e){if(e){n===e.gen&&(g=e.gen);for(let[t,s]of e.probe)f(t)===s&&a.set(t,s);o()}}typeof document<"u"&&u&&x();typeof window<"u"&&(window.clay=window.clay||{},window.clay.markDirty=b);export{x as a,L as b,k as c,C as d,D as e,O as f,b as g,H as h};
@@ -1,3 +1,3 @@
1
- import{b as U}from"./c-ATKAOH23.js";import{a as oe,g as ie,h as C}from"./c-EK63G3CG.js";import{a as ne,b as re,c as M}from"./c-NQJRVJ56.js";import{d as w}from"./c-XGH4GS2T.js";import{c as V,e as q,g as Z}from"./c-IJUK2GPW.js";import{b as R,f as N}from"./c-3O7OBDCM.js";import{c as X}from"./c-BPF2NSPV.js";import{g as Y}from"./c-N7JPUPGC.js";import{a as k,g as Q,h as ee,i as te}from"./c-7MG5RU63.js";var D=null,ae=null,A=null;function we(e){let t=e?.document?.maxBytes;return Number.isSafeInteger(t)&&t>0?t:null}function se(e){return D=we(e),ae=e?.document?.maxBytesMeasures==="file"?"file":null,D}var Ae=/<script\b[^>]*\bmerge=(["'])page\1[^>]*>[\s\S]*?<\/script\s*>/i;function F(e,t=ae){if(t!=="file"||typeof e!="string")return e;let n=Ae.exec(e);if(!n)return e;let o=n.index,s=o+n[0].length,r=e.lastIndexOf(`
1
+ import{b as U}from"./c-ATKAOH23.js";import{a as oe,g as ie,h as C}from"./c-EK63G3CG.js";import{a as ne,b as re,c as M}from"./c-NQJRVJ56.js";import{d as w}from"./c-XGH4GS2T.js";import{c as V,e as q,g as Z}from"./c-IJUK2GPW.js";import{b as R,f as N}from"./c-3O7OBDCM.js";import{c as X}from"./c-BPF2NSPV.js";import{g as Y}from"./c-N7JPUPGC.js";import{a as k,g as Q,h as ee,i as te}from"./c-EGTIAL6P.js";var D=null,ae=null,A=null;function we(e){let t=e?.document?.maxBytes;return Number.isSafeInteger(t)&&t>0?t:null}function se(e){return D=we(e),ae=e?.document?.maxBytesMeasures==="file"?"file":null,D}var Ae=/<script\b[^>]*\bmerge=(["'])page\1[^>]*>[\s\S]*?<\/script\s*>/i;function F(e,t=ae){if(t!=="file"||typeof e!="string")return e;let n=Ae.exec(e);if(!n)return e;let o=n.index,s=o+n[0].length,r=e.lastIndexOf(`
2
2
  `,o-1)+1,l=e.indexOf(`
3
- `,s),c=l===-1?e.length:l+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function B(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function le(){return D}function P({fresh:e=!1}={}){return e?(A=w({fresh:!0}).then(se),A):(A||(A=w().then(se)),A)}function vt({fresh:e=!1}={}){return P({fresh:e}).then(t=>({maxBytes:t}))}async function yt(e){let t=await P();return B(F(e),t)}function ue(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-HT2DKBV2.js").then(n=>n.start(t),()=>{})}var L="/_/clayjs/",Te=/[\u0000-\u001F\u007F]/,be=/^[\t\n\f\r ]|[\t\n\f\r ]$/,Oe=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,Ee=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,ce=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,$e=/%2e|%2f|%5c/i;function Re(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function ke(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function Me(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Pe(e){if(e===""||e.includes("\\")||$e.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function T(e,{documentURL:t}={}){if(typeof e!="string"||e===""||be.test(e)||Te.test(e))return null;let{head:n,search:o,hash:s}=Me(e),r=null,l=null,c=null,u=null,i=Oe.exec(n);if(i&&(r="rolling",c=i[1],u=i[2]),r||(i=Ee.exec(n),i&&(r="exact",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4])),r||(i=ce.exec(n),i&&(r="local",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4])),!r){let d=ke(t);d&&n.startsWith(`${d}/`)&&(i=ce.exec(n.slice(d.length)),i&&(r="local",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4]))}if(!r)return null;let a=Pe(u);return a===null?null:{kind:r,major:c,version:l,rawPath:u,path:a,search:o,hash:s}}function Le(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function je(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function Ie(e,t,n){if(!n)return!0;let o=Le(n,t);return!!(o&&Object.hasOwn(o,e.path))}function fe(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=T(e,{documentURL:o});if(!r||r.kind!=="local")return e;let l=je(t),c=Re(r.version);for(let u of l){if(u.local!==e||typeof u.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,u.original)&&i[u.original]===r.path)return u.original;let a=T(u.original);if(a&&!(a.kind!=="rolling"&&a.kind!=="exact")&&a.rawPath===r.rawPath&&a.search===r.search&&a.hash===r.hash&&!(a.kind==="rolling"?a.major!==c:a.version!==r.version)&&Ie(r,r.version,n))return a.kind==="exact"?u.original:`https://clayjs.com/v${a.major}/${r.rawPath}${r.search}${r.hash}`}for(let u of l){if(typeof u.original!="string")continue;let i=T(u.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var _e=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),J="clay-runtime-map",Ne=new Set(["stylesheet","preload","modulepreload"]),de=null,H=null;function Ue(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Ce(){if(typeof document>"u")return null;let e=document.getElementById(J);if(!e)return null;let t=e.textContent??"";return t===de||(de=t,H=Ue(t)),H}var De=`script[src*="${L}"], link[href*="${L}"], #${J}`;function he(e){if(e.querySelector(De))return!0;for(let t of e.querySelectorAll("template"))if(he(t.content))return!0;return!1}function Fe(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function Be(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>Ne.has(n))?"href":null}function He(e){if(!e||!he(e))return;let t=[],n=!1;for(let r of Fe(e)){if(r.getAttribute("id")===J){r.remove();continue}let l=Be(r);l&&(t.push({element:r,name:l}),!n&&(r.getAttribute(l)??"").includes(L)&&(n=!0))}if(!n)return;let o=location.href,s=Ce();for(let{element:r,name:l}of t){let c=r.getAttribute(l),u=T(c,{documentURL:o});!u||u.kind!=="local"||r.setAttribute(l,fe(c,{descriptor:s,documentURL:o,aliases:_e}))}}te(He);var y=!1,E=null,pe="/_/save",ze=12e3,me=6e4,Ge=1024*1024,Se="text/plain;charset=UTF-8",j=null,$=!1,G=new Map;function Ft(e,t){t==null?G.delete(e):G.set(e,String(t))}async function Bt(e,t){$=!!e;try{return await t()}finally{$=!1}}function Ht(){return y}function Jt(){return y?null:(y=!0,E={reserved:!0},E)}function zt(e){!e||E!==e||(E=null,y=!1)}function Gt(){return $}var I=[],_=[];function Kt(e){return I.push(e),()=>{let t=I.indexOf(e);t>=0&&I.splice(t,1)}}function Wt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function Ke(e){for(let t of I)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function We(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ge(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null}}var b=[],Xe=8,v=null;function Xt(){return v!==null}function ve(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function Ye(e){b.push(e),b.length>Xe&&b.shift()}function Ve(e){return typeof e=="string"&&e!==""&&b.includes(e)}function Yt(){b.length=0,v=null}function K(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&v!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function O(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function qe(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...K(t),sent:!1,size:e}}var S=null;function Ze(e){return S?null:(S={kind:e},S)}function Qe(e){S===e&&(S=null)}function et(){return S?S.kind:null}function tt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var nt=3,rt=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function ot(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!rt.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var it=/^[0-9a-f]{64}$/,st=/^[A-Za-z0-9-]{1,64}$/;function at(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!it.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!st.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function lt(e,t,n,o,s,r=!1,l=null){let c=X(),u=c?`${pe}/${c}`:pe,i={method:"POST",credentials:c?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[oe]:String(1)},body:ut(e)};for(let[a,d]of G)i.headers[a]=d;return typeof i.body!="string"&&(i.headers["Content-Type"]=Se),l&&(i.headers["Page-Conversion"]=l),s&&(i.headers["If-Match"]=s),r&&e.length<me&&new Blob([e]).size<me&&(i.keepalive=!0),{url:ct(u),options:i}}function ut(e){if(e.length<Ge)return e;if(j&&j.content===e)return j.blob;let t=new Blob([e],{type:Se});return j={content:e,blob:t},t}function ye(){let e=ne();return re()&&e?e:null}function ct(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function z(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function ft(e){let t=Y();return t?Promise.resolve().then(()=>{try{return t(e),z(200,{msg:"Saved in this browser",msgType:"success"})}catch(n){return z(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:n.code||"draft-storage"})}}):Promise.resolve(z(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function dt(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[]}={}){let l=new AbortController,c=setTimeout(()=>l.abort(),ze),u=q(),i=Z(),a=u||i,d=$;$=!1;let{url:m,options:x}=lt(e,a,l.signal,t,n,d,s);return Ye(t),R||(r.some(f=>f.saveId===t&&f.etag===(n??null))||r.push({saveId:t,etag:n??null}),Ke({captureId:o,saveId:t,html:e,etag:n??null})),(R?ft(e):fetch(m,x)).then(f=>f.text().then(p=>{let h={};if(p)try{h=JSON.parse(p)}catch{if(f.ok)throw new Error("Server sent a response that was not JSON")}if(!f.ok){let g=new Error(h.msg||h.error||`HTTP ${f.status}: ${f.statusText}`);throw g.code=f.status===413?"save-too-large":h.code??null,g.status=f.status,g.changedBy=h.changedBy??null,g.etag=h.etag??null,g.saveId=h.saveId??null,g.reason=typeof h.reason=="string"?h.reason:null,g.saveOutcome=h.saveOutcome??null,g.retryAfter=ot(f.headers?.get?.("Retry-After")),g}return M(h.etag??null),v=null,h})).catch(f=>{throw console.error("Failed to save page:",f),f.name==="AbortError"&&(v={saveId:t,etag:n}),a&&V(),f}).finally(()=>{clearTimeout(c)})}async function ht(){let e=v;if(!e)return{landed:null,resend:!1};let n=(await w({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(M(o),v=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(v=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function pt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[]}={}){let s=ve(),r=ye(),l=!1,c=!1,u=0,i=t??k();for(;;)try{return await dt(e,s,r,{captureId:t,conversionHeader:n,attempts:o})}catch(a){if(l&&(a.hadTimeout=!0),a.name==="AbortError"){if(l)throw a;let{landed:d,resend:m,etag:x}=await ht();if(d)return d;if(!m)throw a;r=x,l=!0;continue}if(a.status===412&&!c&&Ve(a.saveId)){M(a.etag??null),v=null,s=ve(),r=ye(),c=!0;continue}if(a.code==="page-converting"&&u<nt){if(k()!==i||(u+=1,await new Promise(d=>setTimeout(d,Math.max(0,a.retryAfter??1)*1e3)),k()!==i))throw a;continue}throw a}}function W(e,t,n,o,s=null,r=0,l=null){return e=ie(e,Math.max(C(),r)),new Promise(c=>{let u=[],i=Q(s),a=()=>l!==null&&E===l,d=()=>{a()||(y=!1)},m=(p,h=!1)=>{h&&U(e,t??null,i),ee(s),We({captureId:t??null,result:p,attempts:u,sent:u.length>0}),typeof n=="function"&&n(p),c(p)};if(!N&&!window.clay?.testMode)return m(O("Not in edit mode"));if(y&&!a())return m(O("Save already in progress"));let x=at(o);if(x.invalid)return m(tt());if(y=!0,window.clay?.testMode){setTimeout(()=>{d(),m(ge({msg:"Test mode: save skipped"}))},0);return}P();let f=B(F(e),le());if(ue(f),f.state==="over")return d(),m(qe(f));pt(e,{captureId:t,conversionHeader:x.header,attempts:u}).then(ge,K).then(p=>{d(),p.code==="save-too-large"&&!p.size&&(p.size=f),p.ok&&U(e,t??null,i),m(p)})})}function mt(e,t=()=>{}){return W(e,null,t,null)}function Vt(e,t,n=()=>{},{conversion:o,capture:s=null,pageFormatFloor:r,lane:l=null}={}){return W(e,t,n,o,s,r,l)}function qt({html:e,captureId:t,conversion:n}){return W(e,t??null,void 0,n)}function Zt(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{Qe(o),typeof t=="function"&&t(r),n(r)};if(!N)return s(O("Not in edit mode"));if(et())return s(O("Another document operation is in progress"));if(y)return s(O("Save already in progress"));if(R)return s(!1);o=Ze("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>mt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(K(r))})})}var xe=null;function Qt(e){xe=e}function en(){return xe}export{P as a,vt as b,yt as c,Ft as d,Bt as e,Ht as f,Jt as g,zt as h,Gt as i,Kt as j,Wt as k,Xt as l,ve as m,Yt as n,Ze as o,Qe as p,et as q,lt as r,mt as s,Vt as t,qt as u,Zt as v,Qt as w,en as x};
3
+ `,s),c=l===-1?e.length:l+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function B(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function le(){return D}function P({fresh:e=!1}={}){return e?(A=w({fresh:!0}).then(se),A):(A||(A=w().then(se)),A)}function vt({fresh:e=!1}={}){return P({fresh:e}).then(t=>({maxBytes:t}))}async function yt(e){let t=await P();return B(F(e),t)}function ue(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-PIVIYLTY.js").then(n=>n.start(t),()=>{})}var L="/_/clayjs/",Te=/[\u0000-\u001F\u007F]/,be=/^[\t\n\f\r ]|[\t\n\f\r ]$/,Oe=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,Ee=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,ce=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,$e=/%2e|%2f|%5c/i;function Re(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function ke(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function Me(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Pe(e){if(e===""||e.includes("\\")||$e.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function T(e,{documentURL:t}={}){if(typeof e!="string"||e===""||be.test(e)||Te.test(e))return null;let{head:n,search:o,hash:s}=Me(e),r=null,l=null,c=null,u=null,i=Oe.exec(n);if(i&&(r="rolling",c=i[1],u=i[2]),r||(i=Ee.exec(n),i&&(r="exact",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4])),r||(i=ce.exec(n),i&&(r="local",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4])),!r){let d=ke(t);d&&n.startsWith(`${d}/`)&&(i=ce.exec(n.slice(d.length)),i&&(r="local",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4]))}if(!r)return null;let a=Pe(u);return a===null?null:{kind:r,major:c,version:l,rawPath:u,path:a,search:o,hash:s}}function Le(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function je(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function Ie(e,t,n){if(!n)return!0;let o=Le(n,t);return!!(o&&Object.hasOwn(o,e.path))}function fe(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=T(e,{documentURL:o});if(!r||r.kind!=="local")return e;let l=je(t),c=Re(r.version);for(let u of l){if(u.local!==e||typeof u.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,u.original)&&i[u.original]===r.path)return u.original;let a=T(u.original);if(a&&!(a.kind!=="rolling"&&a.kind!=="exact")&&a.rawPath===r.rawPath&&a.search===r.search&&a.hash===r.hash&&!(a.kind==="rolling"?a.major!==c:a.version!==r.version)&&Ie(r,r.version,n))return a.kind==="exact"?u.original:`https://clayjs.com/v${a.major}/${r.rawPath}${r.search}${r.hash}`}for(let u of l){if(typeof u.original!="string")continue;let i=T(u.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var _e=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),J="clay-runtime-map",Ne=new Set(["stylesheet","preload","modulepreload"]),de=null,H=null;function Ue(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Ce(){if(typeof document>"u")return null;let e=document.getElementById(J);if(!e)return null;let t=e.textContent??"";return t===de||(de=t,H=Ue(t)),H}var De=`script[src*="${L}"], link[href*="${L}"], #${J}`;function he(e){if(e.querySelector(De))return!0;for(let t of e.querySelectorAll("template"))if(he(t.content))return!0;return!1}function Fe(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function Be(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>Ne.has(n))?"href":null}function He(e){if(!e||!he(e))return;let t=[],n=!1;for(let r of Fe(e)){if(r.getAttribute("id")===J){r.remove();continue}let l=Be(r);l&&(t.push({element:r,name:l}),!n&&(r.getAttribute(l)??"").includes(L)&&(n=!0))}if(!n)return;let o=location.href,s=Ce();for(let{element:r,name:l}of t){let c=r.getAttribute(l),u=T(c,{documentURL:o});!u||u.kind!=="local"||r.setAttribute(l,fe(c,{descriptor:s,documentURL:o,aliases:_e}))}}te(He);var y=!1,E=null,pe="/_/save",ze=12e3,me=6e4,Ge=1024*1024,Se="text/plain;charset=UTF-8",j=null,$=!1,G=new Map;function Ft(e,t){t==null?G.delete(e):G.set(e,String(t))}async function Bt(e,t){$=!!e;try{return await t()}finally{$=!1}}function Ht(){return y}function Jt(){return y?null:(y=!0,E={reserved:!0},E)}function zt(e){!e||E!==e||(E=null,y=!1)}function Gt(){return $}var I=[],_=[];function Kt(e){return I.push(e),()=>{let t=I.indexOf(e);t>=0&&I.splice(t,1)}}function Wt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function Ke(e){for(let t of I)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function We(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ge(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null}}var b=[],Xe=8,v=null;function Xt(){return v!==null}function ve(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function Ye(e){b.push(e),b.length>Xe&&b.shift()}function Ve(e){return typeof e=="string"&&e!==""&&b.includes(e)}function Yt(){b.length=0,v=null}function K(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&v!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function O(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function qe(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...K(t),sent:!1,size:e}}var S=null;function Ze(e){return S?null:(S={kind:e},S)}function Qe(e){S===e&&(S=null)}function et(){return S?S.kind:null}function tt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var nt=3,rt=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function ot(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!rt.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var it=/^[0-9a-f]{64}$/,st=/^[A-Za-z0-9-]{1,64}$/;function at(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!it.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!st.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function lt(e,t,n,o,s,r=!1,l=null){let c=X(),u=c?`${pe}/${c}`:pe,i={method:"POST",credentials:c?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[oe]:String(1)},body:ut(e)};for(let[a,d]of G)i.headers[a]=d;return typeof i.body!="string"&&(i.headers["Content-Type"]=Se),l&&(i.headers["Page-Conversion"]=l),s&&(i.headers["If-Match"]=s),r&&e.length<me&&new Blob([e]).size<me&&(i.keepalive=!0),{url:ct(u),options:i}}function ut(e){if(e.length<Ge)return e;if(j&&j.content===e)return j.blob;let t=new Blob([e],{type:Se});return j={content:e,blob:t},t}function ye(){let e=ne();return re()&&e?e:null}function ct(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function z(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function ft(e){let t=Y();return t?Promise.resolve().then(()=>{try{return t(e),z(200,{msg:"Saved in this browser",msgType:"success"})}catch(n){return z(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:n.code||"draft-storage"})}}):Promise.resolve(z(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function dt(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[]}={}){let l=new AbortController,c=setTimeout(()=>l.abort(),ze),u=q(),i=Z(),a=u||i,d=$;$=!1;let{url:m,options:x}=lt(e,a,l.signal,t,n,d,s);return Ye(t),R||(r.some(f=>f.saveId===t&&f.etag===(n??null))||r.push({saveId:t,etag:n??null}),Ke({captureId:o,saveId:t,html:e,etag:n??null})),(R?ft(e):fetch(m,x)).then(f=>f.text().then(p=>{let h={};if(p)try{h=JSON.parse(p)}catch{if(f.ok)throw new Error("Server sent a response that was not JSON")}if(!f.ok){let g=new Error(h.msg||h.error||`HTTP ${f.status}: ${f.statusText}`);throw g.code=f.status===413?"save-too-large":h.code??null,g.status=f.status,g.changedBy=h.changedBy??null,g.etag=h.etag??null,g.saveId=h.saveId??null,g.reason=typeof h.reason=="string"?h.reason:null,g.saveOutcome=h.saveOutcome??null,g.retryAfter=ot(f.headers?.get?.("Retry-After")),g}return M(h.etag??null),v=null,h})).catch(f=>{throw console.error("Failed to save page:",f),f.name==="AbortError"&&(v={saveId:t,etag:n}),a&&V(),f}).finally(()=>{clearTimeout(c)})}async function ht(){let e=v;if(!e)return{landed:null,resend:!1};let n=(await w({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(M(o),v=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(v=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function pt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[]}={}){let s=ve(),r=ye(),l=!1,c=!1,u=0,i=t??k();for(;;)try{return await dt(e,s,r,{captureId:t,conversionHeader:n,attempts:o})}catch(a){if(l&&(a.hadTimeout=!0),a.name==="AbortError"){if(l)throw a;let{landed:d,resend:m,etag:x}=await ht();if(d)return d;if(!m)throw a;r=x,l=!0;continue}if(a.status===412&&!c&&Ve(a.saveId)){M(a.etag??null),v=null,s=ve(),r=ye(),c=!0;continue}if(a.code==="page-converting"&&u<nt){if(k()!==i||(u+=1,await new Promise(d=>setTimeout(d,Math.max(0,a.retryAfter??1)*1e3)),k()!==i))throw a;continue}throw a}}function W(e,t,n,o,s=null,r=0,l=null){return e=ie(e,Math.max(C(),r)),new Promise(c=>{let u=[],i=Q(s),a=()=>l!==null&&E===l,d=()=>{a()||(y=!1)},m=(p,h=!1)=>{h&&U(e,t??null,i),ee(s),We({captureId:t??null,result:p,attempts:u,sent:u.length>0}),typeof n=="function"&&n(p),c(p)};if(!N&&!window.clay?.testMode)return m(O("Not in edit mode"));if(y&&!a())return m(O("Save already in progress"));let x=at(o);if(x.invalid)return m(tt());if(y=!0,window.clay?.testMode){setTimeout(()=>{d(),m(ge({msg:"Test mode: save skipped"}))},0);return}P();let f=B(F(e),le());if(ue(f),f.state==="over")return d(),m(qe(f));pt(e,{captureId:t,conversionHeader:x.header,attempts:u}).then(ge,K).then(p=>{d(),p.code==="save-too-large"&&!p.size&&(p.size=f),p.ok&&U(e,t??null,i),m(p)})})}function mt(e,t=()=>{}){return W(e,null,t,null)}function Vt(e,t,n=()=>{},{conversion:o,capture:s=null,pageFormatFloor:r,lane:l=null}={}){return W(e,t,n,o,s,r,l)}function qt({html:e,captureId:t,conversion:n}){return W(e,t??null,void 0,n)}function Zt(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{Qe(o),typeof t=="function"&&t(r),n(r)};if(!N)return s(O("Not in edit mode"));if(et())return s(O("Another document operation is in progress"));if(y)return s(O("Save already in progress"));if(R)return s(!1);o=Ze("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>mt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(K(r))})})}var xe=null;function Qt(e){xe=e}function en(){return xe}export{P as a,vt as b,yt as c,Ft as d,Bt as e,Ht as f,Jt as g,zt as h,Gt as i,Kt as j,Wt as k,Xt as l,ve as m,Yt as n,Ze as o,Qe as p,et as q,lt as r,mt as s,Vt as t,qt as u,Zt as v,Qt as w,en as x};
@@ -1,4 +1,4 @@
1
- var e={light:[255,252,246],dark:[26,29,44],mutedLight:[107,89,66],mutedDark:[163,169,194]},a=`.clay-menu-dock, .clay-menu-spots, .clay-seo {
1
+ var r={light:[255,252,246],dark:[26,29,44],mutedLight:[107,89,66],mutedDark:[163,169,194]},e=`.clay-menu-dock, .clay-menu-spots, .clay-seo {
2
2
  --bevel-font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
3
3
  --bevel-font-serif: Newsreader, Georgia, "Times New Roman", serif;
4
4
  --bevel-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
@@ -35,19 +35,11 @@ var e={light:[255,252,246],dark:[26,29,44],mutedLight:[107,89,66],mutedDark:[163
35
35
  text-size-adjust: 100%;
36
36
  }
37
37
 
38
- /* The dock: the roster (when a page opts in) and the capsule, fixed in one corner. */
39
- .clay-menu-dock { position: fixed; z-index: 2147482000; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 1.4; }
40
- .clay-menu-dock[data-corner$="left"] { right: auto; left: max(12px, env(safe-area-inset-left)); flex-direction: row-reverse; }
41
- .clay-menu-dock[data-corner^="bottom"] { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); }
38
+ .clay-menu-dock { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 1.4; }
39
+ .clay-menu-dock[data-embedded] { position: relative; display: inline-flex; }
42
40
  .clay-menu-dock[hidden], .clay-menu-spots[hidden], .clay-menu-dock [hidden], .clay-seo [hidden] { display: none !important; }
43
41
 
44
- .clay-menu { box-sizing: border-box; display: inline-flex; align-items: center; gap: 2px; height: 34px; padding: 0 4px 0 2px; border: 1px solid var(--bevel-line-3); background: var(--bevel-surface); box-shadow: var(--clay-shadow); user-select: none; -webkit-user-select: none; }
45
- .clay-menu-dock[data-dragging] .clay-menu { border-color: var(--bevel-brass); cursor: grabbing; }
46
-
47
- .clay-menu-grip { position: relative; display: inline-grid; place-items: center; width: 18px; height: 28px; margin: 0; padding: 0; border: 0; background: none; color: var(--bevel-faint); cursor: grab; touch-action: none; }
48
- .clay-menu-grip::before { content: ""; position: absolute; inset: -8px -2px -8px -10px; }
49
- .clay-menu-grip:hover { color: var(--bevel-ink-2); }
50
- .clay-menu-grip svg { display: block; width: 6px; height: 12px; fill: currentColor; }
42
+ .clay-menu { box-sizing: border-box; display: inline-flex; align-items: center; gap: 2px; user-select: none; -webkit-user-select: none; }
51
43
 
52
44
  .clay-menu-edit { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 28px; margin: 0; padding: 0 8px 0 5px; border: 0; background: none; font: 500 13px/1 var(--bevel-font-sans); color: var(--bevel-ink); cursor: pointer; }
53
45
  .clay-menu-edit::before { content: ""; position: absolute; inset: -8px 0; }
@@ -63,12 +55,8 @@ var e={light:[255,252,246],dark:[26,29,44],mutedLight:[107,89,66],mutedDark:[163
63
55
 
64
56
  .clay-menu-divider { width: 1px; height: 18px; margin: 0 2px; background: var(--bevel-line-2); }
65
57
 
66
- .clay-menu-goo { position: relative; display: inline-grid; place-items: center; box-sizing: border-box; width: 28px; height: 28px; min-height: 0; border-radius: 0; margin: 0; padding: 0; border: 2px solid transparent; background: none; color: var(--bevel-ink); cursor: pointer; }
67
- .clay-menu-goo::before { content: ""; position: absolute; inset: -8px -8px -8px -4px; }
68
- .clay-menu-goo svg { display: block; width: 18px; height: auto; fill: currentColor; }
69
- .clay-menu-goo:hover svg { translate: 0 -1px; }
70
- .clay-menu-goo:active, .clay-menu-goo[aria-expanded="true"] { background: var(--bevel-face-in); border-color: var(--bevel-edge-in) var(--bevel-edge-in-hi) var(--bevel-edge-in-hi) var(--bevel-edge-in); }
71
- .clay-menu-goo:active svg, .clay-menu-goo[aria-expanded="true"] svg { translate: 1px 1px; }
58
+ .clay-menu-goo { position: relative; display: inline-grid; place-items: center; box-sizing: border-box; margin: 0; padding: 0; cursor: pointer; }
59
+ .clay-menu-goo svg { display: block; }
72
60
  .clay-menu-dot { position: absolute; top: -1px; right: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--bevel-brass); box-shadow: 0 0 0 2px var(--bevel-surface); }
73
61
 
74
62
  .clay-menu :focus-visible, .clay-roster:focus-visible { outline: 2px solid var(--bevel-brass); outline-offset: 2px; }
@@ -93,22 +81,24 @@ var e={light:[255,252,246],dark:[26,29,44],mutedLight:[107,89,66],mutedDark:[163
93
81
  .clay-avatar[data-tone="teal"] { background: var(--bevel-teal-soft); color: var(--bevel-teal); border-color: color-mix(in srgb, var(--bevel-teal) 35%, var(--bevel-teal-soft)); }
94
82
 
95
83
  /* Popovers: the menu, the people panel, the status note. Below the dock, above it in a bottom corner. */
96
- .clay-menu-list, .clay-people, .clay-menu-note { position: absolute; z-index: 1; top: calc(100% + 8px); right: 0; box-sizing: border-box; margin: 0; border: 1px solid var(--bevel-line-2); background: var(--bevel-surface); box-shadow: var(--clay-shadow); color: var(--bevel-ink); text-align: left; }
97
- .clay-menu-dock[data-corner$="left"] :is(.clay-menu-list, .clay-people, .clay-menu-note) { right: auto; left: 0; }
98
- .clay-menu-dock[data-corner^="bottom"] :is(.clay-menu-list, .clay-people, .clay-menu-note) { top: auto; bottom: calc(100% + 8px); }
84
+ .clay-menu-list, .clay-people, .clay-menu-note { position: absolute; z-index: 1; top: calc(100% + 8px); right: 0; box-sizing: border-box; margin: 0; color: var(--bevel-ink); text-align: left; }
85
+ .clay-people, .clay-menu-note { border: 1px solid var(--bevel-line-2); background: var(--bevel-surface); box-shadow: var(--clay-shadow); }
99
86
 
100
- .clay-menu-list { width: max-content; min-width: 284px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 72px); overflow-y: auto; overscroll-behavior: contain; padding: 6px; }
101
- .clay-menu-list [role="menuitem"] { box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 32px; margin: 0; padding: 5px 9px; border: 0; background: none; font: 400 13px/1.35 var(--bevel-font-sans); color: var(--bevel-ink); text-align: left; text-decoration: none; cursor: pointer; }
87
+ .clay-menu-list { width: max-content; max-width: calc(100vw - 24px); max-height: calc(100dvh - 72px); overflow-y: auto; overscroll-behavior: contain; }
88
+ .clay-menu-list[popover] { position: fixed; inset: auto; margin: 0; }
89
+ .clay-menu-list [role="menuitem"] { box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin: 0; border: 0; background: none; text-align: left; text-decoration: none; cursor: pointer; }
102
90
  .clay-menu-list [role="menuitem"]:hover:not([aria-disabled="true"]), .clay-menu-list [role="menuitem"]:focus-visible { outline: none; background: var(--bevel-sunk); }
103
- .clay-menu-list [role="menuitem"][aria-disabled="true"] { color: var(--bevel-faint); cursor: default; }
104
- .clay-menu-list [role="menuitem"][aria-disabled="true"] kbd { opacity: .6; }
91
+ .clay-menu-list [role="menuitem"][aria-disabled="true"] { cursor: default; }
105
92
  .clay-menu-pair { display: flex; gap: 12px; padding: 3px 9px; }
106
- .clay-menu-list .clay-menu-pair [role="menuitem"] { flex: none; width: auto; min-height: 30px; justify-content: flex-start; gap: 9px; padding: 4px 6px 4px 9px; border: 1px solid var(--bevel-line); }
107
- .clay-menu-list kbd { flex: none; font: 500 11px/1 var(--bevel-font-mono); padding: 3px 5px; border: 1px solid var(--bevel-line-2); background: var(--bevel-sunk); color: var(--bevel-muted); white-space: nowrap; }
108
- .clay-menu-sep { height: 1px; margin: 4px 2px; background: var(--bevel-line); }
93
+ .clay-menu-list .clay-menu-pair [role="menuitem"] { flex: none; width: auto; justify-content: flex-start; gap: 9px; }
94
+ .clay-menu-list kbd { flex: none; white-space: nowrap; }
95
+ .clay-menu-row { display: flex; align-items: center; gap: 2px; }
96
+ .clay-menu-list .clay-menu-row > [part~="item"] { flex: 1; width: auto; min-width: 0; }
97
+ .clay-menu-list .clay-menu-row > [part~="dismiss"] { flex: none; width: 28px; justify-content: center; padding: 0; }
98
+ .clay-menu-row > [part~="dismiss"] svg { display: block; width: 10px; height: 10px; fill: currentColor; }
109
99
  .clay-menu-upgrade { display: inline-flex; align-items: center; gap: 8px; }
110
100
  .clay-menu-upgrade::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--bevel-brass); }
111
- .clay-menu-version { margin: 0; padding: 6px 9px 4px; font: 400 11.5px/1.4 var(--bevel-font-mono); color: var(--bevel-muted); }
101
+ .clay-menu-version { margin: 0; }
112
102
 
113
103
  .clay-menu-note { z-index: 2; width: max-content; max-width: 264px; padding: 8px 12px; font-size: 13px; line-height: 1.45; }
114
104
 
@@ -144,6 +134,17 @@ var e={light:[255,252,246],dark:[26,29,44],mutedLight:[107,89,66],mutedDark:[163
144
134
  .clay-menu-btn-small { height: 26px; padding: 0 9px; font-size: 12px; }
145
135
  .clay-menu-btn-primary { --bevel-face: var(--bevel-ink); --bevel-edge-hi: color-mix(in srgb, var(--bevel-ink), light-dark(#FFFCF6, #FFFFFF) 22%); --bevel-edge-lo: color-mix(in srgb, var(--bevel-ink), light-dark(#0B0C13, #6A7090) 34%); color: var(--bevel-ground); }
146
136
  .clay-menu-btn-primary:hover { background: color-mix(in srgb, var(--bevel-ink), var(--bevel-ground) 12%); }
137
+ `,a=`/* The dock: the roster (when a page opts in) and the capsule, fixed in one corner. */
138
+ .clay-menu-dock { position: fixed; z-index: 2147482000; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
139
+ .clay-menu-dock[data-corner$="left"] { right: auto; left: max(12px, env(safe-area-inset-left)); flex-direction: row-reverse; }
140
+ .clay-menu-dock[data-corner^="bottom"] { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); }
141
+ .clay-menu-dock[data-corner$="left"] :is(.clay-menu-list, .clay-people, .clay-menu-note) { right: auto; left: 0; }
142
+ .clay-menu-dock[data-corner^="bottom"] :is(.clay-menu-list, .clay-people, .clay-menu-note) { top: auto; bottom: calc(100% + 8px); }
143
+ .clay-menu-dock[data-dragging] .clay-menu { border-color: var(--bevel-brass); cursor: grabbing; }
144
+ .clay-menu-grip { position: relative; display: inline-grid; place-items: center; width: 18px; height: 28px; margin: 0; padding: 0; border: 0; background: none; color: var(--bevel-faint); cursor: grab; touch-action: none; }
145
+ .clay-menu-grip::before { content: ""; position: absolute; inset: -8px -2px -8px -10px; }
146
+ .clay-menu-grip:hover { color: var(--bevel-ink-2); }
147
+ .clay-menu-grip svg { display: block; width: 6px; height: 12px; fill: currentColor; }
147
148
 
148
149
  /* Drop spots while dragging. */
149
150
  .clay-menu-spots { position: fixed; inset: 0; z-index: 2147481999; pointer-events: none; }
@@ -153,8 +154,23 @@ var e={light:[255,252,246],dark:[26,29,44],mutedLight:[107,89,66],mutedDark:[163
153
154
  .clay-menu-spot[data-to$="left"] { left: 12px; }
154
155
  .clay-menu-spot[data-to$="right"] { right: 12px; }
155
156
  .clay-menu-spot[data-near] { border: 2px solid var(--bevel-brass); background: var(--bevel-brass-soft); }
156
-
157
- @media (pointer: coarse), (max-width: 680px) {
157
+ `,l=`.clay-menu { height: 34px; padding: 0 4px 0 2px; border: 1px solid var(--bevel-line-3); background: var(--bevel-surface); box-shadow: var(--clay-shadow); }
158
+ .clay-menu-goo { width: 28px; height: 28px; min-height: 0; border-radius: 0; border: 2px solid transparent; background: none; color: var(--bevel-ink); }
159
+ .clay-menu-goo::before { content: ""; position: absolute; inset: -8px -8px -8px -4px; }
160
+ .clay-menu-goo svg { width: 18px; height: auto; fill: currentColor; }
161
+ .clay-menu-goo:hover svg { translate: 0 -1px; }
162
+ .clay-menu-goo:active, .clay-menu-goo[aria-expanded="true"] { background: var(--bevel-face-in); border-color: var(--bevel-edge-in) var(--bevel-edge-in-hi) var(--bevel-edge-in-hi) var(--bevel-edge-in); }
163
+ .clay-menu-goo:active svg, .clay-menu-goo[aria-expanded="true"] svg { translate: 1px 1px; }
164
+ .clay-menu-list { min-width: 284px; padding: 6px; border: 1px solid var(--bevel-line-2); background: var(--bevel-surface); box-shadow: var(--clay-shadow); }
165
+ .clay-menu-list [role="menuitem"] { min-height: 32px; padding: 5px 9px; font: 400 13px/1.35 var(--bevel-font-sans); color: var(--bevel-ink); }
166
+ .clay-menu-list [role="menuitem"][aria-disabled="true"] { color: var(--bevel-faint); }
167
+ .clay-menu-list [role="menuitem"][aria-disabled="true"] kbd { opacity: .6; }
168
+ .clay-menu-list .clay-menu-pair [role="menuitem"] { min-height: 30px; padding: 4px 6px 4px 9px; border: 1px solid var(--bevel-line); }
169
+ .clay-menu-list kbd { font: 500 11px/1 var(--bevel-font-mono); padding: 3px 5px; border: 1px solid var(--bevel-line-2); background: var(--bevel-sunk); color: var(--bevel-muted); }
170
+ .clay-menu-list [part~="quiet"] { font-size: 12px; color: var(--bevel-muted); }
171
+ .clay-menu-sep { height: 1px; margin: 4px 2px; background: var(--bevel-line); }
172
+ .clay-menu-version { padding: 6px 9px 4px; font: 400 11.5px/1.4 var(--bevel-font-mono); color: var(--bevel-muted); }
173
+ `,o=`@media (pointer: coarse), (max-width: 680px) {
158
174
  .clay-menu-list [role="menuitem"] { min-height: 44px; font-size: 15px; }
159
175
  .clay-menu-list .clay-menu-pair [role="menuitem"] { min-height: 44px; }
160
176
  :is(.clay-menu-dock, .clay-seo) :is(input, textarea, select) { font-size: 16px; }
@@ -163,4 +179,5 @@ var e={light:[255,252,246],dark:[26,29,44],mutedLight:[107,89,66],mutedDark:[163
163
179
  }
164
180
  @media (prefers-reduced-motion: reduce) {
165
181
  .clay-menu-track, .clay-menu-thumb { transition: none; }
166
- }`;export{e as a,a as b};
182
+ }
183
+ `,i=e+a+l+o;export{r as a,e as b,a as c,l as d,o as e,i as f};
@@ -1 +1 @@
1
- import{d as A,e as I}from"./c-XGH4GS2T.js";import{f as b,j as T}from"./c-3O7OBDCM.js";import{c as M}from"./c-BPF2NSPV.js";var B=15e3,P=12e4,K=15e3,V=4e3,W=5e3,U=50,y=new Set(["sent","acked"]),R=new Set(["done","error","cancelled"]),j="wire",i=new Map,k=new Set,f=null,g=null,D=0,h=null;function Q(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`page-${Date.now()}-${Math.random().toString(16).slice(2)}`}function H(e){return new URL(e,window.location.origin).href}function N(){let e=M();return typeof e=="string"&&e!==""?e:null}function w(e){return{id:e.id,type:e.type,state:e.state,helper:e.helper,text:e.text,result:e.result,error:e.error,errorCode:e.errorCode,errorDetails:e.errorDetails,errorSource:e.errorSource,startedAt:e.startedAt}}function m(e,t){let n=w(e);for(let r of k)try{r(n,t||null)}catch(s){console.error("clay.wire: a listener threw",s)}document.dispatchEvent(new CustomEvent("clay:wire-state",{detail:n}))}function Y(e,t){e.state!==t&&(e.state=t,m(e))}function v(e,t,n,{cancelFirst:r=!1,errorCode:s=null}={}){clearTimeout(e.timer),e.timer=setTimeout(()=>{e.timer=null,r&&z(e),l(e,"error",n,{errorCode:s,errorSource:"client"})},t)}function q(e){clearTimeout(e.timer),e.timer=null}function Z(){if(!(i.size<=U))for(let[e,t]of i){if(i.size<=U)break;!y.has(t.state)&&t.state!=="landing"&&i.delete(e)}}function ee(){if(g)return g;let e=N(),t=`/_/wire/subscribe?page-url=${encodeURIComponent(window.location.href)}`+(e?`&token=${encodeURIComponent(e)}`:"");return f=new EventSource(H(t)),f.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch{return}te(r)},f.onerror=()=>{},g=new Promise(n=>{let r=!1,s=()=>{r||(r=!0,n())};f.onopen=s,setTimeout(s,2e3)}),g}function L(){for(let e of i.values())if(y.has(e.state))return;f&&(f.close(),f=null,g=null)}function te(e){if(!e||typeof e.id!="string")return;let t=i.get(e.id);if(!(!t||!y.has(t.state)))switch(e.type){case"wire/ack":e.payload?.mode==="jsonl"&&Number.isFinite(e.payload.budgetMs)&&e.payload.budgetMs>0?(t.structured=!0,v(t,e.payload.budgetMs+K,"the helper did not finish within its execution budget",{cancelFirst:!0,errorCode:"helper_timeout"})):v(t,P,"the agent stopped responding"),Y(t,"acked");break;case"wire/status":t.structured||v(t,P,"the agent stopped responding"),t.text=typeof e.text=="string"?e.text:"",t.state="acked",ne(t,e),m(t,e);break;case"wire/done":t.result=Object.prototype.hasOwnProperty.call(e,"payload")?e.payload:null,t.document==="edit"?ae(t):l(t,"done",null);break;case"wire/error":re(t,e);break;default:break}}function ne(e,t){if(!e.onStatus||typeof t.text!="string")return;let n={text:t.text};t.payload&&typeof t.payload=="object"&&Object.prototype.hasOwnProperty.call(t.payload,"progress")&&(n.progress=t.payload.progress);try{e.onStatus(n)}catch(r){console.error("clay.wire: an onStatus listener threw",r)}}function re(e,t){let n=t.payload,r=n&&typeof n=="object"&&!Array.isArray(n)&&(n.source==="application"||n.source==="host")&&typeof n.code=="string"&&n.code,s=typeof t.text=="string"&&t.text?t.text:"the handler reported an error";if(!r){l(e,"error",s);return}let a=n.source==="host"&&n.code==="helper_cancelled"?"cancelled":"error";l(e,a,s,{errorCode:n.code,errorDetails:Object.prototype.hasOwnProperty.call(n,"details")?n.details:null,errorSource:n.source})}function oe(){h||(h=e=>{if(e.detail?.source!=="peer"){for(let t of i.values())if(t.state==="landing"){l(t,"done",null);return}}},document.addEventListener("clay:sync-applied",h))}function se(){D>0||!h||(document.removeEventListener("clay:sync-applied",h),h=null)}function ae(e){R.has(e.state)||e.state==="landing"||(q(e),e.state="landing",D++,oe(),e.landingTimer=setTimeout(()=>{l(e,"done",null)},V),m(e),L())}function l(e,t,n,r={}){if(R.has(e.state))return;let s=e.state==="landing";if(q(e),clearTimeout(e.landingTimer),e.landingTimer=null,e.abort?.abort(),s&&(D--,se()),e.error=n,Object.prototype.hasOwnProperty.call(r,"errorCode")&&(e.errorCode=r.errorCode),Object.prototype.hasOwnProperty.call(r,"errorDetails")&&(e.errorDetails=r.errorDetails),Object.prototype.hasOwnProperty.call(r,"errorSource")&&(e.errorSource=r.errorSource),e.state=t,e.signal&&e.signalHandler&&(e.signal.removeEventListener("abort",e.signalHandler),e.signalHandler=null),ue(e),m(e),L(),Z(),e.settle){let a=e.settle;e.settle=null,a(w(e))}}var C=0,$=null,E=null;function ie(){return E||(E=import("./core/save-A5JXV6ME.js")),E}async function le(e){if(!b||e.holdsSave)return;let t=await ie();e.state==="sent"&&($=t,e.holdsSave=!0,!(C++>0)&&t.suspendAutosave())}function ue(e){e.holdsSave&&(e.holdsSave=!1,!(--C>0)&&(C=0,$?.resumeAutosave()))}var c=null,de=()=>!c||c.admitted,ce=(e,t,n)=>Object.assign(new Error(`clay.wire: ${e}`),{code:t,pending:n});function O(e){return e.document!=="edit"||e.generation===T().generation&&de()?!0:(l(e,"error","the page changed mode before this request went out",{errorCode:"stale-document",errorSource:"client"}),!1)}function _e(){return{id:"clay:wire",order:900,prepare(e={}){let t={admitted:e.initial===!0};return c=t,{enable(){c===t&&(t.admitted=!0)},quiesce(){if(c!==t)return;t.admitted=!1;let n=[...i.values()].filter(r=>r.document==="edit"&&(r.holdsSave||y.has(r.state))).map(r=>r.id);if(n.length)throw ce("a request on this page has not settled","pending-input",n)},resume(){c===t&&(t.admitted=!0)},dispose(){c===t&&(c=null)}}}}}function fe(e,t){return new Promise(n=>{let r=!1,s=()=>{r||(r=!0,document.removeEventListener(e,s),n())};document.addEventListener(e,s),setTimeout(s,t)})}async function pe(){if(!b)return;let e=window.clay;if(!e||typeof e.save!="function")return;let{isSaveInProgress:t}=await import("./core/save-core-MKRPSEEO.js"),{savesHeld:n,saveHoldReason:r}=await import("./core/save-A5JXV6ME.js");if(n())throw new Error(r());let s=Date.now()+W;for(let a=0;a<3;a++){t()&&await fe("clay:save-saved",Math.max(0,s-Date.now()));let u=await e.save();if(u?.ok||u?.msgType==="skipped"&&!t())return;if(u?.msgType==="error"||u?.msgType==="unknown")throw new Error(`could not save this page first: ${u.msg||u.msgType}`);if(Date.now()>=s)break}throw new Error("could not save this page before sending")}async function F(e,t){let n={"Content-Type":"application/json","Page-URL":window.location.href},r=N();r&&(n["Save-Token"]=r);let s=await fetch(H("/_/wire/send"),{method:"POST",headers:n,body:JSON.stringify(e),signal:t}),a=null;try{a=await s.json()}catch{a=null}return{ok:s.ok,status:s.status,reply:a}}function he(e,t={}){let n=typeof t.id=="string"&&t.id?t.id:Q(),r=typeof t.type=="string"&&t.type?t.type:"wire/request",s=Object.prototype.hasOwnProperty.call(t,"helper"),a=s&&typeof t.helper=="string"&&t.helper?t.helper:null,u=t.document===void 0?a?"none":"edit":t.document;if(s&&!a)return _(n,r,null,"helper must be a nonempty string","invalid_helper");if(u!=="edit"&&u!=="none")return _(n,r,a,'document must be "edit" or "none"',"invalid_document");if(i.has(n))return _(n,r,a,"a request with this id is already on the wire","duplicate_request");let o={id:n,type:r,state:"sent",helper:a,document:u,structured:!1,onStatus:typeof t.onStatus=="function"?t.onStatus:null,text:"",result:null,error:null,errorCode:null,errorDetails:null,errorSource:null,startedAt:Date.now(),timer:null,landingTimer:null,abort:typeof AbortController=="function"?new AbortController:null,holdsSave:!1,generation:T().generation,settle:null,signal:t.signal&&typeof t.signal.addEventListener=="function"?t.signal:null,signalHandler:null};return o.done=new Promise(d=>{o.settle=d}),i.set(n,o),m(o),o.signal&&(o.signalHandler=()=>x(n),o.signal.addEventListener("abort",o.signalHandler,{once:!0}),o.signal.aborted&&o.signalHandler()),(async()=>{if(o.state!=="sent")return;if(o.helper){let X=await I(j);if(o.state!=="sent")return;if(!X){l(o,"error","this host does not support named wire helpers",{errorCode:"helper_protocol_unsupported",errorSource:"client"});return}}if(!O(o)||o.document==="edit"&&(await le(o),o.state!=="sent"||!O(o)||(await pe(),o.state!=="sent")||!O(o)))return;if(await ee(),o.state!=="sent"){L();return}v(o,B,"the agent never answered",o.helper?{cancelFirst:!0,errorCode:"ack_timeout"}:void 0);let d={type:o.type,id:o.id,text:t.text,payload:e};o.helper&&(d.helper=o.helper),(o.helper||t.document!==void 0)&&(d.document=o.document);let{ok:G,status:J,reply:S}=await F(d,o.abort?.signal);if(o.state!=="sent")return;if(!G){l(o,"error",`the wire refused this request (${J})`);return}let p=S&&S.refused;if(p&&typeof p.code=="string"&&p.code){l(o,"error",p.message||"the handler refused this request",{errorCode:p.code,errorSource:p.source==="application"?"application":"host",errorDetails:null});return}(!S||S.delivered===0)&&l(o,"error","no agent is attached to this file")})().catch(d=>{l(o,"error",d&&d.message?d.message:String(d))}),{id:n,get state(){return o.state},done:o.done,cancel:()=>x(n)}}function _(e,t,n,r,s){let a={id:e,type:t,state:"error",helper:n,text:"",result:null,error:r,errorCode:s,errorDetails:null,errorSource:"client",startedAt:Date.now()};return{id:e,get state(){return a.state},done:Promise.resolve(w(a)),cancel:()=>!1}}function x(e){let t=i.get(e);return!t||!y.has(t.state)?!1:(z(t),l(t,"cancelled",null),!0)}function z(e){F({type:"wire/cancel",id:e.id}).catch(()=>{})}function ye(e){let t=i.get(e);return t?w(t):void 0}function ge(){return[...i.values()].map(w)}function we(){for(let e of i.values())if(y.has(e.state))return!0;return!1}function me(e){return typeof e!="function"?()=>{}:(k.add(e),()=>k.delete(e))}async function Se(){let e=await A({fresh:!0});if(!e.extensions.includes(j))return[];let t=e.document?.helpers;return Array.isArray(t)?t.filter(n=>n&&typeof n.name=="string"&&["ready","denied","unavailable"].includes(n.state)).map(({name:n,state:r})=>({name:n,state:r})):[]}var ve={send:he,cancel:x,get:ye,list:ge,isBusy:we,on:me,helpers:Se},ke=ve;export{_e as a,ve as b,ke as c};
1
+ import{d as A,e as I}from"./c-XGH4GS2T.js";import{f as b,j as T}from"./c-3O7OBDCM.js";import{c as M}from"./c-BPF2NSPV.js";var B=15e3,P=12e4,K=15e3,V=4e3,W=5e3,U=50,y=new Set(["sent","acked"]),R=new Set(["done","error","cancelled"]),j="wire",a=new Map,k=new Set,f=null,g=null,D=0,h=null;function Q(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`page-${Date.now()}-${Math.random().toString(16).slice(2)}`}function H(e){return new URL(e,window.location.origin).href}function N(){let e=M();return typeof e=="string"&&e!==""?e:null}function w(e){return{id:e.id,type:e.type,state:e.state,helper:e.helper,text:e.text,result:e.result,error:e.error,errorCode:e.errorCode,errorDetails:e.errorDetails,errorSource:e.errorSource,startedAt:e.startedAt}}function m(e,t){let n=w(e);for(let r of k)try{r(n,t||null)}catch(s){console.error("clay.wire: a listener threw",s)}document.dispatchEvent(new CustomEvent("clay:wire-state",{detail:n}))}function Y(e,t){e.state!==t&&(e.state=t,m(e))}function v(e,t,n,{cancelFirst:r=!1,errorCode:s=null}={}){clearTimeout(e.timer),e.timer=setTimeout(()=>{e.timer=null,r&&z(e),l(e,"error",n,{errorCode:s,errorSource:"client"})},t)}function q(e){clearTimeout(e.timer),e.timer=null}function Z(){if(!(a.size<=U))for(let[e,t]of a){if(a.size<=U)break;!y.has(t.state)&&t.state!=="landing"&&a.delete(e)}}function ee(){if(g)return g;let e=N(),t=`/_/wire/subscribe?page-url=${encodeURIComponent(window.location.href)}`+(e?`&token=${encodeURIComponent(e)}`:"");return f=new EventSource(H(t)),f.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch{return}te(r)},f.onerror=()=>{},g=new Promise(n=>{let r=!1,s=()=>{r||(r=!0,n())};f.onopen=s,setTimeout(s,2e3)}),g}function L(){for(let e of a.values())if(y.has(e.state))return;f&&(f.close(),f=null,g=null)}function te(e){if(!e||typeof e.id!="string")return;let t=a.get(e.id);if(!(!t||!y.has(t.state)))switch(e.type){case"wire/ack":e.payload?.mode==="jsonl"&&Number.isFinite(e.payload.budgetMs)&&e.payload.budgetMs>0?(t.structured=!0,v(t,e.payload.budgetMs+K,"the helper did not finish within its execution budget",{cancelFirst:!0,errorCode:"helper_timeout"})):v(t,P,"the agent stopped responding"),Y(t,"acked");break;case"wire/status":t.structured||v(t,P,"the agent stopped responding"),t.text=typeof e.text=="string"?e.text:"",t.state="acked",ne(t,e),m(t,e);break;case"wire/done":t.result=Object.prototype.hasOwnProperty.call(e,"payload")?e.payload:null,t.document==="edit"?ie(t):l(t,"done",null);break;case"wire/error":re(t,e);break;default:break}}function ne(e,t){if(!e.onStatus||typeof t.text!="string")return;let n={text:t.text};t.payload&&typeof t.payload=="object"&&Object.prototype.hasOwnProperty.call(t.payload,"progress")&&(n.progress=t.payload.progress);try{e.onStatus(n)}catch(r){console.error("clay.wire: an onStatus listener threw",r)}}function re(e,t){let n=t.payload,r=n&&typeof n=="object"&&!Array.isArray(n)&&(n.source==="application"||n.source==="host")&&typeof n.code=="string"&&n.code,s=typeof t.text=="string"&&t.text?t.text:"the handler reported an error";if(!r){l(e,"error",s);return}let i=n.source==="host"&&n.code==="helper_cancelled"?"cancelled":"error";l(e,i,s,{errorCode:n.code,errorDetails:Object.prototype.hasOwnProperty.call(n,"details")?n.details:null,errorSource:n.source})}function oe(){h||(h=e=>{if(e.detail?.source!=="peer"){for(let t of a.values())if(t.state==="landing"){l(t,"done",null);return}}},document.addEventListener("clay:sync-applied",h))}function se(){D>0||!h||(document.removeEventListener("clay:sync-applied",h),h=null)}function ie(e){R.has(e.state)||e.state==="landing"||(q(e),e.state="landing",D++,oe(),e.landingTimer=setTimeout(()=>{l(e,"done",null)},V),m(e),L())}function l(e,t,n,r={}){if(R.has(e.state))return;let s=e.state==="landing";if(q(e),clearTimeout(e.landingTimer),e.landingTimer=null,e.abort?.abort(),s&&(D--,se()),e.error=n,Object.prototype.hasOwnProperty.call(r,"errorCode")&&(e.errorCode=r.errorCode),Object.prototype.hasOwnProperty.call(r,"errorDetails")&&(e.errorDetails=r.errorDetails),Object.prototype.hasOwnProperty.call(r,"errorSource")&&(e.errorSource=r.errorSource),e.state=t,e.signal&&e.signalHandler&&(e.signal.removeEventListener("abort",e.signalHandler),e.signalHandler=null),ue(e),m(e),L(),Z(),e.settle){let i=e.settle;e.settle=null,i(w(e))}}var C=0,$=null,E=null;function ae(){return E||(E=import("./core/save-AOJBDSOK.js")),E}async function le(e){if(!b||e.holdsSave)return;let t=await ae();e.state==="sent"&&($=t,e.holdsSave=!0,!(C++>0)&&t.suspendAutosave())}function ue(e){e.holdsSave&&(e.holdsSave=!1,!(--C>0)&&(C=0,$?.resumeAutosave()))}var c=null,de=()=>!c||c.admitted,ce=(e,t,n)=>Object.assign(new Error(`clay.wire: ${e}`),{code:t,pending:n});function O(e){return e.document!=="edit"||e.generation===T().generation&&de()?!0:(l(e,"error","the page changed mode before this request went out",{errorCode:"stale-document",errorSource:"client"}),!1)}function _e(){return{id:"clay:wire",order:900,prepare(e={}){let t={admitted:e.initial===!0};return c=t,{enable(){c===t&&(t.admitted=!0)},quiesce(){if(c!==t)return;t.admitted=!1;let n=[...a.values()].filter(r=>r.document==="edit"&&(r.holdsSave||y.has(r.state))).map(r=>r.id);if(n.length)throw ce("a request on this page has not settled","pending-input",n)},resume(){c===t&&(t.admitted=!0)},dispose(){c===t&&(c=null)}}}}}function fe(e,t){return new Promise(n=>{let r=!1,s=()=>{r||(r=!0,document.removeEventListener(e,s),n())};document.addEventListener(e,s),setTimeout(s,t)})}async function pe(){if(!b)return;let e=window.clay;if(!e||typeof e.save!="function")return;let{isSaveInProgress:t}=await import("./core/save-core-IOCMXO5L.js"),{savesHeld:n,saveHoldReason:r}=await import("./core/save-AOJBDSOK.js");if(n())throw new Error(r());let s=Date.now()+W;for(let i=0;i<3;i++){t()&&await fe("clay:save-saved",Math.max(0,s-Date.now()));let u=await e.save();if(u?.ok||u?.msgType==="skipped"&&!t())return;if(u?.msgType==="error"||u?.msgType==="unknown")throw new Error(`could not save this page first: ${u.msg||u.msgType}`);if(Date.now()>=s)break}throw new Error("could not save this page before sending")}async function F(e,t){let n={"Content-Type":"application/json","Page-URL":window.location.href},r=N();r&&(n["Save-Token"]=r);let s=await fetch(H("/_/wire/send"),{method:"POST",headers:n,body:JSON.stringify(e),signal:t}),i=null;try{i=await s.json()}catch{i=null}return{ok:s.ok,status:s.status,reply:i}}function he(e,t={}){let n=typeof t.id=="string"&&t.id?t.id:Q(),r=typeof t.type=="string"&&t.type?t.type:"wire/request",s=Object.prototype.hasOwnProperty.call(t,"helper"),i=s&&typeof t.helper=="string"&&t.helper?t.helper:null,u=t.document===void 0?i?"none":"edit":t.document;if(s&&!i)return _(n,r,null,"helper must be a nonempty string","invalid_helper");if(u!=="edit"&&u!=="none")return _(n,r,i,'document must be "edit" or "none"',"invalid_document");if(a.has(n))return _(n,r,i,"a request with this id is already on the wire","duplicate_request");let o={id:n,type:r,state:"sent",helper:i,document:u,structured:!1,onStatus:typeof t.onStatus=="function"?t.onStatus:null,text:"",result:null,error:null,errorCode:null,errorDetails:null,errorSource:null,startedAt:Date.now(),timer:null,landingTimer:null,abort:typeof AbortController=="function"?new AbortController:null,holdsSave:!1,generation:T().generation,settle:null,signal:t.signal&&typeof t.signal.addEventListener=="function"?t.signal:null,signalHandler:null};return o.done=new Promise(d=>{o.settle=d}),a.set(n,o),m(o),o.signal&&(o.signalHandler=()=>x(n),o.signal.addEventListener("abort",o.signalHandler,{once:!0}),o.signal.aborted&&o.signalHandler()),(async()=>{if(o.state!=="sent")return;if(o.helper){let X=await I(j);if(o.state!=="sent")return;if(!X){l(o,"error","this host does not support named wire helpers",{errorCode:"helper_protocol_unsupported",errorSource:"client"});return}}if(!O(o)||o.document==="edit"&&(await le(o),o.state!=="sent"||!O(o)||(await pe(),o.state!=="sent")||!O(o)))return;if(await ee(),o.state!=="sent"){L();return}v(o,B,"the agent never answered",o.helper?{cancelFirst:!0,errorCode:"ack_timeout"}:void 0);let d={type:o.type,id:o.id,text:t.text,payload:e};o.helper&&(d.helper=o.helper),(o.helper||t.document!==void 0)&&(d.document=o.document);let{ok:G,status:J,reply:S}=await F(d,o.abort?.signal);if(o.state!=="sent")return;if(!G){l(o,"error",`the wire refused this request (${J})`);return}let p=S&&S.refused;if(p&&typeof p.code=="string"&&p.code){l(o,"error",p.message||"the handler refused this request",{errorCode:p.code,errorSource:p.source==="application"?"application":"host",errorDetails:null});return}(!S||S.delivered===0)&&l(o,"error",o.helper?`The local program "${o.helper}" is not connected to this file.`:"No program is connected to this file.")})().catch(d=>{l(o,"error",d&&d.message?d.message:String(d))}),{id:n,get state(){return o.state},done:o.done,cancel:()=>x(n)}}function _(e,t,n,r,s){let i={id:e,type:t,state:"error",helper:n,text:"",result:null,error:r,errorCode:s,errorDetails:null,errorSource:"client",startedAt:Date.now()};return{id:e,get state(){return i.state},done:Promise.resolve(w(i)),cancel:()=>!1}}function x(e){let t=a.get(e);return!t||!y.has(t.state)?!1:(z(t),l(t,"cancelled",null),!0)}function z(e){F({type:"wire/cancel",id:e.id}).catch(()=>{})}function ye(e){let t=a.get(e);return t?w(t):void 0}function ge(){return[...a.values()].map(w)}function we(){for(let e of a.values())if(y.has(e.state))return!0;return!1}function me(e){return typeof e!="function"?()=>{}:(k.add(e),()=>k.delete(e))}async function Se(){let e=await A({fresh:!0});if(!e.extensions.includes(j))return[];let t=e.document?.helpers;return Array.isArray(t)?t.filter(n=>n&&typeof n.name=="string"&&["ready","denied","unavailable"].includes(n.state)).map(({name:n,state:r})=>({name:n,state:r})):[]}var ve={send:he,cancel:x,get:ye,list:ge,isBusy:we,on:me,helpers:Se},ke=ve;export{_e as a,ve as b,ke as c};
@@ -0,0 +1 @@
1
+ import{b as E,c as g,d as c,e as f,f as v}from"./c-WRBKEJD4.js";var w=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],N=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],u=w.join(","),_=new RegExp("^(?:"+N.join("|")+")(?:-|$)");function X(e){if(!(!e||!e.querySelectorAll))try{for(let a of e.querySelectorAll(u))a.remove();let t=a=>{let r=a.attributes;if(!r)return;let n=null;for(let s=0;s<r.length;s++){let o=r[s].name;_.test(o.toLowerCase())&&(n||(n=[])).push(o)}if(n)for(let s of n)a.removeAttribute(s)};t(e);for(let a of e.querySelectorAll("*"))t(a)}catch(t){typeof console<"u"&&console.warn("[clay] stripExtensionNoise skipped:",t)}}var l={FULL:"full",FROZEN:"frozen",NONE:"none"},k=["no-save","no-trigger-autosave","no-dirty","no-undo","no-watch","no-data","freeze","editor-ui","live"],A=[...E,"no-copy","no-copy-unless:paid-forms"],i=g;function z(e,t){let a=new Set((e.getAttribute("clay")||"").trim().split(/\s+/).filter(Boolean));a.has(t)||(a.add(t),e.setAttribute("clay",Array.from(a).join(" ")))}var T=`${f("save")}, [save-remove]`,y='[clay~="freeze"], [freeze], [save-freeze]',h='[clay~="no-save"], [clay~="no-trigger-autosave"], [clay~="no-dirty"], [clay~="freeze"], [clay~="no-watch"], [no-save], [save-remove], [no-trigger-autosave], [no-dirty], [save-ignore], [freeze], [save-freeze], [no-watch], [mutations-ignore], [clay~="live"]',x='[clay~="no-trigger-autosave"], [no-trigger-autosave]',j='[clay~="live"]',R='[clay~="no-dirty"], [no-dirty], [save-ignore]',S='[clay~="no-save"], [clay~="no-dirty"], [clay~="freeze"], [clay~="no-watch"], [no-save], [save-remove], [no-dirty], [save-ignore], [freeze], [save-freeze], [no-watch], [mutations-ignore], [clay~="live"]',p=`${f("snapshot")}, [snapshot-remove]`,O=f("data");function I(e){let t=m(e);return!!(t&&t.closest&&t.closest(p))}function b(e){return v(e,"data")}var d={full:0,frozen:1,none:2},C=["full","frozen","none"];function m(e){return e&&e.nodeType!==1?e.parentElement:e}function L(e){let t=m(e);if(t&&t.closest&&t.closest(u))return{watched:!1,autosaveTriggered:!1,dirtyTracked:!1,undoable:!1,persist:l.FULL,extension:!0};let a=!0,r=!0,n=!1,s=!1,o=0;for(;t&&t.nodeType===1;)t.hasAttribute&&(c(t,"no-watch")&&(a=!1),i(t,"no-trigger-autosave")&&(n=!0),i(t,"no-dirty")&&(n=!0,s=!0),i(t,"live")&&(n=!0,s=!0,r=!1),c(t,"no-undo")&&(r=!1),c(t,"no-save")&&(o=Math.max(o,d.none)),i(t,"freeze")&&(o=Math.max(o,d.frozen)),i(t,"mutations-ignore")&&(a=!1),i(t,"save-remove")&&(o=Math.max(o,d.none),r=!1),i(t,"save-ignore")&&(n=!0,s=!0,r=!1),i(t,"save-freeze")&&(o=Math.max(o,d.frozen),r=!1)),t=t.parentElement;return a||(n=!0,r=!1,s=!0),o>0&&(n=!0,s=!0),{watched:a,autosaveTriggered:!n,dirtyTracked:!s,undoable:r,persist:C[o],extension:!1}}function P(e){let t=m(e);if(t&&t.closest&&t.closest(u))return!0;for(;t&&t.nodeType===1;){if(t.hasAttribute&&(c(t,"no-watch")||i(t,"mutations-ignore")))return!0;t=t.parentElement}return!1}function F(e,t){return{watched:e.watched&&t.watched,autosaveTriggered:e.autosaveTriggered&&t.autosaveTriggered,dirtyTracked:e.dirtyTracked&&t.dirtyTracked,undoable:e.undoable&&t.undoable,persist:d[e.persist]>=d[t.persist]?e.persist:t.persist,extension:e.extension||t.extension}}var D={"no-watch":e=>!e.watched,"mutations-ignore":e=>!e.watched,"no-save":e=>e.persist===l.NONE,"save-remove":e=>e.persist===l.NONE,freeze:e=>e.persist===l.FROZEN,"save-freeze":e=>e.persist===l.FROZEN,"no-trigger-autosave":e=>!e.autosaveTriggered,"no-dirty":e=>!e.dirtyTracked,"save-ignore":e=>!e.dirtyTracked,"no-undo":e=>!e.undoable};function M(e,t,a){if(e.extension)return!0;if(a&&a.length)return a.some(r=>D[r]?.(e)||!1);switch(t){case"observed":return!e.watched;case"autosave":return!e.autosaveTriggered;case"dirty":return!e.dirtyTracked;case"undo":return!e.undoable;default:return!e.watched||!e.autosaveTriggered||e.persist!==l.FULL}}var K={resolveRegionPolicy:L,isInert:P,isSnapshotRemoved:I,isDataExcluded:b,skipForPolicy:M,strictestPolicy:F,addRegionToken:z,PERSIST:l,TOKENS:A,REGION_ATTRS:k,STRIP_FROM_SAVE:T,STRIP_FROM_COMPARISON:h,STRIP_FROM_DIRTY_CHECK:S,NO_TRIGGER_AUTOSAVE_SELECTOR:x,NO_DIRTY_SELECTOR:R,SNAPSHOT_REMOVE_SELECTOR:p,NO_DATA_SELECTOR:O,FREEZE_SELECTOR:y,selectors:{stripFromSave:T,stripFromComparison:h,stripFromDirtyCheck:S,noTriggerAutosave:x,noDirty:R,snapshotRemove:p,noData:O,freeze:y}},q=K;export{u as a,_ as b,X as c,l as d,k as e,A as f,z as g,T as h,y as i,h as j,x as k,j as l,R as m,S as n,p as o,O as p,I as q,b as r,L as s,P as t,F as u,M as v,K as w,q as x};