@panphora/clayjs 1.25.1 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +1 -1
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +1141 -345
- package/dist/m/c-2EPHRF47.js +1 -0
- package/dist/m/{c-2GB34XL4.js → c-2SUFMUZX.js} +2 -2
- package/dist/m/{c-BHLYQGTA.js → c-3S3647J6.js} +1 -1
- package/dist/m/{c-QL4NYM2L.js → c-3S5TNRZA.js} +1 -1
- package/dist/m/{c-3Y234AUB.js → c-3XGLJAS7.js} +2 -2
- package/dist/m/{c-O4YIDULY.js → c-42WBOKFM.js} +1 -1
- package/dist/m/{c-42RLKGEY.js → c-4TP3UXBT.js} +1 -1
- package/dist/m/{c-ASGHHLFX.js → c-5ELELG2F.js} +1 -1
- package/dist/m/{c-T5IWJOMW.js → c-5ZYLTN3Q.js} +1 -1
- package/dist/m/{c-DDCYVLGG.js → c-67TBU56I.js} +1 -1
- package/dist/m/{c-WNOLMHI2.js → c-6BGJAJ67.js} +1 -1
- package/dist/m/{c-XS7G6U3Z.js → c-ABOBD7F3.js} +1 -1
- package/dist/m/{c-5IIEOPIV.js → c-ARO6CPMA.js} +1 -1
- package/dist/m/{c-XUZMRQ7O.js → c-BCS3AZQZ.js} +1 -1
- package/dist/m/c-BOS7GONO.js +1 -0
- package/dist/m/{c-NICICT4P.js → c-DEYHCYJB.js} +1 -1
- package/dist/m/{c-T7LOTEWO.js → c-DZT6W2NG.js} +1 -1
- package/dist/m/c-EHJWIGWN.js +1 -0
- package/dist/m/{c-V2V5FKXX.js → c-EIUKME3W.js} +1 -1
- package/dist/m/{c-ASMLERFA.js → c-EXZOA6XY.js} +1 -1
- package/dist/m/{c-STAPQ2X6.js → c-EYFMAR3M.js} +1 -1
- package/dist/m/{c-DVMDYRAE.js → c-FUN6AKFE.js} +1 -1
- package/dist/m/{c-XMIDHEKF.js → c-GY36NO7C.js} +1 -1
- package/dist/m/{c-TWB5ZQU4.js → c-H47C6PJZ.js} +1 -1
- package/dist/m/c-KD2ME5UN.js +2 -0
- package/dist/m/{c-GO635CRU.js → c-LAKBBJOU.js} +2 -2
- package/dist/m/{c-GNFDX6SU.js → c-LETPPG2F.js} +1 -1
- package/dist/m/{c-LS7IVQVW.js → c-MMV5JULA.js} +1 -1
- package/dist/m/{c-NEQRFC4O.js → c-MVVEIJUU.js} +1 -1
- package/dist/m/{c-XCOQNISP.js → c-N362HNGO.js} +1 -1
- package/dist/m/{c-7K4SCQB7.js → c-ND3W7D5U.js} +1 -1
- package/dist/m/{c-4NAYDOWH.js → c-NNHNXD6M.js} +1 -1
- package/dist/m/{c-DAUQ6JZ3.js → c-NYJ577NL.js} +1 -1
- package/dist/m/{c-3AAQJAKJ.js → c-PWILUN4T.js} +1 -1
- package/dist/m/{c-7Z2625LX.js → c-QA3Q3MDI.js} +1 -1
- package/dist/m/{c-2A2ATCIH.js → c-QKOKMQXA.js} +1 -1
- package/dist/m/{c-TGIMBAWE.js → c-RBWVF4N5.js} +1 -1
- package/dist/m/{c-A5IYL7JI.js → c-SPOEDIMP.js} +1 -1
- package/dist/m/{c-ZJ7726FO.js → c-SRW5OBCF.js} +1 -1
- package/dist/m/{c-A3OKSYRI.js → c-SYOA4T7V.js} +1 -1
- package/dist/m/{c-MHTO3QAD.js → c-TJ5PFOJ2.js} +1 -1
- package/dist/m/{c-NW4ZFKCY.js → c-TKV273YU.js} +1 -1
- package/dist/m/{c-D4N4UJCQ.js → c-UEKJWXCB.js} +2 -2
- package/dist/m/{c-44WITKWQ.js → c-V4DBV5ZV.js} +1 -1
- package/dist/m/c-WHMZCRQD.js +6 -0
- package/dist/m/{c-WMRJKQ2V.js → c-WHQUZM2V.js} +1 -1
- package/dist/m/{c-C27EVUQ6.js → c-XHD7XJTE.js} +1 -1
- package/dist/m/{c-PP3CUF3U.js → c-XONFK3WC.js} +1 -1
- package/dist/m/c-YYIN4NAF.js +30 -0
- package/dist/m/c-ZFAPQQIB.js +1 -0
- package/dist/m/core/{conflict-notice-Y2NTMDGJ.js → conflict-notice-UNDOD4BL.js} +1 -1
- package/dist/m/core/site-edits-C22O53GS.js +1 -0
- package/dist/m/loader-DCKCZKY6.js +1 -0
- package/dist/m/{manifest-A27A4278.js → manifest-7954CBE3.js} +1 -1
- package/dist/m/{manifest-edit-E8A61EB4.js → manifest-edit-93AA79D7.js} +1 -1
- package/dist/m/manifest.json +442 -441
- package/dist/m/page/{editor-HS2CAV3W.js → editor-UF3CIA6V.js} +2 -2
- package/dist/m/plugins/{cms-4KET6RZT.js → cms-KG6TCTR3.js} +1 -1
- package/dist/m/plugins/{live-CO4VJS46.js → live-DF5YS5AH.js} +1 -1
- package/dist/m/plugins/page-GZSU77JS.js +2 -0
- package/dist/m/plugins/{page-view-6KNTXABH.js → page-view-7MM3FEAR.js} +1 -1
- package/dist/m/plugins/{quickcrop-VNRXGRPC.js → quickcrop-UHURKA2F.js} +2 -2
- package/dist/m/plugins/richclay-MXH2GFAZ.js +549 -0
- package/dist/m/plugins/undo-KLHAGV75.js +1 -0
- package/dist/m/sync/{live-sync-DX4K5GDB.js → live-sync-RZQSDMZW.js} +1 -1
- package/dist/offline-manifest.json +360 -360
- package/package.json +1 -1
- package/src/core/site-edits.js +1 -1
- package/src/loader-logic.js +0 -13
- package/src/page/boot-pack.js +1 -0
- package/src/page/history-intent.js +111 -4
- package/src/page/ybind/bridge.js +14 -7
- package/src/page/ybind/moves.js +437 -3
- package/src/page/ybind/origins.js +1 -1
- package/src/page/ybind/recovery.js +1 -1
- package/src/plugins/page.js +48 -4
- package/src/plugins/richclay.js +136 -0
- package/src/plugins/undo.js +169 -7
- package/src/recovery/undo.js +14 -7
- package/src/sync/live-sync.js +24 -0
- package/src/ui/vendor-skin.js +9 -4
- package/dist/m/c-3XNTQQEJ.js +0 -1
- package/dist/m/c-4OZZ7ENT.js +0 -30
- package/dist/m/c-D2OPWOWO.js +0 -2
- package/dist/m/c-LUBZU4AZ.js +0 -6
- package/dist/m/c-LYNLY3MR.js +0 -1
- package/dist/m/c-MLMJUNRV.js +0 -1
- package/dist/m/c-V5L6HWVL.js +0 -1
- package/dist/m/core/site-edits-TIJDPG6H.js +0 -1
- package/dist/m/loader-7ORQVRCK.js +0 -1
- package/dist/m/plugins/page-L3VKIQU2.js +0 -2
- package/dist/m/plugins/richclay-V6WKJTUF.js +0 -549
- package/dist/m/plugins/undo-WUK2NLBA.js +0 -1
- /package/dist/m/plugins/{quickcrop-VNRXGRPC.js.LEGAL.txt → quickcrop-UHURKA2F.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-V6WKJTUF.js.LEGAL.txt → richclay-MXH2GFAZ.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as xt,c as Nt}from"../c-7DJDKPGL.js";import{g as ke}from"../c-P73XPAOA.js";import{a as ve}from"../c-WYFDLITL.js";import"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import{k as Ct}from"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import{a as Vt}from"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import{l as St}from"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var Pt=(()=>{var l=Object.defineProperty,f=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,A=Object.prototype.hasOwnProperty,x=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},j=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of m(n))!A.call(e,a)&&a!==t&&l(e,a,{get:()=>n[a],enumerable:!(o=f(n,a))||o.enumerable});return e},O=e=>j(l({},"__esModule",{value:!0}),e),q={};x(q,{default:()=>$n,endsSentence:()=>Qe,undo:()=>Pe});function pe(e,n=null){let t=[];if(e.type==="attributes"){let o=e.target,a=e.attributeName,i=e.oldValue,d=o.getAttribute(a);return i==null&&d!=null?t.push({kind:"attr-add",target:o,name:a,newValue:d}):i!=null&&d==null?t.push({kind:"attr-remove",target:o,name:a,oldValue:i}):i!==d&&t.push({kind:"attr-set",target:o,name:a,oldValue:i,newValue:d}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let o=e.target,a=e.nextSibling,i=e.nextSibling;for(;i&&n?.(i);)i=i.nextSibling;let d=e.previousSibling;for(;d&&n?.(d);)d=d.previousSibling;let c=n?Array.from(e.addedNodes).filter(v=>!n(v)):Array.from(e.addedNodes),g=n?Array.from(e.removedNodes).filter(v=>!n(v)):Array.from(e.removedNodes);return c.length>0&&t.push({kind:"add",parent:o,nodes:c,before:a,afterAuthored:i,beforeAuthored:d,record:e}),g.length>0&&t.push({kind:"remove",parent:o,nodes:g,before:a,afterAuthored:i,beforeAuthored:d,record:e}),t}return t}function Ut(e,n=null){let t=[],o=new Map;for(let a of e){if(a.type==="attributes"){let i=a.target,d=a.attributeName,c=o.get(i);c||(c=new Map,o.set(i,c)),c.has(d)||(c.set(d,{idx:t.length,oldValue:a.oldValue}),t.push(null));continue}for(let i of pe(a,n))t.push(i)}for(let[a,i]of o)for(let[d,c]of i){let g=c.oldValue,v=a.getAttribute(d),b=null;g===v?b=null:g==null?b={kind:"attr-add",target:a,name:d,newValue:v}:v==null?b={kind:"attr-remove",target:a,name:d,oldValue:g}:b={kind:"attr-set",target:a,name:d,oldValue:g,newValue:v},t[c.idx]=b}return t.filter(a=>a!=null)}function _t(e,{sameContent:n=(t,o)=>t===o}={}){let t=[],o=new Map;for(let i of e){let d=Fe(i);if(d==null){t.push(i);continue}let c=o.get(i.target);c||(c=new Map,o.set(i.target,c));let g=c.get(d);if(g==null){let v=Ue(i);if(v.oldValue===v.newValue)continue;c.set(d,t.length),t.push({...i,...v})}else t[g]={...t[g],newValue:Ue(i).newValue}}let a=[];for(let i of t){if(Fe(i)==null){a.push(i);continue}i.oldValue!==i.newValue&&(i.kind==="value"&&i.content===!0&&n(i.oldValue,i.newValue)||a.push(Ht(i)))}return a}var Wt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function Fe(e){return Wt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function Ue(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function Ht(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var _e=new WeakMap,Jt=0;function $(e){let n=_e.get(e);return n||(n=`n${++Jt}`,_e.set(e,n)),n}function R(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function Yt(e){return e.kind==="add"||e.kind==="remove"}function We(e,n){let t=[],o=e.childNodes;if(!o)return t;for(let a of o)n&&n(a)||t.push($(a));return t}function He(e,n,t){if(typeof n!="function"||!R(e)||e.nodeType!==1)return null;let o=null;try{o=n(e,t)}catch{o=null}return typeof o=="string"?`#form:${JSON.stringify(o)}`:null}function le(e,n,t=null,o=null,a=null,i=null){if(!R(e))return null;let d=He(e,a,t);if(d!=null)return d;if(e.nodeType===3)return`#text:${JSON.stringify(i&&i.has(e)?i.get(e):e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let c=[];if(e.attributes){for(let v of e.attributes)Gt(v.name,e,n,t)||c.push(`${v.name}=${JSON.stringify(v.value)}`);c.sort()}let g=[];if(e.childNodes)for(let v of e.childNodes){let b=He(v,a,t);if(b!=null){g.push(b);continue}Xt(v,o)||g.push(le(v,n,t,o,a,i))}return`<${String(e.tagName||"").toLowerCase()}${c.length?` ${c.join(" ")}`:""}>${g.join("")}</>`}function Ae(e,n=[]){if(!R(e))return n;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&n.push(t)}if(e.childNodes)for(let t of e.childNodes)Ae(t,n);return n}function Gt(e,n,t,o=null){if(typeof t!="function")return!1;try{return!!t(e,n,o)}catch{return!1}}function Xt(e,n){if(typeof n!="function")return!1;try{return!!n(e)}catch{return!1}}function Je(e,n){if(typeof n!="function")return[];let t=[],o=a=>{if(!R(a))return;let i=!1;try{i=!!n(a)}catch{i=!1}if(i&&t.push(D(a,"protected")),a.childNodes)for(let d of a.childNodes)o(d)};for(let a of e)o(a);return t}function D(e,n,t=null){let o=e;o&&o.nodeType!==1&&(o=o.parentElement);let a=o&&typeof o.closest=="function"?o.closest("[data-id]"):null;return!a&&t&&typeof t.closest=="function"&&(a=t.closest("[data-id]")),{id:(a?a.getAttribute("data-id"):null)||null,kind:n||null}}function Zt(e,n,t=null){return(e||[]).filter(R).map(o=>D(o,n,t))}function de(e){return{replayable:!1,reason:e,steps:[]}}function ge(e,n){let t=[[n.afterAuthored,a=>a],[n.beforeAuthored,a=>a+1],[n.before,a=>a]],o=!1;for(let[a,i]of t){if(!R(a))continue;o=!0;let d=e.indexOf($(a));if(d>=0)return i(d)}return o?null:e.length}function Qt(e,n={}){let t=n.isIgnored||null,o=n.ignoreAttribute||null,a=n.durableForm||null,i=_t(e,{sameContent:Ee}),d=[];for(let E of i){if(!Yt(E)){if(!R(E.target))return de("non-dom-target");continue}if(!R(E.parent))return de("non-dom-parent");let C=Array.from(E.nodes||[]).filter(R);if(C.length!==0){if(C.length!==Array.from(E.nodes||[]).length)return de("non-dom-node");d.push({primitive:E,nodes:C,parent:E.parent})}}if(en(d))return de("in-record-move");let c=tn(d,t);if(!c)return de("ambiguous-structure");let g=nn(d,c),v=new Map(d.map(E=>[E.primitive,E])),b=[];for(let E of i){let C=v.get(E);if(!C){b.push(on(E));continue}let N=g.get(C);if(N){N.at===C&&b.push(N.step);continue}b.push(rn(C,c.get(C),o,t,a))}return{replayable:!0,reason:null,steps:b}}function en(e){let n=new Map;for(let t of e){let o=t.primitive.record;if(!o)continue;let a=n.get(o);a||(a=new Map,n.set(o,a));for(let i of t.nodes){let d=a.get(i);d||(d=new Set,a.set(i,d)),d.add(t.primitive.kind)}}for(let t of n.values())for(let o of t.values())if(o.size>1)return!0;return!1}function tn(e,n){let t=new Map;for(let a of e)t.has(a.parent)||t.set(a.parent,We(a.parent,n));let o=new Map;for(let a=e.length-1;a>=0;a--){let i=e[a],d=t.get(i.parent);if(!d)return null;let c=d.slice(),g;if(i.primitive.kind==="add"){let v=i.nodes.map($);if(!v.every(b=>d.includes(b)))return null;g=d.filter(b=>!v.includes(b))}else{let v=ge(c,i.primitive);if(v==null)return null;g=c.slice(),g.splice(v,0,...i.nodes.map($))}o.set(i,{before:g,after:c}),t.set(i.parent,g)}return o}function nn(e,n){let t=new Map,o=new Map;e.forEach((i,d)=>{for(let c of i.nodes){let g=$(c);i.primitive.kind==="remove"?t.set(g,{item:i,index:d,node:c}):o.set(g,{item:i,index:d,node:c})}});let a=new Map;for(let[i,d]of t){let c=o.get(i);if(!c||c.index<d.index||d.item.nodes.length!==1||c.item.nodes.length!==1)continue;let g={type:"move",node:d.node,sourceParent:d.item.parent,destParent:c.item.parent,source:n.get(d.item),dest:n.get(c.item),sourceSlot:d.item.primitive,destSlot:c.item.primitive,targets:[D(d.node,"move")]};a.set(d.item,{step:g,at:c.item}),a.set(c.item,{step:g,at:c.item})}return a}function rn(e,n,t,o,a=null){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:n.before,seqAfter:n.after,slot:e.primitive,content:e.nodes.map(d=>le(d,t,e.parent,o,a)),ids:i==="remove"?e.nodes.flatMap(d=>Ae(d)):[],targets:Zt(e.nodes,i==="add"?"added":"removed",e.parent)}}function on(e){return{type:e.kind,primitive:e,targets:[D(e.target,e.name||e.prop||"text")]}}function an(e,n,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let o={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,durableForm:t.durableForm||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,texts:new Map,operations:[]};for(let a=0;a<e.steps.length;a++){let i=e.steps[n==="undo"?e.steps.length-1-a:a],d=ln(i,n,o);if(d)return{ok:!1,code:d.code,targets:d.targets}}return{ok:!0,operations:o.operations}}function Q(e,n){return e.sim.has(n)||e.sim.set(n,We(n,e.isIgnored)),e.sim.get(n)}function ee(e,n){for(let t=e;t;t=t.parentNode)if(n.planned.has(t))return n.planned.get(t);return n.inScope(e)}function Ye(e,n){return n.liveNodesWithIds(e).filter(t=>ee(t,n)).length>0}function S(e,n){return{code:e,targets:n||[]}}function Ee(e,n){return e===n?!0:typeof e!="string"||typeof n!="string"?!1:e.replace(/\u00A0| /g," ")===n.replace(/\u00A0| /g," ")}function un(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function ln(e,n,t){let o=n==="undo";return e.type==="move"?pn(e,o,t):e.type==="add"?sn(e,o,t):e.type==="restore"?cn(e,o,t):dn(e,o,t)}function dn(e,n,t){let o=e.primitive,a=n?o.newValue:o.oldValue,i=n?o.oldValue:o.newValue;if(!R(o.target))return S("unsupported",e.targets);if(!ee(o.target,t))return S("target-detached",e.targets);if(o.kind==="value"&&typeof o.write=="function"&&typeof o.read!="function")return S("unsupported",e.targets);let d=un(o);return(o.content===!0?!Ee(d,a):d!==a)?S("content-changed",e.targets):(o.kind==="value"?t.operations.push({type:"value",target:o.target,prop:o.prop||"value",value:i,read:o.read||null,write:o.write||null,content:o.content===!0}):o.kind==="text"?(t.operations.push({type:"text",target:o.target,data:i}),t.texts.set(o.target,i)):t.operations.push({type:"attr",target:o.target,name:o.name,value:i??null}),null)}function sn(e,n,t){if(!R(e.parent)||!ee(e.parent,t))return S("target-detached",e.targets);if(n){if(!te(Q(t,e.parent),e.seqAfter))return S("structure-changed",e.targets);let c=Je(e.nodes,t.isProtected);if(c.length>0)return S("protected",c);for(let g=0;g<e.nodes.length;g++)if(le(e.nodes[g],t.ignoreAttribute,e.parent,t.isIgnored,t.durableForm)!==e.content[g])return S("content-changed",e.targets);for(let g of e.nodes)t.operations.push({type:"remove",node:g}),t.planned.set(g,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!te(Q(t,e.parent),e.seqBefore))return S("structure-changed",e.targets);for(let c of e.nodes)if(c.parentNode)return S("structure-changed",e.targets);let o=e.nodes.flatMap(c=>Ae(c));if(o.length>0&&Ye(o,t))return S("duplicate-id",e.targets);let a=ge(e.seqBefore,e.slot);if(a==null)return S("unsupported",e.targets);let i=e.seqBefore.slice(),d=a;for(let c of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:c,beforeId:i[d]??null}),i=i.slice(0,d).concat($(c),i.slice(d)),d+=1,t.planned.set(c,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function cn(e,n,t){if(!R(e.parent)||!ee(e.parent,t))return S("target-detached",e.targets);if(n){if(!te(Q(t,e.parent),e.seqAfter))return S("structure-changed",e.targets);for(let g=0;g<e.nodes.length;g++){let v=e.nodes[g];if(v.parentNode||le(v,t.ignoreAttribute,e.parent,t.isIgnored,t.durableForm)!==e.content[g])return S("content-changed",e.targets)}if(e.ids.length>0&&Ye(e.ids,t))return S("duplicate-id",e.targets);let i=ge(e.seqAfter,e.slot);if(i==null)return S("unsupported",e.targets);let d=e.seqAfter.slice(),c=i;for(let g of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:g,beforeId:d[c]??null}),d=d.slice(0,c).concat($(g),d.slice(c)),c+=1,t.planned.set(g,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!te(Q(t,e.parent),e.seqBefore))return S("structure-changed",e.targets);let o=Je(e.nodes,t.isProtected);if(o.length>0)return S("protected",o);let a=i=>t.planned.get(i)===!0||typeof t.isIgnored=="function"&&t.isIgnored(i);for(let i=0;i<e.nodes.length;i++){let d=e.nodes[i];if(d.parentNode!==e.parent||le(d,t.ignoreAttribute,e.parent,a,t.durableForm,t.texts)!==e.content[i])return S("content-changed",e.targets)}for(let i of e.nodes)t.operations.push({type:"remove",node:i}),t.planned.set(i,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function fn(e,n){let t=e.indexOf(n);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function pn(e,n,t){let o=$(e.node),a=n?e.destParent:e.sourceParent,i=n?e.sourceParent:e.destParent,d=Q(t,a),c=Q(t,i),g=n?e.dest.after:e.source.before,v=n?e.source.after:e.dest.before,b=n?e.sourceSlot:e.destSlot;if(!R(a)||!R(i)||!ee(a,t)||!ee(i,t))return S("target-detached",e.targets);if(!te(d,g))return S("structure-changed",e.targets);let E=a===i?fn(c,o):c;if(!te(E,v))return S("structure-changed",e.targets);let C=ge(v,b);return C==null?S("unsupported",e.targets):(t.operations.push({type:"insert",parent:i,node:e.node,beforeId:v[C]??null}),t.planned.set(e.node,!0),n?(t.sim.set(i,e.source.before.slice()),a!==i&&t.sim.set(a,e.dest.before.slice())):(t.sim.set(i,e.dest.after.slice()),a!==i&&t.sim.set(a,e.source.after.slice())),null)}function te(e,n){if(!e||!n||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function gn(e,n){for(let t of e.childNodes||[])if($(t)===n)return t;return null}function Ge(e,n){let t=Math.min(e.length,n.length),o=0;for(;o<t&&e[o]===n[o];)o++;let a=0;for(;a<t-o&&e[e.length-1-a]===n[n.length-1-a];)a++;return n.length-a}function Xe(e,n){typeof e.write=="function"?e.write(e.target,n):e.target[e.prop]=n}function mn(e){let n=[];try{let t=null;for(let o of e)t=yn(o,n)||t;return{ok:!0,caret:t}}catch(t){for(let o=n.length-1;o>=0;o--)try{n[o]()}catch{}return{ok:!1,error:t}}}function yn(e,n){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),n.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;return e.target.data=e.data,n.push(()=>{e.target.data=t}),{node:e.target,offset:Ge(t,e.data)}}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop],o=e.content?e.target.textContent:null;if(Xe(e,e.value),n.push(()=>Xe(e,t)),!e.content)return;let a=e.target.textContent;return a===o?void 0:{root:e.target,textOffset:Ge(o,a)}}if(e.type==="insert"){let t=e.beforeId==null?null:gn(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let o=e.node.parentNode,a=e.node.nextSibling;return e.parent.insertBefore(e.node,t),n.push(()=>{o?o.insertBefore(e.node,a&&a.parentNode===o?a:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)}),e.node.nodeType!==3?void 0:{node:e.node,offset:e.node.data.length}}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let o=e.node.nextSibling,a=Array.prototype.indexOf.call(t.childNodes,e.node);return t.removeChild(e.node),n.push(()=>t.insertBefore(e.node,o)),e.node.nodeType!==3?void 0:{node:t,offset:a}}}var hn=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],bn=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],wn=hn.join(","),vn=new RegExp("^(?:"+bn.join("|")+")(?:-|$)"),Ir=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"]})}),kn=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),An=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function Se(e,n){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(n)||e.hasAttribute?.(n))}function Ze(e,n){if(Se(e,n))return!0;for(let[t,o]of Object.entries(kn))if(o.includes(n)&&Se(e,t))return!0;return!1}function En(e){return e==="clay"||An.includes(e)}var Sn=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function Cn(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function Ce(e){let n=Cn();if(n)try{if(!n(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(wn))return!0;for(;t&&t.nodeType===1;){if(Ze(t,"no-undo")||Ze(t,"no-watch"))return!0;for(let o of Sn)if(Se(t,o))return!0;t=t.parentElement}return!1}function Vn(e){let n=e.target,t=n.cloneNode(!1),o=t;for(;n.parentElement;){n=n.parentElement;let a=n.cloneNode(!1);a.appendChild(t),t=a}return e.oldValue==null?o.removeAttribute(e.attributeName):o.setAttribute(e.attributeName,e.oldValue),Ce(o)}function me(e,n,t){if(t?.type==="attributes"&&En(t.attributeName)){if(Ce(e)&&Vn(t))return!0}else if(Ce(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&vn.test(t.attributeName.toLowerCase()))return!0;if(n)try{if(n(t.attributeName,t.target))return!0}catch{}}return!1}function xn(){let e=new Map;function n(a,i){let d=e.get(a);return d||(d=new Set,e.set(a,d)),d.add(i),()=>t(a,i)}function t(a,i){let d=e.get(a);d&&d.delete(i)}function o(a,i){let d=e.get(a);if(d)for(let c of Array.from(d))try{c(i)}catch(g){console.error("[hyper-undo] listener threw",g)}}return{on:n,off:t,emit:o}}var Nn=/[.?!]["'\u201D\u2019)\]]*$/,Pn=new Set(["insertParagraph","insertLineBreak"]),Rn=new Set(["insertFromPaste","insertFromDrop","insertFromYank","insertReplacementText","deleteByCut","deleteByDrag"]),In=new Set(["Enter","Backspace","Delete"]),Tn=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function Qe(e){return Nn.test(e)}function On(e,{sentence:n,endStep:t,stepOpen:o=()=>!0,composing:a}){let i=e.ownerDocument&&e.ownerDocument.defaultView;if(!i)return()=>{};let d=h=>!!h&&typeof h.nodeType=="number"&&(h===e||e.contains(h)),c=!1,g=!1,v=!1,b={kind:"other",host:null},E=h=>Rn.has(h)||h.startsWith("format")?"alone":h.startsWith("delete")?"delete":h.startsWith("insert")?"insert":"other",C=h=>{if(!h)return null;let T=h.nodeType===1?h:h.parentElement;return T&&T.closest&&T.closest('[contenteditable]:not([contenteditable="false"])')||h},N=()=>{c&&(c=!1,t())},I=h=>{if(!n||h.isComposing||!d(h.target))return;let T=h.inputType||"",z=E(T),se=C(h.target),ye=i.getSelection&&i.getSelection(),ce=!ye||ye.isCollapsed,Re=g;g=!1;let ne=v;if(v=!1,(z==="alone"||!ne&&z!==b.kind&&z!=="other"&&b.kind!=="other"||!ne&&(b.host!==null&&se!==b.host||!ce||Re))&&t(),b={kind:z,host:se},z==="alone"){c=!0,setTimeout(N,0);return}let re=T==="insertText"&&(h.data===" "||h.data==="\xA0");!re&&!Pn.has(T)||re&&!o()||Qe(Ln(i))&&(c=!0,setTimeout(N,0))},B=h=>{d(h.target)&&N()},L=h=>{d(h.target)&&a(!0)},W=h=>{d(h.target)&&a(!1)},H=h=>{d(h.target)&&(g=!0)},J=h=>{if(!d(h.target))return;if(Tn.has(h.key)){g=!0;return}if(!n||h.isComposing||h.keyCode===229||h.ctrlKey||h.metaKey||!h.key||h.key.length!==1&&!In.has(h.key))return;let T=i.getSelection&&i.getSelection(),z=b.host!==null&&C(h.target)!==b.host;!g&&!z&&(!T||T.isCollapsed)||(t(),g=!1,v=!0,setTimeout(()=>{v=!1},0))};return e.addEventListener("beforeinput",I,!0),e.addEventListener("input",B,!0),e.addEventListener("compositionstart",L,!0),e.addEventListener("compositionend",W,!0),e.addEventListener("pointerdown",H,!0),e.addEventListener("keydown",J,!0),()=>{e.removeEventListener("beforeinput",I,!0),e.removeEventListener("input",B,!0),e.removeEventListener("compositionstart",L,!0),e.removeEventListener("compositionend",W,!0),e.removeEventListener("pointerdown",H,!0),e.removeEventListener("keydown",J,!0)}}function Ln(e){let n=e.getSelection&&e.getSelection();if(!n||!n.isCollapsed||!n.anchorNode)return"";let t=n.anchorNode,o=t.nodeType===1?t:t.parentElement,a=o&&o.closest('[contenteditable]:not([contenteditable="false"])');if(!a)return"";let i=a.ownerDocument.createRange();return i.setStart(a,0),i.setEnd(t,n.anchorOffset),i.toString().replace(/\u200B/g,"").slice(-8)}var Mn={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,durableForm:null,typingBreak:null,refused:null,debug:!1};function et(e){let n={...Mn,...e};if(!n.scope)throw new Error("hyper-undo: scope is required");let t=xn(),o=[],a=[],i=`u${Math.random().toString(36).slice(2,8)}`,d=0,c=null,g=[],v=null,b=null,E=0,C=!1,N=n.recording==="commands"?"commands":"automatic",I=null,B=!1,L=new WeakMap,W=!1,H=!1,J=null;function h(...r){n.debug&&console.log("[hyper-undo]",...r)}function T(){C||(C=!0,b=z(Y),b.observe(n.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),J=On(n.scope,{sentence:n.typingBreak==="sentence",stepOpen:()=>(E===0&&b&&Y(b.takeRecords()),g.length>0),endStep:X,composing:Fn}),h("started"))}function z(r){let u=typeof document<"u"&&n.scope===document.body,s=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&s&&typeof s.createObserver=="function"?(h("sourcing records from the platform Mutation hub (shared observer)"),s.createObserver(r)):new MutationObserver(r)}function se(){C&&(C=!1,b&&(b.disconnect(),b=null),J&&(J(),J=null),W=!1,G(),o.length=0,a.length=0,g=[],c=null,I=null,B=!1,E=0,L=new WeakMap,h("stopped"))}function ye(){let r=n.scope;return!!(r&&r.nodeType===1&&r.isConnected===!1)}function ce(r,u){try{let s=u(r);return typeof s=="string"?s:null}catch{return null}}function Re(r,{read:u,write:s,prop:p="content"}={}){if(!r||typeof u!="function"||typeof s!="function")return()=>{};let k={prop:p,read:u,write:s,baseline:ce(r,u)};return L.set(r,k),()=>{L.get(r)===k&&L.delete(r)}}function ne(r){for(let u=r;u;u=u.parentNode)if(L.has(u))return u;return null}function re(r){let u=ne(r.target);return!!u&&!(r.type==="attributes"&&r.target===u)}function _(r){let u=new Set;for(let s of r)re(s)&&u.add(ne(s.target));return u}function Ie(r){let u=[];for(let s of r){let p=L.get(s),k=ce(s,p.read);if(k!=null){if(Ee(k,p.baseline)){p.baseline=k;continue}p.baseline!=null&&u.push({kind:"value",target:s,prop:p.prop,oldValue:p.baseline,newValue:k,read:p.read,write:p.write,content:!0}),p.baseline=k}}return u}function oe(r){for(let u of r){let s=L.get(u);s.baseline=ce(u,s.read)}}function ut(r){let u=_(r);!H&&g.some(s=>s.kind==="value"?u.has(s.target):r.some(p=>p.target===s.target&&(p.type==="characterData"?s.kind==="text":p.type==="attributes"&&p.attributeName===s.name)))&&(H=!0),oe(u)}function Y(r){lt(r,!1)}function lt(r,u){if(I){for(let p of r)I.records.push(p);return}if(N==="commands"){oe(_(r));return}if(E>0){ut(r);return}let s=Te(Bn(r),u);for(let p of Ie(_(r)))s.push(p);if(s.length>0){for(let p of s)g.push(p);Oe()}}function Bn(r){return typeof n.ignoreNode!="function"?r:r.filter(u=>{if(u.type!=="childList")return!0;let s=[...u.addedNodes,...u.removedNodes];return s.length===0?!0:!s.every(p=>zn(p))})}function zn(r){try{return!!n.ignoreNode(r)}catch{return!1}}function Te(r,u=!1){let s=ar(r),p=r.filter(k=>(De(k.target)||s(k.target)||u&&Et(k.target))&&!re(k)&&!me(k.target,n.ignoreAttribute,k));return Ut(p,k=>me(k,n.ignoreAttribute))}function Fn(r){W=!!r,!W&&g.length>0&&Oe()}function Oe(){G(),v=setTimeout(dt,n.idleWindowMs)}function dt(){if(v=null,W){v=setTimeout(dt,n.idleWindowMs);return}Le()}function G(){v!=null&&(clearTimeout(v),v=null)}function Le(){if(v=null,g.length===0)return;let r=g;g=[],he(n.idleLabel,r)}function he(r,u){let s=Qt(u,{isIgnored:be,ignoreAttribute:st,durableForm:n.durableForm});if(s.steps.length===0)return h("commit",r,"with nothing to record"),t.emit("commit"),null;let p={id:`${i}-${++d}`,label:r,timestamp:Date.now(),primitives:u,certificate:s};for(o.push(p),a.length=0,c=null;o.length>n.maxHistory;)o.shift();return h("commit",r,"primitives:",u.length),t.emit("commit"),p}function be(r){return me(r,n.ignoreAttribute)}function st(r,u,s=null){if(typeof n.ignoreAttribute!="function")return!1;try{return!!n.ignoreAttribute(r,u,s)}catch{return!1}}function Un(r){if(typeof n.isProtected!="function")return!1;try{return!!n.isProtected(r)}catch{return!1}}function _n(r,u){if(!C)throw new Error("hyper-undo: scope not started");if(N==="commands")return pt(r,u,{honorPause:!0,receipt:!1});Y(b.takeRecords()),X();let s=E===0?ct():null,p=u();if(p&&typeof p.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(lt(b.takeRecords(),!0),s!=null&&ft(s),g.length===0){t.emit("commit");return}G();let k=g;g=[],he(r,k)}function Wn(r){if(!C)throw new Error("hyper-undo: scope not started");if(!b)return;if(E>1){oe(_(b.takeRecords()));return}X();let u=b.takeRecords(),s=Te(u,!0);for(let p of Ie(_(u)))s.push(p);s.length!==0&&(G(),he(r,s))}function Hn(){b&&oe(_(b.takeRecords()))}function Me(){let r=n.scope;return r&&r.ownerDocument||(typeof document<"u"?document:null)}function we(){let r=Me();return!r||!r.head||typeof r.head.querySelector!="function"?null:r.head.querySelector("title")}function ct(){let r=we();return r?r.textContent:null}function ft(r){let u=we();if(!u||r==null)return;let s=u.textContent;s!==r&&mt({kind:"value",target:u,prop:"textContent",oldValue:r,newValue:s})}function Jn(r){if(!r)return null;let u=Me();if(!u||r.target!==u||r.prop!=="title")return r;let s=we();return s?{kind:"value",target:s,prop:"textContent",oldValue:r.oldValue,newValue:r.newValue}:null}function Yn(){if(typeof window>"u")return!1;let r=window.clay?.effect||window.hyperclay?.effect;return!!(r&&r.running)}function Gn(){b&&Y(b.takeRecords()),X(),I={records:[],primitives:[]}}function Xn(){let r=I;if(I=null,!r)return[];let u=Te(r.records,!0);for(let s of Ie(_(r.records)))u.push(s);for(let s of r.primitives)u.push(s);return u}function pt(r,u,{honorPause:s,receipt:p}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(I)throw new Error("hyper-undo: command() cannot nest inside another command");if(B)throw new Error("hyper-undo: command() cannot run during undo or redo");if(Yn())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let k=s&&E>0,V=k?null:ct();Gn();let M=[],P=null,K;try{try{K=u()}catch(ie){P=ie}if(b&&Y(b.takeRecords()),K&&typeof K.then=="function"){try{K.then(void 0,()=>{})}catch{}P||(P=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}k||ft(V)}finally{M=Xn()}let F=k||M.length===0?null:he(r,M);if(P)throw P;return p?F?{id:F.id,label:F.label}:null:F}function Zn(r,u){if(!C)throw new Error("hyper-undo: scope not started");return pt(r,u,{honorPause:!1,receipt:!0})}function Qn(r){if(r!=="automatic"&&r!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(I)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return N===r||(X(),N=r,h("recording",r)),N}function gt(r){if(!C||!r||!I&&(E>0||N==="commands"))return;let u=Jn(r);u&&mt(u)}function mt(r){if(I){I.primitives.push(r);return}g.push(r),Oe()}function er(r,{prop:u="value",oldValue:s,newValue:p,read:k,write:V}={}){!r||s===p||gt({kind:"value",target:r,prop:u,oldValue:s,newValue:p,read:k,write:V})}function X(){E===0&&b&&Y(b.takeRecords()),g.length!==0&&(G(),Le())}function yt(){E===0&&b&&Y(b.takeRecords()),E++,h("paused",E)}function ht(){E!==0&&(E--,E===0&&b&&(ut(b.takeRecords()),H&&(H=!1,G(),Le())),h("resumed",E))}function bt(r,u){if(ye())return se(),{ok:!1,code:"disconnected"};if(typeof n.holdReplay=="function"&&n.holdReplay())return{ok:!1,code:"held"};X();let s=r==="undo"?o:a,p=r==="undo"?a:o,k=[],V=s.at(-1);if(!V)return{ok:!1,code:"empty"};if(u&&u!==V.id){let P=vt(u)||V;return je(P,r,"stale-entry")}let M=n.refused==="skip"&&!u;for(;V;){let P;B=!0;try{P=an(V.certificate,r,{isIgnored:be,ignoreAttribute:st,durableForm:n.durableForm,isProtected:Un,inScope:ur,liveNodesWithIds:lr})}finally{B=!1}if(!P.ok){if(!M)return je(V,r,P.code,P.targets);wt(V,r,P.code,P.targets,k),V=s.at(-1);continue}yt();let K;B=!0;try{K=mn(P.operations)}finally{B=!1,ht()}if(!K.ok){if(h(`${r} failed and was rolled back`,K.error),!M)return je(V,r,"replay-error");wt(V,r,"replay-error",[],k),V=s.at(-1);continue}oe(new Set(P.operations.filter(ie=>ie.type==="value"&&L.has(ie.target)).map(ie=>ie.target))),s.pop(),p.push(V),c=null;let F={ok:!0,entryId:V.id,label:V.label,direction:r};return k.length&&(F.skipped=k),K.caret&&(F.caret=K.caret),h(r,V.label),t.emit(r,F),F}return{ok:!1,code:"empty",direction:r,skipped:k}}function wt(r,u,s,p,k){c={entryId:r.id,direction:u,code:s,targets:p};let V=kt(r.id);(u==="undo"?o:a).pop(),c=null;let M={entryId:r.id,label:r.label,direction:u,code:s,targets:p,description:V};h("skipped",u,s),t.emit("skipped",M),k.push(M)}function tr(r){return bt("undo",r&&r.entryId)}function nr(r){return bt("redo",r&&r.entryId)}function vt(r){return o.find(u=>u.id===r)||a.find(u=>u.id===r)||null}function je(r,u,s,p=[]){return c={entryId:r.id,direction:u,code:s,targets:p},h("refused",u,s),t.emit("refused",{entryId:r.id,label:r.label,direction:u,code:s,targets:p}),{ok:!1,code:s,entryId:r.id,label:r.label,direction:u}}function rr(r){if(!c||c.entryId!==r)return{ok:!1,code:"not-refused",entryId:r};let u=c.direction,s=u==="undo"?o:a,p=s.at(-1);return!p||p.id!==r?{ok:!1,code:"stale-entry",entryId:r}:(s.pop(),c=null,h("discarded",p.label),t.emit("discard",{entryId:r,label:p.label,direction:u}),{ok:!0,entryId:r,direction:u})}function kt(r){let u=vt(r);if(!u||!u.certificate||!u.certificate.replayable)return null;let s=c&&c.entryId===u.id?{direction:c.direction,code:c.code,targets:(c.targets||[]).map(p=>({id:p.id??null,kind:p.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:s,steps:u.certificate.steps.map(ir)}}function or(r){return typeof r!="string"?null:r.replace(/#form:("(?:[^"\\]|\\.)*")/g,(u,s)=>{try{return JSON.parse(s)}catch{return""}})}function ir(r){if(r.type==="move")return{kind:"move",node:{id:D(r.node).id},from:{id:D(r.sourceParent).id},to:{id:D(r.destParent).id}};if(r.type==="add"||r.type==="restore")return{kind:r.type==="add"?"add":"remove",parent:{id:D(r.parent).id},nodes:r.nodes.map((V,M)=>({id:D(V).id,html:or(r.content[M])}))};let u=r.primitive,s={id:D(u.target).id},p=u.oldValue??null,k=u.newValue??null;return r.type==="value"?{kind:"value",target:s,prop:u.prop??"value",before:p,after:k}:r.type==="text"?{kind:"text",target:s,before:p,after:k}:r.type==="attr-set"||r.type==="attr-add"||r.type==="attr-remove"?{kind:"attribute",target:s,name:u.name??null,before:p,after:k}:{kind:r.type,target:s,before:p,after:k}}function ar(r){let u=new Set,s=!0;for(;s;){s=!1;for(let p of r)if(!(p.type!=="childList"||!p.removedNodes?.length)&&!re(p)&&!(!De(p.target)&&!At(p.target,u))&&!me(p.target,n.ignoreAttribute,p))for(let k of p.removedNodes)u.has(k)||(u.add(k),s=!0)}return p=>!De(p)&&At(p,u)}function At(r,u){for(let s=r;s;s=s.parentNode)if(u.has(s))return!0;return!1}function De(r){let u=n.scope;return!u||!r||typeof r.nodeType!="number"?!1:r===u||typeof u.contains=="function"&&u.contains(r)}function Et(r){let u=Me(),s=u&&u.head;if(!s||!r)return!1;let p=r.nodeType===1?r:r.parentElement;for(;p&&p!==s;p=p.parentElement)if(p.localName==="title")return!1;return p===s}function ur(r){let u=n.scope;return!r||!u?!1:r===u||we()===r||Et(r)?!0:typeof u.contains=="function"?u.contains(r):!1}function lr(r){let u=n.scope;if(!r||r.length===0||typeof u?.querySelectorAll!="function")return[];let s=new Set(r),p=[];for(let k of u.querySelectorAll("[data-id]"))s.has(k.getAttribute("data-id"))&&(be(k)||p.push(k));return p}function dr(){b&&oe(_(b.takeRecords())),o.length=0,a.length=0,g=[],c=null,G(),h("cleared"),t.emit("clear")}return{_config:n,_tracksContentAt:r=>N!=="commands"&&!!ne(r),_recordsAt:r=>N!=="commands"&&!be(r),start:T,stop:se,commit:_n,commitCaptured:Wn,discardCaptured:Hn,flush:X,command:Zn,setRecording:Qn,record:gt,recordValue:er,trackContent:Re,undo:tr,redo:nr,clear:dr,discard:rr,describe:kt,pause:yt,resume:ht,on:t.on,off:t.off,get canUndo(){return o.length>0},get canRedo(){return a.length>0},get isPaused(){return E>0},get history(){return o.map(r=>{let u={id:r.id,label:r.label,timestamp:r.timestamp};return c&&c.entryId===r.id&&(u.refused={direction:c.direction,code:c.code,targets:c.targets}),u})},get future(){return a.map(r=>{let u={id:r.id,label:r.label,timestamp:r.timestamp};return c&&c.entryId===r.id&&(u.refused={direction:c.direction,code:c.code,targets:c.targets}),u}).reverse()},get scope(){return n.scope}}}var jn=new Set(["checkbox","radio","button","submit","reset","image","file","range","color"]);function tt(e){let n=typeof e.composedPath=="function"?e.composedPath():[];return n.length>0?n:Kn(e.target)}function Dn(e){for(let n of tt(e)){if(!n||n.nodeType!==1)continue;let t=String(n.tagName||"").toUpperCase();if(t==="TEXTAREA"||t==="SELECT"||t==="INPUT"&&!jn.has(String(n.type||n.getAttribute?.("type")||"text").toLowerCase()))return!0}return!1}function nt(e){for(let n of tt(e)){if(!n||n.nodeType!==1)continue;if(n.isContentEditable===!0)return!0;let t=n.getAttribute&&n.getAttribute("contenteditable");if(t!=null&&String(t).toLowerCase()!=="false")return!0}return!1}function Ve(e,n){if(!e||!e.closest||!Array.isArray(n))return!1;for(let t of n)try{if(e.closest(t))return!0}catch{}return!1}function rt(e,n){if(Dn(e))return!0;let t=n._config,o=e.target;return t.editableKeys!=="page"?nt(e)||Ve(o,t.shadowKeydownIn):Ve(o,t.ownKeysIn)||n._tracksContentAt(o)?!1:Ve(o,t.shadowKeydownIn)?!0:nt(e)&&!n._recordsAt(o)}function Kn(e){let n=[];for(let t=e;t;t=t.parentNode||(t.host??null))n.push(t);return n}function qn(e,n){let t=i=>{let d=e.scope;if(d&&d.nodeType===1&&d.isConnected===!1){n&&n();return}if(i.defaultPrevented||i.isComposing||i.keyCode===229||rt(i,e)||!(i.metaKey||i.ctrlKey))return;let c=(i.key||"").toLowerCase();if(c==="z"&&!i.shiftKey){i.preventDefault(),i.stopPropagation(),e.undo();return}if(c==="z"&&i.shiftKey){i.preventDefault(),i.stopPropagation(),e.redo();return}if(c==="y"&&!i.shiftKey){i.preventDefault(),i.stopPropagation(),e.redo();return}},o=i=>{if(i.inputType!=="historyUndo"&&i.inputType!=="historyRedo")return;let d=e.scope;d&&d.nodeType===1&&d.isConnected===!1||i.defaultPrevented||i.isComposing||rt(i,e)||(i.preventDefault(),i.stopPropagation(),i.inputType==="historyRedo"?e.redo():e.undo())},a=e._config.editableKeys==="page";return window.addEventListener("keydown",t,!0),a&&window.addEventListener("beforeinput",o,!0),()=>{window.removeEventListener("keydown",t,!0),a&&window.removeEventListener("beforeinput",o,!0)}}var xe=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]",".ck-editor__editable","[data-lexical-editor]","[data-slate-editor]","trix-editor",".mce-content-body"],y=null,Ne=null,ot=null,U=null;function it(e,n){if(U){if(U.inst===e)return U.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=qn(e,n);return U={inst:e,cleanup:t},t}function at(e){U&&U.inst===e&&(U.cleanup(),U=null)}var Pe={defaults:{shadowKeydownIn:xe},start(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(y){if(Ne===n)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),y;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||xe};return y=et(t),y.start(),Ne=n,e.bindKeys!==!1&&(ot=it(y,()=>Pe.stop())),y},stop(){y&&(at(y),ot=null,y.stop(),y=null,Ne=null)},create(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||xe},o=et(t),a=null,i={_config:o._config,commit:o.commit,command:o.command,setRecording:o.setRecording,commitCaptured:o.commitCaptured,discardCaptured:o.discardCaptured,flush:o.flush,record:o.record,recordValue:o.recordValue,trackContent:o.trackContent,undo:o.undo,redo:o.redo,clear:o.clear,discard:o.discard,describe:o.describe,pause:o.pause,resume:o.resume,on:o.on,off:o.off,get canUndo(){return o.canUndo},get canRedo(){return o.canRedo},get isPaused(){return o.isPaused},get history(){return o.history},get future(){return o.future},get scope(){return o.scope},start(){e.bindKeys&&(a=it(o,()=>i.stop())),o.start()},stop(){at(o),a=null,o.stop()}};return i},commit(e,n){return y?y.commit(e,n):void 0},command(e,n){return y?y.command(e,n):void 0},setRecording(e){return y?y.setRecording(e):void 0},commitCaptured(e){return y?y.commitCaptured(e):void 0},discardCaptured(){return y?y.discardCaptured():void 0},record(e){return y?y.record(e):void 0},recordValue(e,n){return y?y.recordValue(e,n):void 0},trackContent(e,n){return y?y.trackContent(e,n):()=>{}},undo(e){return y?y.undo(e):void 0},redo(e){return y?y.redo(e):void 0},clear(){return y?y.clear():void 0},discard(e){return y?y.discard(e):void 0},describe(e){return y?y.describe(e):void 0},pause(){return y?y.pause():void 0},resume(){return y?y.resume():void 0},flush(){return y?y.flush():void 0},on(e,n){return y?y.on(e,n):void 0},off(e,n){return y?y.off(e,n):void 0},get canUndo(){return y?y.canUndo:!1},get canRedo(){return y?y.canRedo:!1},get history(){return y?y.history:[]},get future(){return y?y.future:[]},get isPaused(){return y?y.isPaused:!1}},$n=Pe;return O(q)})();window.__hyperclayNoAutoExport||(window.hyperclay=window.hyperclay||{},window.hyperclay.undo=Pt.undo,window.h=window.hyperclay);var w=Pt.undo;var jt='[contenteditable]:not([contenteditable="false"])';function sr(l,f){let m=Number(f)||0;m<0&&(m=0);let x=(l.ownerDocument||document).createTreeWalker(l,4),j=null;for(let O=x.nextNode();O;O=x.nextNode()){if(m<=O.data.length)return{node:O,offset:m};m-=O.data.length,j=O}return j?{node:j,offset:j.data.length}:{node:l,offset:l.childNodes.length}}function cr(l){let m=(l.nodeType===1?l:l.parentElement)?.closest?.(jt);return!m||!m.isConnected||typeof m.checkVisibility=="function"&&m.checkVisibility()===!1?null:m}function fr(l){if(!l)return;let f=l.root?sr(l.root,l.textOffset):l;if(!f?.node)return;let m=cr(f.node);m&&(typeof m.scrollIntoView=="function"&&m.scrollIntoView({block:"nearest",inline:"nearest"}),document.activeElement?.closest?.(jt)&&(document.activeElement!==m&&m.focus({preventScroll:!0}),document.getSelection()?.collapse(f.node,f.offset)))}var qe=new Set,$e=new Set,Dt=(l,f=null)=>{for(let m of $e){let A=m(l,f);if(typeof A=="string")return A}},Kt=(l={})=>{let f=l.ignoreAttribute;return{...l,ignoreAttribute:(m,A,x)=>qe.has(m)||St(m,A)||Vt(A,m,x)||xt(m,A)||(f?f(m,A,x):!1),isProtected:l.isProtected||pr,ignoreNode:l.ignoreNode||Nt,durableForm:l.durableForm||Dt}};function pr(l){let f=window.clay?.region?.resolveRegionPolicy;if(!f||l.nodeType!==1||Dt(l)!==void 0)return!1;let m=f(l);if(m.undoable!==!1||m.persist==="none")return!1;let A=l.parentElement;return!A||f(A).undoable!==!1}var gr=w.create.bind(w);w.create=l=>gr(Kt(l));var fe=null,mr=w.setRecording.bind(w);w.setRecording=l=>(fe=l??null,document.dispatchEvent(new CustomEvent("clay:undo-recording",{detail:{mode:fe}})),mr(l));Object.defineProperty(w,"recordingMode",{get:()=>fe,configurable:!0});var Rt=()=>w.history.at(-1)?.id??null,qt=w.command.bind(w);w.command=(l,f)=>{let m=qt(l,f);return m&&ke(),m};w.recordStep=(l,f)=>qt(l,()=>w.record(f));var $t=l=>!!l?.steps?.length&&l.steps.every(f=>f.kind==="value"&&/^blockeditor-step(?::|$)/.test(f.prop)),yr=w.commit.bind(w),It=!1;w.commit=(l,f)=>{!It&&window.clay?.effect?.running&&(It=!0,console.warn(`clay.effect: undo.commit("${l}") was called inside an effect. Run commands from event handlers, not from an effect.`));let m=Rt(),A=yr(l,f);return(A||Rt()!==m)&&ke(),A};var hr=`input${ve}:not([type="password"]):not([type="hidden"]):not([type="file"]), textarea${ve}, select${ve}`;function br(){let l=f=>window.clay?.region?.resolveRegionPolicy?.(f)?.undoable!==!1;document.querySelectorAll(hr).forEach(f=>{if(!l(f))return;if(f.tagName==="SELECT"){for(let q of f.options){let pe=q.hasAttribute("selected");q.selected!==pe&&(q.selected=pe)}return}let m=(f.getAttribute("type")||"text").toLowerCase();if(f.tagName==="INPUT"&&(m==="checkbox"||m==="radio")){let q=f.hasAttribute("checked");f.checked!==q&&(f.checked=q);return}let A=f.tagName==="TEXTAREA"?f.getAttribute("data-value")??f.textContent:f.getAttribute("value")??"";if(f.value===A)return;let x=f===document.activeElement,j,O;try{j=f.selectionStart,O=f.selectionEnd}catch{}if(f.value=A,x&&j!=null)try{f.setSelectionRange(Math.min(j,A.length),Math.min(O,A.length))}catch{}})}var Tt=l=>{l?.ok&&($t(w.describe(l.entryId))||ke(),br(),l.caret&&w.pageHistory&&fr(l.caret))},Ot=({entryId:l,label:f,direction:m,code:A})=>{document.dispatchEvent(new CustomEvent("clay:undo-refused",{detail:{ok:!1,code:A,entryId:l,label:f,direction:m}})),zt({ok:!1,code:A,entryId:l,label:f,direction:m})},Lt=({entryId:l,label:f,direction:m,code:A,description:x})=>{document.dispatchEvent(new CustomEvent("clay:undo-skipped",{detail:{entryId:l,label:f,direction:m,code:A}})),!$t(x)&&zt({ok:!1,code:A,entryId:l,label:f,direction:m,description:x})},Ke=null;function Bt(){return Ke??=import("../c-2EPHRF47.js").catch(l=>(Ke=null,console.error("clayjs: the undo recovery module could not be downloaded; a refused step stays in this tab only",l),null)),Ke}async function zt(l){let f={ok:!1,code:"unavailable"};try{let A=await Bt();A&&(f=await A.keepRefusal(w,l))}catch{f={ok:!1,code:"error"}}let m=f?.ok===!0?{ok:!0,entryId:l.entryId,direction:l.direction}:{ok:!1,code:f?.code||"error",entryId:l.entryId,direction:l.direction};document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:m}))}var ze=(l,f)=>(...m)=>Bt().then(A=>A?A[l](...m):f,()=>f),wr=ze("keep",{ok:!1,code:"unavailable"});w.addDurableForm=l=>($e.add(l),()=>{$e.delete(l)});w.ignoreAttribute=l=>{let f=String(l||"");return f?(qe.add(f),()=>{qe.delete(f)}):()=>{}};w.keep=async l=>{let f=await wr(l);return f?.ok===!0&&document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:{ok:!0,key:l?.key==null?null:`app:${l.key}`}})),f};w.kept=ze("kept",{ok:!1,code:"unavailable",records:[]});w.dismissKept=ze("dismissKept",{ok:!1,code:"unavailable"});var Be=new Set;w.reviewActions=l=>typeof l!="function"?()=>{}:(Be.add(l),()=>{Be.delete(l)});w.reviewActionsFor=l=>{let f=[];for(let m of Be){let A;try{A=m(l)}catch(x){console.error("clayjs: a review action could not describe itself; the copy stays reviewable",x);continue}for(let x of Array.isArray(A)?A:[])x&&typeof x.run=="function"&&x.label&&f.push(x)}return f};var vr=["commit","undo","redo","refused","skipped","discard","clear"],ue=new Set,Ft=l=>{for(let f=w;f;f=Object.getPrototypeOf(f)){let m=Object.getOwnPropertyDescriptor(f,l);if(m)return typeof m.get=="function"?()=>m.get.call(w):()=>!!m.value.call(w)}return()=>!1},kr=Ft("canUndo"),Ar=Ft("canRedo");Object.defineProperty(w,"canUndo",{get:()=>ue.size===0&&kr(),configurable:!0});Object.defineProperty(w,"canRedo",{get:()=>ue.size===0&&Ar(),configurable:!0});w.hold=()=>{let l=Symbol("hold");ue.add(l),ae();let f=!1;return()=>{f||(f=!0,ue.delete(l),ae())}};var ae=()=>{let l=!!Z?.started&&ue.size===0;document.dispatchEvent(new CustomEvent("clay:undo-change",{detail:{canUndo:l&&w.canUndo,canRedo:l&&w.canRedo,undo:l&&w.history.at(-1)||null,redo:l&&w.future?.[0]||null}}))},Z=null;Object.defineProperty(w,"pageHistory",{get:()=>!!Z?.started,configurable:!0});var Mt=()=>{typeof document>"u"||document.dispatchEvent(new CustomEvent("clay:undo-session",{detail:{started:!!Z?.started,pageHistory:w.pageHistory}}))};function Er(){return{started:!1,admitted:!1,subscriptions:[]}}var Sr=l=>l?l.signal?.aborted?!0:typeof l.isCurrent=="function"&&!l.isCurrent():!1;function Cr(){return typeof document>"u"||document.readyState!=="loading"?Promise.resolve():new Promise(l=>document.addEventListener("DOMContentLoaded",l,{once:!0}))}function Vr(l){return{enable(){if(!l.started){l.started=!0,l.admitted=!0,w.start(Kt({bindKeys:!0,editableKeys:"page",ownKeysIn:[".blockeditor-editor"],typingBreak:"sentence",refused:"skip",holdReplay:()=>ue.size>0,...fe?{recording:fe}:{}}));for(let f of["undo","redo"])w.on(f,Tt),l.subscriptions.push({type:f,handler:Tt});w.on("refused",Ot),l.subscriptions.push({type:"refused",handler:Ot}),w.on("skipped",Lt),l.subscriptions.push({type:"skipped",handler:Lt});for(let f of vr)w.on(f,ae),l.subscriptions.push({type:f,handler:ae});ae(),Mt()}},quiesce(){l.admitted&&(l.admitted=!1,w.pause())},resume(){l.admitted||(l.admitted=!0,w.resume())},dispose(){if(l.admitted=!1,Z===l&&(Z=null),!!l.started){l.started=!1;for(let{type:f,handler:m}of l.subscriptions.splice(0))w.off(f,m);w.stop(),ae(),Mt()}}}}function xr(){return{id:"clay:undo",order:350,async prepare(l={}){if(l.initial===!0)return Nr();if(await Cr(),Sr(l))throw Object.assign(new Error("clay:undo prepared for a stale generation"),{code:"stale-document"});return Vr(Z||(Z=Er()))}}}async function Nr(){let l=await Rr;return{enable(){},quiesce:()=>l?.quiesce(),resume:()=>l?.resume(),dispose:()=>l?.dispose()}}async function Pr(){if(!Ct()||typeof document>"u")return null;let l=await xr().prepare();return l.enable(),l}var Rr=Pr();var Br=w;export{Br as default,Pr as init,xr as modeParticipant,Rr as ready,br as restoreControls,w as undo,xr as undoParticipant};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as c,c as d,d as e,e as f,f as g,g as h}from"../c-
|
|
1
|
+
import{a,b as c,c as d,d as e,e as f,f as g,g as h}from"../c-ZFAPQQIB.js";import{f as b}from"../c-ARO6CPMA.js";import"../c-LZJPNR2W.js";import"../c-FILLTJA7.js";import"../c-5VYOWDTI.js";import"../c-P73XPAOA.js";import"../c-WYFDLITL.js";import"../c-MZCOGNZL.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-KU3PX7LL.js";import"../c-EQ5NBOGA.js";import"../c-IJUK2GPW.js";import"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import"../c-UW6MMZ4V.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";export{e as LiveSync,d as REMOTE_WINS_SELECTOR,c as SYNC_IGNORE_SELECTOR,b as WIRE_PROFILES,a as conflicts,h as default,f as liveSync,g as morph};
|