@panphora/clayjs 1.24.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +1 -1
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +15016 -13603
- package/dist/m/c-277QP5ET.js +1 -0
- package/dist/m/{c-BULK5J4M.js → c-3UW5EJ77.js} +1 -1
- package/dist/m/{c-GM7OA6EJ.js → c-42ZNV7LI.js} +1 -1
- package/dist/m/{c-RXTPKCMC.js → c-6IJEVE6B.js} +1 -1
- package/dist/m/{c-2R4OBWIP.js → c-6LEYVQJK.js} +1 -1
- package/dist/m/{c-LO4C4J77.js → c-6Q6RGFBF.js} +1 -1
- package/dist/m/{c-PD5AKHY3.js → c-7CM4GMTS.js} +1 -1
- package/dist/m/c-APGHGDZM.js +1 -0
- package/dist/m/{c-Q6VNQDJE.js → c-B7GOFGQR.js} +1 -1
- package/dist/m/{c-RJKKRWHW.js → c-BGN7RCTJ.js} +1 -1
- package/dist/m/{c-A7N5TNSL.js → c-C5AKJVRH.js} +1 -1
- package/dist/m/{c-SNVDWMM3.js → c-CJ7QYEWI.js} +1 -1
- package/dist/m/{c-PVJMJL3P.js → c-CZHTXGJS.js} +1 -1
- package/dist/m/{c-KJHVB2KG.js → c-DDS23EY6.js} +1 -1
- package/dist/m/{c-VSEUFJAO.js → c-DFKBGSN2.js} +1 -1
- package/dist/m/{c-DLBX4JCJ.js → c-EDE45NM7.js} +1 -1
- package/dist/m/c-EILLN2H2.js +1 -0
- package/dist/m/{c-EY5KDUZF.js → c-FEC6LGFF.js} +1 -1
- package/dist/m/{c-PMRRMT72.js → c-HDVH3MVC.js} +1 -1
- package/dist/m/c-HKSLOVU4.js +1 -0
- package/dist/m/{c-GNIVHLEJ.js → c-HL6BLJNA.js} +1 -1
- package/dist/m/c-HTLYXCUH.js +1 -0
- package/dist/m/{c-RTSRGGTP.js → c-JQF2EUCG.js} +1 -1
- package/dist/m/{c-O5ARALMJ.js → c-JWDCQL6J.js} +1 -1
- package/dist/m/{c-WOELSNWS.js → c-LATNQ6Q5.js} +1 -1
- package/dist/m/{c-UM7VZDTW.js → c-LSVN3OLG.js} +1 -1
- package/dist/m/{c-HSNGLIFB.js → c-MFOSMAVM.js} +2 -2
- package/dist/m/{c-FZRZPIFS.js → c-MQYEDF3Q.js} +1 -1
- package/dist/m/{c-2OIKXOY6.js → c-ND3Q2G2I.js} +1 -1
- package/dist/m/{c-PZRWZZRO.js → c-OCYG4NBQ.js} +1 -1
- package/dist/m/{c-54ZZZYUN.js → c-P2HKMJAW.js} +1 -1
- package/dist/m/{c-VI3BJHCM.js → c-PCNJETUA.js} +1 -1
- package/dist/m/{c-7YETSAVY.js → c-PDBNCJCT.js} +1 -1
- package/dist/m/{c-A5ZBFICF.js → c-PYG2NGWU.js} +1 -1
- package/dist/m/{c-RBPZNU2D.js → c-QQFHEODI.js} +1 -1
- package/dist/m/{c-YINHPF4V.js → c-SGH3UTF3.js} +1 -1
- package/dist/m/{c-FV46ZKGX.js → c-SKMIR5HQ.js} +1 -1
- package/dist/m/{c-TWOXQQKV.js → c-STRI73GQ.js} +1 -1
- package/dist/m/{c-75N3KG35.js → c-T3P3AXEW.js} +1 -1
- package/dist/m/c-U4NTUVDZ.js +1 -0
- package/dist/m/{c-P5NKFRL4.js → c-UOOIF2AL.js} +1 -1
- package/dist/m/c-VHSMPITY.js +1 -0
- package/dist/m/{c-6UPEKW6O.js → c-X75G43SZ.js} +1 -1
- package/dist/m/{c-YGGO2G2L.js → c-XW5TIYYB.js} +1 -1
- package/dist/m/{c-DZPO22O3.js → c-YDW4VCHP.js} +1 -1
- package/dist/m/{c-YB3CDTDZ.js → c-YLHTD3KX.js} +1 -1
- package/dist/m/c-Z4G2UK6T.js +4 -0
- package/dist/m/{c-VNAYHV2J.js → c-ZGCO4J3H.js} +1 -1
- package/dist/m/core/{admin-attrs-5UGMYCKW.js → admin-attrs-ONRWVXPK.js} +1 -1
- package/dist/m/core/{autosave-4P66VXX7.js → autosave-TBKAAAFB.js} +1 -1
- package/dist/m/core/{conflict-notice-BAR23OWH.js → conflict-notice-FOEE6I7E.js} +1 -1
- package/dist/m/core/draft-mode-4MCL3LYI.js +1 -0
- package/dist/m/core/{host-permission-3HE4CFD6.js → host-permission-X4BENZEU.js} +1 -1
- package/dist/m/core/{is-edit-mode-GK7IFFMT.js → is-edit-mode-FFHCQ5DR.js} +1 -1
- package/dist/m/core/{persist-AIJGTKKI.js → persist-6ILUR34S.js} +1 -1
- package/dist/m/core/{recovery-LPB6X72P.js → recovery-APWADU4K.js} +1 -1
- package/dist/m/core/{save-FV4ZCKBI.js → save-6HT2LABE.js} +1 -1
- package/dist/m/core/{save-core-K7XFAWQ4.js → save-core-EVMNZQ4V.js} +1 -1
- package/dist/m/core/{site-edits-TEQORBJU.js → site-edits-G4BOZMV4.js} +1 -1
- package/dist/m/core/{unsaved-warning-FF63QGKI.js → unsaved-warning-ITZDIZ2I.js} +1 -1
- package/dist/m/internals/{index-AX4CG7B2.js → index-HS3CQDFW.js} +1 -1
- package/dist/m/loader-GLLVDUZA.js +1 -0
- package/dist/m/manifest-50FF1C45.js +1 -0
- package/dist/m/manifest-edit-BE1A621D.js +1 -0
- package/dist/m/manifest.json +710 -674
- package/dist/m/plugins/{ai-edit-CUKQQWJX.js → ai-edit-LABECCSN.js} +1 -1
- package/dist/m/plugins/{cms-JANMGPHM.js → cms-T2HLI7JG.js} +16 -16
- package/dist/m/plugins/{demo-JIR7DXJA.js → demo-T7B4RIKL.js} +1 -1
- package/dist/m/plugins/{derive-QVI3LI3A.js → derive-6LPJOCAV.js} +1 -1
- package/dist/m/plugins/{indicator-DAKZGAWI.js → indicator-J4ABFARX.js} +1 -1
- package/dist/m/plugins/{live-UAJGWRNP.js → live-PGBIEMGB.js} +1 -1
- package/dist/m/plugins/{menu-BFJ644YX.js → menu-YZL3X2AJ.js} +1 -1
- package/dist/m/plugins/page-WOCNX2IN.js +2 -0
- package/dist/m/plugins/{page-view-OYN7Z5TS.js → page-view-SJODOOGE.js} +1 -1
- package/dist/m/plugins/{people-VBDR5Y22.js → people-C4TCWFOQ.js} +1 -1
- package/dist/m/plugins/{richclay-CBLZRFB4.js → richclay-Y2NV44NA.js} +3 -3
- package/dist/m/plugins/sortable-XCHQG65Z.js +1 -0
- package/dist/m/plugins/{source-ZXDD7F6X.js → source-YK7MO23W.js} +1 -1
- package/dist/m/plugins/{undo-5JI5G7CQ.js → undo-VLRBQNPN.js} +1 -1
- package/dist/m/plugins/{upgrade-6B6QS3NR.js → upgrade-NNTJBSK2.js} +1 -1
- package/dist/m/plugins/{upload-DNJNW6H3.js → upload-ZKKJV76X.js} +1 -1
- package/dist/m/plugins/visitor-drafts-RTZNONHT.js +20 -0
- package/dist/m/plugins/{visitor-drafts-owner-VIAZC3CF.js → visitor-drafts-owner-LHUHFU3L.js} +1 -1
- package/dist/m/plugins/{visitor-menu-ZHKWIKKY.js → visitor-menu-FY4KM2SW.js} +1 -1
- package/dist/m/plugins/wire-M2NR354P.js +1 -0
- package/dist/m/{reader-core-F6RY3V64.js → reader-core-T2S3JC4E.js} +2 -2
- package/dist/m/sync/{live-sync-M2PP2IWY.js → live-sync-Z64YREWQ.js} +1 -1
- package/dist/m/vendor/{sap-core.vendor-OA5SKL7Q.js → sap-core.vendor-QAEPMETX.js} +1 -1
- package/dist/offline-manifest.json +455 -425
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +1 -1
- package/package.json +2 -2
- package/src/core/draft-mode.js +6 -0
- package/src/core/save-core.js +7 -8
- package/src/core/unsaved-warning.js +2 -2
- package/src/lib/idb-error-code.js +20 -0
- package/src/loader.js +2 -0
- package/src/plugins/page.js +19 -5
- package/src/plugins/sortable.js +7 -0
- package/src/plugins/visitor-drafts/commit.js +303 -0
- package/src/plugins/visitor-drafts/idb.js +221 -0
- package/src/plugins/visitor-drafts/prompt.js +23 -3
- package/src/plugins/visitor-drafts/session.js +345 -0
- package/src/plugins/visitor-drafts/store.js +210 -26
- package/src/plugins/visitor-drafts.js +148 -28
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hypercms.vendor.js +16 -16
- package/src/vendor/richclay.vendor.js +1 -1
- package/src/vendor/sap-core.vendor.js +1 -1
- package/dist/m/c-234RSEIW.js +0 -1
- package/dist/m/c-2YIJ6ZA6.js +0 -1
- package/dist/m/c-H2H7TI6O.js +0 -1
- package/dist/m/c-JMDKPBMC.js +0 -4
- package/dist/m/c-N7JPUPGC.js +0 -1
- package/dist/m/c-NEXFVJIT.js +0 -1
- package/dist/m/c-T527QHOB.js +0 -1
- package/dist/m/core/draft-mode-WSQAT67S.js +0 -1
- package/dist/m/loader-5IA5OJ3J.js +0 -1
- package/dist/m/manifest-98258645.js +0 -1
- package/dist/m/manifest-edit-ABF56000.js +0 -1
- package/dist/m/plugins/page-ZBIYHGK4.js +0 -2
- package/dist/m/plugins/sortable-HDOQ6GAC.js +0 -1
- package/dist/m/plugins/visitor-drafts-A5FDQ2G7.js +0 -20
- package/dist/m/plugins/wire-XOT7XKJL.js +0 -1
- /package/dist/m/plugins/{richclay-CBLZRFB4.js.LEGAL.txt → richclay-Y2NV44NA.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as m}from"./c-
|
|
1
|
+
import{d as m}from"./c-QQFHEODI.js";import{f as l}from"./c-EDE45NM7.js";var _=window.__clayWorkspaceBackground===!0;document.addEventListener("clay:workspace-background",()=>{_=!0});document.addEventListener("clay:workspace-foreground",()=>{_=!1});var c=()=>document.hidden||_,y=class extends EventTarget{constructor(e,{shared:s=!1,sharedData:i=!1,documentURL:n,lane:o,clientId:h,startupCheck:t=!1,keepAliveWhenHidden:a=!1,workerFeatures:d=["live-data"]}={}){super(),this.url=e,this.readyState=0,this.onopen=null,this.onmessage=null,this.onerror=null,this._shared=s&&typeof SharedWorker=="function"&&(!i||o==="live"),this._sharedData=i,this._documentURL=n,this._lane=o,this._clientId=h,this._keepAliveWhenHidden=a,this._workerFeatures=d,this._since=0,this._closed=!1,this._suspended=!1,this._repair=!1,this._startup=t,this._worker=null,this._source=null,this._visibility=()=>{clearTimeout(this._hiddenTimer),c()?(this._worker&&this._postWorker(this._worker,"hidden"),this._keepHidden()||(this._hiddenTimer=setTimeout(()=>this._suspend(),5e3))):this._suspended?this._resume():this._worker&&this._postWorker(this._worker,"visible")},this._pagehide=()=>this._suspend(!0),this._pageshow=()=>{(!c()||this._keepHidden())&&this._resume()},document.addEventListener("visibilitychange",this._visibility),document.addEventListener("clay:workspace-background",this._visibility),document.addEventListener("clay:workspace-foreground",this._visibility),window.addEventListener("pagehide",this._pagehide),window.addEventListener("pageshow",this._pageshow),this._open(),c()&&this._visibility()}_emit(e,s){if(this._closed)return;let i=s===void 0?new Event(e):new MessageEvent(e,{data:s});this.dispatchEvent(i),this[`on${e}`]?.(i)}_postWorker(e,s,i={}){e.port.postMessage({v:this._sharedData?2:1,type:s,...i})}_open(){if(!(this._closed||this._suspended)){if(this.readyState=0,!this._shared)return this._openDirect();try{let e=new SharedWorker(new URL(this._sharedData?"/_/sync/data-worker.js":"/_/sync/worker.js",window.location.origin).href,this._sharedData?"clay-sync-data":"clay-sync");this._worker=e;let s=Date.now(),i=!1;e.onerror=()=>{this._worker===e&&(this._shared=!1,this._repair=!0,this._reopen(),c()&&this._visibility())},this._startTimer=setTimeout(e.onerror,5e3),e.port.onmessage=({data:t})=>{if(!(this._worker!==e||t?.v!==(this._sharedData?2:1))){if(this._sharedData){if(t.type==="unsupported"||t.type==="capacity"){e.onerror();return}if(t.type==="gone"){this.readyState=2,this._emit("error"),this.close();return}if(!i){if(t.type!=="hello")return;if(!Array.isArray(t.features)||!this._workerFeatures.every(a=>t.features.includes(a))){e.onerror();return}i=!0,clearTimeout(this._startTimer),s=Date.now();return}if(t.type==="hello")return}if(s=Date.now(),!this._sharedData&&["status","pong","cursor","frame","gone"].includes(t.type)&&clearTimeout(this._startTimer),t.type==="status")t.state==="open"?(!this._sharedData||this.readyState!==1)&&(this.readyState=1,this._emit("open")):t.state==="connecting"&&(this.readyState=0,this._emit("error"));else if(t.type==="cursor"){clearTimeout(this._startTimer),Number.isSafeInteger(t.seq)&&(this._since=Math.max(this._since,t.seq));let a=t.resync===!0||this._repair,d=this._startup;this._repair=!1,this._startup=!1,this._emit("cursor",JSON.stringify({...t,resync:a,startup:d}))}else if(t.type==="frame"&&typeof t.data=="string")this._remember(t.data),this._emit("message",t.data);else if(this._sharedData&&t.type==="event"&&["data","data-state","data-writer","presence"].includes(t.event)&&t.data!==null&&typeof t.data=="object"&&!Array.isArray(t.data))try{this._emit(t.event,JSON.stringify(t.data))}catch{}else t.type==="gone"&&(this.readyState=2,this._emit("error"),this.close())}},e.port.start(),this._postWorker(e,c()?"hidden":"visible");let n={document:this._documentURL,lane:this._lane,since:this._since};this._sharedData&&this._lane==="live"&&(n.clientId=this._clientId),this._postWorker(e,"subscribe",n);let o=0,h=Date.now();this._pingTimer=setInterval(()=>{if(this._worker!==e)return;let t=Date.now(),a=t-h>15e3*6;if(h=t,s>=o&&(o=0),a||o&&t-o>=15e3*3){this._repair=!0,this._reopen();return}o||(o=t),this._postWorker(e,"ping")},15e3)}catch{this._shared=!1,this._reopen(),c()&&this._visibility()}}}_openDirect(){let e=new EventSource(this.url);this._source=e;let s=!1,i=!1;e.onopen=()=>{if(this._source===e&&(s&&!i&&(this._repair=!0),s=!0,this.readyState=1,this._emit("open"),this._repair||this._startup)){let n=this._repair,o=this._startup;this._repair=!1,this._startup=!1,this._emit("cursor",JSON.stringify({resync:n,startup:o}))}},e.onerror=()=>{this._source===e&&(this.readyState=e.readyState,this._emit("error"))},e.onmessage=n=>{this._source===e&&(this._remember(n.data),this._emit("message",n.data))};for(let n of["cursor","presence","data","data-state","data-writer"])e.addEventListener(n,o=>{this._source===e&&(n==="cursor"&&(i=!0),this._emit(n,o.data))})}_remember(e){try{let{seq:s}=JSON.parse(e);Number.isSafeInteger(s)&&(this._since=Math.max(this._since,s))}catch{}}_disconnect(){if(clearTimeout(this._startTimer),clearInterval(this._pingTimer),this._worker){let e=this._worker;this._worker=null,e.onerror=null,e.port.onmessage=null;try{this._postWorker(e,"unsubscribe")}catch{}e.port.close()}this._source&&(this._source.close(),this._source=null)}_keepHidden(){return this._keepAliveWhenHidden===!0||this._keepAliveWhenHidden==="shared"&&this._shared}_reopen(){let e=(this._sharedData||this._keepAliveWhenHidden===!0)&&this.readyState===1;this.readyState=0,e&&this._emit("error"),this._disconnect(),this._open()}_suspend(e=!1){clearTimeout(this._hiddenTimer),!(this._closed||this._suspended)&&(this._suspended=!0,this._repair=!0,this.readyState=0,e&&this._keepAliveWhenHidden===!0&&this._emit("error"),this._disconnect())}_resume(){clearTimeout(this._hiddenTimer),!(this._closed||!this._suspended)&&(this._suspended=!1,this._open())}close(){this._closed=!0,this.readyState=2,clearTimeout(this._hiddenTimer),this._disconnect(),document.removeEventListener("visibilitychange",this._visibility),document.removeEventListener("clay:workspace-background",this._visibility),document.removeEventListener("clay:workspace-foreground",this._visibility),window.removeEventListener("pagehide",this._pagehide),window.removeEventListener("pageshow",this._pageshow)}};var v="This document was upgraded.",u=!1;function p(r,e){let s=r.querySelector(`meta[name="${e}"]`),i=s?s.getAttribute("content"):null;return i&&i.trim()?i.trim():null}function g(r=document){return p(r,"hyper-version")}function k(r){return typeof r!="string"||!r.includes("hyper-version")?null:p(new DOMParser().parseFromString(r,"text/html"),"hyper-version")}function w(r){let e=g();return!!e&&!!r&&r!==e}function S(r){return u?!0:w(k(r))}function D(r){return u?!0:!r||typeof r.querySelector!="function"?!1:w(p(r,"hyper-version"))}function b(){if(u)return Promise.resolve();u=!0;let r=l?import("./core/save-6HT2LABE.js").then(i=>i.holdAllSaves(v),()=>{}):Promise.resolve(),e=new CustomEvent("clay:document-upgraded",{detail:{message:v}}),s=l?Promise.resolve():import("./c-42ZNV7LI.js").then(i=>i.start(e),()=>{});return document.dispatchEvent(e),Promise.all([r,s]).then(()=>{})}var f={spec:{name:"spec",relayPath:"/_/sync",documentHeader:"Document-URL",snapshotKey:"snapshot",streamPath:(r,e,s,i)=>`/_/sync?document-url=${encodeURIComponent(r)}&lane=${e}&resume-id=${s}&client-id=${encodeURIComponent(i)}`},legacy:{name:"legacy",relayPath:"/_/live-sync/save",documentHeader:"Page-URL",snapshotKey:"html",streamPath:(r,e,s,i)=>`/_/live-sync/stream?page-url=${encodeURIComponent(r)}&lane=${e}&resume-id=${s}&client-id=${encodeURIComponent(i)}`}};function A(){return m().then(r=>{let e=r?.extensions||[],s=e.includes("sync"),i=e.includes("live-data"),n=e.includes("presence"),o=s&&i&&e.includes("sync-worker-data"),h=s&&(o||e.includes("sync-worker")&&!i&&!n);return{profile:s?f.spec:f.legacy,sharedSync:h,sharedData:o,liveData:i,workerFeatures:n?["live-data","presence"]:["live-data"]}}).catch(()=>({profile:f.legacy,sharedSync:!1,sharedData:!1,liveData:!1,workerFeatures:["live-data"]}))}export{c as a,y as b,S as c,D as d,b as e,f,A as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./c-YDW4VCHP.js";import"./c-MFOSMAVM.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-6IJEVE6B.js";import"./c-QQFHEODI.js";import"./c-IJUK2GPW.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-PWJSJEJU.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";export{a as replace};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-
|
|
1
|
+
import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-QQFHEODI.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d="#FFFCF6",l=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],y=18,h=3,p=null,f=null;function C(){return f??=Promise.all([import("./c-TFLRT5JX.js"),import("./c-46LJAZZJ.js")]).then(([i,e])=>p={RUNTIME_ONLY:i.RUNTIME_ONLY,CHIP_FONT:`600 11px/16px ${e.FONT_MONO}`}).catch(i=>{throw f=null,i}),f}var $=()=>C().then(()=>!0,()=>!1);function a(i){return i.setAttribute("clay",p.RUNTIME_ONLY),i}function A(i){let e=i&&Array.isArray(i.people)?i.people:[],o=[];for(let t of e){if(!t||t.you===!0||typeof t.id!="string"||!t.id||typeof t.editing!="string"||!_.test(t.editing))continue;let n=typeof t.name=="string"&&t.name.trim()?t.name.trim():"Someone";o.push({id:t.id,name:n,path:t.editing})}return o}var m=class{constructor(){this.editors=[],this.root=null,this._gate=null,this._frame=0,this._following=!1,this._onMove=()=>this.schedule()}supported(){return this._gate||(this._gate=b("presence").then(e=>e===!0,()=>!1)),this._gate}async update(e){this.editors=A(e),await this.supported()&&await this.render()}clear(){this.editors=[],this.follow(!1),this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this.root&&this.root.remove(),this.root=null}schedule(){this._frame||(this._frame=requestAnimationFrame(()=>{this._frame=0,this.render()}))}render(){return p?(this.paint(),Promise.resolve()):$().then(e=>{e&&this.paint()})}paint(){let e=new Map;for(let t of this.editors){let n=v(t.path);n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let o=[];for(let[t,n]of e){let r=this.box(t,n);r&&o.push(r)}if(!o.length){this.root&&(this.root.textContent="",u(this.root,"display","none")),this.follow(this.editors.length>0);return}this.build()&&(this.root.textContent="",this.root.append(...o),u(this.root,"display","block"),this.follow(!0))}box(e,o){let t=e.getBoundingClientRect();if(!(t.width||t.height))return null;let n=c(o[0].id),r=a(s("div",[...l,"position:fixed","box-sizing:border-box","pointer-events:none",`top:${Math.round(t.top-h)}px`,`left:${Math.round(t.left-h)}px`,`width:${Math.round(t.width+h*2)}px`,`height:${Math.round(t.height+h*2)}px`,`border:2px solid ${n}`,`box-shadow:0 0 0 1px ${d}, inset 0 0 0 1px ${d}`]));r.setAttribute("data-clay-editing-marker","");let M=t.top-h>=y+2,x=a(s("div",[...l,"position:absolute","left:-2px",M?"bottom:100%":"top:100%","display:flex","gap:2px","pointer-events:none"]));for(let g of o){let w=a(s("span",[...l,"box-sizing:border-box",`height:${y}px`,"padding:1px 6px",`font:${p.CHIP_FONT}`,"letter-spacing:.02em","white-space:nowrap","max-width:180px","overflow:hidden","text-overflow:ellipsis",`background-color:${c(g.id)}`,`color:${d}`,`box-shadow:0 0 0 1px ${d}`],g.name));w.setAttribute("data-clay-editing-chip",""),x.appendChild(w)}return r.appendChild(x),r}build(){return this.root&&this.root.isConnected?!0:typeof document>"u"||!document.body?!1:(this.root=a(s("div",[...l,"position:fixed","top:0","left:0","width:0","height:0","overflow:visible","z-index:2147482999","pointer-events:none","display:none"])),this.root.setAttribute("data-clay-editing",""),document.body.appendChild(this.root),!0)}follow(e){if(typeof window>"u"||!!e===this._following)return;this._following=!!e;let o=e?"addEventListener":"removeEventListener";window[o]("scroll",this._onMove,{capture:!0,passive:!0}),window[o]("resize",this._onMove,{passive:!0}),document[o]("input",this._onMove),document[o]("clay:sync-applied",this._onMove)}},N=new m;var O=N;export{m as EditingMarker,O as default,N as editingMarker};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as u,b as m,c as b,d as k}from"./c-Y6F2FORL.js";import{b as y}from"./c-QY7F6EN6.js";import{d as v}from"./c-PKCCHJ5X.js";import{b as g}from"./c-
|
|
1
|
+
import{a as u,b as m,c as b,d as k}from"./c-Y6F2FORL.js";import{b as y}from"./c-QY7F6EN6.js";import{d as v}from"./c-PKCCHJ5X.js";import{b as g}from"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var A=.8,c={draft:"You're seeing a private draft, like a visitor.",draftAction:"Edit the original",edit:"You're editing the original. Visitors get these changes.",editAction:"Back to my draft",close:"Hide this note"},L=`.clay-owner {
|
|
2
2
|
--hcp-surface: light-dark(#FFFCF6, #11131E);
|
|
3
3
|
--hcp-ground: var(--bevel-surface, var(--hcp-surface));
|
|
4
4
|
--hcp-ink: light-dark(#2B241B, #ECEAF2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as g,s as k}from"./c-
|
|
1
|
+
import{n as g,s as k}from"./c-MFOSMAVM.js";import{a as u,b as r,c as d,h as p}from"./c-6IJEVE6B.js";var v=3e4;function a(){return{ok:!1,code:"failed"}}async function x(n,{etag:o}={}){if(typeof n!="string"||n==="")return a();let m=o!==void 0,y=typeof o=="string"&&o?o:null;if(r()||await p(),!r())return{ok:!1,code:"unsupported"};let s=m?y:u();if(!s)return{ok:!1,code:"conflict"};let i=new AbortController,S=setTimeout(()=>i.abort(),v);try{let{url:c,options:b}=k(n,!0,i.signal,g(),s,!1,null,!1),t=await fetch(c,b),f=await t.text(),e={};if(f)try{e=JSON.parse(f)}catch{e={}}if(!t.ok)return t.status===412?{ok:!1,code:"conflict"}:t.status===401||t.status===403?{ok:!1,code:"forbidden"}:a();let l=typeof e.etag=="string"&&e.etag?e.etag:null;return d(l),{ok:!0,etag:l}}catch{return a()}finally{clearTimeout(S)}}export{x as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{j as Me}from"./c-
|
|
1
|
+
import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{j as Me}from"./c-MFOSMAVM.js";import{a as Ce}from"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as Ae}from"./c-6IJEVE6B.js";import"./c-QQFHEODI.js";import"./c-IJUK2GPW.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import{b as Y,c as Oe,d as Ie,l as ce,u as fe}from"./c-PWJSJEJU.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 Et=16384;function Ot(e){let t=new Map,n=e?.onParseError;return{parser:new Re({...e,onParseError:s=>{t.set(s.code,(t.get(s.code)||0)+1),n?.(s)}}),errors:t}}function It(e,t,n,r){let s=Math.min(n+r,t.length);return e.tokenizer.write(t.slice(n,s),s>=t.length),s}function*de(e,t,{chunk:n=Et}={}){let{parser:r,errors:s}=Ot(t),o=0;do o=It(r,e,o,n),o<e.length&&(yield);while(o<e.length);return{document:r.document,errors:s}}var ge=new Set(["script","style","xmp","iframe","noembed","noframes","plaintext","noscript"]),Je=new Set(["textarea","title"]),be=e=>ge.has(e)?"raw":Je.has(e)?"rcdata":"normal",pe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e="http://www.w3.org/1999/xhtml",K=1500,Ct=e=>e.replace(/&/g,"&").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">"),Fe=e=>e.replace(/&/g,"&").replace(/ /g," ").replace(/"/g,""");function Qe(e){return j(ie(e))}function*ie(e){let{document:t,errors:n}=yield*de(e,{sourceCodeLocationInfo:!0});return We(e,t,n)}function We(e,t,n){let r=t.childNodes.find(l=>l.nodeName==="html"),s=t.childNodes.filter(l=>l!==r).map(l=>l.nodeName==="#documentType"?{kind:"doctype",name:l.name||"",publicId:l.publicId||"",systemId:l.systemId||""}:{kind:l.nodeName==="#comment"?"comment":l.nodeName,value:l.data}),o=r?ze(r,null,e):null;return o&&Ve(o,e),{src:e,doc:t,outside:s,root:o,parseErrors:n,relocated:o?me(o):null,movedIn:o?me(o,"movedIn"):null,tailOwner:o?He(o):null}}function ze(e,t,n){let r=e.sourceCodeLocation||null,s=e.nodeName==="#text"?"text":e.nodeName==="#comment"?"comment":"element",o={node:e,parent:t,live:null,kind:s,children:[],from:r?r.startOffset:-1,to:r?r.endOffset:-1};if(s==="text")return o.value=e.value,o;if(s==="comment")return o.value=e.data,o;o.tag=e.tagName,o.located=!!(r&&r.startTag),o.openFrom=o.located?r.startTag.startOffset:-1,o.openTo=o.located?r.startTag.endOffset:-1,o.closeFrom=r&&r.endTag?r.endTag.startOffset:o.located?o.to:-1,o.closeTo=r&&r.endTag?r.endTag.endOffset:o.located?o.to:-1,o.endTagged=!!(r&&r.endTag),o.located&&(o.to<o.openTo&&(o.to=o.openTo),o.closeFrom<o.openTo&&(o.closeFrom=o.closeTo=o.openTo)),o.attrs=[];let l=o.located&&r.startTag.attrs||r&&r.attrs||{};for(let a of e.attrs){let g=a.prefix?a.prefix+":"+a.name:a.name,c=l[g.toLowerCase()];o.attrs.push({name:g,key:g.toLowerCase(),value:a.value,from:c?c.startOffset:-1,to:c?c.endOffset:-1})}let d=e.nodeName==="template"&&e.content?e.content.childNodes:e.childNodes;for(let a of d)a.nodeName!=="#documentType"&&o.children.push(ze(a,o,n));if(!o.located){let a=o.children.filter(p=>p.from>=0),g=a.length?Math.min(...a.map(p=>p.from)):-1,c=a.length?Math.max(...a.map(p=>p.to)):-1;o.openFrom=o.openTo=g,o.closeFrom=o.closeTo=c,o.from=g,o.to=c}return o}function Ve(e,t,n=1/0){if(e.kind!=="element")return;for(let o of e.children){if(o.from>=n&&!(o.kind==="text"&&!/\S/.test(o.value))&&(e.movedIn=!0),o.from>=0&&e.located){let l=Math.max(e.openTo,Math.min(o.to,e.closeFrom)),d=Math.min(Math.max(o.from,e.openTo),l);if(d!==o.from||l!==o.to){if(o.kind==="text"&&!ge.has(e.tag)&&!Je.has(e.tag)){let a=t.slice(l,o.to).replace(/<!--[\s\S]*?-->|<[^>]*>/g,"").replace(/\r\n?/g,`
|
|
2
2
|
`);a&&!/\S/.test(a)&&o.value.endsWith(a)&&(o.outsideTail=a)}o.clamped=!0,o.from=d,o.to=l}}o.kind==="element"&&o.located&&!o.endTagged&&o.closeFrom>o.to&&(o.closeFrom=o.closeTo=o.to)}let r=e.located?e.openTo:-1;for(let o of e.children)if(!(o.from<0)){if(o.from<r){e.outOfOrder=!0;break}r=o.to}let s=e.located&&e.endTagged?Math.min(n,e.closeTo):n;for(let o of e.children)Ve(o,t,s)}function me(e,t="outOfOrder"){if(e[t])return e.tag;for(let n of e.children){if(n.kind!=="element")continue;let r=me(n,t);if(r)return r}return null}function He(e){if(e.outsideTail)return e;for(let t of e.children||[]){let n=He(t);if(n)return n}return null}function Z(e,t){if(!e.root)return"source has no <html> element";if(e.root.openFrom<0)return"source has no content inside <html>";if(e.relocated)return"the parser moved content out of <"+e.relocated+">, so source order and tree order disagree";if(e.movedIn)return"the parser moved content written after the end of <"+e.movedIn+"> back inside it, so source order and tree order disagree";let n=Rt(t),r=e.outside.map(At);if(n.length!==r.length)return"outside <html>: "+JSON.stringify(r)+" vs live "+JSON.stringify(n);for(let s=0;s<n.length;s++)if(n[s]!==r[s])return"outside <html>: "+r[s]+" vs live "+n[s];return null}function At(e){return e.kind==="doctype"?"doctype:"+e.name+"|"+e.publicId+"|"+e.systemId:e.kind+":"+e.value}function Rt(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype:"+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment:"+n.data):n.nodeType!==1&&t.push("#"+n.nodeType+":"+(n.data||""));return t}var ae="\0",Ge={align:0,hashKey:0};function Pe(e,t){for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function J(e){Ge.hashKey++;let t=2166136261,n=5381;for(let r of e)t=Pe(t,r),n=(Math.imul(n,33)^Pe(t^2654435769,r))>>>0;return t.toString(36)+"."+n.toString(36)}function q(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}var ye=e=>Array.from(e.attributes,t=>t.name.toLowerCase()+"="+t.value).sort().join(ae),Xe=e=>e.attrs.map(t=>t.key+"="+t.value).sort().join(ae);function Ye(e,t){let n;if(e.nodeType===3)n={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)n={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let r=q(e).map(o=>Ye(o,t)),s="e:"+e.localName+"|"+ye(e);n={tag:e.localName,shallow:s,content:"e:"+e.localName+"|"+J(r.map(o=>o.content)),deep:s+"|"+J(r.map(o=>o.deep))}}return t.set(e,n),n}function*Ke(e,t,n){++n.n%K===0&&(yield);let r;if(e.nodeType===3)r={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)r={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let s=[];for(let l of q(e))s.push(yield*Ke(l,t,n));let o="e:"+e.localName+"|"+ye(e);r={tag:e.localName,shallow:o,content:"e:"+e.localName+"|"+J(s.map(l=>l.content)),deep:o+"|"+J(s.map(l=>l.deep))}}return t.set(e,r),r}function*Ze(e,t){if(++t.n%K===0&&(yield),e.kind==="text")return e.keys={tag:"#text",shallow:"t:"+e.value,content:"t:"+e.value,deep:"t:"+e.value};if(e.kind==="comment")return e.keys={tag:"#comment",shallow:"c:"+e.value,content:"c:"+e.value,deep:"c:"+e.value};let n=[];for(let s of e.children)n.push(yield*Ze(s,t));let r="e:"+e.tag+"|"+Xe(e);return e.keys={tag:e.tag,shallow:r,content:"e:"+e.tag+"|"+J(n.map(s=>s.content)),deep:r+"|"+J(n.map(s=>s.deep))}}var De=["deep","content","shallow","tag"],Mt=4096;function Lt(e,t){Ge.align++;let n=[],r=e.map((p,y)=>y),s=t.map((p,y)=>y);g(r,s,0);let o=new Set(n.map(p=>p[0])),l=new Set(n.map(p=>p[1])),d=r.filter(p=>!o.has(p)),a=s.filter(p=>!l.has(p));return d.length&&a.length&&g(d,a,0),n.sort((p,y)=>p[0]-y[0]),n;function g(p,y,S){let w=0,h=p.length,v=0,N=y.length;if(w>=h||v>=N)return;if(S>=De.length)return c(p,y);let b=De[S];for(;w<h&&v<N&&e[p[w]][b]===t[y[v]][b];)n.push([p[w],y[v]]),w++,v++;for(;w<h&&v<N&&e[p[h-1]][b]===t[y[N-1]][b];)h--,N--,n.push([p[h],y[N]]);if(w>=h||v>=N)return;let P=new Map,Q=new Map;for(let I=w;I<h;I++){let A=e[p[I]][b];P.set(A,P.has(A)?-1:I)}for(let I=v;I<N;I++){let A=t[y[I]][b];Q.set(A,Q.has(A)?-1:I)}let ne=[];for(let I=w;I<h;I++){let A=e[p[I]][b];if(P.get(A)===I){let D=Q.get(A);D!==void 0&&D>=0&&ne.push([I,D])}}let W=bt(ne);if(!W.length){if((h-w)*(N-v)<=Mt){let I=Ft(e,t,p,y,w,h,v,N,b);if(I.length){let A=w,D=v;for(let[H,G]of I)n.push([p[H],y[G]]),g(p.slice(A,H),y.slice(D,G),S+1),A=H+1,D=G+1;g(p.slice(A,h),y.slice(D,N),S+1);return}}return g(p.slice(w,h),y.slice(v,N),S+1)}let z=w,V=v;for(let[I,A]of W)n.push([p[I],y[A]]),g(p.slice(z,I),y.slice(V,A),S),z=I+1,V=A+1;g(p.slice(z,h),y.slice(V,N),S)}function c(p,y){let S=new Map,w=new Map;for(let h of p){let v=e[h].tag;S.has(v)||S.set(v,[]),S.get(v).push(h)}for(let h of y){let v=t[h].tag;w.has(v)||w.set(v,[]),w.get(v).push(h)}for(let[h,v]of S){let N=w.get(h);N&&N.length===v.length&&h!=="#text"&&h!=="#comment"&&v.forEach((b,P)=>n.push([b,N[P]]))}}}function bt(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l][1],a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(e[o]),o=r[o];return s.reverse()}function Ft(e,t,n,r,s,o,l,d,a){let g=o-s,c=d-l,p=(v,N)=>e[n[s+v]][a]===t[r[l+N]][a],y=Array.from({length:g+1},()=>new Uint16Array(c+1));for(let v=g-1;v>=0;v--)for(let N=c-1;N>=0;N--)y[v][N]=p(v,N)?y[v+1][N+1]+1:Math.max(y[v+1][N],y[v][N+1]);let S=[],w=0,h=0;for(;w<g&&h<c;)p(w,h)?(S.push([s+w,l+h]),w++,h++):y[w+1][h]>=y[w][h+1]?w++:h++;return S}function Be(e){return e.nodeType===3?"#text "+JSON.stringify(e.data.slice(0,40)):e.nodeType===8?"#comment":"<"+e.localName+Array.from(e.attributes,t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function je(e){return e.kind==="text"?"#text "+JSON.stringify(e.value.slice(0,40)):e.kind==="comment"?"#comment":"<"+e.tag+e.attrs.map(t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function et(e,t,n=r=>r){return j(we(e,t,n))}function*we(e,t,n=r=>r){let r=new WeakMap,s=new Map,o={n:0};yield*Ke(e,s,o),yield*Ze(t.root,o);let l={paired:0,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:0},d={};return t.gen=d,yield*tt(e,t.root,r,s,l,"html",n,d,o),{map:r,stats:l}}function*tt(e,t,n,r,s,o,l,d,a){++a.n%K===0&&(yield);let g=l(e);if(g?(n.set(g,t),t.gen=d,s.paired++):s.unresolved++,t.kind!=="element"){e.data!==t.value&&s.textDiffs++;return}ye(e)!==Xe(t)&&s.attrDiffs.push({path:o,live:Be(e),source:je(t)});let c=q(e),p=t.children,y=Lt(c.map(h=>r.get(h)),p.map(h=>h.keys)),S=new Set,w=new Set;for(let[h,v]of y)S.add(h),w.add(v),yield*tt(c[h],p[v],n,r,s,o+">"+(c[h].nodeType===1?c[h].localName:"#")+"["+h+"]",l,d,a);for(let h=0;h<c.length;h++)S.has(h)||s.unmatchedLive.push({path:o,node:Be(c[h])});for(let h=0;h<p.length;h++)w.has(h)||s.unmatchedSource.push({path:o,node:je(p[h])})}function*nt(e,t,n=r=>r){if(!t.root)return null;let r=[],s=yield*rt(e,t.root,n,r,{n:0});if(s<0)return null;let o=new WeakMap,l={};t.gen=l;let d=0;for(let[a,g]of r)a&&(o.set(a,g),g.gen=l,d++);return{map:o,stats:{paired:d,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:s}}}function*rt(e,t,n,r,s){if(++s.n%K===0&&(yield),t.kind==="text"){if(e.nodeType!==3||e.data!==t.value)return-1}else if(t.kind==="comment"){if(e.nodeType!==8||e.data!==t.value)return-1}else if(e.nodeType!==1||e.localName!==t.tag||e.namespaceURI!==t.node.namespaceURI||Pt(e)!==Dt(t.node))return-1;let o=n(e);r.push([o,t]);let l=o?0:1;if(t.kind!=="element")return l;let d=Bt(e),a=t.children;if(d.length!==a.length)return-1;for(let g=0;g<d.length;g++){let c=yield*rt(d[g],a[g],n,r,s);if(c<0)return-1;l+=c}return l}var ot=e=>JSON.stringify(e),Pt=e=>Array.from(e.attributes,t=>ot([t.namespaceURI||"",t.name,t.value])).sort().join(ae),Dt=e=>e.attrs.map(t=>ot([t.namespace||"",t.prefix?t.prefix+":"+t.name:t.name,t.value])).sort().join(ae);function Bt(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}function st(e,t,n){let r=t.get(e);if(!r||r.gen!==n.gen||r.from<0||r.to<0||r.kind==="element"&&r.located&&n.src.slice(r.openFrom,r.openFrom+r.tag.length+1).toLowerCase()!=="<"+r.tag.toLowerCase())return null;let s=jt(n),o=Ut(s,r.from);return{from:r.from,to:r.to,line:o+1,column:r.from-s[o]+1}}function jt(e){if(!e.lineStarts){let t=[0];for(let n=0;n<e.src.length;n++)e.src.charCodeAt(n)===10&&t.push(n+1);e.lineStarts=t}return e.lineStarts}function Ut(e,t){let n=0,r=e.length-1;for(;n<r;){let s=n+r+1>>1;e[s]<=t?n=s:r=s-1}return n}function it(e,t,n,r,s={}){let o=()=>typeof performance<"u"?performance.now():Date.now(),l=o(),d=n.src,a=[],g=0,c=(u,m)=>{if(!(u>=0&&m>u))return;let f=a.length>g?a[a.length-1]:null;f&&f.text===void 0&&f.to===u?f.to=m:a.push({from:u,to:m})},p=u=>{u&&a.push({text:u})},y=0,S=u=>{if(y)return null;let m=r(u),f=m?t.get(m):null;return f&&f.gen===n.gen?f:null},w=null,h=-1,v=!1,N=n.root;if(c(0,N.openFrom),I(e,N),c(N.closeTo,d.length),n.tailOwner&&h>=0&&!v){for(let u=h;u<a.length;u++)a[u]={text:Q(P(a[u]))};w&&w.tail&&a.splice(w.at,0,{text:w.tail})}return{text:a.map(P).join(""),ms:o()-l};function P(u){return u.text!==void 0?u.text:d.slice(u.from,u.to)}function Q(u){return u.split(/(<!--[\s\S]*?-->|<[^>]*>)/).map((m,f)=>f%2?m:m.replace(/[\t\n\f\r ]+/g,"")).join("")}function ne(){h=a.length,g=a.length,v=!!w&&w.whole&&/^(?:<\/[^>]*>)*$/.test(a.slice(w.at).map(P).join(""))}function W(u,m){if(u.nodeType===3)return V(u,m);if(u.nodeType===8)return z(u);if(u.nodeType===1){if(s.print&&s.print.has(u)){y++;try{I(u,null)}finally{y--}}else I(u,S(u));u.localName==="body"&&u.parentNode===e&&ne()}}function z(u){let m=S(u);m&&m.kind==="comment"&&m.value===u.data&&m.from>=0&&!s.breakText?c(m.from,m.to):p("<!--"+u.data+"-->")}function V(u,m){let f=S(u),x=u.data;s.corrupt==="drop-first-text"&&!s.corrupted&&x.trim()&&(s.corrupted=!0,x=x.slice(1));let T=f&&f.parent&&be(f.parent.tag)===be(m);if(f&&f.kind==="text"&&f.value===x&&f.from>=0&&!s.breakText&&T){c(f.from,f.to),s.doubleCopied!==void 0&&x===s.doubleCopied&&c(f.from,f.to),f.outsideTail&&(w={at:a.length,tail:f.outsideTail,whole:!0},g=a.length);return}let M=null;if(f&&f.kind==="text"&&f.outsideTail){let R=x.endsWith(f.outsideTail);R&&(x=x.slice(0,x.length-f.outsideTail.length)),M={tail:R?f.outsideTail:"",whole:R}}p(ge.has(m)?x:Ct(x)),M&&(w={at:a.length,...M},g=a.length)}function I(u,m){let f=u.localName,x=pe.has(f)&&u.namespaceURI===$e,T=m&&m.kind==="element"&&!s.breakTags?m:null;if(T&&!T.located){if(u.attributes.length===0){if(T.openFrom>=0){X(u,T,f);return}q(u).length&&X(u,null,f);return}if(p(A(u)),x)return;X(u,T.openFrom>=0?T:null,f),p("</"+f+">");return}if(!T){if(p(A(u)),x)return;X(u,null,f),p("</"+f+">");return}H(u,T),!x&&(X(u,T,f),c(T.closeFrom,T.closeTo))}function A(u){let m="<"+u.localName;for(let f of u.attributes)m+=" "+f.name+(f.value===""?"":'="'+Fe(f.value)+'"');return m+">"}function D(u,m){let f=u.attributes;if(f.length!==m.attrs.length)return!1;for(let x=0;x<f.length;x++){let T=m.attrs[x];if(T.from<0||f[x].value!==T.value||f[x].name.toLowerCase()!==T.key)return!1}return!0}function H(u,m){if(D(u,m)){c(m.openFrom,m.openTo);return}let f=new Map;for(let O of u.attributes)f.set(O.name.toLowerCase(),O);let x=new Set,T=m.openFrom;for(let O of m.attrs){if(O.from<0){let _=f.get(O.key);_&&_.value===O.value&&x.add(O.key);continue}let L=f.get(O.key);if(x.add(O.key),!L){c(T,G(T,O.from)),T=O.to;continue}if(L.value===O.value){c(T,O.to),T=O.to;continue}c(T,O.from),p(xt(d.slice(O.from,O.to),L.value)),T=O.to}let M=m.openTo-1,R=m.attrs.reduce((O,L)=>L.to>O?L.to:O,m.openFrom);d[M-1]==="/"&&M-1>=R&&M--,c(T,M);for(let O of u.attributes)x.has(O.name.toLowerCase())||p(" "+O.name+(O.value===""?"":'="'+Fe(O.value)+'"'));c(M,m.openTo)}function G(u,m){let f=m;for(;f>u&&/[ \t\n\r\f]/.test(d[f-1]);)f--;return f}function xt(u,m){let f=u.indexOf("="),x=(f<0?u:u.slice(0,f)).trimEnd(),T=f<0?"":u.slice(f+1).trim(),M=T[0]==="'"?"'":T[0]==='"'?'"':"",R=m.replace(/&/g,"&").replace(/ /g," ");return M==="'"&&!m.includes("'")?x+"='"+R+"'":M===""&&T!==""&&m!==""&&!/[\s"'=<>`]/.test(m)?x+"="+R:x+'="'+R.replace(/"/g,""")+'"'}function St(u){if(u.nodeType!==1||y||s.print&&s.print.has(u))return null;let m=S(u);return m&&m.kind==="element"&&m.located&&!m.endTagged&&!pe.has(m.tag)&&!s.breakTags?m:null}function ue(u){let m=St(u);if(!m)return null;let f=q(u);return((f.length?ue(f[f.length-1]):null)||[]).concat(m.tag)}function X(u,m,f){let x=q(u),T=null,M=(C,k)=>{T&&!(k>=0&&T.j>=0&&k===T.j+1)&&p(T.tags.map(E=>"</"+E+">").join("")),T=null};if(!m){for(let C of x){M(-1,-1),W(C,f);let k=ue(C);k&&(T={tags:k,j:-1})}return}let R=m.children,O=new Map(R.map((C,k)=>[C,k])),L=x.map(C=>{let k=S(C);return k&&k.parent===m&&k.from>=0?O.get(k):-1}),_=new Set;if(!s.breakText&&!s.breakTags){let C=new Set(L),k=new Map;R.forEach((E,F)=>{C.has(F)||E.from<0||!E.keys||(k.has(E.keys.deep)||k.set(E.keys.deep,[]),k.get(E.keys.deep).push(F))}),k.size&&x.forEach((E,F)=>{if(L[F]>=0||S(E))return;let B=k.get(Ye(E,new Map).deep);B&&B.length&&(L[F]=B.shift(),_.add(F))})}let Se=(C,k)=>{if(!_.has(k))return W(C,f);let E=R[L[k]];c(E.from,E.to),E.outsideTail&&(w={at:a.length,tail:E.outsideTail,whole:!0},g=a.length)},kt=(C,k)=>{if(!_.has(k))return ue(C);let E=R[L[k]];return E.kind==="element"&&E.located&&!E.endTagged&&!pe.has(E.tag)?[E.tag]:null},Nt=new Set(_t(L)),U=m.openTo,ke=-1,Ne=C=>{for(let k=ke+1;k<C;k++){let E=R[k];E.from<0||(c(U,E.from),U=Math.max(U,E.to))}};for(let C=0;C<x.length;C++){let k=x[C],E=kt(k,C);if(Nt.has(C)){let B=L[C],Ee=R[B];M(C,B),Ne(B),c(U,Ee.from),Se(k,C),U=Math.max(U,Ee.to),ke=B,T=E?{tags:E,j:B}:null;continue}let F=S(k);M(C,F&&F.parent===m?O.get(F):-1),Se(k,C),T=E?{tags:E,j:-1}:null}Ne(R.length),c(U,m.closeFrom)}}function _t(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l];if(d<0)continue;let a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(o),o=r[o];return s.reverse()}function*at(e,t,n,r=null,s=null){return yield*ve(e,t,n,r,s,!0)}function*ve(e,t,n,r,s,o){let l=new DOMParser,d=l.parseFromString(e,"text/html"),a=qe(d),g=qe(n);if(a.join(`
|
|
3
3
|
`)!==g.join(`
|
|
4
4
|
`))return{ok:!1,diff:"document: outside <html> "+JSON.stringify(a)+" vs live "+JSON.stringify(g)};let c=null,p=null;if(r&&(c=[],p=yield*se(d.documentElement,r,"html",c),!p)){let h=yield*Ue(e,s,o);return h.diff?{ok:!1,diff:h.diff}:o?_e({ok:!0,diff:null,oracle:"clone"},h,e,n):{ok:!0,diff:null,oracle:"clone"}}let y=l.parseFromString(t,"text/html"),S=yield*se(d.documentElement,y.documentElement,"html"),w=S?null:yield*Ue(e,s,o);return S?r?{ok:!1,diff:S,at:c}:{ok:!1,diff:S}:w.diff?{ok:!1,diff:w.diff}:o?_e({ok:!0,diff:null,oracle:"today"},w,e,n):{ok:!0,diff:null,oracle:"today"}}function lt(e,t){let n=e;for(let r of t){let s=he(n);if(r>=s.length)return null;n=s[r]}return n}function*Ue(e,t,n){if(!t)return{diff:null};let{document:r,errors:s}=yield*de(e,n?{sourceCodeLocationInfo:!0}:{});for(let[o,l]of s){let d=t.get(o)||0;if(l>d)return{diff:`the render introduced parse errors the source does not have: ${o} ${d} -> ${l}`}}return n?{diff:null,doc:r,parseErrors:s}:{diff:null}}function _e(e,t,n,r){if(!t.doc)return e;let s=We(n,t.doc,t.parseErrors);return Z(s,r)||(e.model=s),e}function qe(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype "+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment "+n.data):n.nodeType!==1&&t.push("node"+n.nodeType+" "+(n.data||""));return t}function*qt(e,t,n,r){let s=new DOMParser,o=l=>{let d=Array.from(l.childNodes);return d.length&&d.every(a=>a.nodeType===3)?d.map(a=>a.data).join(""):l.innerHTML};return yield*se(s.parseFromString(e.innerHTML,"text/html").body,s.parseFromString(o(t),"text/html").body,n+">#noscript",[],r)}function he(e){let t=e.localName==="template"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r=0;r<t.length;r++){let s=t[r];(s.nodeType===1||s.nodeType===3||s.nodeType===8)&&n.push(s)}return n}var oe=e=>Array.from(e.attributes,t=>(t.namespaceURI||"")+" "+t.name+"="+JSON.stringify(t.value)).sort().join("; ");function Jt(e,t){let n=e.attributes,r=t.attributes;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++){let o=n[s],l=r[s];if(o.name!==l.name||o.value!==l.value||o.namespaceURI!==l.namespaceURI)return!1}return!0}function*se(e,t,n,r=[],s={n:0}){if(++s.n%K===0&&(yield),e.nodeType!==t.nodeType)return n+": node type "+e.nodeType+" vs "+t.nodeType;if(e.nodeType===3||e.nodeType===8)return e.data===t.data?null:n+": text "+JSON.stringify(e.data.slice(0,60))+" vs "+JSON.stringify(t.data.slice(0,60));if(e.localName!==t.localName||e.namespaceURI!==t.namespaceURI)return n+": tag "+e.localName+" vs "+t.localName;if(!Jt(e,t)&&oe(e)!==oe(t))return n+": attrs "+oe(e)+" vs "+oe(t);if(e.localName==="noscript"&&e.namespaceURI===$e)return yield*qt(e,t,n,s);let o=he(e),l=he(t);if(o.length!==l.length)return n+": "+o.length+" vs "+l.length+" children";for(let d=0;d<o.length;d++){r.push(d);let a=yield*se(o[d],l[d],n+">"+(o[d].localName||"#")+"["+d+"]",r,s);if(a)return a;r.pop()}return null}var i={installed:!1,refused:null,session:0,model:null,map:null,stats:null,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastOutcome:null,lastRenderMs:null,lastBytes:null,timing:{fetch:null,model:null,pair:null,refresh:null},refreshes:0,repairs:0,refreshQueued:!1,pendingBytes:null,refetch:!1,adoptions:0},$t=2,$=()=>typeof performance<"u"?performance.now():Date.now(),dt=4,le=Object.freeze({superseded:!0});function pt(e){return document.hidden||Me()?!1:e>=307200}var mt='<script type="application/json" id="clay-runtime-map"',ht=e=>e.includes(mt)||e.includes("/_/clayjs/");async function gt(e){let t=await fetch(e,{cache:"no-store",redirect:"manual",credentials:"same-origin",headers:{"Clay-Source":"1"}});if(!t.ok)throw new Error(`source fetch: status ${t.status}`);if(t.redirected||t.type==="opaqueredirect")throw new Error("source fetch: redirected");let n=(t.headers.get("content-type")||"").toLowerCase();if(!n.startsWith("text/html"))throw new Error(`source fetch: content-type ${n||"missing"}`);let r=await t.text();if(r.includes(mt))throw new Error("source fetch: projected response");return r}function yt(e){let t=fe({flushUndo:!1,authored:!1});return et(t,e,Y)}function*Qt(e){let t=fe({flushUndo:!1,authored:!1});return yield*we(t,e,Y)}function Wt(e){let t=e.doc&&e.doc.childNodes.find(r=>r.nodeName==="html"),n=t&&Array.isArray(t.attrs)?t.attrs.find(r=>r.name==="documentetag"):null;return n&&n.value?n.value:null}function zt(e){let t=e&&e.represented&&e.represented.etag;if(t)return t;let n=Ae();return n||e===null&&document.documentElement.getAttribute("documentetag")||null}function Vt(e,t){let n=Wt(e),r=zt(t);return!n||!r||n===r?null:`source refused: the fetch answered version ${n} while this page holds ${r}`}async function wt(e,t=null,n=0,r=!0,s=null){let o=i.session,l=$(),d=i.adoptions;i.refused=null;let a=s?s():null,g=a&&typeof a.bytes=="string"&&!ht(a.bytes)?a.bytes:null;try{let c=g!==null?g:await gt(e);if(o!==i.session)return null;let p=$(),y=await Ht({src:c,context:t,render:r,session:o,generation:d,t0:l,t1:p});if(y!==le)return y;if(n<$t)return wt(e,t,n+1,r,s);throw new Error("source refused: a save replaced the file while the fetch was in flight")}catch(c){return o!==i.session||(i.refused=String(c&&c.message?c.message:c),console.info(`clayjs: source map off (${i.refused}); saves use the full serialization`)),null}}function*ut(e){let t=yield*ie(e.src),n=Z(t,document);if(n)throw new Error(`source refused: ${n}`);let r=Vt(t,e.context);if(r)throw new Error(r);if(i.adoptions!==e.generation)return le;let s=$();if(yield,i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let{map:o,stats:l}=yield*Qt(t);if(i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let d=$();return i.model=t,i.map=o,i.stats=l,i.timing={fetch:e.t1-e.t0,model:s-e.t1,pair:d-s,refresh:null},i.installed=!0,e.render&&ce(Gt,{steps:vt}),Tt()}async function Ht(e){if(!pt(e.src.length))return j(ut(e));let t={get aborted(){return i.session!==e.session}},n=await re(ut(e),{budgetMs:dt,signal:t});return n&&n.aborted===!0?null:n}function Gt(e,t,n={}){return j(vt(e,t,n))}function*vt(e,t,n={}){if(!i.installed)return t;yield*xe();let r=i.session,s=i.repairs,o=Oe(),l=!!o&&!o.authoredHandlers,d=new Set,a=null;for(let g=0;g<=Yt;g++){let c;try{c=it(e,i.map,i.model,Y,{...n,print:d})}catch(y){return ee("render threw: "+(y&&y.message?y.message:y),t)}let p=l?yield*at(c.text,t,document,e,i.model.parseErrors):yield*ve(c.text,t,document,e,i.model.parseErrors,!1);if(p.ok){let y=ct(r,s);if(y)return ee(y,t);let S=d.size?{text:c.text,scope:"partial",reason:a,printed:d.size}:{text:c.text,scope:null},w=p.model?yield*nt(e,p.model,Y):null,h=ct(r,s);return h?ee(h,t):(i.lastRenderMs=c.ms,i.lastBytes=c.text.length,i.lastOutcome=S,p.model&&Xt(p.model,c.text,o,w),c.text)}if(a===null&&(a=p.diff),!p.at||!Kt(e,lt(e,p.at),d))return ee(a,t)}return ee(a,t)}function ct(e,t){return i.session!==e?"render refused: the session ended while this render ran":i.installed?i.repairs!==t?"render refused: the map was re-paired while this render ran":null:"render refused: the source map was uninstalled while this render ran"}function Xt(e,t,n,r){r&&Ie({captureId:n.captureId,html:t,source:{model:e,map:r.map,stats:r.stats,repairGeneration:i.repairs,outcome:i.lastOutcome}})}var Yt=8;function Kt(e,t,n){let r=t&&t.nodeType===1?t:t&&t.parentNode;for(let s=r;s&&s!==e;s=s.parentNode)if(n.has(s)){n.delete(s),r=s.parentNode;break}return!r||r.nodeType!==1||r===e?!1:(n.add(r),!0)}function ee(e,t){return i.lastOutcome={text:t,scope:"full",reason:e},t}function Zt(e){i.reprints++,i.lastReprint=e,console.warn("clayjs: source map did not verify, saving the full serialization instead:",e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"full"}}))}function en(e,t){i.partialReprints++,i.lastPartialReprint=e,console.info(`clayjs: source map printed ${t} element(s) in full to match the page:`,e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"partial",printed:t}}))}function tn(e,t){i.adoptions++,i.installed&&(rn(e,t&&t.artifact?t.artifact.source.outcome:null),!nn(e,t)&&(i.pendingBytes=e,Te()))}function nn(e,t){let n=t&&t.artifact;return!n||!n.source||n.html!==e||t.captureId===null||t.captureId===void 0||n.captureId!==t.captureId||n.source.repairGeneration!==i.repairs||i.refreshQueued||i.pendingBytes!==null?!1:(i.model=n.source.model,i.map=n.source.map,i.stats=n.source.stats,!0)}function rn(e,t=null){let n=i.lastOutcome&&i.lastOutcome.text===e?i.lastOutcome:t;!n||n.text!==e||(i.lastOutcome===n&&(i.lastOutcome=null),i.saves++,n.scope==="full"?Zt(n.reason):n.scope==="partial"&&en(n.reason,n.printed))}function on(e){let t=e&&e.detail;t&&t.source==="disk"&&typeof t.html=="string"&&i.adoptions++,i.installed&&(t&&t.source==="disk"&&typeof t.html=="string"&&(ht(t.html)?i.refetch=!0:i.pendingBytes=t.html),Te())}function Te(){i.refreshQueued||(i.refreshQueued=!0,typeof requestIdleCallback=="function"?requestIdleCallback(ft,{timeout:2e3}):setTimeout(ft,0))}function ft(){if(!pt(sn())){te();return}an()}function sn(){return typeof i.pendingBytes=="string"?i.pendingBytes.length:i.model?i.model.src.length:0}async function an(){let e=i.session,t={get aborted(){return i.session!==e}};try{await re(xe(),{budgetMs:dt,signal:t})}catch(n){console.warn("clayjs: source map could not run the queued repair:",n)}!i.refreshQueued||!i.installed||i.session!==e||(i.refreshQueued=!1,Te())}function te(){j(xe())}function*xe(){if(!i.refreshQueued)return;if(!i.installed){i.refreshQueued=!1;return}let e=i.session,t=i.repairs,n=i.adoptions,r=i.pendingBytes,s=i.refetch&&r===null,o=$(),l=i.model;if(r!==null)try{let a=yield*ie(r),g=Z(a,document);if(g)throw new Error(g);l=a}catch(a){console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",a)}if(yield,!ln(e,t,n))return;let d=null;try{d=yt(l)}catch(a){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",a)}i.refreshQueued=!1,i.pendingBytes=null,s&&(i.refetch=!1),i.repairs++,d&&(i.model=l,i.map=d.map,i.stats=d.stats,i.refreshes++,i.timing.refresh=$()-o),s&&un()}function ln(e,t,n){return i.session===e&&i.installed&&i.repairs===t&&i.adoptions===n}function un(){let e=i.repairs,t=i.adoptions;gt(window.location.href).then(n=>{let r=Qe(n),s=Z(r,document);if(s)throw new Error(s);return r}).then(n=>{if(!(i.repairs!==e||i.adoptions!==t))try{i.repairs++,i.adoptions++;let{map:r,stats:s}=yt(n);i.model=n,i.map=r,i.stats=s,i.refreshes++}catch(r){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",r)}}).catch(n=>{console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",n)})}function Tt(){let e=i.stats;return{installed:i.installed,refused:i.refused,sourceBytes:i.model?i.model.src.length:null,paired:e?e.paired:0,unresolved:e?e.unresolved:0,unmatchedLive:e?e.unmatchedLive.length:0,unmatchedSource:e?e.unmatchedSource.length:0,attrDiffs:e?e.attrDiffs.length:0,saves:i.saves,reprints:i.reprints,lastReprint:i.lastReprint,partialReprints:i.partialReprints,lastPartialReprint:i.lastPartialReprint,lastRenderMs:i.lastRenderMs,lastBytes:i.lastBytes,refreshes:i.refreshes,timing:i.timing}}function kn(){return te(),i.model?i.model.src:null}function Nn(e){return te(),i.installed&&e?st(e,i.map,i.model):null}function En(){return te(),i.stats?{live:i.stats.unmatchedLive.slice(0,50),source:i.stats.unmatchedSource.slice(0,50)}:null}function On(){return te(),Tt()}var In=()=>i.installed,Cn=()=>i.repairs;function An(){cn()}function cn(){i.session++,i.installed=!1,i.refreshQueued=!1,i.pendingBytes=null,i.refetch=!1,ce(null)}function Rn({context:e=null,latest:t=null}={}){return wt(window.location.href,e,0,!0,t)}Ce(tn);document.addEventListener("clay:sync-applied",on);export{tn as adoptAccepted,In as installed,Nn as locateLive,xe as refreshNowSteps,An as release,Gt as renderSave,vt as renderSaveSteps,Cn as repairGeneration,Rn as start,On as stats,kn as text,En as unpaired};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as ee}from"./c-YDW4VCHP.js";import{b as Q}from"./c-3G2DGZUP.js";import{p as K,q as Z}from"./c-MFOSMAVM.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as B,h as X}from"./c-6IJEVE6B.js";import"./c-QQFHEODI.js";import"./c-IJUK2GPW.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-PWJSJEJU.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 We=Object.defineProperty,Ve=(e,t)=>{for(var r in t)We(e,r,{get:t[r],enumerable:!0})},Fe=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],ze=new Set(Fe),_e=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),he=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),te=new Set(["checked","selected","disabled","readOnly","paused"]);function Je(e,t){return t==null?te.has(e)?!1:"":te.has(e)?t==="false"?!1:!!t:t}var Ye={};Ve(Ye,{CodecRefused:()=>et,EmptyListInsert:()=>R,MAX_RULE_DEPTH:()=>L,MaxRuleDepthExceeded:()=>G,NoRulesTag:()=>Ze,RuleTargetReadOnly:()=>ge,RulesParseError:()=>$,ShapeMismatch:()=>ye,UnknownCodec:()=>we,UnknownRulesVersion:()=>me,WriteNotRoundTripped:()=>Ke,WriteRefused:()=>Ge,WriteRejected:()=>Qe});var $=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},me=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=e}},L=20,G=class extends Error{constructor(e){super(`rule depth exceeded ${L} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},ye=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},R=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},ge=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Ge=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function Xe(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var Ke=class extends Error{constructor(e){super(`write did not round-trip at "${Xe(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},Ze=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},Qe=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}},we=class extends Error{constructor(e){super(`unknown codec "${e}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=e}},et=class extends Error{constructor(e,t){super(t),this.name="CodecRefused",this.code=e}};function M(e){let t=0,r=null,o=-1;for(let n=0;n<e.length;n++){let l=e[n];l==="\\"?n++:r?l===r&&(r=null):l==='"'||l==="'"?r=l:l==="["||l==="("?t++:l==="]"||l===")"?t>0&&t--:l==="@"&&t===0&&(o=n)}return o}var re="[*]";function j(e){let t=M(e),r=t===-1?e:e.slice(0,t),o=r.endsWith(re),n={selector:o?r.slice(0,-re.length):r,prop:t===-1?null:e.slice(t+1)||null};return o&&(n.all=!0),n}function ve(e){let t=0,r=null,o=-1,n=!1;for(let l=0;l<e.length;l++){let i=e[l];i==="\\"?l++:r?i===r&&(r=null):i==='"'||i==="'"?r=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:t===0&&i===">"?o=l:t===0&&i===","&&(n=!0)}return n||o===-1||!tt(e,o+1)?null:e.slice(0,o).trim()||null}function tt(e,t){let r=t,o=e.replace(/\s+$/,"").length;for(;r<o&&/\s/.test(e[r]);)r++;let n=0,l=null;for(;r<o;r++){let i=e[r];if(i==="\\")r++;else if(l)i===l&&(l=null);else if(i==='"'||i==="'")l=i;else if(i==="["||i==="(")n++;else if(i==="]"||i===")")n>0&&n--;else if(n===0&&(i==="+"||i==="~"||/\s/.test(i)))return!1}return!0}var rt=/^codec\(([a-z][a-z0-9-]*)\)$/;function P(e){if(typeof e!="string")return null;let t=M(e);if(t===-1)return null;let r=rt.exec(e.slice(t+1));if(!r)return null;let{selector:o,all:n}=j(e);if(n)throw new $("A @codec(name) rule cannot use [*].");return{selector:o,name:r[1]}}var nt=/^--[A-Za-z0-9_-]+$/;function be(e){return typeof e=="string"&&nt.test(e)}function xe(e){let t=[],r=[],o=null,n=0;for(let l=0;l<e.length;l++){let i=e[l];if(o){i==="\\"?l++:i===o&&(o=null);continue}if(i==="/"&&e[l+1]==="*"){let a=e.indexOf("*/",l+2);l=a===-1?e.length:a+1;continue}i==='"'||i==="'"?o=i:i==="("?r.push(")"):i==="["?r.push("]"):i==="{"?r.push("}"):(i===")"||i==="]"||i==="}")&&r[r.length-1]===i?r.pop():i===";"&&r.length===0&&(t.push(e.slice(n,l)),n=l+1)}return t.push(e.slice(n)),t}function ot(e){let t="",r=null;for(let o=0;o<e.length;o++){let n=e[o];if(r){t+=n,n==="\\"&&o+1<e.length?t+=e[++o]:n===r&&(r=null);continue}if(n==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function Ae(e){e=ot(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),o=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(o);return n&&(o=o.slice(0,n.index).trim()),{name:r,value:o,important:!!n}}function Te(e,t){if(e==null)return null;let r=null;for(let o of xe(String(e))){let n=Ae(o);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function lt(e,t,r){let o=e==null?"":String(e),n=r==null||r==="",l=xe(o),i=l.map(Ae),a=i.some(u=>u&&u.name===t&&u.important),s=[],c=!1;l.forEach((u,d)=>{let m=i[d];if(!m||m.name!==t){s.push(u);return}if(n||c)return;let p=/^\s*/.exec(u)[0];s.push(`${p}${t}: ${r}${a?" !important":""}`),c=!0});let f=s.join(";");if(!n&&!c){let u=f.trimEnd();f=u===""?`${t}: ${r}`:`${u}${u.endsWith(";")?" ":"; "}${t}: ${r}`}return f.trim()===""?null:f}function it(e,t,r,o){let n=e.attr(t,"style");if((Te(n,r)??"")===o)return;let l=lt(n,r,o);l==null?e.removeAttr(t,"style"):e.attr(t,"style",l)}var at='The @codec(name) rule form needs a rules tag with data-rules-version="2".',st="A @codec(name) rule must be the value of a top level key.";function Oe(e,t){let r=P(e);return r?{...r,codec:t.codecs[r.name]}:null}function Ee(e,t={}){let r=t.version??"1",o=t.codecs??{};n(e,0);function n(l,i){if(!(i>L)){if(typeof l=="string"){let a=P(l);if(!a)return;if(r!=="2")throw new $(at);if(i!==1)throw new $(st);if(!Object.prototype.hasOwnProperty.call(o,a.name))throw new we(a.name);return}if(Array.isArray(l)){n(l[1],i+1);return}if(l&&typeof l=="object")for(let a of Object.values(l))n(a,i+1)}}}function ke(e,t,r,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Ee(r,o),V(e,t,r,{depth:0,path:[]},o)}function V(e,t,r,o,n){if(o.depth>L)throw new G(o.path);if(typeof r=="string")return ut(e,t,r,o,n);if(Array.isArray(r)){let[l,i]=r,a=e.find(t,l,n);return Ne(n,o,a),a.map((s,c)=>V(e,s,i,{depth:o.depth+1,path:[...o.path,c]},n))}if(typeof r=="object"&&r!==null){let l={};for(let[i,a]of Object.entries(r))l[i]=V(e,t,a,{depth:o.depth+1,path:[...o.path,i]},n);return l}return null}function ut(e,t,r,o,n){if(r.endsWith("[]")){let f=r.slice(0,-2),u=e.find(t,f,n);return Ne(n,o,u),u.map(d=>e.text(d))}let l=Oe(r,n);if(l)return ct(e,t,l,n);if(r.startsWith("@"))return W(e,t,r.slice(1));let i=M(r);if(i!==-1){let{selector:f,all:u}=j(r),d=r.slice(i+1),m=f?e.find(t,f,n):[t];return u&&n.allMatches?m.map(p=>W(e,p,d)):m.length===0?null:W(e,m[0],d)}if(r===".")return e.text(t);let{selector:a,all:s}=j(r),c=e.find(t,a,n);return s&&n.allMatches?c.map(f=>e.text(f)):c.length===0?null:e.text(c[0])}function ct(e,t,{selector:r,codec:o},n){let l=r?e.find(t,r,n):[t];return l.length===0?null:o.read(e,l[0],{query:n.query,view:n.view,region:n.region})}function Ne(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function W(e,t,r){if(be(r))return Te(e.attr(t,"style"),r);if(ze.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function ft(e,t,r,o){let n=e.length,l=t.length,i=new Array(n).fill(-1);if(o){let h=new Set;for(let y=0;y<n;y++){let g=o[y];!(g>=0&&g<l)||h.has(g)||(i[y]=g,h.add(g))}}if(n===0||l===0)return i;let a=e.map(h=>ne(h,r)),s=t.map(h=>ne(h,r)),c=new Array(l).fill(!1);for(let h of i)h>=0&&(c[h]=!0);let f=new Map;s.forEach((h,y)=>{c[y]||f.set(h,f.has(h)?-1:y)});let u=new Map;a.forEach((h,y)=>{i[y]>=0||u.set(h,(u.get(h)||0)+1)}),a.forEach((h,y)=>{if(i[y]>=0||u.get(h)!==1)return;let g=f.get(h);g===void 0||g===-1||c[g]||(i[y]=g,c[g]=!0)});let d=[];for(let h=0;h<n;h++)i[h]<0&&d.push(h);let m=[];for(let h=0;h<l;h++)c[h]||m.push(h);if(d.length===0||m.length===0)return i;let p=n*l+1,w=dt(e,t,r),v=(h,y)=>w(h,y)*p+Math.abs(h-y);for(let[h,y]of pt(d,m,v))i[h]=y;return i}var Se=e=>typeof e=="object"&&e!==null;function ne(e,t){if(!Se(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(o=>{let n=JSON.stringify(e?.[o]);return n===void 0?" undef":n}))}function dt(e,t,r){if(!Se(r))return(a,s)=>e[a]===t[s]?0:1;let o=Object.keys(r),n=a=>o.map(s=>JSON.stringify(a?.[s])),l=e.map(n),i=t.map(n);return(a,s)=>{let c=l[a],f=i[s],u=0;for(let d=0;d<o.length;d++)c[d]!==f[d]&&u++;return u}}function pt(e,t,r){return e.length<=t.length?oe(e,t,r,!1):oe(t,e,(o,n)=>r(n,o),!0)}function oe(e,t,r,o){let n=e.length,l=t.length,i=[];for(let u=0;u<=n;u++)i.push(new Float64Array(l+1).fill(1/0));let a=[];for(let u=0;u<=n;u++)a.push(new Uint8Array(l+1));for(let u=0;u<=l;u++)i[n][u]=0;for(let u=n-1;u>=0;u--)for(let d=l-1;d>=0;d--){let m=r(e[u],t[d])+i[u+1][d+1],p=i[u][d+1];m<=p?(i[u][d]=m,a[u][d]=1):i[u][d]=p}let s=[],c=0,f=0;for(;c<n&&f<l;)a[c][f]&&(s.push(o?[t[f],e[c]]:[e[c],t[f]]),c++),f++;return s}function Re(e,t,r,o,n,l,i,a={}){let s=e.find(t,r,a);if(n.length===0){s.forEach(b=>e.remove(b)),F(a,"onRowsApplied",l.path,[]);return}let c=n.length>s.length,f=s[0]||null;if(c&&!f&&(f=gt(e,t,r,a),!f))throw new R(l.path);let u=s.map(b=>yt(e,b,o,a)),d=null;if(c&&f){d=e.clone(f),a.templateAttr&&e.removeAttr(d,a.templateAttr);let b=e.stripIds(d);b>0&&console.warn(`[hyper-html-api] stripped ${b} id attribute(s) from cloned template at "${l.path.join(".")||"(root)"}"`)}let m=ft(n,u,o,ht(e,s,n,l,a)),p=s.length>0?e.parent(s[0]):xt(e,t,r,f,l,a),w=s.length>0?$e(e,p,s[0]):0,v=Ot(e,s),h=new Set,y=[],g=n.map((b,E)=>{let k=m[E];if(k>=0)return h.add(k),y.push(!1),s[k];y.push(!0);let T=e.clone(d);return e.stripIds(T),T});s.forEach((b,E)=>{h.has(E)||e.remove(b)}),v?Tt(e,p,w,g,y):Et(e,g,y,p,w),mt(e,g,o,n,l,i,a),F(a,"onRowsApplied",l.path,g)}function F(e,t,r,o){if(typeof e[t]=="function")try{return e[t](r.slice(),o)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function ht(e,t,r,o,n){let l=F(n,"identifyRows",o.path,r);if(!Array.isArray(l))return null;let i=new Array(r.length).fill(-1),a=new Set,s=new Map(t.map((c,f)=>[e.identity(c),f]));for(let c=0;c<r.length;c++){if(!l[c])continue;let f=s.get(e.identity(l[c]));f===void 0||a.has(f)||(i[c]=f,a.add(f))}return i}function mt(e,t,r,o,n,l,i){t.forEach((a,s)=>{if(r===null){let c=o[s],f=c==null?"":String(c);e.text(a)!==f&&e.text(a,f)}else{let c=l(e,a,r,o[s],{depth:n.depth+1,path:[...n.path,s]},i);c&&c!==a&&(t[s]=c)}})}function yt(e,t,r,o){return r===null?e.text(t):ke(e,t,r,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function $e(e,t,r){let o=e.children(t);for(let n=0;n<o.length;n++)if(e.sameNode(o[n],r))return n;return-1}function gt(e,t,r,o){if(!o.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),l=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),i=r.replace(/^\s*:scope\s*>\s*/,"").replace(l,""),a=n?wt(i):0,s=ve(i),c=t;for(;c;){let f=e.find(c,i,{includeRulesTag:!1,templateAttr:null});for(let u of f)if(e.attr(u,o.templateAttr)!=null&&!(n&&!bt(e,t,u,a))&&!(s&&!e.matches(e.parent(u),s)))return u;c=e.parent(c)}return null}function wt(e){let t=0,r=null,o=1;for(let n=0;n<e.length;n++){let l=e[n];if(l==="\\")n++;else if(r)l===r&&(r=null);else if(l==='"'||l==="'")r=l;else if(l==="["||l==="(")t++;else if(l==="]"||l===")")t>0&&t--;else if(t===0&&l===">")o++;else{if(t===0&&(l==="+"||l==="~"))return null;if(t===0&&/\s/.test(l)){if(!vt(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return o}function vt(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let o=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return le(o)||le(n)}function le(e){return e===">"||e==="+"||e==="~"}function bt(e,t,r,o){if(o===null)return!0;let n=r;for(let s=0;s<o;s++)if(n=e.parent(n),!n)return!1;let l=e.prop(t,"tagName");if(!l)return!0;let i=e.prop(n,"tagName");if(!i||String(i).toLowerCase()!==String(l).toLowerCase())return!1;let a=new Set(ie(e,n));return ie(e,t).every(s=>a.has(s))}function ie(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function xt(e,t,r,o,n,l){let i=e.parent(o);if(i&&At(e,t,i)&&!se(e,i,l))return i;let a=ve(r);if(!a)throw new R(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let s=(a===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,a,l)).filter(c=>!se(e,c,l));if(s.length===0)throw new R(n.path,`no container matching "${a}" inside this context to hold the new rows`);if(s.length>1)throw new R(n.path,`"${a}" matches ${s.length} containers inside this context, so the new rows have no single destination`);return s[0]}function At(e,t,r){let o=r;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var ae=["no-data","editor-ui"];function se(e,t,r){let o=t;for(;o;){if(r.templateAttr&&e.attr(o,r.templateAttr)!=null||ae.some(l=>e.attr(o,l)!=null))return!0;let n=e.attr(o,"clay");if(n&&n.split(/\s+/).some(l=>ae.includes(l)))return!0;o=e.parent(o)}return!1}function Tt(e,t,r,o,n){let l=e.children(t),i=l.map(s=>e.identity(s)),a=!1;o.forEach((s,c)=>{let f=e.identity(s),u=r+c;if(i[u]===f)return;if(!n[c]){let m=i.indexOf(f);m!==-1&&(i.splice(m,1),l.splice(m,1))}let d=Math.min(u,l.length);d<l.length?e.insertBefore(l[d],s):l.length?a?e.insertAfter(l[l.length-1],s):(e.insertAt(t,s,u),a=!0):e.insertAt(t,s,0),i.splice(d,0,f),l.splice(d,0,s)})}function Ot(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let o=new Map(e.children(r).map((l,i)=>[e.identity(l),i])),n=[];for(let l of t){let i=o.get(e.identity(l));if(i===void 0)return!1;n.push(i)}return n.sort((l,i)=>l-i),n[n.length-1]-n[0]===n.length-1}function Et(e,t,r,o,n){let l=null,i=n;for(let a=0;a<t.length;a++){if(!r[a]){l=t[a];continue}let s=l?e.parent(l):o;if(!s)continue;let c=l?$e(e,s,l)+1:i++;e.insertAt(s,t[a],c),l=t[a]}}function kt(e,t,r,o,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");Ee(r,n);let l=[];if(z(r,o,[],l),l.length)throw new ye(l);I(e,t,r,o,{depth:0,path:[]},n)}function I(e,t,r,o,n,l={}){if(n.depth>L)throw new G(n.path);if(o===void 0)return t;if(typeof r=="string")return Nt(e,t,r,o,n,l);if(Array.isArray(r)){let[i,a]=r;return Re(e,t,i,a,o,n,I,l),t}if(typeof r=="object"&&r!==null){for(let[i,a]of Object.entries(r)){let s=I(e,t,a,o==null?o:o[i],{depth:n.depth+1,path:[...n.path,i]},l);s&&s!==t&&(t=s)}return t}return t}function Nt(e,t,r,o,n,l){if(r.endsWith("[]")){let u=r.slice(0,-2);return Re(e,t,u,null,o,n,I,l),t}let i=Oe(r,l);if(i){let u=i.selector?e.find(t,i.selector,l):[t];return u.length&&i.codec.write(e,u[0],o,{query:l.query}),t}if(r.startsWith("@"))return ce(e,t,r.slice(1),o);let a=M(r);if(a!==-1){let{selector:u,all:d}=j(r),m=r.slice(a+1),p=u?e.find(t,u,l):[t];for(let w of d?p:p.slice(0,1))ce(e,w,m,o);return t}if(r===".")return ue(e,t,o),t;let{selector:s,all:c}=j(r),f=e.find(t,s,l);for(let u of c?f:f.slice(0,1))ue(e,u,o);return t}function ue(e,t,r){let o=r==null?"":String(r);e.text(t)!==o&&e.text(t,o)}function St(e,t,r,o){if(e.styleVar){e.styleVar(t,r,o);return}it(e,t,r,o)}function ce(e,t,r,o){if(be(r))return St(e,t,r,o==null?"":String(o).trim()),t;if(he.has(r)){let n=e.prop(t,r);if(n===o||n!=null&&o!=null&&String(n)===String(o))return t;throw new ge(r)}if(r==="outerHTML"){let n=o==null?"":String(o);return e.replaceWith(t,n)}if(_e.has(r)){let n=Je(r,o);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(o==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(o);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function z(e,t,r,o){if(t!==void 0){if(typeof e=="string"){if(P(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,l)=>{typeof n=="object"&&n!==null&&o.push({path:S([...r,l]),expected:"scalar",got:N(n)})}):o.push({path:S(r),expected:"array",got:N(t)});return}t!==null&&typeof t=="object"&&o.push({path:S(r),expected:"scalar",got:N(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:S(r),expected:"array",got:N(t)});return}let n=e[1];t.forEach((l,i)=>z(n,l,[...r,i],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:S(r),expected:"object",got:N(t)});return}for(let[n,l]of Object.entries(e))z(l,t[n],[...r,n],o)}}}function N(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function S(e){return e.join(".")}function Rt(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let l=[],i=0;for(;i<n.length;){let a=n[i];if(/\s/.test(a)){i++;continue}if("{}".includes(a)){l.push({type:a,value:a}),i++;continue}if(a==="["){let u=!1,d=i+1;for(;d<n.length&&/\s/.test(n[d]);)d++;if(d<n.length&&/[a-zA-Z_]/.test(n[d])&&(u=!0),!u){l.push({type:a,value:a}),i++;continue}}if(a==="]"){l.push({type:a,value:a}),i++;continue}if(a===":"){l.push({type:t.COLON,value:a}),i++;continue}if(a===","){l.push({type:t.COMMA,value:a}),i++;continue}if(a==='"'||a==="'"){let u=a,d=i+1;for(;d<n.length&&n[d]!==u;)n[d]==="\\"&&d++,d++;l.push({type:t.STRING,value:n.substring(i+1,d),quoted:!0,sourceQuote:u}),i=d+1;continue}let s=i,c;for(;s<n.length&&!/[{},]/.test(n[s]);)if(n[s]===":"){let u=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let m of u){let p=m.substring(1);if(n.substring(s+1,s+1+p.length)===p){d=!0,s+=p.length;break}}if(!d)break}else if(n[s]==="["){for(s++;s<n.length&&n[s]!=="]";){if(n[s]==='"'||n[s]==="'"){let u=n[s];for(s++;s<n.length&&n[s]!==u;)n[s]==="\\"&&s++,s++}s++}s<n.length&&n[s]==="]"&&s++}else s++;c=n.substring(i,s);let f=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?f=t.NUMBER:c==="true"||c==="false"||c==="null"?f=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(f=t.SELECTOR),l.push({type:f,value:c,quoted:!1}),i=s}return l}function o(n){let l="";for(let i=0;i<n.length;i++){let a=n[i];if("{}".includes(a.type)||"[]".includes(a.type)){l+=a.value;continue}if(a.type===t.COLON){l+=a.value;continue}if(a.type===t.COMMA){let s=n[i+1];if(s&&(s.type==="}"||s.type==="]"))continue;l+=a.value;continue}if(a.type===t.STRING&&a.quoted){let s=a.value;a.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(c,f)=>f.length%2===0?f+'\\"':c)),l+=`"${s}"`;continue}if(a.type===t.NUMBER||a.type===t.BOOLEAN){l+=a.value;continue}if(a.type===t.SELECTOR||a.type===t.IDENTIFIER){l+=`"${a.value}"`;continue}l+=`"${a.value}"`}return l}try{let n=r(e),l=o(n);return JSON.parse(l)}catch(n){throw new $("Invalid extraction rules syntax: "+n.message,n)}}var $t=["1","2"];var Ar=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Tr=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),jt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);var Or=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...jt],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function Ct(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Lt(e){return e?(e.nodeType===9||e.nodeType,e):null}function fe(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function Mt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Ut(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let o=r.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var It={semanticExclude:!0,find(e,t,r={}){let o=Lt(e);if(!o||!o.querySelectorAll)return[];let n=Array.from(o.querySelectorAll(t));r.includeRulesTag||(n=n.filter(a=>!Ct(a)));let l=[];r.skip&&l.push(r.skip);let i=r.templateAttr===null?null:r.templateAttr||"cms-template";if(i&&l.push("["+i+"]"),l.length){let a=l.join(", ");n=n.filter(s=>!s.closest||!s.closest(a))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Mt(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),fe(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),fe(e,t,null)},prop(e,t,r){if(r===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return Ut(t),t},insertAt(e,t,r){let o=e.children[r]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let o=r.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};var U=It;var Pt="hha:upgrade-check:";function x(e,t){let r=e.querySelector(`meta[name="${t}"]`),o=r?r.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function de(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Dt(e,t){let r=de(e),o=de(t);if(!r||!o)return!1;let n=Math.max(r.length,o.length);for(let l=0;l<n;l++){let i=r[l]||0,a=o[l]||0;if(i!==a)return i>a}return!1}function qt(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Ht(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Bt({force:e=!1,doc:t,loc:r,fetchFn:o,now:n,ttlMs:l=864e5}={}){if(t=t||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),o=o||(d=>fetch(d)),n=n??Date.now(),!t)return null;let i=x(t,"hyper-source");if(!i)return null;let a=x(t,"hyper-version"),s;try{s=new URL(i,r?r.href:void 0)}catch{return null}if(r&&s.origin===r.origin&&s.pathname===r.pathname)return null;let c=`${Pt}${s.href}:${a||"none"}`,f,u=e?null:qt(c);if(u&&typeof u.checkedAt=="number"&&n-u.checkedAt<l)f=u.sourceVersion;else{try{let d=await o(s.href);if(!d.ok)throw new Error(`HTTP ${d.status}`);let m=await d.text(),p=new DOMParser().parseFromString(m,"text/html");f=x(p,"hyper-version")}catch{f=null}Ht(c,{checkedAt:n,sourceVersion:f})}return f?{available:Dt(f,a||"0.0.0"),currentVersion:a,sourceVersion:f,sourceUrl:s.href}:null}var Wt="script[data-rules-name]";function Vt(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function je(e,t){let r=e.find(t,Wt,{includeRulesTag:!0}),o=new Set,n=[];for(let l of r){let i=Vt(e.attr(l,"data-rules-name"));if(!i)continue;if(o.has(i)){console.warn(`hyper-html-api: duplicate rules tag name "${i}"; using the first.`);continue}let a=e.attr(l,"data-rules-version");if(!$t.includes(a))throw new me(a);o.add(i),n.push({name:i,rules:Rt(e.text(l)),version:a})}return n}function Ce(e,t){if(t!=="2"||!e||typeof e!="object"||Array.isArray(e))return{rules:e,carried:[]};let r={},o=[];for(let[n,l]of Object.entries(e)){let i=P(l);i?o.push({key:n,selector:i.selector}):r[n]=l}return{rules:r,carried:o}}function Le(e,t,r){return e.find(t,r)[0]||null}function Me(e,t){let r={};for(let{name:o,rules:n,version:l}of je(e,t)){let{rules:i,carried:a}=Ce(n,l),s=ke(e,t,i,{version:l});for(let{key:c,selector:f}of a){let u=Le(e,t,f);s[c]=u?e.prop(u,"innerHTML"):null}r[o]=s}return r}function Ft(e){let t=e||document,r=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Me(U,t),version:x(r,"hyper-version")}}var pe=class extends Error{constructor(e,t){super(`could not fetch upgrade source: ${e}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=e,this.cause=t}},zt=class extends Error{constructor(e){super(`upgrade source has no rules tags; refusing to drop all existing data: ${e}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=e}},_=class extends Error{constructor(e,t){super(e),this.name="UpgradeTransformInvalid",this.cause=t}},_t=class extends Error{constructor(e){super(`found ${e} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=e}},Jt="text/hyper-upgrade";function Yt(e,t){let r=e.find(t,`script[type="${Jt}"]`);if(r.length===0)return null;if(r.length>1)throw new _t(r.length);return e.text(r[0])||null}var Gt=new Function("url","return import(url)");async function Xt(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),o;try{o=await Gt(r)}catch(n){throw new _(`transform failed to load: ${n&&n.message?n.message:n}`,n)}finally{URL.revokeObjectURL(r)}if(typeof o.default!="function")throw new _("transform must `export default` a function");return o.default}function Ue(e,t){let r={carriedOver:0,discarded:0,listItems:0},o=J(t,e,r);return Y(t,e,r),{data:o,summary:r}}function J(e,t,r,o=!1){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(r.listItems+=t.length,r.carriedOver+=t.length,t):o?[]:void 0:t==null||typeof t=="object"?o&&!Kt(e)?null:void 0:(r.carriedOver++,t);if(Array.isArray(e)){let[,n]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(l=>J(n,l,r,!0))):o?[]:void 0}if(typeof e=="object"&&e!==null){let n={};for(let[l,i]of Object.entries(e)){let a=J(i,t?.[l],r,o);a!==void 0&&(n[l]=a)}return n}}function Kt(e){let t=M(e);return t!==-1&&he.has(e.slice(t+1))}function Y(e,t,r){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let n of Object.keys(t))o.has(n)?Y(e[n],t[n],r):r.discarded+=C(t[n]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(n=>Y(o,n,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=C(t))}}function C(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+C(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+C(r),0):1}function Zt(e,t,r){let o=je(e,t),n={carriedOver:0,discarded:0,listItems:0},l={},i=new Set;for(let{name:a,rules:s,version:c}of o){if(i.add(a),!Object.prototype.hasOwnProperty.call(r,a)){l[a]={carriedOver:0,discarded:0,listItems:0};continue}let{rules:f,carried:u}=Ce(s,c),d=r[a],{data:m,summary:p}=Ue(Qt(d,u),f);kt(e,t,f,m,{templateAttr:"cms-template"});for(let{key:w,selector:v}of u){let h=Ie(d)?d[w]:void 0;if(h==null)continue;let y=Le(e,t,v);typeof h=="string"&&y?(e.prop(y,"innerHTML",h),p.carriedOver+=1):p.discarded+=1}l[a]=p,n.carriedOver+=p.carriedOver,n.discarded+=p.discarded,n.listItems+=p.listItems}for(let a of Object.keys(r))i.has(a)||(n.discarded+=C(r[a]));return{totals:n,byName:l,rulesTagCount:o.length}}function Ie(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Qt(e,t){if(!t.length||!Ie(e))return e;let r={...e};for(let{key:o}of t)delete r[o];return r}async function er({sourceUrl:e,dataByName:t,fromVersion:r,doc:o,loc:n,fetchFn:l}={}){if(o=o||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),l=l||(h=>fetch(h)),!o)throw new Error("upgrade.run requires a document context");if(e=e||x(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let i=new URL(e,n?n.href:void 0);r=r!==void 0?r:x(o,"hyper-version"),t=t||Me(U,o);let a;try{a=await l(i.href)}catch(h){throw new pe(i.href,h)}if(!a.ok)throw new pe(i.href,new Error(`HTTP ${a.status}`));let s=await a.text(),c=new DOMParser().parseFromString(s,"text/html"),f=x(c,"hyper-version"),u=t,d=!1,m=Yt(U,c);if(m){let h=await(await Xt(m))(u,{fromVersion:r,toVersion:f});if(!h||typeof h!="object"||Array.isArray(h))throw new _("transform must return a plain object map of { rulesName: data }");u=h,d=!0}let{totals:p,byName:w,rulesTagCount:v}=Zt(U,c,u);if(v===0&&Object.keys(u).length>0)throw new zt(i.href);return{html:rr(c),fromVersion:r,toVersion:f,summary:{transformApplied:d,totals:p,byName:w}}}function tr(e){for(let t of e.querySelectorAll("input")){let r=(t.getAttribute("type")||"").toLowerCase();r!=="file"&&(r==="checkbox"||r==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let r=[...t.options];if(!t.multiple){let o=r.findIndex(n=>n.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of r)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function rr(e){return tr(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
2
|
+
`+e.documentElement.outerHTML}var D={checkForUpdate:Bt,run:er,extractAll:Ft,shapeMatch:Ue};var A="The new version could not be downloaded. Nothing was changed.",q="The upgrade could not be saved. Nothing was changed.",qe="This document changed somewhere else. Reload and try again.",nr="Something else is changing this document. Nothing was changed.",or="This document does not say which parts are its data, so it cannot be upgraded safely. Nothing was changed.",lr="The new version has no place for this page's content. Nothing was changed.";async function ir(e){let t=globalThis.crypto&&globalThis.crypto.subtle;if(!t)return null;let r=await t.digest("SHA-256",e);return[...new Uint8Array(r)].map(o=>o.toString(16).padStart(2,"0")).join("")}async function Pe(e,t){try{let r=await e(t,{credentials:"omit"});return!r||!r.ok?null:r}catch{return null}}function ar(e,t,r){if(e&&typeof e.latestUrl=="string"&&e.latestUrl)return e.latestUrl;let o=x(t,"hyper-source");if(!o)return null;try{let n=new URL(o,r?r.href:void 0);return n.pathname=n.pathname.replace(/\.html$/,".json"),n.href}catch{return null}}function sr(e){let t=x(e,"clay-template");if(!t)return null;let[r,o]=t.split(/\s+/);return r&&o?{id:r,variant:o}:null}function H(e,t="",r=[]){if(Array.isArray(e)){for(let o of e)H(o,`${t}[]`,r);return r}if(e&&typeof e=="object"){for(let[o,n]of Object.entries(e))H(n,t?`${t}.${o}`:o,r);return r}return e!=null&&r.push({path:t,value:e}),r}function ur(e,t){let r=[e];for(let o of String(t).split(".")){let n=o.endsWith("[]"),l=n?o.slice(0,-2):o,i=[];for(let a of r){let s=l?a?.[l]:a;n?Array.isArray(s)&&i.push(...s):i.push(s)}r=i}return r}function cr(e,t,r={}){let o=new Map;for(let{path:l,value:i}of H(t)){let a=`${l}\0${String(i)}`;o.set(a,(o.get(a)||0)+1)}let n=[];for(let{path:l,value:i}of H(e)){let a=`${l}\0${String(i)}`;if(o.get(a)>0){o.set(a,o.get(a)-1);continue}let s=r[l];typeof s=="string"&&ur(t,s).some(c=>c===i)||n.push({path:l,value:i})}return n}async function fr(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t);try{return await new Function("url","return import(url)")(r)}finally{URL.revokeObjectURL(r)}}async function dr(e){let r=new DOMParser().parseFromString(e,"text/html").querySelector('script[type="text/hyper-upgrade"]');if(!r)return{};let o=await fr(r.textContent||"");return o&&o.renames&&typeof o.renames=="object"?o.renames:{}}var De='script[clay~="live"][merge]';function pr(e,t,r){let o=t.querySelector("article[data-blockeditor]");if(!o)return null;o.replaceWith(t.importNode(r,!0));for(let l of e.querySelectorAll(De)){let i=l.getAttribute("merge");if(i!=="blockeditor"&&!i.startsWith("blockeditor."))continue;let a=t.importNode(l,!0),s=[...t.querySelectorAll(De)].find(c=>c.getAttribute("merge")===i);s?s.replaceWith(a):t.querySelector("article[data-blockeditor]").after(a)}return(t.doctype?`<!DOCTYPE ${t.doctype.name}>
|
|
3
|
+
`:"")+t.documentElement.outerHTML}async function He(e,{doc:t=document,loc:r=location,fetchFn:o=(n,l)=>fetch(n,l)}={}){if((typeof window<"u"&&window.clay||{}).isDraftMode)return{ok:!1,code:"draft"};if(!e||typeof e.version!="string")return{ok:!1,code:"unavailable",message:A};let l=ar(e,t,r);if(!l)return{ok:!1,code:"unavailable",message:A};let i=await Pe(o,l);if(!i)return{ok:!1,code:"unavailable",message:A};let a;try{a=await i.json()}catch{return{ok:!1,code:"unavailable",message:A}}if(!a||typeof a!="object")return{ok:!1,code:"unavailable",message:A};let s=sr(t);if(!s||a.id!==s.id||a.variant!==s.variant)return{ok:!1,code:"template",message:"This upgrade is for a different document."};let c=x(t,"hyper-version");if(!c||typeof a.version!="string"||!Q(a.version,c))return{ok:!1,code:"not-newer",message:"There is no newer version to install."};if(typeof a.html!="string"||!a.html)return{ok:!1,code:"unavailable",message:A};let f;try{f=new URL(a.html,l).href}catch{return{ok:!1,code:"unavailable",message:A}}if(!/^https:\/\/hyperclay\.com\/templates\//.test(f))return{ok:!1,code:"source",message:"This upgrade is not from the template host."};let u=await Pe(o,f);if(!u)return{ok:!1,code:"unavailable",message:A};let d;try{d=await u.text()}catch{return{ok:!1,code:"unavailable",message:A}}let m=await ir(new TextEncoder().encode(d));if(!m||m!==String(a.sha256||"").toLowerCase())return{ok:!1,code:"unavailable",message:A};let p,w;try{w=await dr(d),p=await D.run({sourceUrl:f,doc:t,loc:r,fromVersion:c,fetchFn:async()=>({ok:!0,status:200,text:async()=>d})})}catch(T){return{ok:!1,code:"transform",message:T&&T.message?T.message:A}}let v=new DOMParser().parseFromString(p.html,"text/html"),h=D.extractAll(t).dataByName,y=t.querySelector("article[data-blockeditor]");if(!y&&!Object.keys(h||{}).length)return{ok:!1,code:"undeclared",message:or};let g=p.html;if(y){let T=pr(t,v,y);if(!T)return{ok:!1,code:"lost",lost:[],discarded:0,message:lr};g=T}let b=D.extractAll(v).dataByName,E=cr(h,b,w),k=p.summary&&p.summary.totals&&p.summary.totals.discarded||0;return E.length||k>0?{ok:!1,code:"lost",lost:E,discarded:k,message:hr(E,k)}:{ok:!0,html:g,version:p.toVersion||a.version}}function hr(e,t){let r=e.slice(0,5).map(({path:n})=>n),o=e.length>r.length?` and ${e.length-r.length} more`:"";return r.length?`This upgrade would lose data: ${r.join(", ")}${o}. Nothing was changed.`:`This upgrade would lose ${t} value${t===1?"":"s"}. Nothing was changed.`}function mr(e){let t=e&&e.state;if(t==="conflict")return{ok:!1,code:"conflict",message:qe};let r=e&&e.message?e.message:"The document could not be saved.";return{ok:!1,code:"flush",state:t||"failed",message:r}}async function Be(e,{doc:t=document,loc:r=location,fetchFn:o=(s,c)=>fetch(s,c),clay:n=typeof window<"u"?window.clay:null,reload:l=()=>window.location.reload(),replace:i=null,etag:a}={}){if((n||{}).isDraftMode)return{ok:!1,code:"draft"};let c=K("upgrade");if(!c)return{ok:!1,code:"busy",message:nr};try{return await yr(e,{doc:t,loc:r,fetchFn:o,clay:n,reload:l,replace:i,etag:a})}finally{Z(c)}}async function yr(e,{doc:t,loc:r,fetchFn:o,clay:n,reload:l,replace:i,etag:a}){let s=n||{};if(s.isEditMode&&s.save&&typeof s.save.flush=="function"){let p;try{p=await s.save.flush()}catch(w){return mr(w)}if(p&&typeof p.state=="string"&&p.state!=="saved"&&p.state!=="clean"&&p.state!=="view")return{ok:!1,code:"flush",state:p.state,message:"This document has changes that could not be saved. Nothing was changed."}}if(a===void 0&&!B())try{await X()}catch{}let c=a!==void 0?a:B(),f=t;if(s.isEditMode&&typeof s.getHTML=="function")try{f=new DOMParser().parseFromString(await s.getHTML(),"text/html")}catch{return{ok:!1,code:"failed",message:q}}else f=new DOMParser().parseFromString(`<!DOCTYPE html>
|
|
4
|
+
`+t.documentElement.outerHTML,"text/html");let u=await He(e,{doc:f,loc:r,fetchFn:o});if(!u.ok)return u;let d=typeof i=="function"?i:s.save&&typeof s.save.replace=="function"?s.save.replace:ee,m;try{m=await d(u.html,{etag:c})}catch{return{ok:!1,code:"failed",message:q}}if(!m||!m.ok){let p=m&&m.code?m.code:"failed";return p==="conflict"?{ok:!1,code:p,message:qe}:p==="forbidden"?{ok:!1,code:p,message:"You are not allowed to save this document."}:p==="unsupported"?{ok:!1,code:p,message:"This host cannot save the upgrade."}:{ok:!1,code:p,message:q}}return l(),{ok:!0,html:u.html,version:u.version,etag:m.etag}}function O(e,t,r={}){let o=e.createElement(t);o.setAttribute("clay","editor-ui");for(let[n,l]of Object.entries(r))n==="style"?o.setAttribute("style",l):n==="text"?o.textContent=l:o.setAttribute(n,l);return o}function gr(e){let r=(e&&e.pathname?e.pathname:"/").split("/").filter(Boolean).pop()||"page.html";try{r=decodeURIComponent(r)}catch{}return/\.html?$/i.test(r)?r:`${r}.html`}async function wr(e,{loc:t=location,fetchFn:r=(o,n)=>fetch(o,n)}={}){if(typeof e.getHTML=="function")return e.getHTML();let o=await r(t.href,{cache:"no-store",credentials:"same-origin"});if(!o.ok)throw new Error(`copy fetch ${o.status}`);return o.text()}async function vr({clay:e,doc:t=document,loc:r=location,fetchFn:o}={}){if(typeof URL>"u"||typeof URL.createObjectURL!="function")return!1;try{let n=await wr(e,{loc:r,fetchFn:o});if(typeof n=="string"&&/clay|data-paid-only/i.test(n)){let{stripCopyContent:a}=await import("./c-C4IIQZGJ.js");n=a(n)}let l=URL.createObjectURL(new Blob([n],{type:"text/html"})),i=t.createElement("a");return i.setAttribute("clay","editor-ui"),i.href=l,i.download=gr(r),i.style.setProperty("display","none","important"),t.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(l),4e4),!0}catch{return!1}}async function br(e){let t=e&&e.host;if(!t||!t.versions)return!1;try{return await t.versions===!0}catch{return!1}}async function xr(e,t={}){let r=t.doc||document,o=t.clay||(typeof window<"u"?window.clay:null)||{};if(o.isDraftMode||!e||typeof e.version!="string")return null;let n=await br(o),l=O(r,"div",{role:"dialog","aria-modal":"true","data-clay-upgrade":"",style:"position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(15,17,21,.42);font-family:system-ui,-apple-system,'Segoe UI',sans-serif;"}),i=O(r,"div",{style:"width:min(460px,100%);padding:20px;border-radius:14px;background:var(--clay-ui-bg,#fff);color:var(--clay-ui-fg,#1f2328);box-shadow:0 18px 48px -16px rgba(0,0,0,.55);font-size:14px;line-height:1.5;"}),a=O(r,"h2",{text:`Upgrade to version ${e.version}`,style:"margin:0 0 8px;font-size:16px;"}),s=O(r,"p",{text:`Your data moves into version ${e.version}. The page's layout and code are replaced; your current version stays in this document's history.`,style:"margin:0 0 16px;"}),c=O(r,"p",{role:"status",style:"margin:0 0 12px;min-height:1.5em;"}),f=O(r,"div",{style:"display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;"}),u="padding:7px 12px;border-radius:8px;border:1px solid rgba(23,28,36,.2);background:transparent;color:inherit;font:inherit;cursor:pointer;",d=O(r,"button",{type:"button",text:"Cancel",style:u}),m=n?null:O(r,"button",{type:"button",text:"Download a copy first",style:u}),p=O(r,"button",{type:"button",text:"Upgrade",style:`${u}border-color:transparent;background:#2f6fed;color:#fff;font-weight:600;`});n||(p.disabled=!0),m&&f.append(m),f.append(d,p),i.append(a,s,c,f),l.append(i),r.body.appendChild(l);let w=!1,v=()=>{w||(w=!0,l.remove())};m&&m.addEventListener("click",async()=>{await vr({clay:o,doc:r,loc:t.loc,fetchFn:t.fetchFn})?(p.disabled=!1,c.textContent="Your copy was downloaded."):c.textContent="The copy could not be downloaded. Nothing was changed."}),d.addEventListener("click",v);let h,y=new Promise(g=>{h=g});return p.addEventListener("click",async()=>{p.disabled=!0,m&&(m.disabled=!0),c.textContent=`Upgrading to version ${e.version}\u2026`;let g=await Be(e,t);if(g.ok){v(),h(g);return}c.textContent=g.message||q,p.disabled=!1,m&&(m.disabled=!1),h(g)}),{root:l,title:a,body:s,status:c,cancel:d,download:m,upgrade:p,close:v,done:y}}export{Be as apply,He as prepare,xr as start};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as X,f as G,h as J,i as Q,j as P,k as U}from"./c-NICICT4P.js";import{a as C,f as L}from"./c-
|
|
1
|
+
import{e as X,f as G,h as J,i as Q,j as P,k as U}from"./c-NICICT4P.js";import{a as C,f as L}from"./c-CZHTXGJS.js";import"./c-WN3MXOLT.js";import"./c-V2V5FKXX.js";import{a as O,b as N,k as z,l as K,m as j,n as V,v as T}from"./c-WMRJKQ2V.js";import{p as w}from"./c-ZRGEN6QQ.js";import"./c-OH2FPYSY.js";import{b as y,d as H}from"./c-RETTCOWO.js";import{b as W}from"./c-RS77ODLY.js";import"./c-7SWMYKAI.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import{d as q}from"./c-QQFHEODI.js";import"./c-IJUK2GPW.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.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 ce=128,D=r=>r.depth?r.node(1).attrs.id:null,Z=r=>!!r.depth&&r.node(1).type.name==="table",ae=(r,t,o,e,n)=>O(K(z(r.flow,J(t,o.holes,e,o.visible),n)));function te({pd:r,w:t,doc:o},e){if(!r||!t||!o||!e)return null;if(e instanceof y.TextSelection){let n=e.$anchor,s=e.$head;if(Z(n)||Z(s)){let a=P(o,n.pos),u=P(o,s.pos);return!a||!u||a.table!==u.table||a.row!==u.row||a.col!==u.col?null:{kind:"cell",block:a.table,row:a.row,col:a.col}}let i=Math.min(e.from,e.to),l=a=>{let u=D(a);return u===null?null:{block:u,rel:ae(r,o,t,a.pos,e.empty||a.pos===i?0:-1)}},c=l(n),m=l(s);return c&&m?{kind:"text",anchor:c,head:m}:null}if(e instanceof w||e instanceof y.NodeSelection){let n=[];if(e instanceof w){let{lo:s,hi:i}=e.span();o.forEach((l,c,m)=>{m>=s&&m<=i&&n.push(l.attrs.id)})}else{let s=o.nodeAt(e.from);s&&n.push(s.attrs.id)}if(!n.length)return null;if(n.length>ce){let s=D(e.$from);return s?{kind:"blocks",ids:[s]}:null}return{kind:"blocks",ids:n}}return null}var ue=(r,t)=>{if(!t||typeof t!="object"||typeof t.block!="string"||!t.block||typeof t.rel!="string"||!t.rel)return null;let o;try{o=j(N(t.rel))}catch{return null}let e;try{e=V(o,r.ydoc)}catch{return null}return!e||e.type!==r.flow?null:e.index},fe=(r,t)=>{let o=0;for(let e=r.flow._start;e;e=e.right){let n=o+e.length;if(t<n)return!e.deleted;o=n}return!1},de=(r,t)=>{for(let o=r.flow._start;o;o=o.right)if(!o.deleted&&o.content instanceof T&&o.content.embed?.b===t)return!0;return!1},me=(r,t)=>{let o=0,e=null,n=0;for(let s=r.flow._start;s;s=s.right)if(s.content instanceof T&&s.content.embed?.b!==void 0&&(e=s.content.embed.b,n=o+s.length),o+=s.length,o>t&&e!==null)return{id:e,offset:t-n};return e===null?null:{id:e,offset:t-n}},pe=(r,t,o)=>{let e=null;return r.forEach((n,s)=>{e===null&&n.attrs.id===t&&n.isTextblock&&(e=s+1+Math.min(Math.max(o,0),n.content.size))}),e},ee=({pd:r,w:t,doc:o},e)=>{let n=ue(r,e);if(n===null)return null;let s=Q(o,t.holes,t.tokens,n,t.visible);if(D(o.resolve(s))===e.block)return s;let i=me(r,n);if(i&&i.id===e.block){let l=pe(o,e.block,i.offset);if(l!==null)return l}return de(r,e.block)||!fe(r,n)||t.holes.some(l=>n>=G(t.holes,l.at)&&n<X(t.holes,l.at))?null:o.resolve(s).parent.inlineContent?s:null};function oe({pd:r,w:t,doc:o},e){if(!r||!t||!o||!e||typeof e!="object")return null;if(e.kind==="text"){let n=ee({pd:r,w:t,doc:o},e.anchor),s=ee({pd:r,w:t,doc:o},e.head);return n===null||s===null?null:{kind:"text",from:Math.min(n,s),to:Math.max(n,s)}}if(e.kind==="cell"){let n=U(o,{table:e.block,row:e.row,col:e.col,offset:0});return n?{kind:"cell",from:n.from,to:n.to,block:n.block,row:n.row,col:n.col}:null}if(e.kind==="blocks"){let n=[],s=[];for(let i of Array.isArray(e.ids)?e.ids:[])o.forEach((l,c)=>{l.attrs.id!==i||n.includes(i)||(n.push(i),s.push({from:c,to:c+l.nodeSize}))});return s.length?{kind:"blocks",ids:n,ranges:s}:null}return null}var{Plugin:be,PluginKey:ge}=y,{Decoration:h,DecorationSet:x}=H,k=new ge("blockeditor-awareness"),ne="blockeditor-awareness-style",he=`
|
|
2
2
|
.blockeditor-remote-selection { background-color: color-mix(in srgb, var(--blockeditor-remote-color, currentColor) 22%, transparent); }
|
|
3
3
|
.blockeditor-remote-caret { position: relative; display: inline-block; width: 0; height: 1.1em; vertical-align: text-bottom; }
|
|
4
4
|
.blockeditor-remote-caret::before { content: ""; position: absolute; inset-inline-start: -1px; top: 0; bottom: 0; width: 2px; background: var(--blockeditor-remote-color, currentColor); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,b as C,c as O,d as L,e as R,f as A,g as S,h as T,i as I}from"../c-
|
|
1
|
+
import{a as b,b as C,c as O,d as L,e as R,f as A,g as S,h as T,i as I}from"../c-CJ7QYEWI.js";import{a as l,b as u,c,d as f}from"../c-MQYEDF3Q.js";import{a as d,b as E,c as m,d as p}from"../c-JQF2EUCG.js";import"../c-TWCXBWS3.js";import"../c-VKEDWYDF.js";import{a}from"../c-LA2BW7UY.js";import"../c-IJUK2GPW.js";import{f as s}from"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import"../c-PWJSJEJU.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 N=[d,R,A,b,l].join(", "),x=[E,S,C,u],o=null,n=null,i=!1,D=t=>{let e=t.parentNode||t;for(let q of x)q(e)};function r(){i=!0,!n&&(n=a.onAddElement({selectorFilter:N,require:"observed",pausable:!1,debounce:0},t=>{i&&t.forEach(({element:e})=>D(e))}))}function k(){i=!1,n&&(n(),n=null)}function h(){return o||(p(),I(),L(),f(),o={selector:N},s&&r(),o)}h();function w(t=document){return{enable(){for(let e of x)e(t);r()},quiesce(){i=!1},resume(){i=!0},dispose(){k(),m(),T(),O(),c()}}}function y(){return{id:"clay:controls",order:110,prepare(t={}){let e=w();return t.initial!==!0?e:{enable:()=>r(),quiesce:()=>e.quiesce(),resume:()=>e.resume(),dispose:()=>e.dispose()}}}}var F=h;export{w as controlsLease,F as default,h as init,h as install,y as modeParticipant};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e,h as i}from"../c-
|
|
1
|
+
import{R as e,h as i}from"../c-HTLYXCUH.js";import"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import{a as p}from"../c-5VYOWDTI.js";import"../c-6Q6RGFBF.js";import"../c-SKMIR5HQ.js";import{a as f,b as m}from"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import{a as d}from"../c-LA2BW7UY.js";import"../c-MFOSMAVM.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-6IJEVE6B.js";import"../c-QQFHEODI.js";import{c}from"../c-IJUK2GPW.js";import{f as a}from"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import"../c-PWJSJEJU.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import{s as n,v as o}from"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function y(){d.onAnyChange({debounce:0,omitChangeDetails:!0,require:"autosave"},()=>{i()&&e.noteActivity()})}function A(){document.addEventListener("input",t=>{t.target.closest(f)&&(t.isTrusted&&!o(n(t.target),"dirty")&&c(),i()&&e.noteActivity())},!0)}function g(){let t=v=>{if(!e.pending())return;let r=v.target;if(!r||typeof r.closest!="function")return;let s=r.closest("input, textarea, select, [contenteditable]");s&&(o(n(s),"dirty")||i()&&e.noteActivity())};document.addEventListener("input",t,!0),document.addEventListener("compositionupdate",t,!0)}var l=!1;function u(){l||document.documentElement.matches(m)&&a&&(l=!0,p(!0),y(),A(),g())}u();var C=u;function L(){return{id:"clay:autosave",order:20,prepare(t={}){return t.initial===!0?{enable(){},quiesce(){},resume(){},dispose(){}}:{enable:u,quiesce(){},resume(){},dispose(){}}}}}export{C as default,u as init,L as modeParticipant};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as m}from"../c-VKEDWYDF.js";import{r as h}from"../c-
|
|
1
|
+
import{a as m}from"../c-VKEDWYDF.js";import{r as h}from"../c-HTLYXCUH.js";import"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import"../c-5VYOWDTI.js";import"../c-6Q6RGFBF.js";import"../c-SKMIR5HQ.js";import"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import"../c-LA2BW7UY.js";import"../c-MFOSMAVM.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-6IJEVE6B.js";import{d as g}from"../c-QQFHEODI.js";import"../c-IJUK2GPW.js";import{f as p}from"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import{b as f}from"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import"../c-PWJSJEJU.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 s=()=>window.clay?.conflicts||null,o=!1,r=null,l=null;function e(t){o||(o=!0,v(),import("../c-42ZNV7LI.js").then(n=>{r=n,n.start(t)},n=>{console.error("clayjs: the conflict notice could not be downloaded; it will try again on the next conflict",n),o=!1,u()}))}function u(){l||=new AbortController;let{signal:t}=l;document.addEventListener("clay:sync-conflicts-changed",w,{signal:t}),document.addEventListener("clay:save-conflict",b,{signal:t}),document.addEventListener("clay:document-upgraded",k,{signal:t}),document.addEventListener("clay:undo-kept",x,{signal:t})}function v(){l?.abort(),l=null}function w(t){s()?.size&&e(t)}function b(t){e(t)}function k(t){e(t)}function x(t){t?.detail?.ok===!0&&e(t)}var C="conflicts",L="undo",y=t=>f.local.get(t)?.count>0;function D(){y(L)&&e(null),y(C)&&import("../c-OIDRZKAF.js").then(t=>{!o&&t.pendingConflicts()>0&&e(null)},()=>{})}function N(){let t=(s()?.list?.()??[]).filter(n=>!n.claimedBy).map(n=>n.id);return t.length?t:h()?["save"]:[]}var a=null,i=0;function E(){let t=++i;g().then(n=>{let c=n.extensions.includes("data-guard-v1")?n.document?.dataGuard?.href:null;return t!==i||typeof c!="string"||!c?null:import("../c-CVSWLX3X.js").then(d=>{t===i&&(a=d,d.start({href:c}))})}).catch(n=>{console.error("clayjs: the data-loss notice could not start; it will try again on the next open",n)})}function j(){i++,a?.stop(),a=null}function A(){return{id:"clay:conflict-notice",order:960,prepare(t={}){return{enable(){t.initial!==!0&&(!r&&!o&&u(),E())},quiesce(){let n=N();if(n.length)throw Object.assign(new Error("clay.conflict-notice: a conflict here is still unresolved"),{code:"conflict",pending:n})},resume(){},dispose(){v(),o=!1,r?.stop?.(),r=null,j()}}}}}m(()=>{p&&(s()?.size?e(null):(u(),D()),E())});export{A as conflictNoticeParticipant,A as modeParticipant};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../c-U4NTUVDZ.js";import"../c-VHNSBD2M.js";export{a as DRAFT_ATTR,b as DRAFT_PLUGIN,e as draftEligible,d as draftSlot,k as draftStoreFailed,g as draftTransport,m as draftUnconfirmed,i as flushDraft,c as noteBootParams,h as setDraftFlush,j as setDraftStoreFailed,f as setDraftTransport,l as setDraftUnconfirmed};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as n,c as m,d as r}from"../c-
|
|
1
|
+
import{a as s,b as n,c as m,d as r}from"../c-QQFHEODI.js";import{d as l}from"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var e=null,u=0;async function p({fresh:f=!1}={}){let o=location.pathname,t=await r({fresh:f});if(location.pathname!==o||n(t)!==o&&(t=await r({fresh:!0}),location.pathname!==o||n(t)!==o))return e;let a=s(t);if(a==="failed"||a==="ok"&&!t.document)return e;let i=a==="ok"?t.document.writable:void 0,c=m(t);return c<u||(u=c,e=typeof i=="boolean"?i:null,l(e)),e}export{p as checkHostPermission};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o}from"../c-
|
|
1
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o}from"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";export{b as canEdit,h as commitModeFacts,a as isDraftMode,e as isEditMode,g as isOwner,d as learnedHostWritable,f as mode,i as modeState,c as noteHostWritable,k as noteParticipantForget,l as peekModeParticipants,n as registerModeParticipant,o as siteVisibility,j as startsAtImport,m as takeModeParticipants};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as h}from"../c-WYFDLITL.js";import{f as m}from"../c-
|
|
1
|
+
import{a as h}from"../c-WYFDLITL.js";import{f as m}from"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import{k as b}from"../c-PWJSJEJU.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";function v(t){return(t.getAttribute("type")||"text").toLowerCase()}function d(t){let n=t.tagName;if(n==="INPUT"){let i=v(t);i==="checkbox"||i==="radio"?t.checked?t.setAttribute("checked",""):t.removeAttribute("checked"):t.setAttribute("value",t.value);return}if(n==="TEXTAREA"){t.setAttribute("data-value",t.value);return}if(n==="SELECT"){let i=t.options;for(let o=0;o<i.length;o++)i[o].selected?i[o].setAttribute("selected",""):i[o].removeAttribute("selected")}}function y(t,n=t){let i=t.tagName;if(i==="INPUT"){let o=v(t);o==="checkbox"||o==="radio"?n.checked?t.hasAttribute("checked")||t.setAttribute("checked",""):t.removeAttribute("checked"):n.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",n.value);return}if(i==="TEXTAREA"){let o=n.value.startsWith(`
|
|
2
2
|
`)?`
|
|
3
3
|
`+n.value:n.value;t.textContent!==o&&(t.textContent=o),t.removeAttribute("data-value");return}if(i==="SELECT"){let o=t.options,u=n.options;for(let s=0;s<o.length;s++)u[s]&&u[s].selected?o[s].hasAttribute("selected")||o[s].setAttribute("selected",""):o[s].removeAttribute("selected")}}function E(t=h){let n=`input${t}:not([type="password"]):not([type="hidden"]):not([type="file"])`,i=`textarea${t}`,o=`select${t}`,u=a=>{if(!m)return;let e=a.target;(e.matches(n)&&e.type!=="checkbox"&&e.type!=="radio"||e.matches(i))&&d(e)};document.addEventListener("input",u,!0);let s=a=>{if(!m)return;let e=a.target;if((e.matches(n)&&(e.type==="checkbox"||e.type==="radio")||e.matches(o))&&(d(e),e.type==="radio"&&e.name)){let c=e.form?[...e.form.elements]:[...document.getElementsByName(e.name)];for(let r of c)r!==e&&r.type==="radio"&&r.name===e.name&&r.form===e.form&&r.matches(n)&&d(r)}};document.addEventListener("change",s,!0);let x=[{target:document,type:"input",handler:u,options:!0},{target:document,type:"change",handler:s,options:!0}];return b((a,e)=>{let c=r=>{a.querySelectorAll(r).forEach(f=>{let A=e.original(f);A&&y(f,A)})};c(n),c(i);for(let r of a.querySelectorAll(o))if(e.original(r))for(let l of r.options){let f=e.original(l);f&&f.selected?l.hasAttribute("selected")||l.setAttribute("selected",""):l.removeAttribute("selected")}}),{stop(){for(let{target:a,type:e,handler:c,options:r}of x.splice(0))a.removeEventListener(e,c,r)}}}var p=null;function T(){return p||(p=E(h),p)}T();export{E as default,T as init,T as install};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f}from"../c-
|
|
1
|
+
import{a,b,c,d,e,f}from"../c-SKMIR5HQ.js";import"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";export{b as beginRecoveryCapture,e as createRecovery,c as finishRecoveryCapture,a as noteRecoveryCapture,d as noteRecoverySettled,f as recovery};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as C,B as D,C as E,D as F,E as G,F as H,G as I,H as J,I as K,J as L,K as M,L as N,M as O,N as P,O as Q,P as R,Q as S,R as T,S as U,T as V,U as W,V as X,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p,o as q,p as r,q as s,r as t,s as u,t as v,u as w,v as x,w as y,x as z,y as A,z as B}from"../c-
|
|
1
|
+
import{A as C,B as D,C as E,D as F,E as G,F as H,G as I,H as J,I as K,J as L,K as M,L as N,M as O,N as P,O as Q,P as R,Q as S,R as T,S as U,T as V,U as W,V as X,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p,o as q,p as r,q as s,r as t,s as u,t as v,u as w,v as x,w as y,x as z,y as A,z as B}from"../c-HTLYXCUH.js";import{a as e}from"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import"../c-5VYOWDTI.js";import"../c-6Q6RGFBF.js";import"../c-SKMIR5HQ.js";import"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import"../c-LA2BW7UY.js";import{b as c,c as d}from"../c-MFOSMAVM.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-6IJEVE6B.js";import"../c-QQFHEODI.js";import"../c-IJUK2GPW.js";import"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import{K as b,r as a}from"../c-PWJSJEJU.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";export{e as SLICED_SAVE_MIN_BYTES,m as acceptedReceipt,a as addDocumentTransform,n as adoptEntryBaseline,i as autosaveIsSuspended,T as autosaveScheduler,M as baselineSettled,f as claimFailure,y as closeSavePermit,u as conflictResolvedBySync,N as currentPaintSignature,X as default,I as flushSave,D as getLastSavedBytes,B as getLastSavedContents,C as getLastSavedDirty,b as getPageContents,z as getUnsavedChanges,p as holdAllSaves,W as init,V as initHyperclaySaveButton,U as initSaveKeyboardShortcut,d as inspectSaveSize,t as isSaveConflicted,o as modeParticipant,x as openSavePermit,q as releaseAllSaves,R as releaseBootSettle,K as replacePageWith,h as resumeAutosave,v as saveGeneration,s as saveHoldReason,c as saveLimits,J as saveOverwritingConflict,G as savePage,H as savePageForce,L as savePageSoon,S as savePageThrottled,l as saveSession,j as savesAdmitted,r as savesHeld,O as schedulePaintHeal,k as sessionParked,E as setLastSavedBaselines,F as setLastSavedContents,w as setSaveGeneration,A as setUnsavedChanges,Q as styleAdoptionPending,P as styleAdoptionsSettled,g as suspendAutosave};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p,n as q,o as r,p as s,q as t,r as u,s as v,t as w,u as x,v as y,w as z,x as A,y as B}from"../c-
|
|
1
|
+
import{d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p,n as q,o as r,p as s,q as t,r as u,s as v,t as w,u as x,v as y,w as z,x as A,y as B}from"../c-MFOSMAVM.js";import{a as d}from"../c-LD6UVV5R.js";import{b as e,h as f}from"../c-PGSBXHUE.js";import"../c-6IJEVE6B.js";import"../c-QQFHEODI.js";import"../c-IJUK2GPW.js";import"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import{K as c,k as a,r as b}from"../c-PWJSJEJU.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";export{e as PAGE_FORMAT_META,b as addDocumentTransform,h as addSaveHeaderSource,v as buildSaveRequest,s as claimDocumentOperation,B as exitSave,c as getPageContents,j as isSaveInProgress,m as keepaliveHeld,f as knownPageFormatFloor,q as mintSaveId,d as onSaveAccepted,n as onSaveAttempt,o as onSaveOutcome,a as onSnapshot,u as operationKind,t as releaseDocumentOperation,l as releaseSaveLane,z as replacePageWith,k as reserveSaveLane,r as resetSaveAttempts,x as saveCapturedHtml,y as saveConversion,p as saveFateIsUnknown,w as saveHtml,A as setExitSave,g as setSaveHeader,i as withKeepalive};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as g,z as E}from"../c-
|
|
1
|
+
import{Q as g,z as E}from"../c-HTLYXCUH.js";import"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import"../c-5VYOWDTI.js";import"../c-6Q6RGFBF.js";import"../c-SKMIR5HQ.js";import"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import{a as m}from"../c-LA2BW7UY.js";import{e as S}from"../c-MFOSMAVM.js";import{a as v}from"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-6IJEVE6B.js";import"../c-QQFHEODI.js";import"../c-IJUK2GPW.js";import"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import"../c-PWJSJEJU.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 T="Site-Data",M='script[data-rules-name~="api"]',R=/(?:^|[{,])\s*["']?site["']?\s*:/,h={html:null,now:null,keys:[]},l=null,a=null,u=h,b=null,y=new Set,f=new Map;function k(){let t=E();if(typeof t!="string"||!t)return!1;if(t===b)return!0;let e=d(w(t));if(!a)a=e;else for(let[n,o]of Object.entries(e)){if(y.has(n))continue;let s=f.get(n);a[n]=s&&s.sent===o?s.value:o}return f.clear(),b=t,u=h,!0}function j(t){let e=l.engine.findRulesIn(t,"api")?.rules?.site;return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function d(t){let e=j(t);if(!e)return{};let n=l.extractData(t,{site:e}).site??{};return Object.fromEntries(Object.entries(n).map(([o,s])=>[o,JSON.stringify(s)]))}var w=t=>new DOMParser().parseFromString(t,"text/html").documentElement;function O(t){if(u.html!==t){let e=d(w(t));u={html:t,now:e,keys:Object.keys(e).filter(n=>e[n]!==a[n])}}return u}function x(t){return!l||typeof t!="string"||!k()?null:{[T]:`keys=${O(t).keys.map(encodeURIComponent).join(",")}`}}function H(t,e,n){let o=document.documentElement,s=j(o),c=d(o),p=[];for(let[r,A]of Object.entries(t)){if(n.has(r)||!s||!Object.hasOwn(s,r)||c[r]!==e[r])continue;let C=new Map([...o.querySelectorAll("[editable]")].map(i=>[i,i.innerHTML]));m.pause();try{l.applyData(o,{site:{[r]:A}},{site:{[r]:s[r]}}),a[r]=d(o)[r],f.set(r,{sent:e[r],value:a[r]}),p.push(r)}catch(i){console.error(`clayjs: the shared value "${r}" could not be refreshed on this page`,i)}finally{m.resume()}for(let[i,D]of C)i.isConnected&&i.innerHTML!==D&&i.dispatchEvent(new CustomEvent("clay:external-write"))}return p.length&&g(),p}function L(t,e){if(!l||!k())return;f.clear();let n=O(t).now,o=new Set((e?.refused??[]).filter(c=>c.code!=="stale").map(c=>c.key));for(let c of Object.keys(n))o.has(c)?y.add(c):(a[c]=n[c],y.delete(c));if(u=h,!e)return;let s=e.current?H(e.current,n,o):[];document.dispatchEvent(new CustomEvent("clay:site-data",{detail:{written:e.written??[],refused:e.refused??[],applied:s}}))}var U=R.test(document.querySelector(M)?.textContent??"")?(()=>{let t=import("../c-277QP5ET.js");return S(x),v((e,n)=>L(e,n.siteData??null)),t.then(e=>{l=e}).catch(e=>console.error("clayjs: shared site edits are not tracked on this page",e))})():Promise.resolve();export{T as SITE_DATA_HEADER,U as ready};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"../c-
|
|
1
|
+
import{a,b,c}from"../c-HTLYXCUH.js";import"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import"../c-5VYOWDTI.js";import"../c-6Q6RGFBF.js";import"../c-SKMIR5HQ.js";import"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import"../c-LA2BW7UY.js";import"../c-MFOSMAVM.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-6IJEVE6B.js";import"../c-QQFHEODI.js";import"../c-IJUK2GPW.js";import"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import"../c-PWJSJEJU.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";export{c as bytesUnsaved,b as hasUnsavedChanges,a as reloadAfterDiscard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as t,t as n,w as i}from"../c-
|
|
1
|
+
import{g as t,t as n,w as i}from"../c-MFOSMAVM.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-6IJEVE6B.js";import"../c-QQFHEODI.js";import"../c-IJUK2GPW.js";import"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import{G as o,r as a,t as e}from"../c-PWJSJEJU.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import{w as r}from"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var s=window.clay=window.clay||{};s.internals={captureSnapshot:e,captureForSave:o,addDocumentTransform:a,region:r,save:{saveHtml:n,replacePageWith:i,isSaveInProgress:t}};var l=s.internals;export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as X}from"./c-RS77ODLY.js";import"./c-7SWMYKAI.js";import{f as J}from"./c-46XYM55L.js";import{b as V}from"./c-QTTJYJMA.js";import{a as F}from"./c-VKEDWYDF.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import"./c-IJUK2GPW.js";import{b as G}from"./c-CYWLPPUS.js";import{i as z}from"./c-VG5XIN4T.js";import{a as W}from"./c-2YYDMLNZ.js";import{c as H,l as $}from"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var K={always:["lib/mutation.js","core/preserve-authored.js","core/edit-mode.js","core/mode-key.js","core/stale-host-notice.js","core/page-data.js"],editOnly:["core/snapshot.js","core/persist.js","core/admin-attrs.js","core/save-core.js","core/save.js","core/conflict-notice.js","core/recovery.js","core/unsaved-warning.js","core/autosave.js","attrs/save-freeze.js","attrs/onaftersave.js","attrs/refetch-on-save.js","attrs/add-from.js","lib/cache-bust.js"]},O={richclay:{path:"plugins/richclay.js",editOnly:!0,default:!0},indicator:{path:"plugins/indicator.js",editOnly:!0,default:!1},sync:{path:"sync/live-sync.js",editOnly:!1,default:!1},live:{path:"plugins/live.js",editOnly:!1,default:!1},blockeditor:{path:"plugins/page.js",editOnly:!0,default:!1},"blockeditor-view":{path:"plugins/page-view.js",editOnly:!1,default:!1,internal:!0},sortable:{path:"plugins/sortable.js",editOnly:!0,default:!1},undo:{path:"plugins/undo.js",editOnly:!0,default:!1},unsent:{path:"plugins/unsent.js",editOnly:!0,default:!1},cms:{path:"plugins/cms.js",editOnly:!1,default:!1},quickcrop:{path:"plugins/quickcrop.js",editOnly:!1,default:!1},upload:{path:"plugins/upload.js",editOnly:!0,default:!1},people:{path:"plugins/people.js",editOnly:!1,default:!1},menu:{path:"plugins/menu.js",editOnly:!1,default:!1},wire:{path:"plugins/wire.js",editOnly:!1,default:!1},message:{path:"plugins/message.js",editOnly:!1,default:!1},like:{path:"plugins/like.js",editOnly:!1,default:!1},"ai-edit":{path:"plugins/ai-edit.js",editOnly:!0,default:!1},demo:{path:"plugins/demo.js",editOnly:!1,default:!1},source:{path:"plugins/source.js",editOnly:!0,default:!0},"visitor-drafts":{path:"plugins/visitor-drafts.js",ownerPath:"plugins/visitor-drafts-owner.js",editOnly:!1,default:!1},"visitor-menu":{path:"plugins/visitor-menu.js",editOnly:!0,draft:!0},"bind-text":{path:"plugins/bind-text.js",editOnly:!0,default:!1},derive:{path:"plugins/derive.js",editOnly:!1,default:!1},upgrade:{path:"plugins/upgrade.js",editOnly:!1,default:!1}},S={"core/is-edit-mode.js":()=>import("./core/is-edit-mode-FFHCQ5DR.js"),"core/draft-mode.js":()=>import("./core/draft-mode-4MCL3LYI.js"),"lib/region-policy.js":()=>import("./lib/region-policy-KWBPROWF.js"),"lib/mutation.js":()=>import("./reader-core-T2S3JC4E.js").then(t=>t.core["lib/mutation.js"]),"core/edit-mode.js":()=>import("./reader-core-T2S3JC4E.js").then(t=>t.core["core/edit-mode.js"]),"core/mode-key.js":()=>import("./reader-core-T2S3JC4E.js").then(t=>t.core["core/mode-key.js"]),"core/stale-host-notice.js":()=>import("./reader-core-T2S3JC4E.js").then(t=>t.core["core/stale-host-notice.js"]),"core/page-data.js":()=>import("./reader-core-T2S3JC4E.js").then(t=>t.core["core/page-data.js"]),"core/preserve-authored.js":()=>import("./reader-core-T2S3JC4E.js").then(t=>t.core["core/preserve-authored.js"]),"core/snapshot.js":()=>import("./core/snapshot-FJP5IJL3.js"),"core/save-core.js":()=>import("./core/save-core-EVMNZQ4V.js"),"core/save.js":()=>import("./core/save-6HT2LABE.js"),"core/site-edits.js":()=>import("./core/site-edits-G4BOZMV4.js"),"core/conflict-notice.js":()=>import("./core/conflict-notice-FOEE6I7E.js"),"core/recovery.js":()=>import("./core/recovery-APWADU4K.js"),"core/unsaved-warning.js":()=>import("./core/unsaved-warning-ITZDIZ2I.js"),"core/persist.js":()=>import("./core/persist-6ILUR34S.js"),"core/admin-attrs.js":()=>import("./core/admin-attrs-ONRWVXPK.js"),"core/autosave.js":()=>import("./core/autosave-TBKAAAFB.js"),"attrs/save-freeze.js":()=>import("./attrs/save-freeze-JZHKRQLR.js"),"attrs/onaftersave.js":()=>import("./attrs/onaftersave-OKSWEJQF.js"),"attrs/refetch-on-save.js":()=>import("./attrs/refetch-on-save-DPGJJMGN.js"),"attrs/add-from.js":()=>import("./attrs/add-from-T5LJXFFI.js"),"lib/cache-bust.js":()=>import("./lib/cache-bust-NH7VBWHO.js"),"plugins/richclay.js":()=>import("./plugins/richclay-Y2NV44NA.js"),"plugins/indicator.js":()=>import("./plugins/indicator-J4ABFARX.js"),"sync/live-sync.js":()=>import("./sync/live-sync-Z64YREWQ.js"),"plugins/live.js":()=>import("./plugins/live-PGBIEMGB.js"),"plugins/page.js":()=>import("./plugins/page-WOCNX2IN.js"),"plugins/page-view.js":()=>import("./plugins/page-view-SJODOOGE.js"),"plugins/sortable.js":()=>import("./plugins/sortable-XCHQG65Z.js"),"plugins/undo.js":()=>import("./plugins/undo-VLRBQNPN.js"),"plugins/unsent.js":()=>import("./plugins/unsent-OA4RGBUT.js"),"plugins/cms.js":()=>import("./plugins/cms-T2HLI7JG.js"),"plugins/quickcrop.js":()=>import("./plugins/quickcrop-X5MRIBAP.js"),"plugins/upload.js":()=>import("./plugins/upload-ZKKJV76X.js"),"plugins/people.js":()=>import("./plugins/people-C4TCWFOQ.js"),"plugins/menu.js":()=>import("./plugins/menu-YZL3X2AJ.js"),"plugins/wire.js":()=>import("./plugins/wire-M2NR354P.js"),"plugins/message.js":()=>import("./plugins/message-LQ6EDH4V.js"),"plugins/like.js":()=>import("./plugins/like-EV7MTZ56.js"),"plugins/ai-edit.js":()=>import("./plugins/ai-edit-LABECCSN.js"),"plugins/demo.js":()=>import("./plugins/demo-T7B4RIKL.js"),"plugins/visitor-drafts.js":()=>import("./plugins/visitor-drafts-RTZNONHT.js"),"plugins/visitor-drafts-owner.js":()=>import("./plugins/visitor-drafts-owner-LHUHFU3L.js"),"plugins/visitor-menu.js":()=>import("./plugins/visitor-menu-FY4KM2SW.js"),"plugins/bind-text.js":()=>import("./plugins/bind-text-NX46N5UV.js"),"plugins/source.js":()=>import("./plugins/source-YK7MO23W.js"),"plugins/derive.js":()=>import("./plugins/derive-6LPJOCAV.js"),"plugins/upgrade.js":()=>import("./plugins/upgrade-NNTJBSK2.js")},re=["visitor-drafts","visitor-menu","richclay","indicator","sortable","undo","unsent","quickcrop","upload","people","menu","upgrade","cms","blockeditor-view","sync","live","blockeditor","message","like","wire","ai-edit","demo","derive","bind-text","source"],ae={cms:["quickcrop","upload","menu"],"ai-edit":["wire"],blockeditor:["live","sync","upload","wire","ai-edit"]},ce={blockeditor:["richclay"]},le={blockeditor:["undo"]},ue=new Set(["source","sortable","menu","upgrade"]),de=new Set(["wire","ai-edit"]);function Q(t,e,o,s){let u=t.get(e);if(u)for(let i of u.split(",")){let a=i.trim();if(a){if(!O[a]||O[a].internal){console.warn(`clayjs: unknown plugin "${a}"`);continue}s(o,a)}}}var pe=["sync","live","blockeditor","upload","quickcrop","cms","people","menu","upgrade","wire","ai-edit","demo","source"],fe="core/site-edits.js",me=["attrs/refetch-on-save.js","core/conflict-notice.js"],ge="https://hyperclay.com/templates/";function P(t,e,{isDraftMode:o=!1,hasSap:s=!1,hasVariants:u=!1,hasSite:i=!1,canEdit:a=!1,templateSource:h=null}={}){let d=[...K.always];e&&d.push(...K.editOnly),e&&!o&&i&&d.splice(d.indexOf("core/save.js")+1,0,fe);let p=new Set;Q(t,"plugins",p,(r,c)=>r.add(c));let j=new Set;Q(t,"exclude",j,(r,c)=>r.add(c));let n=new Set(p);for(let[r,c]of Object.entries(O))c.default&&n.add(r);s&&n.add("derive"),u&&(e||a)&&n.add("menu"),!e&&!o&&n.has("blockeditor")&&n.add("blockeditor-view");for(let r of[...n])if(!j.has(r)&&!(O[r].editOnly&&!e))for(let c of ae[r]||[])n.add(c);j.has("wire")&&n.delete("ai-edit");for(let r of j)n.delete(r);if(o){let r=n.has("blockeditor");for(let c of pe)r&&(c==="blockeditor"||c==="live")||n.delete(c);for(let c of me){let y=d.indexOf(c);y>-1&&d.splice(y,1)}n.add("visitor-drafts")}!o&&a&&!j.has("upgrade")&&h&&h.startsWith(ge)&&n.add("upgrade");for(let[r,c]of Object.entries(ce))if(n.has(r))for(let y of c)p.has(y)||n.delete(y);for(let[r,c]of Object.entries(le))if(n.has(r))for(let y of c)n.has(y)&&(n.delete(y),console.warn(`clayjs: plugin "${y}" cannot run with "${r}" and was left out`));let g=[],w=[];for(let r of re){if(!n.has(r))continue;let c=O[r];if(c.editOnly&&!e||c.draft&&!o)continue;(ue.has(r)||de.has(r)&&n.has("blockeditor")?w:g).push(c.ownerPath&&!o?c.ownerPath:c.path)}return{core:d,plugins:g,late:w}}var _="data-deleted-at",I=(t,e)=>window.clay?.undo?.commit?window.clay.undo.commit(t,e):e(),Y=(t,e)=>t.dispatchEvent(new CustomEvent(e,{bubbles:!0})),R=Object.assign((t,{at:e=new Date().toISOString()}={})=>(I("Move to Trash",()=>t.setAttribute(_,e)),Y(t,"clay:trashed"),{undo:()=>R.restore(t)}),{is:t=>!!t.getAttribute(_),restore(t){I("Restore",()=>t.removeAttribute(_)),Y(t,"clay:restored")},purge(t){I("Delete forever",()=>t.remove())}});var Z=50,he=1e3,ye='[clay~="no-snapshot"], [no-snapshot], [snapshot-remove]',L=0,je=t=>{let e=t.nodeType===1?t:t.parentElement;if(!e)return"a detached node";let o=e.localName;return e.id?o+="#"+e.id:e.classList.length&&(o+="."+[...e.classList].slice(0,2).join(".")),"<"+o+">"};function ve(t){let e=window.clay?.region?.resolveRegionPolicy;if(!e)return null;let o=s=>!!s&&!s.closest(ye)&&e(s).dirtyTracked;for(let s of t){if(s.type==="attributes"&&$(s.attributeName,s.target))continue;let u=s.target.nodeType===1?s.target:s.target.parentElement;if(o(u)&&!(s.type==="childList"&&![...s.addedNodes,...s.removedNodes].some(i=>i.nodeType!==1||o(i))))return s.target}return null}function q(t){let e=window.clay,o=e.Mutation,s=new Set,u=(m,f)=>{s.has(m)||(s.add(m),console.warn("clay.effect: "+f))},i=!1,a=!1,h=0,d=0;L&&e.isEditMode&&console.warn("clay.effect: an effect was created inside another effect, so a new one starts on every run. Create effects once, in clay.start.");let p=()=>{let m=Date.now();m-h>he&&(h=m,d=0),++d>Z&&u("loop",`this effect ran more than ${Z} times in a second. Something keeps changing the document, often a timer or async callback the effect started.`)},j=()=>{if(i=!1,a)return;let m=null;o.pause(),L++;try{e.isEditMode===!0&&(p(),s.has("saved")||(m=new MutationObserver(()=>{}),m.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0})));let f=t();f&&typeof f.then=="function"&&(y(),console.error("clay.effect: fn returned a promise. It must be synchronous, so this effect was stopped."))}catch(f){console.error("clay.effect:",f)}finally{L--,o.resume();let f=m?m.takeRecords():[];if(m?.disconnect(),f.length){let E=ve(f);E&&u("saved",`this effect changed ${je(E)}, which is saved with the file. Effect writes never mark the page unsaved, so a merge can leave it dirty with no save scheduled. Draw derived values inside clay="no-dirty" or clay="editor-ui".`)}}},n=()=>{i||a||(i=!0,queueMicrotask(j))},g=["undo","redo"],w=()=>{for(let m of g)e.undo?.on?.(m,n)},r=m=>{m.detail?.applied?.length&&n()},c=o.onAnyChange({debounce:0,require:"observed"},n);document.addEventListener("clay:sync-applied",n),document.addEventListener("clay:site-data",r),document.addEventListener("clay:modechange",w),w();let y=()=>{a=!0,c(),document.removeEventListener("clay:sync-applied",n),document.removeEventListener("clay:site-data",r),document.removeEventListener("clay:modechange",w);for(let m of g)e.undo?.off?.(m,n)};return n(),y}Object.defineProperty(q,"running",{get:()=>L>0});var we={overtype:()=>import("./c-PQ5LK6QE.js"),marked:()=>import("./c-XN6MBKI6.js"),highlight:()=>import("./c-33JJ6CBX.js"),"highlight/bash":()=>import("./c-KI7M4AY3.js"),"highlight/css":()=>import("./c-H4LG442Q.js"),"highlight/javascript":()=>import("./c-VDSS4K3Z.js"),"highlight/json":()=>import("./c-NRPJEVJS.js"),"highlight/python":()=>import("./c-5YIHJ3TJ.js"),"highlight/xml":()=>import("./c-WN5AY3OZ.js"),uimotion:()=>import("./c-B5CS55WR.js")};function be(t){let e=new Map;function o(s){return Object.hasOwn(t,s)?(e.has(s)||e.set(s,t[s]().catch(u=>{throw e.delete(s),u})),e.get(s)):Promise.reject(new Error(`clay.assets: no asset named "${s}"`))}return{load:o,names:()=>Object.keys(t)}}var ee=be(we);function T(t,e){if(!t||!e)return t;let o={...e,...t};for(let s of["entries","imports","bootImports"])o[s]={...e[s],...t[s]};return o}var Oe="plugins/page.js";function M(t,e,{isEditMode:o=!1,isDraftMode:s=!1,hasSapJs:u=!1}={},i=document){if(!t?.entries)return 0;let a=[...e];for(let n of e)for(let g of t.bootImports?.[n]??[])u&&g==="vendor/sap-core.vendor.js"||a.push(g);o&&!s&&a.push(...t.editBootImports??[]),o&&!s&&e.includes(Oe)&&a.push(...t.editorBootImports??[]);let h=new Set,d=n=>{if(!(!n||h.has(n))){h.add(n);for(let g of t.imports?.[n]??[])d(g)}};for(let n of a)d(t.entries[n]);let p=new Set([...i.querySelectorAll('link[rel="modulepreload"]')].map(n=>n.href)),j=0;for(let n of h){let g=new URL(n,t.base).href;if(p.has(g))continue;let w=i.createElement("link");w.rel="modulepreload",w.href=g,w.setAttribute("clay","no-save"),i.head.append(w),j++}return j}var k=Object.fromEntries(Object.entries(O).flatMap(([t,e])=>e.ownerPath?[[e.path,t],[e.ownerPath,t]]:[[e.path,t]])),v={},te=new Set;function oe(t){te.has(t)||(te.add(t),document.dispatchEvent(new CustomEvent("clay:plugin-ready",{detail:{plugin:k[t]}})))}var Se=(t,e,o,s)=>()=>t().then(u=>(M(T(e,u),[...o.core,...o.plugins,...o.late],{isEditMode:!0,hasSapJs:s}),u));function Ee(){return new Promise(t=>F(t))}function A(){let t=document.querySelector('meta[name="hyper-source"]');return t?t.getAttribute("content"):null}async function Je(t,e,o,s=null,u=null,i=null){J(),(await S["core/draft-mode.js"]()).noteBootParams(e),await Ee();let h=await S["core/is-edit-mode.js"](),{isEditMode:d,isDraftMode:p,isOwner:j,siteVisibility:n,canEdit:g}=h;d&&!p&&import("./core/host-permission-X4BENZEU.js").then(l=>l.checkHostPermission()).catch(()=>{}),window.__hyperclayEditMode=d;let w=await S["lib/region-policy.js"](),r=!!document.querySelector("[sap]"),c=document.querySelectorAll("head style[clay-variant]").length>=2,y=/(?:^|[{,])\s*["']?site["']?\s*:/.test(document.querySelector('script[data-rules-name~="api"]')?.textContent??""),m=!!document.querySelector('script[src*="sap.js"]');W.holdSettle=r&&d;let f=P(e,d,{isDraftMode:p,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()});f.plugins.includes("plugins/demo.js")&&h.commitModeFacts({destination:"demo"}),M(T(s,u),[...f.core,...f.plugins],{isEditMode:d,isDraftMode:p,hasSapJs:m}),(d||p)&&!u&&i&&i().then(l=>M(T(s,l),[...f.core,...f.plugins],{isEditMode:d,isDraftMode:p,hasSapJs:m})).catch(()=>{});let E,ne=new Promise(l=>{E=l}),ie={sync:f.plugins.includes("sync/live-sync.js")};for(let l of f.core)v[l]=await S[l](),v[l].install?.();if(Le(v,{isDraftMode:p,isOwner:j,siteVisibility:n},w),se(v),document.documentElement.getAttribute("clay-mode-switch")==="live"){let l=P(e,!0,{isDraftMode:p,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()});v["core/edit-mode.js"].noteLiveSwitch({edit:l,view:P(e,!1,{isDraftMode:p,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()}),loaded:v,modules:S,attach:(b,x)=>{U(b,x);let D=k[b],C=window.clay.plugins;D&&Array.isArray(C)&&!C.includes(D)&&(window.clay.plugins=Object.freeze([...C,D]))},attachEditCore:se,announce:oe,loadEditHints:i?Se(i,s,l,m):null,late:ne})}await v["core/edit-mode.js"].activateInitialMode(),window.clay.plugins=Object.freeze([...f.plugins,...f.late].map(l=>k[l]));let B=d?f:P(e,!0,{isDraftMode:p,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()});window.clay.editPlugins=Object.freeze([...B.plugins,...B.late].map(l=>k[l]));for(let l of f.plugins){let b;try{b=await S[l]()}catch(x){console.error(`clayjs: plugin "${l}" failed to load, continuing without it:`,x);continue}v[l]=b,l==="plugins/visitor-drafts.js"&&await b.restoring,l==="plugins/page-view.js"&&b.start(ie),U(l,b,v)}await Promise.allSettled(f.plugins.map(l=>v[l]?.ready).filter(Boolean)),r&&Pe(v),Te(h),o(window.clay),document.dispatchEvent(new CustomEvent("clay:ready",{detail:{clay:window.clay}})),f.late.length?ke(f.late,h).then(E,E):E()}var N=(t,e)=>O[k[t]]?.editOnly&&!e.startsAtImport();async function ke(t,e){try{await window.clay.blockeditor?.ready}catch{}for(let o of t)if(!N(o,e))try{let s=await S[o]();if(N(o,e)||(v[o]=s,U(o,s,v),await s.ready,N(o,e)))continue;oe(o)}catch(s){console.error(`clayjs: plugin "${o}" failed to load, continuing without it:`,s),document.dispatchEvent(new CustomEvent("clay:plugin-failed",{detail:{plugin:k[o]}}))}}function Pe(t){let e=t["core/save.js"],o=null;try{o=e?e.currentPaintSignature():null}catch(s){console.error("clayjs: could not read the page's painted values:",s)}try{window.Sap&&typeof window.Sap.mount=="function"&&window.Sap.mount()}catch(s){console.error("clayjs: the derive engine failed to mount:",s)}finally{e?.releaseBootSettle()}e&&o!=null&&e.schedulePaintHeal(o)}function Le(t,{isDraftMode:e,isOwner:o,siteVisibility:s},u){let i=window.clay,a=t["lib/mutation.js"],h=t["core/edit-mode.js"];Object.assign(i,{toggleEditMode:h.toggleEditMode,setMode:h.setMode,modeLifecycle:h.modeLifecycle,isDraftMode:e,isOwner:o,siteVisibility:s,Mutation:a.default,region:u.windowRegionShape});for(let p of["mode","isEditMode","canEdit"])Object.defineProperty(i,p,{get:()=>h[p],enumerable:!0,configurable:!0});i.assets=ee;let d=t["core/page-data.js"];i.readData=d.readData,i.writeData=d.writeData,i.ephemeral=H,i.storage=G,i.host={get versions(){return import("./c-B7GOFGQR.js").then(p=>p.hostVersions())}},i.trash=R,i.derived=z,i.effect=q,i.style=X,i.morph=(p,j,n)=>V().then(({morph:g})=>g(p,j,n))}function se(t){let e=window.clay,o=t["core/save.js"];if(o){let a=o.savePage||o.default;a.force=o.savePageForce,a.overwrite=o.saveOverwritingConflict,a.flush=o.flushSave,a.soon=o.savePageSoon,a.limits=o.saveLimits,a.inspect=o.inspectSaveSize,e.save!==a&&typeof e.save?.replace=="function"&&(a.replace=e.save.replace),e.save!==a&&(e.save=a)}e.hasUnsavedChanges=t["core/unsaved-warning.js"]?.hasUnsavedChanges??e.hasUnsavedChanges??(()=>!1);let s=t["core/snapshot.js"];s&&(e.getHTML||(e.getHTML=s.getPageContents),e.addDocumentTransform||(e.addDocumentTransform=s.addDocumentTransform),e.onSnapshot||(e.onSnapshot=s.onSnapshot));let u=t["lib/cache-bust.js"];u&&!e.cacheBust&&(e.cacheBust=u.default);let i=t["core/recovery.js"];i&&!e.recovery&&(e.recovery=i.recovery)}function U(t,e,o=v){let s=window.clay;t==="plugins/undo.js"?s.undo=e.undo||e.default:t==="plugins/unsent.js"?s.unsent=e.unsent:t==="sync/live-sync.js"?(s.morph=e.morph,s.conflicts=e.conflicts,o["core/page-data.js"].setPageDataLiveSync(e.liveSync)):t==="plugins/live.js"?s.live=e.live:t==="plugins/page.js"?s.blockeditor=e.page:t==="plugins/upgrade.js"?(s.save=s.save||{},s.save.replace=e.replace):t==="plugins/cms.js"?s.cms=e.cms||e.default:t==="plugins/upload.js"?s.upload=e.upload||e.default:t==="plugins/people.js"?(s.people=e.people,s.author=e.author,Object.defineProperty(s,"me",{get:e.currentMe,configurable:!0,enumerable:!0})):t==="plugins/message.js"?s.message=e.message:t==="plugins/like.js"?s.like=e.like:t==="plugins/wire.js"?s.wire=e.wire||e.default:t==="plugins/ai-edit.js"?s.aiEdit=e.aiEdit||e.default:t==="plugins/demo.js"?s.demo=e.demo:t==="plugins/richclay.js"?s.RichClay=e.RichClay||e.default:t==="plugins/quickcrop.js"?s.quickcrop=e.quickcrop||e.default:t==="plugins/sortable.js"?s.sortable=e.sortable:t==="plugins/source.js"?s.source=e.source||e.default:t==="plugins/visitor-drafts.js"||t==="plugins/visitor-drafts-owner.js"?s.visitorDrafts=e.visitorDrafts:t==="plugins/bind-text.js"&&(s.bindText=e.bindText)}function Te(t){t.isEditMode||document.addEventListener("click",e=>{e.target.closest?.("[trigger-save]")&&(t.isEditMode||(console.info("clayjs: you're not the owner of this page; changes stay local"),document.dispatchEvent(new CustomEvent("clay:view-save-attempt"))))})}export{Je as boot,Pe as mountDerivedEngine};
|