e.__isTeleport,ws=Symbol("_leaveCb");function Zi(e){let t=e[0];if(e.length>1){for(const s of e)if(s.type!==$e){t=s;break}}return t}function Sr(e){if(!tn(e))return us(e.type)&&e.children?Zi(e.children):e;if(e.component)return e.component.subTree;const{shapeFlag:t,children:s}=e;if(s){if(t&16)return s[0];if(t&32&&I(s.default))return s.default()}}function en(e,t){if(e.shapeFlag&6&&e.component){e.transition=t;const s=e.component.subTree;en(us(s.type)&&Sr(s)||s,t)}else e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function wr(e){e.ids=[e.ids[0]+e.ids[2]+++"-",0,0]}function bn(e,t){let s;return!!((s=Object.getOwnPropertyDescriptor(e,t))&&!s.configurable)}const Qt=new WeakMap;function St(e,t,s,n,r=!1){if(O(e)){e.forEach((M,J)=>St(M,t&&(O(t)?t[J]:t),s,n,r));return}if(wt(n)&&!r){n.shapeFlag&512&&n.type.__asyncResolved&&n.component.subTree.component&&St(e,t,s,n.component.subTree);return}const i=n.shapeFlag&4?ps(n.component):n.el,o=r?null:i,{i:l,r:c}=e,d=t&&t.r,a=l.refs===K?l.refs={}:l.refs,p=l.setupState,w=D(p),C=p===K?Wn:M=>bn(a,M)?!1:V(w,M),N=(M,J)=>!(J&&bn(a,J));if(d!=null&&d!==c){if(yn(t),G(d))a[d]=null,C(d)&&(p[d]=null);else if(k(d)){const M=t;N(d,M.k)&&(d.value=null),M.k&&(a[M.k]=null)}}if(I(c))Ft(c,l,12,[o,a]);else{const M=G(c),J=k(c);if(M||J){const B=()=>{if(e.f){const F=M?C(c)?p[c]:a[c]:N()||!e.k?c.value:a[e.k];if(r)O(F)&&$s(F,i);else if(O(F))F.includes(i)||F.push(i);else if(M)a[c]=[i],C(c)&&(p[c]=a[c]);else{const j=[i];N(c,e.k)&&(c.value=j),e.k&&(a[e.k]=j)}}else M?(a[c]=o,C(c)&&(p[c]=o)):J&&(N(c,e.k)&&(c.value=o),e.k&&(a[e.k]=o))};if(o){const F=()=>{B(),Qt.delete(e)};F.id=-1,Qt.set(e,F),ie(F,s)}else yn(e),B()}}}function yn(e){const t=Qt.get(e);t&&(t.flags|=8,Qt.delete(e))}ls().requestIdleCallback;ls().cancelIdleCallback;const wt=e=>!!e.type.__asyncLoader,tn=e=>e.type.__isKeepAlive;function Qi(e,t){Cr(e,"a",t)}function ki(e,t){Cr(e,"da",t)}function Cr(e,t,s=re){const n=e.__wdc||(e.__wdc=()=>{let r=s;for(;r;){if(r.isDeactivated)return;r=r.parent}return e()});if(as(t,n,s),s){let r=s.parent;for(;r&&r.parent;)tn(r.parent.vnode)&&eo(n,t,s,r),r=r.parent}}function eo(e,t,s,n){const r=as(t,e,n,!0);Tr(()=>{$s(n[t],r)},s)}function as(e,t,s=re,n=!1){if(s){const r=s[e]||(s[e]=[]),i=t.__weh||(t.__weh=(...o)=>{He();const l=Dt(s),c=pe(t,s,e,o);return l(),Le(),c});return n?r.unshift(i):r.push(i),i}}const Ke=e=>(t,s=re)=>{(!Mt||e==="sp")&&as(e,(...n)=>t(...n),s)},to=Ke("bm"),so=Ke("m"),no=Ke("bu"),ro=Ke("u"),io=Ke("bum"),Tr=Ke("um"),oo=Ke("sp"),lo=Ke("rtg"),fo=Ke("rtc");function co(e,t=re){as("ec",e,t)}const uo=Symbol.for("v-ndc");function Dl(e,t,s,n){let r;const i=s,o=O(e);if(o||G(e)){const l=o&&Ge(e);let c=!1,d=!1;l&&(c=!ce(e),d=Pe(e),e=fs(e)),r=new Array(e.length);for(let a=0,p=e.length;at(l,c,void 0,i));else{const l=Object.keys(e);r=new Array(l.length);for(let c=0,d=l.length;ce?zr(e)?ps(e):Ds(e.parent):null,Ct=ee(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>Ds(e.parent),$root:e=>Ds(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>Or(e),$forceUpdate:e=>e.f||(e.f=()=>{ks(e.update)}),$nextTick:e=>e.n||(e.n=gr.bind(e.proxy)),$watch:e=>Yi.bind(e)}),Cs=(e,t)=>e!==K&&!e.__isScriptSetup&&V(e,t),ao={get({_:e},t){if(t==="__v_skip")return!0;const{ctx:s,setupState:n,data:r,props:i,accessCache:o,type:l,appContext:c}=e;if(t[0]!=="$"){const w=o[t];if(w!==void 0)switch(w){case 1:return n[t];case 2:return r[t];case 4:return s[t];case 3:return i[t]}else{if(Cs(n,t))return o[t]=1,n[t];if(r!==K&&V(r,t))return o[t]=2,r[t];if(V(i,t))return o[t]=3,i[t];if(s!==K&&V(s,t))return o[t]=4,s[t];Vs&&(o[t]=0)}}const d=Ct[t];let a,p;if(d)return t==="$attrs"&&Q(e.attrs,"get",""),d(e);if((a=l.__cssModules)&&(a=a[t]))return a;if(s!==K&&V(s,t))return o[t]=4,s[t];if(p=c.config.globalProperties,V(p,t))return p[t]},set({_:e},t,s){const{data:n,setupState:r,ctx:i}=e;return Cs(r,t)?(r[t]=s,!0):n!==K&&V(n,t)?(n[t]=s,!0):V(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(i[t]=s,!0)},has({_:{data:e,setupState:t,accessCache:s,ctx:n,appContext:r,props:i,type:o}},l){let c;return!!(s[l]||e!==K&&l[0]!=="$"&&V(e,l)||Cs(t,l)||V(i,l)||V(n,l)||V(Ct,l)||V(r.config.globalProperties,l)||(c=o.__cssModules)&&c[l])},defineProperty(e,t,s){return s.get!=null?e._.accessCache[t]=0:V(s,"value")&&this.set(e,t,s.value,null),Reflect.defineProperty(e,t,s)}};function xn(e){return O(e)?e.reduce((t,s)=>(t[s]=null,t),{}):e}let Vs=!0;function ho(e){const t=Or(e),s=e.proxy,n=e.ctx;Vs=!1,t.beforeCreate&&vn(t.beforeCreate,e,"bc");const{data:r,computed:i,methods:o,watch:l,provide:c,inject:d,created:a,beforeMount:p,mounted:w,beforeUpdate:C,updated:N,activated:M,deactivated:J,beforeDestroy:B,beforeUnmount:F,destroyed:j,unmounted:A,render:Y,renderTracked:ge,renderTriggered:me,errorCaptured:Ue,serverPrefetch:Vt,expose:ze,inheritAttrs:ut,components:Nt,directives:jt,filters:gs}=t;if(d&&po(d,n,null),o)for(const q in o){const U=o[q];I(U)&&(n[q]=U.bind(s))}if(r){const q=r.call(s,s);L(q)&&(e.data=Xs(q))}if(Vs=!0,i)for(const q in i){const U=i[q],Ye=I(U)?U.bind(s,s):I(U.get)?U.get.bind(s,s):Ee,Ht=!I(U)&&I(U.set)?U.set.bind(s):Ee,Xe=ko({get:Ye,set:Ht});Object.defineProperty(n,q,{enumerable:!0,configurable:!0,get:()=>Xe.value,set:ae=>Xe.value=ae})}if(l)for(const q in l)Er(l[q],n,s,q);if(c){const q=I(c)?c.call(s):c;Reflect.ownKeys(q).forEach(U=>{Gi(U,q[U])})}a&&vn(a,e,"c");function te(q,U){O(U)?U.forEach(Ye=>q(Ye.bind(s))):U&&q(U.bind(s))}if(te(to,p),te(so,w),te(no,C),te(ro,N),te(Qi,M),te(ki,J),te(co,Ue),te(fo,ge),te(lo,me),te(io,F),te(Tr,A),te(oo,Vt),O(ze))if(ze.length){const q=e.exposed||(e.exposed={});ze.forEach(U=>{Object.defineProperty(q,U,{get:()=>s[U],set:Ye=>s[U]=Ye,enumerable:!0})})}else e.exposed||(e.exposed={});Y&&e.render===Ee&&(e.render=Y),ut!=null&&(e.inheritAttrs=ut),Nt&&(e.components=Nt),jt&&(e.directives=jt),Vt&&wr(e)}function po(e,t,s=Ee){O(e)&&(e=Ns(e));for(const n in e){const r=e[n];let i;L(r)?"default"in r?i=Gt(r.from||n,r.default,!0):i=Gt(r.from||n):i=Gt(r),k(i)?Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:()=>i.value,set:o=>i.value=o}):t[n]=i}}function vn(e,t,s){pe(O(e)?e.map(n=>n.bind(t.proxy)):e.bind(t.proxy),t,s)}function Er(e,t,s,n){let r=n.includes(".")?vr(s,n):()=>s[n];if(G(e)){const i=t[e];I(i)&&Ss(r,i)}else if(I(e))Ss(r,e.bind(s));else if(L(e))if(O(e))e.forEach(i=>Er(i,t,s,n));else{const i=I(e.handler)?e.handler.bind(s):t[e.handler];I(i)&&Ss(r,i,e)}}function Or(e){const t=e.type,{mixins:s,extends:n}=t,{mixins:r,optionsCache:i,config:{optionMergeStrategies:o}}=e.appContext,l=i.get(t);let c;return l?c=l:!r.length&&!s&&!n?c=t:(c={},r.length&&r.forEach(d=>kt(c,d,o,!0)),kt(c,t,o)),L(t)&&i.set(t,c),c}function kt(e,t,s,n=!1){const{mixins:r,extends:i}=t;i&&kt(e,i,s,!0),r&&r.forEach(o=>kt(e,o,s,!0));for(const o in t)if(!(n&&o==="expose")){const l=go[o]||s&&s[o];e[o]=l?l(e[o],t[o]):t[o]}return e}const go={data:Sn,props:wn,emits:wn,methods:_t,computed:_t,beforeCreate:se,created:se,beforeMount:se,mounted:se,beforeUpdate:se,updated:se,beforeDestroy:se,beforeUnmount:se,destroyed:se,unmounted:se,activated:se,deactivated:se,errorCaptured:se,serverPrefetch:se,components:_t,directives:_t,watch:_o,provide:Sn,inject:mo};function Sn(e,t){return t?e?function(){return ee(I(e)?e.call(this,this):e,I(t)?t.call(this,this):t)}:t:e}function mo(e,t){return _t(Ns(e),Ns(t))}function Ns(e){if(O(e)){const t={};for(let s=0;st==="modelValue"||t==="model-value"?e.modelModifiers:e[`${t}Modifiers`]||e[`${de(t)}Modifiers`]||e[`${nt(t)}Modifiers`];function vo(e,t,...s){if(e.isUnmounted)return;const n=e.vnode.props||K;let r=s;const i=t.startsWith("update:"),o=i&&xo(n,t.slice(7));o&&(o.trim&&(r=s.map(a=>G(a)?a.trim():a)),o.number&&(r=r.map(os)));let l,c=n[l=_s(t)]||n[l=_s(de(t))];!c&&i&&(c=n[l=_s(nt(t))]),c&&pe(c,e,6,r);const d=n[l+"Once"];if(d){if(!e.emitted)e.emitted={};else if(e.emitted[l])return;e.emitted[l]=!0,pe(d,e,6,r)}}const So=new WeakMap;function Pr(e,t,s=!1){const n=s?So:t.emitsCache,r=n.get(e);if(r!==void 0)return r;const i=e.emits;let o={},l=!1;if(!I(e)){const c=d=>{const a=Pr(d,t,!0);a&&(l=!0,ee(o,a))};!s&&t.mixins.length&&t.mixins.forEach(c),e.extends&&c(e.extends),e.mixins&&e.mixins.forEach(c)}return!i&&!l?(L(e)&&n.set(e,null),null):(O(i)?i.forEach(c=>o[c]=null):ee(o,i),L(e)&&n.set(e,o),o)}function ds(e,t){return!e||!ns(t)?!1:(t=t.slice(2),t=t==="Once"?t:t.replace(/Once$/,""),V(e,t[0].toLowerCase()+t.slice(1))||V(e,nt(t))||V(e,t))}function Cn(e){const{type:t,vnode:s,proxy:n,withProxy:r,propsOptions:[i],slots:o,attrs:l,emit:c,render:d,renderCache:a,props:p,data:w,setupState:C,ctx:N,inheritAttrs:M}=e,J=Zt(e);let B,F;try{if(s.shapeFlag&4){const A=r||n,Y=A;B=we(d.call(Y,A,a,p,C,w,N)),F=l}else{const A=t;B=we(A.length>1?A(p,{attrs:l,slots:o,emit:c}):A(p,null)),F=t.props?l:wo(l)}}catch(A){st.length=0,cs(A,e,1),B=Oe($e)}let j=B;if(F&&M!==!1){const A=Object.keys(F),{shapeFlag:Y}=j;A.length&&Y&7&&(i&&A.some(rs)&&(F=Co(F,i)),j=ft(j,F,!1,!0))}if(s.dirs&&(j=ft(j,null,!1,!0),j.dirs=j.dirs?j.dirs.concat(s.dirs):s.dirs),s.transition){const A=us(j.type)&&Sr(j)||j;en(A,s.transition)}return B=j,Zt(J),B}const wo=e=>{let t;for(const s in e)(s==="class"||s==="style"||ns(s))&&((t||(t={}))[s]=e[s]);return t},Co=(e,t)=>{const s={};for(const n in e)(!rs(n)||!(n.slice(9)in t))&&(s[n]=e[n]);return s};function To(e,t,s){const{props:n,children:r,component:i}=e,{props:o,children:l,patchFlag:c}=t,d=i.emitsOptions;if(t.dirs||t.transition)return!0;if(s&&c>=0){if(c&1024)return!0;if(c&16)return n?Tn(n,o,d):!!o;if(c&8){const a=t.dynamicProps;for(let p=0;pObject.create(Ir),Fr=e=>Object.getPrototypeOf(e)===Ir;function Oo(e,t,s,n=!1){const r={},i=Rr();e.propsDefaults=Object.create(null),Dr(e,t,r,i);for(const o in e.propsOptions[0])o in r||(r[o]=void 0);s?e.props=n?r:Fi(r):e.type.props?e.props=r:e.props=i,e.attrs=i}function Ao(e,t,s,n){const{props:r,attrs:i,vnode:{patchFlag:o}}=e,l=D(r),[c]=e.propsOptions;let d=!1;if((n||o>0)&&!(o&16)){if(o&8){const a=e.vnode.dynamicProps;for(let p=0;p{c=!0;const[w,C]=Vr(p,t,!0);ee(o,w),C&&l.push(...C)};!s&&t.mixins.length&&t.mixins.forEach(a),e.extends&&a(e.extends),e.mixins&&e.mixins.forEach(a)}if(!i&&!c)return L(e)&&n.set(e,et),et;if(O(i))for(let a=0;ae==="_"||e==="_ctx"||e==="$stable",nn=e=>O(e)?e.map(we):[we(e)],Mo=(e,t,s)=>{if(t._n)return t;const n=qi((...r)=>nn(t(...r)),s);return n._c=!1,n},Nr=(e,t,s)=>{const n=e._ctx;for(const r in e){if(sn(r))continue;const i=e[r];if(I(i))t[r]=Mo(r,i,n);else if(i!=null){const o=nn(i);t[r]=()=>o}}},jr=(e,t)=>{const s=nn(t);e.slots.default=()=>s},Hr=(e,t,s)=>{for(const n in t)(s||!sn(n))&&(e[n]=t[n])},Io=(e,t,s)=>{const n=e.slots=Rr();if(e.vnode.shapeFlag&32){const r=t._;r?(Hr(n,t,s),s&&zn(n,"_",r,!0)):Nr(t,n)}else t&&jr(e,t)},Ro=(e,t,s)=>{const{vnode:n,slots:r}=e;let i=!0,o=K;if(n.shapeFlag&32){const l=t._;l?s&&l===1?i=!1:Hr(r,t,s):(i=!t.$stable,Nr(t,r)),o=t}else t&&(jr(e,t),o={default:1});if(i)for(const l in r)!sn(l)&&o[l]==null&&delete r[l]},ie=jo;function Fo(e){return Do(e)}function Do(e,t){const s=ls();s.__VUE__=!0;const{insert:n,remove:r,patchProp:i,createElement:o,createText:l,createComment:c,setText:d,setElementText:a,parentNode:p,nextSibling:w,setScopeId:C=Ee,insertStaticContent:N}=e,M=(f,u,h,b=null,g=null,_=null,v=void 0,x=null,y=!!u.dynamicChildren)=>{if(f===u)return;f&&!gt(f,u)&&(b=Lt(f),ae(f,g,_,!0),f=null),u.patchFlag===-2&&(y=!1,u.dynamicChildren=null),u.dynamicChildren&&f&&f.dynamicChildren&&f.dynamicChildren.hasOnce&&(u.dynamicChildren===et&&(u.dynamicChildren=[]),u.dynamicChildren.hasOnce=!0);const{type:m,ref:E,shapeFlag:S}=u;switch(m){case hs:J(f,u,h,b);break;case $e:B(f,u,h,b);break;case Jt:f==null&&F(u,h,b,v);break;case Re:Nt(f,u,h,b,g,_,v,x,y);break;default:S&1?Y(f,u,h,b,g,_,v,x,y):S&6?jt(f,u,h,b,g,_,v,x,y):(S&64||S&128)&&m.process(f,u,h,b,g,_,v,x,y,dt)}E!=null&&g?St(E,f&&f.ref,_,u||f,!u):E==null&&f&&f.ref!=null&&St(f.ref,null,_,f,!0)},J=(f,u,h,b)=>{if(f==null)n(u.el=l(u.children),h,b);else{const g=u.el=f.el;u.children!==f.children&&d(g,u.children)}},B=(f,u,h,b)=>{f==null?n(u.el=c(u.children||""),h,b):u.el=f.el},F=(f,u,h,b)=>{[f.el,f.anchor]=N(f.children,u,h,b,f.el,f.anchor)},j=({el:f,anchor:u},h,b)=>{let g;for(;f&&f!==u;)g=w(f),n(f,h,b),f=g;n(u,h,b)},A=({el:f,anchor:u})=>{let h;for(;f&&f!==u;)h=w(f),r(f),f=h;r(u)},Y=(f,u,h,b,g,_,v,x,y)=>{if(u.type==="svg"?v="svg":u.type==="math"&&(v="mathml"),f==null)ge(u,h,b,g,_,v,x,y);else{const m=f.el&&f.el._isVueCE?f.el:null;try{m&&m._beginPatch(),Vt(f,u,g,_,v,x,y)}finally{m&&m._endPatch()}}},ge=(f,u,h,b,g,_,v,x)=>{let y,m;const{props:E,shapeFlag:S,transition:T,dirs:P}=f;if(y=f.el=o(f.type,_,E&&E.is,E),S&8?a(y,f.children):S&16&&Ue(f.children,y,null,b,g,Ts(f,_),v,x),P&&Ze(f,null,b,"created"),me(y,f,f.scopeId,v,b),E){for(const $ in E)$!=="value"&&!yt($)&&i(y,$,null,E[$],_,b);"value"in E&&i(y,"value",null,E.value,_),(m=E.onVnodeBeforeMount)&&xe(m,b,f)}P&&Ze(f,null,b,"beforeMount");const R=Vo(g,T);R&&T.beforeEnter(y),n(y,u,h),((m=E&&E.onVnodeMounted)||R||P)&&ie(()=>{m&&xe(m,b,f),R&&T.enter(y),P&&Ze(f,null,b,"mounted")},g)},me=(f,u,h,b,g)=>{if(h&&C(f,h),b)for(let _=0;_{for(let m=y;m{const x=u.el=f.el;let{patchFlag:y,dynamicChildren:m,dirs:E}=u;y|=f.patchFlag&16;const S=f.props||K,T=u.props||K;let P;if(h&&Qe(h,!1),(P=T.onVnodeBeforeUpdate)&&xe(P,h,u,f),E&&Ze(u,f,h,"beforeUpdate"),h&&Qe(h,!0),m&&(!f.dynamicChildren||f.dynamicChildren.length!==m.length)&&(y=0,v=!1,m=null),(S.innerHTML&&T.innerHTML==null||S.textContent&&T.textContent==null)&&a(x,""),m?ze(f.dynamicChildren,m,x,h,b,Ts(u,g),_):v||U(f,u,x,null,h,b,Ts(u,g),_,!1),y>0){if(y&16)ut(x,S,T,h,g);else if(y&2&&S.class!==T.class&&i(x,"class",null,T.class,g),y&4&&i(x,"style",S.style,T.style,g),y&8){const R=u.dynamicProps;for(let $=0;${P&&xe(P,h,u,f),E&&Ze(u,f,h,"updated")},b)},ze=(f,u,h,b,g,_,v)=>{for(let x=0;x{if(u!==h){if(u!==K)for(const _ in u)!yt(_)&&!(_ in h)&&i(f,_,u[_],null,g,b);for(const _ in h){if(yt(_))continue;const v=h[_],x=u[_];v!==x&&_!=="value"&&i(f,_,x,v,g,b)}"value"in h&&i(f,"value",u.value,h.value,g)}},Nt=(f,u,h,b,g,_,v,x,y)=>{const m=u.el=f?f.el:l(""),E=u.anchor=f?f.anchor:l("");let{patchFlag:S,dynamicChildren:T,slotScopeIds:P}=u;P&&(x=x?x.concat(P):P),f==null?(n(m,h,b),n(E,h,b),Ue(u.children||[],h,E,g,_,v,x,y)):S>0&&S&64&&T&&f.dynamicChildren&&f.dynamicChildren.length===T.length?(ze(f.dynamicChildren,T,h,g,_,v,x),(u.key!=null||g&&u===g.subTree)&&Lr(f,u,!0)):U(f,u,h,E,g,_,v,x,y)},jt=(f,u,h,b,g,_,v,x,y)=>{u.slotScopeIds=x,f==null?u.shapeFlag&512?g.ctx.activate(u,h,b,v,y):gs(u,h,b,g,_,v,y):rn(f,u,y)},gs=(f,u,h,b,g,_,v)=>{const x=f.component=Go(f,b,g);if(tn(f)&&(x.ctx.renderer=dt),zo(x,!1,v),x.asyncDep){if(g&&g.registerDep(x,te,v),!f.el){const y=x.subTree=Oe($e);B(null,y,u,h),f.placeholder=y.el}}else te(x,f,u,h,g,_,v)},rn=(f,u,h)=>{const b=u.component=f.component;if(To(f,u,h))if(b.asyncDep&&!b.asyncResolved){u.el=f.el,q(b,u,h);return}else b.next=u,b.update();else u.el=f.el,b.vnode=u},te=(f,u,h,b,g,_,v)=>{const x=()=>{if(f.isMounted){let{next:S,bu:T,u:P,parent:R,vnode:$}=f;{const be=$r(f);if(be){S&&(S.el=$.el,q(f,S,v)),be.asyncDep.then(()=>{ie(()=>{f.isUnmounted||m()},g)});return}}let H=S,z;Qe(f,!1),S?(S.el=$.el,q(f,S,v)):S=$,T&&qt(T),(z=S.props&&S.props.onVnodeBeforeUpdate)&&xe(z,R,S,$),Qe(f,!0);const X=Cn(f),_e=f.subTree;f.subTree=X,M(_e,X,p(_e.el),Lt(_e),f,g,_),S.el=X.el,H===null&&Eo(f,X.el),P&&ie(P,g),(z=S.props&&S.props.onVnodeUpdated)&&ie(()=>xe(z,R,S,$),g)}else{let S;const{el:T,props:P}=u,{bm:R,m:$,parent:H,root:z,type:X}=f,_e=wt(u);Qe(f,!1),R&&qt(R),!_e&&(S=P&&P.onVnodeBeforeMount)&&xe(S,H,u),Qe(f,!0);{z.ce&&z.ce._hasShadowRoot()&&z.ce._injectChildStyle(X,f.parent?f.parent.type:void 0);const be=f.subTree=Cn(f);M(null,be,h,b,f,g,_),u.el=be.el}if($&&ie($,g),!_e&&(S=P&&P.onVnodeMounted)){const be=u;ie(()=>xe(S,H,be),g)}(u.shapeFlag&256||H&&wt(H.vnode)&&H.vnode.shapeFlag&256)&&f.a&&ie(f.a,g),f.isMounted=!0,u=h=b=null}};f.scope.on();const y=f.effect=new Qn(x);f.scope.off();const m=f.update=y.run.bind(y),E=f.job=y.runIfDirty.bind(y);E.i=f,E.id=f.uid,y.scheduler=()=>ks(E),Qe(f,!0),m()},q=(f,u,h)=>{u.component=f;const b=f.vnode.props;f.vnode=u,f.next=null,Ao(f,u.props,b,h),Ro(f,u.children,h),He(),_n(f),Le()},U=(f,u,h,b,g,_,v,x,y=!1)=>{const m=f&&f.children,E=f?f.shapeFlag:0,S=u.children,{patchFlag:T,shapeFlag:P}=u;if(T>0){if(T&128){Ht(m,S,h,b,g,_,v,x,y);return}else if(T&256){Ye(m,S,h,b,g,_,v,x,y);return}}P&8?(E&16&&at(m,g,_),S!==m&&a(h,S)):E&16?P&16?Ht(m,S,h,b,g,_,v,x,y):at(m,g,_,!0):(E&8&&a(h,""),P&16&&Ue(S,h,b,g,_,v,x,y))},Ye=(f,u,h,b,g,_,v,x,y)=>{f=f||et,u=u||et;const m=f.length,E=u.length,S=Math.min(m,E);let T;for(T=0;TE?at(f,g,_,!0,!1,S):Ue(u,h,b,g,_,v,x,y,S)},Ht=(f,u,h,b,g,_,v,x,y)=>{let m=0;const E=u.length;let S=f.length-1,T=E-1;for(;m<=S&&m<=T;){const P=f[m],R=u[m]=y?Fe(u[m]):we(u[m]);if(gt(P,R))M(P,R,h,null,g,_,v,x,y);else break;m++}for(;m<=S&&m<=T;){const P=f[S],R=u[T]=y?Fe(u[T]):we(u[T]);if(gt(P,R))M(P,R,h,null,g,_,v,x,y);else break;S--,T--}if(m>S){if(m<=T){const P=T+1,R=PT)for(;m<=S;)ae(f[m],g,_,!0),m++;else{const P=m,R=m,$=new Map;for(m=R;m<=T;m++){const oe=u[m]=y?Fe(u[m]):we(u[m]);oe.key!=null&&$.set(oe.key,m)}let H,z=0;const X=T-R+1;let _e=!1,be=0;const ht=new Array(X);for(m=0;m=X){ae(oe,g,_,!0);continue}let ye;if(oe.key!=null)ye=$.get(oe.key);else for(H=R;H<=T;H++)if(ht[H-R]===0&>(oe,u[H])){ye=H;break}ye===void 0?ae(oe,g,_,!0):(ht[ye-R]=m+1,ye>=be?be=ye:_e=!0,M(oe,u[ye],h,null,g,_,v,x,y),z++)}const fn=_e?No(ht):et;for(H=fn.length-1,m=X-1;m>=0;m--){const oe=R+m,ye=u[oe],cn=u[oe+1],un=oe+1{const{el:_,type:v,transition:x,children:y,shapeFlag:m}=f;if(m&6){Xe(f.component.subTree,u,h,b);return}if(m&128){f.suspense.move(u,h,b);return}if(m&64){v.move(f,u,h,dt);return}if(v===Re){n(_,u,h);for(let S=0;Sx.enter(_),g));else{const{leave:S,delayLeave:T,afterLeave:P}=x,R=()=>{f.ctx.isUnmounted?r(_):n(_,u,h)},$=()=>{const H=_._isLeaving||!!_[ws];_._isLeaving&&_[ws](!0),x.persisted&&!H?R():S(_,()=>{R(),P&&P()})};T?T(_,R,$):$()}else n(_,u,h)},ae=(f,u,h,b=!1,g=!1)=>{const{type:_,props:v,ref:x,children:y,dynamicChildren:m,shapeFlag:E,patchFlag:S,dirs:T,cacheIndex:P,memo:R}=f;if((S===-2||m&&m.hasOnce)&&(g=!1),x!=null&&(He(),St(x,null,h,f,!0),Le()),P!=null&&(!f.ctx||f.ctx===u)&&(u.renderCache[P]=void 0),E&256){u.ctx.deactivate(f);return}const $=E&1&&T,H=!wt(f);let z;if(H&&(z=v&&v.onVnodeBeforeUnmount)&&xe(z,u,f),E&6)ei(f.component,h,b);else{if(E&128){f.suspense.unmount(h,b);return}$&&Ze(f,null,u,"beforeUnmount"),E&64?f.type.remove(f,u,h,dt,b):m&&!m.hasOnce&&(_!==Re||S>0&&S&64)?at(m,u,h,!1,!0):(_===Re&&S&384||!g&&E&16)&&at(y,u,h),b&&on(f)}const X=R!=null&&P==null;(H&&(z=v&&v.onVnodeUnmounted)||$||X)&&ie(()=>{z&&xe(z,u,f),$&&Ze(f,null,u,"unmounted"),X&&(f.el=null)},h)},on=f=>{const{type:u,el:h,anchor:b,transition:g}=f;if(u===Re){kr(h,b);return}if(u===Jt){A(f),g&&!g.persisted&&g.afterLeave&&g.afterLeave();return}const _=()=>{r(h),g&&!g.persisted&&g.afterLeave&&g.afterLeave()};if(f.shapeFlag&1&&g&&!g.persisted){const{leave:v,delayLeave:x}=g,y=()=>v(h,_);x?x(f.el,_,y):y()}else _()},kr=(f,u)=>{let h;for(;f!==u;)h=w(f),r(f),f=h;r(u)},ei=(f,u,h)=>{const{bum:b,scope:g,job:_,subTree:v,um:x,m:y,a:m}=f;On(y),On(m),b&&qt(b),g.stop(),_?(_.flags|=8,ae(v,f,u,h)):f.vnode.el&&v&&(v.transition=f.vnode.transition,ae(v,f,u,h)),x&&ie(x,u),ie(()=>{f.isUnmounted=!0},u)},at=(f,u,h,b=!1,g=!1,_=0)=>{for(let v=_;v{if(f.shapeFlag&6)return Lt(f.component.subTree);if(f.shapeFlag&128)return f.suspense.next();const u=w(f.anchor||f.el),h=u&&u[Xi];return h?w(h):u};let ms=!1;const ln=(f,u,h)=>{let b;f==null?u._vnode&&(ae(u._vnode,null,null,!0),b=u._vnode.component):M(u._vnode||null,f,u,null,null,null,h),u._vnode=f,ms||(ms=!0,_n(b),_r(),ms=!1)},dt={p:M,um:ae,m:Xe,r:on,mt:gs,mc:Ue,pc:U,pbc:ze,n:Lt,o:e};return{render:ln,hydrate:void 0,createApp:yo(ln)}}function Ts({type:e,props:t},s){return s==="svg"&&e==="foreignObject"||s==="mathml"&&e==="annotation-xml"&&t&&t.encoding&&t.encoding.includes("html")?void 0:s}function Qe({effect:e,job:t},s){s?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function Vo(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function Lr(e,t,s=!1){const n=e.children,r=t.children;if(O(n)&&O(r))for(let i=0;i>1,e[s[l]]0&&(t[n]=s[i-1]),s[i]=n)}}for(i=s.length,o=s[i-1];i-- >0;)s[i]=o,o=t[o];return s}function $r(e){const t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:$r(t)}function On(e){if(e)for(let t=0;te.__isSuspense;function jo(e,t){t&&t.pendingBranch?O(e)?t.effects.push(...e):t.effects.push(e):Bi(e)}const Re=Symbol.for("v-fgt"),hs=Symbol.for("v-txt"),$e=Symbol.for("v-cmt"),Jt=Symbol.for("v-stc"),st=[];let le=null;function Ho(e=!1){st.push(le=e?null:[])}function Wr(){st.pop(),le=st[st.length-1]||null}let At=1;function An(e,t=!1){At+=e,e<0&&le&&t&&(le.hasOnce=!0)}function Br(e){return e.dynamicChildren=At>0?le||et:null,Wr(),At>0&&le&&le.push(e),e}function Vl(e,t,s,n,r,i){return Br(Jr(e,t,s,n,r,i,!0))}function Lo(e,t,s,n,r){return Br(Oe(e,t,s,n,r,!0))}function qr(e){return e?e.__v_isVNode===!0:!1}function gt(e,t){return e.type===t.type&&e.key===t.key}const Gr=({key:e})=>e!=null?e:null,zt=({ref:e,ref_key:t,ref_for:s})=>(typeof e=="number"&&(e=""+e),e!=null?G(e)||k(e)||I(e)?{i:fe,r:e,k:t,f:!!s}:e:null);function Jr(e,t=null,s=null,n=0,r=null,i=e===Re?0:1,o=!1,l=!1){const c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&Gr(t),ref:t&&zt(t),scopeId:yr,slotScopeIds:null,children:s,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:n,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:fe};return l?(es(c,s),i&128&&e.normalize(c)):s&&(c.shapeFlag|=G(s)?8:16),At>0&&!o&&le&&(c.patchFlag>0||i&6)&&c.patchFlag!==32&&le.push(c),c}const Oe=$o;function $o(e,t=null,s=null,n=0,r=null,i=!1){if((!e||e===uo)&&(e=$e),qr(e)){const l=ft(e,t,!0);return s&&es(l,s),At>0&&!i&&le&&(l.shapeFlag&6?le[le.indexOf(e)]=l:le.push(l)),l.patchFlag=-2,l}if(Qo(e)&&(e=e.__vccOpts),t){t=Ko(t);let{class:l,style:c}=t;l&&!G(l)&&(t.class=Ws(l)),L(c)&&(Qs(c)&&!O(c)&&(c=ee({},c)),t.style=Us(c))}const o=G(e)?1:Ur(e)?128:us(e)?64:L(e)?4:I(e)?2:0;return Jr(e,t,s,n,r,o,i,!0)}function Ko(e){return e?Qs(e)||Fr(e)?ee({},e):e:null}function ft(e,t,s=!1,n=!1){const{props:r,ref:i,patchFlag:o,children:l,transition:c}=e,d=t?Wo(r||{},t):r,a={__v_isVNode:!0,__v_skip:!0,type:e.type,props:d,key:d&&Gr(d),ref:t&&t.ref?s&&i?O(i)?i.concat(zt(t)):[i,zt(t)]:zt(t):i,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:l,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==Re?o===-1?16:o|16:o,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:c,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&ft(e.ssContent),ssFallback:e.ssFallback&&ft(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce,cacheIndex:e.cacheIndex};return c&&n&&en(a,c.clone(a)),a}function Uo(e=" ",t=0){return Oe(hs,null,e,t)}function Nl(e,t){const s=Oe(Jt,null,e);return s.staticCount=t,s}function jl(e="",t=!1){return t?(Ho(),Lo($e,null,e)):Oe($e,null,e)}function we(e){return e==null||typeof e=="boolean"?Oe($e):O(e)?Oe(Re,null,e.slice()):qr(e)?Fe(e):Oe(hs,null,String(e))}function Fe(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:ft(e)}function es(e,t){let s=0;const{shapeFlag:n}=e;if(t==null)t=null;else if(O(t))s=16;else if(typeof t=="object")if(n&65){const r=t.default;r&&(r._c&&(r._d=!1),es(e,r()),r._c&&(r._d=!0));return}else{s=32;const r=t._;!r&&!Fr(t)?t._ctx=fe:r===3&&fe&&(fe.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else if(I(t)){if(n&65){es(e,{default:t});return}t={default:t,_ctx:fe},s=32}else t=String(t),n&64?(s=16,t=[Uo(t)]):s=8;e.children=t,e.shapeFlag|=s}function Wo(...e){const t={};for(let s=0;sre||fe;let ts,Pt;{const e=ls(),t=(s,n)=>{let r;return(r=e[s])||(r=e[s]=[]),r.push(n),i=>{r.length>1?r.forEach(o=>o(i)):r[0](i)}};ts=t("__VUE_INSTANCE_SETTERS__",s=>re=s),Pt=t("__VUE_SSR_SETTERS__",s=>Mt=s)}const Dt=e=>{const t=re;return ts(e),e.scope.on(),()=>{e.scope.off(),ts(t)}},Pn=()=>{re&&re.scope.off(),ts(null)};function zr(e){return e.vnode.shapeFlag&4}let Mt=!1;function zo(e,t=!1,s=!1){t&&Pt(t);const{props:n,children:r}=e.vnode,i=zr(e);Oo(e,n,i,t),Io(e,r,s||t);const o=i?Yo(e,t):void 0;return t&&Pt(!1),o}function Yo(e,t){const s=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,ao);const{setup:n}=s;if(n){He();const r=e.setupContext=n.length>1?Zo(e):null,i=Dt(e),o=Ft(n,e,0,[e.props,r]),l=Bn(o);if(Le(),i(),(l||e.sp)&&!wt(e)&&wr(e),l){if(o.then(Pn,Pn),t)return o.then(c=>{Pt(!0);try{Mn(e,c,t)}finally{Pt(!1)}}).catch(c=>{cs(c,e,0)});e.asyncDep=o}else Mn(e,o)}else Yr(e)}function Mn(e,t,s){I(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:L(t)&&(e.setupState=hr(t)),Yr(e)}function Yr(e,t,s){const n=e.type;e.render||(e.render=n.render||Ee);{const r=Dt(e);He();try{ho(e)}finally{Le(),r()}}}const Xo={get(e,t){return Q(e,"get",""),e[t]}};function Zo(e){const t=s=>{e.exposed=s||{}};return{attrs:new Proxy(e.attrs,Xo),slots:e.slots,emit:e.emit,expose:t}}function ps(e){return e.exposed?e.exposeProxy||(e.exposeProxy=new Proxy(hr(Di(e.exposed)),{get(t,s){if(s in t)return t[s];if(s in Ct)return Ct[s](e)},has(t,s){return s in t||s in Ct}})):e.proxy}function Qo(e){return I(e)&&"__vccOpts"in e}const ko=(e,t)=>Li(e,t,Mt),el="3.5.43";let Hs;const In=typeof window!="undefined"&&window.trustedTypes;if(In)try{Hs=In.createPolicy("vue",{createHTML:e=>e})}catch(e){}const Xr=Hs?e=>Hs.createHTML(e):e=>e,tl="http://www.w3.org/2000/svg",sl="http://www.w3.org/1998/Math/MathML",Ie=typeof document!="undefined"?document:null,Rn=Ie&&Ie.createElement("template"),nl={insert:(e,t,s)=>{t.insertBefore(e,s||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,s,n)=>{const r=t==="svg"?Ie.createElementNS(tl,e):t==="mathml"?Ie.createElementNS(sl,e):s?Ie.createElement(e,{is:s}):Ie.createElement(e);return e==="select"&&n&&n.multiple!=null&&r.setAttribute("multiple",n.multiple),r},createText:e=>Ie.createTextNode(e),createComment:e=>Ie.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Ie.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,s,n,r,i){const o=s?s.previousSibling:t.lastChild;if(r&&(r===i||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),s),!(r===i||!(r=r.nextSibling)););else{Rn.innerHTML=Xr(n==="svg"?`${e} `:n==="mathml"?`${e} `:e);const l=Rn.content;if(n==="svg"||n==="mathml"){const c=l.firstChild;for(;c.firstChild;)l.appendChild(c.firstChild);l.removeChild(c)}t.insertBefore(l,s)}return[o?o.nextSibling:t.firstChild,s?s.previousSibling:t.lastChild]}},rl=Symbol("_vtc");function il(e,t,s){const n=e[rl];n&&(t=(t?[t,...n]:[...n]).join(" ")),t==null?e.removeAttribute("class"):s?e.setAttribute("class",t):e.className=t}const ss=Symbol("_vod"),Zr=Symbol("_vsh"),Hl={name:"show",beforeMount(e,{value:t},{transition:s}){e[ss]=e.style.display==="none"?"":e.style.display,s&&t?s.beforeEnter(e):mt(e,t)},mounted(e,{value:t},{transition:s}){s&&t&&s.enter(e)},updated(e,{value:t,oldValue:s},{transition:n}){!t!=!s&&(n?t?(n.beforeEnter(e),mt(e,!0),n.enter(e)):n.leave(e,()=>{mt(e,!1)}):mt(e,t))},beforeUnmount(e,{value:t}){mt(e,t)}};function mt(e,t){e.style.display=t?e[ss]:"none",e[Zr]=!t}const ol=Symbol(""),ll=/(?:^|;)\s*display\s*:/;function fl(e,t,s){const n=e.style,r=G(s);let i=!1;if(s&&!r){if(t)if(G(t))for(const o of t.split(";")){const l=o.slice(0,o.indexOf(":")).trim();s[l]==null&&bt(n,l,"")}else for(const o in t)s[o]==null&&bt(n,o,"");for(const o in s){o==="display"&&(i=!0);const l=s[o];l!=null?ul(e,o,!G(t)&&t?t[o]:void 0,l)||bt(n,o,l):bt(n,o,"")}}else if(r){if(t!==s){const o=n[ol];o&&(s+=";"+o),n.cssText=s,i=ll.test(s)}}else t&&e.removeAttribute("style");ss in e&&(e[ss]=i?n.display:"",e[Zr]&&(n.display="none"))}const Wt=/\s*!important$/;function bt(e,t,s){if(O(s))s.forEach(n=>bt(e,t,n));else if(s==null&&(s=""),t.startsWith("--"))Wt.test(s)?e.setProperty(t,s.replace(Wt,""),"important"):e.setProperty(t,s);else{const n=cl(e,t);Wt.test(s)?e.setProperty(nt(n),s.replace(Wt,""),"important"):e[n]=s}}const Fn=["Webkit","Moz","ms"],Es={};function cl(e,t){const s=Es[t];if(s)return s;let n=de(t);if(n!=="filter"&&n in e)return Es[t]=n;n=Jn(n);for(let r=0;rOs||(ml.then(()=>Os=0),Os=Date.now());function bl(e,t){const s=n=>{if(!n._vts)n._vts=Date.now();else if(n._vts<=s.attached)return;const r=s.value;if(O(r)){const i=n.stopImmediatePropagation;n.stopImmediatePropagation=()=>{i.call(n),n._stopped=!0};const o=r.slice(),l=[n];for(let c=0;ce.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,yl=(e,t,s,n,r,i)=>{const o=r==="svg";t==="class"?il(e,n,o):t==="style"?fl(e,s,n):ns(t)?rs(t)||dl(e,t,s,n,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):xl(e,t,n,o))?(Nn(e,t,n),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&Vn(e,t,n,o,i,t!=="value")):e._isVueCE&&(vl(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!G(n)))?Nn(e,de(t),n,i,t):(t==="true-value"?e._trueValue=n:t==="false-value"&&(e._falseValue=n),Vn(e,t,n,o))};function xl(e,t,s,n){if(n)return!!(t==="innerHTML"||t==="textContent"||t in e&&Hn(t)&&I(s));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const r=e.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return Hn(t)&&G(s)?!1:t in e}function vl(e,t){const s=e._def.props;if(!s)return!1;const n=de(t);return Array.isArray(s)?s.some(r=>de(r)===n):Object.keys(s).some(r=>de(r)===n)}const ct=e=>{const t=e.props["onUpdate:modelValue"]||!1;return O(t)?s=>qt(t,s):t};function Sl(e){e.target.composing=!0}function Ln(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const Te=Symbol("_assign"),Bt=Symbol("_initialValue");function As(e,t,s){return t&&(e=e.trim()),s&&(e=os(e)),e}const Ll={created(e,{modifiers:{lazy:t,trim:s,number:n}},r){e.parentNode&&(e.type==="text"?e[Bt]=e.defaultValue.replace(/[\r\n]/g,""):e.type==="textarea"&&(e[Bt]=e.defaultValue.replace(/\r\n?/g,`
-`))),e[Te]=ct(r);const i=n||r.props&&r.props.type==="number";Be(e,t?"change":"input",o=>{o.target.composing||e[Te](As(e.value,s,i))}),(s||i)&&Be(e,"change",()=>{e.value=As(e.value,s,i)}),t||(Be(e,"compositionstart",Sl),Be(e,"compositionend",Ln),Be(e,"change",Ln))},mounted(e,{value:t,modifiers:{trim:s,number:n}}){const r=t==null?"":t,i=e[Bt];delete e[Bt],i!==void 0&&(e.type==="text"||e.type==="textarea")&&e.value!==i?e[Te](As(e.value,s,n)):e.value=r},beforeUpdate(e,{value:t,oldValue:s,modifiers:{lazy:n,trim:r,number:i}},o){if(e[Te]=ct(o),e.composing)return;const l=(i||e.type==="number")&&!/^0\d/.test(e.value)?os(e.value):e.value,c=t==null?"":t;if(l===c)return;const d=e.getRootNode();(d instanceof Document||d instanceof ShadowRoot)&&d.activeElement===e&&e.type!=="range"&&(n&&t===s||r&&e.value.trim()===c)||(e.value=c)}},$l={deep:!0,created(e,t,s){e[Te]=ct(s),Be(e,"change",()=>{const n=e._modelValue,r=It(e),i=e.checked,o=e[Te];if(O(n)){const l=Bs(n,r),c=l!==-1;if(i&&!c)o(n.concat(r));else if(!i&&c){const d=[...n];d.splice(l,1),o(d)}}else if(Ne(n)){const l=new Set(n);i?l.add(r):l.delete(r),o(l)}else o(Qr(e,i))})},mounted:$n,beforeUpdate(e,t,s){e[Te]=ct(s),$n(e,t,s)}};function $n(e,{value:t,oldValue:s},n){e._modelValue=t;let r;if(O(t))r=Bs(t,n.props.value)>-1;else if(Ne(t))r=t.has(n.props.value);else{if(t===s)return;r=je(t,Qr(e,!0))}e.checked!==r&&(e.checked=r)}const Kl={deep:!0,created(e,{value:t,modifiers:{number:s}},n){e._modelValue=t,Be(e,"change",()=>{const r=Array.prototype.filter.call(e.options,c=>c.selected).map(c=>s?os(It(c)):It(c)),i=e.multiple,o=i?Ne(e._modelValue)?new Set(r):r:r[0],l=e._pendingValue=[i,i?O(o)?r.slice():r:o];try{e[Te](o)}finally{gr(()=>{e._pendingValue===l&&(e._pendingValue=void 0)})}}),e[Te]=ct(n)},mounted(e,{value:t}){Kn(e,t)},beforeUpdate(e,{value:t},s){e._modelValue=t,e[Te]=ct(s)},updated(e,{value:t}){const s=e._pendingValue;e._pendingValue=void 0,(!s||s[0]!==e.multiple||!wl(t,s[1],s[0]))&&Kn(e,t)}};function wl(e,t,s){if(!s||O(e))return je(e,t);if(Ne(e)){if(e.size!==t.length)return!1;for(const n of t)if(!e.has(n))return!1;return!0}return!1}function Kn(e,t){const s=e.multiple,n=O(t);if(!(s&&!n&&!Ne(t))){for(let r=0,i=e.options.length;rString(d)===String(l)):o.selected=Bs(t,l)>-1}else o.selected=t.has(l);else if(je(It(o),t)){e.selectedIndex!==r&&(e.selectedIndex=r);return}}!s&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function It(e){return"_value"in e?e._value:e.value}function Qr(e,t){const s=t?"_trueValue":"_falseValue";return s in e?e[s]:t}const Cl=["ctrl","shift","alt","meta"],Tl={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>Cl.some(s=>e[`${s}Key`]&&!t.includes(s))},Ul=(e,t)=>{if(!e)return e;const s=e._withMods||(e._withMods={}),n=t.join(".");return s[n]||(s[n]=((r,...i)=>{for(let o=0;o{const t=Ol().createApp(...e),{mount:s}=t;return t.mount=n=>{const r=Pl(n);if(!r)return;const i=t._component;!I(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=s(r,!1,Al(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},t});function Al(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function Pl(e){return G(e)?document.querySelector(e):e}export{Wo as A,Wl as B,Re as F,Jr as a,Nl as b,Vl as c,Oe as d,Uo as e,so as f,io as g,jl as h,Lo as i,Dl as j,Ws as k,ko as l,Fl as m,Us as n,Ho as o,Kl as p,$l as q,Il as r,Rl as s,hi as t,Ni as u,Hl as v,Ss as w,Ul as x,Tr as y,Ll as z};
diff --git a/web/ui/assets/index-CpHAVBsY.js b/web/ui/assets/index-CpHAVBsY.js
new file mode 100644
index 0000000..55f78f8
--- /dev/null
+++ b/web/ui/assets/index-CpHAVBsY.js
@@ -0,0 +1,146 @@
+import{o as C,c as M,a as c,b as ye,d as K,e as S,s as Gr,w as Qe,f as Yr,g as ds,n as Cn,h as $,r as q,t as k,i as It,u as j,F as J,j as ie,k as _e,l as Q,m as he,v as En,p as qt,q as Fs,x as bt,y as Aa,z as Ji,A as Nu,B as Iu,C as Du,D as Ru,E as Lu,G as Pu,H as $u,I as Bu,J as zu}from"./bootstrap.min-C5Nka04t.js";const _u={class:"app-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.65","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},ju=["d"],we={__name:"AppIcon",props:{name:{type:String,default:"grid"}},setup(n){const e={shield:"M12 2 3 6v6c0 5 9 10 9 10s9-5 9-10V6Z M8 12l3 3 5-6",location:"M20 10c0 6-8 12-8 12S4 16 4 10a8 8 0 1 1 16 0 M15 10a3 3 0 1 1-6 0 3 3 0 0 1 6 0",home:"m3 10 9-7 9 7v10H3Z M9 20v-7h6v7",journal:"M5 3h14v18H5Z M8 7h8 M8 11h8 M8 15h5",grid:"M3 3h7v7H3Z M14 3h7v7h-7Z M3 14h7v7H3Z M14 14h7v7h-7Z",devices:"M3 4h18v12H3Z M8 20h8 M12 16v4",tree:"M9 2h6v6H9Z M2 16h6v6H2Z M16 16h6v6h-6Z M12 8v4 M5 16v-4h14v4",users:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2 M22 21v-2a4 4 0 0 0-3-3.8 M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8 M17 3a4 4 0 0 1 0 8",settings:"M9 3h6l1 4 4 1v8l-4 1-1 4H9l-1-4-4-1V8l4-1Z M15 12a3 3 0 1 0-6 0 3 3 0 0 0 6 0",database:"M3 6c0-5 18-5 18 0s-18 5-18 0V18c0 5 18 5 18 0V6 M3 12c0 5 18 5 18 0",network:"M9 2h6v6H9Z M2 16h6v6H2Z M16 16h6v6h-6Z M12 8v4 M5 16v-4h14v4",arrow:"M5 12h14 M14 7l5 5-5 5",router:"M3 13h18v8H3Z M6 13V5 M18 13V5 M7 17h.01 M11 17h.01 M15 17h3",camera:"M3 6h12v12H3Z M15 10l6-4v12l-6-4"};return(t,s)=>(C(),M("svg",_u,[c("path",{d:e[n.name]||e.grid},null,8,ju)]))}},Fu={class:"sidebar"},Vu={class:"nav flex-column",id:"main-navigation","aria-label":"主导航"},Hu={"data-page":"households",class:"active"},qu={id:"scope-navigation",hidden:""},Wu={"data-page":"journal"},Uu={"data-page":"overview"},Ku={"data-page":"objects"},Ju={"data-page":"heritage"},Gu={"data-page":"users","data-admin":""},Yu={"data-page":"settings"},Xu={"data-page":"storage"},Zu={__name:"AppSidebar",setup(n){return(e,t)=>(C(),M("aside",Fu,[t[17]||(t[17]=ye('赵府 智能数字管家 ☰ 菜单 家宅 · 起居
',3)),c("nav",Vu,[c("button",Hu,[K(we,{name:"home"}),t[0]||(t[0]=S()),t[1]||(t[1]=c("span",null,"我的家庭与场所",-1))]),c("div",qu,[t[12]||(t[12]=c("div",{id:"scope-nav-name",class:"nav-label"},null,-1)),c("button",Wu,[K(we,{name:"journal"}),t[2]||(t[2]=S()),t[3]||(t[3]=c("span",null,"记事与阅历",-1))]),c("button",Uu,[K(we,{name:"grid"}),t[4]||(t[4]=S()),t[5]||(t[5]=c("span",null,"场所总览",-1))]),c("button",Ku,[K(we,{name:"devices"}),t[6]||(t[6]=S()),t[7]||(t[7]=c("span",null,"区域与设备",-1))]),c("button",Ju,[K(we,{name:"tree"}),t[8]||(t[8]=S()),t[9]||(t[9]=c("span",null,"家庭传承",-1))]),c("button",Gu,[K(we,{name:"users"}),t[10]||(t[10]=S()),t[11]||(t[11]=c("span",null,"成员与权限",-1))])]),c("button",Yu,[K(we,{name:"settings"}),t[13]||(t[13]=S()),t[14]||(t[14]=c("span",null,"设置中心",-1))]),c("button",Xu,[K(we,{name:"database"}),t[15]||(t[15]=S()),t[16]||(t[16]=c("span",null,"平台存储与审计",-1))])]),t[18]||(t[18]=ye(' 独立部署 · 数据自有
按空间组织画面 让每一段记录有处可寻
修改我的密码 退出登录 ',4))]))}},us=(n,e)=>{const t=n.__vccOpts||n;for(const[s,i]of e)t[s]=i;return t},Qu={};function ep(n,e){return C(),M("header",null,[...e[0]||(e[0]=[ye('赵氏家宅 · 起居有序
我的家庭与场所 从一个空间,看到每一个位置。
',2)])])}const tp=us(Qu,[["render",ep]]),B=Gr({state:{households:[],sites:[],cameras:[]},admin:!1,loggedIn:!1,page:"households",session:0,device:null}),Pe=Gr({devices:[],groups:[],rows:[]});window.ZhaoVue={enabled:!0,accept(n){B.value=n},setDevices(n){Pe.value=n},clear(){Pe.value={devices:[],groups:[],rows:[]}}};const te=()=>window.ZhaoVue,Xr=n=>({lan:"局域网",tailscale:"Tailscale",public:"公网",unknown:"接入待确认"})[n]||"接入待确认";function np(n=[]){const e=[{key:"home",label:"家庭",color:"#258b76",count:0},{key:"office",label:"办公",color:"#5c83cb",count:0},{key:"factory",label:"工厂",color:"#c69a52",count:0},{key:"other",label:"其他",color:"#8997a9",count:0}];let t=0,s=0;for(const r of n)(e.find(o=>o.key===(r.kind||"home"))||e[3]).count++,t+=Math.max(0,Number(r.deviceCount)||0),s+=Math.max(0,Number(r.sites)||0);let i=0;return{total:n.length,devices:t,areas:s,kinds:e.filter(r=>r.count).map(r=>{const o={...r,share:r.count/n.length*100,offset:i};return i+=o.share,o})}}const Xn=["#268575","#648bcc","#c49b5b","#8e82b5","#899aa5"],Vs=n=>Math.max(0,Math.floor(Number(n)||0));function Oa(n=[]){return{series:[{type:"pie",radius:["62%","84%"],center:["50%","50%"],avoidLabelOverlap:!0,label:{show:!1},emphasis:{scale:!1},data:n.map((e,t)=>({name:e.label,value:Vs(e.count),itemStyle:{color:e.color||Xn[t%Xn.length],borderRadius:4}}))}]}}function Na(n=[]){return{grid:{left:12,right:35,top:10,bottom:12,containLabel:!0},xAxis:{type:"value",minInterval:1,axisTick:{show:!1}},yAxis:{type:"category",inverse:!0,axisTick:{show:!1},axisLine:{show:!1},axisLabel:{width:90,overflow:"truncate"},data:n.map(e=>e.label)},series:[{type:"bar",barMaxWidth:20,label:{show:!0,position:"right"},data:n.map((e,t)=>({value:Vs(e.count),itemStyle:{color:e.color||Xn[t%Xn.length],borderRadius:[0,5,5,0]}}))}]}}function sp(n={}){const e=[...(n.assets||[]).map(o=>({...o,deviceType:"摄像机"})),...(n.recorders||[]).map(o=>({...o,deviceType:"录像机"})),...n.devices||[]],t=new Map,s=new Map,i={lan:"局域网",tailscale:"Tailscale",public:"公网",unknown:"待登记"};for(const o of e){const l=o.deviceType||"其他",a=i[o.networkAccess]||i.unknown;t.set(l,(t.get(l)||0)+1),s.set(a,(s.get(a)||0)+1)}const r=o=>[...o].map(([l,a])=>({label:l,count:a})).sort((l,a)=>a.count-l.count||l.label.localeCompare(a.label));return{total:e.length,types:r(t),networks:r(s)}}function Ia(n,e){return{tooltip:{formatter:t=>t.dataType==="edge"?"已登记的上级连接":t.data.detail||t.name},series:[{type:"graph",layout:"none",roam:!0,draggable:!1,scaleLimit:{min:.2,max:4},symbol:"roundRect",symbolSize:[145,60],edgeSymbol:["none","arrow"],edgeSymbolSize:6,label:{show:!0,fontSize:11,width:128,overflow:"truncate",formatter:t=>t.data.caption||t.name},lineStyle:{color:"#8aa99f",width:2,curveness:.08},emphasis:{focus:"adjacency",lineStyle:{width:3}},data:n,links:e}]}}function ip(n=[],e=()=>""){const t=new Map(n.map(r=>[r.device.id,r])),s=n.map((r,o)=>({id:r.device.id,targetId:r.device.id,name:r.device.name,caption:r.device.name+`
+`+((r.device.networkHosts||[])[0]||"IP 待填写"),detail:[r.device.name,r.device.deviceType,e(r.device.siteId)||"位置待登记",(r.device.networkHosts||[]).join(" / ")||"IP 待填写",{lan:"局域网",tailscale:"Tailscale",public:"公网"}[r.device.networkAccess]||"接入待确认"].join(`
+`),x:Math.max(0,r.depth||0)*280,y:o*105,itemStyle:{color:r.device.source==="camera"?"#e1ebfb":"#dceddf",borderColor:r.device.source==="camera"?"#648bcc":"#468b73",borderWidth:1},label:{color:"#213f48"}})),i=n.flatMap(r=>{const o=t.get(r.device.uplinkId);return o&&o.depth+1===r.depth?[{source:o.device.id,target:r.device.id}]:[]});return Ia(s,i)}function rp(n=[],e="赵府"){return Ia([{id:"platform",name:e,x:0,y:0,symbolSize:[160,65],itemStyle:{color:"#286d5d"},label:{color:"#fff"}},...n.map((t,s)=>({id:"home:"+t.id,targetId:t.id,name:t.name,caption:t.name+`
+`+Vs(t.deviceCount)+" 台设备",detail:[t.name,{home:"家庭",office:"办公",factory:"工厂"}[t.kind||"home"]||"场所",[t.province,t.city,t.district].filter(Boolean).join(" · "),Vs(t.deviceCount)+" 台已授权设备"].filter(Boolean).join(`
+`),x:300,y:(s-(n.length-1)/2)*120,itemStyle:{color:"#e3efe8",borderColor:"#8ebaa6",borderWidth:1},label:{color:"#213f48"}}))],n.map(t=>({source:"platform",target:"home:"+t.id})))}const op="modulepreload",lp=function(n){return"/ui/"+n},$o={},ap=function(e,t,s){let i=Promise.resolve();if(t&&t.length>0){let a=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=a(t.map(d=>{if(d=lp(d),d in $o)return;$o[d]=!0;const u=d.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":op,u||(f.as="script"),f.crossOrigin="",f.href=d,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((h,m)=>{f.addEventListener("load",h),f.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${d}`)))})}))}function r(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&r(l.reason);return e().catch(r)})},cp={class:"local-chart-wrap"},dp=["aria-label"],up={key:0,class:"small text-secondary px-3",role:"status"},Yt={__name:"LocalChart",props:{option:{type:Object,required:!0},label:String,active:{type:Boolean,default:!0},height:{type:Number,default:260}},emits:["select"],setup(n,{emit:e}){const t=n,s=e,i=q(null),r=q(!1);let o,l,a,d,u=!0,p=!1,f="",h="";function m(){o==null||o.dispose(),o=null,f="",h=""}function g(){!d&&u&&(d=requestAnimationFrame(()=>{d=null,b()}))}async function b(){if(!u||!i.value||!t.active){m();return}const y=Math.floor(i.value.clientWidth),T=Math.floor(i.value.clientHeight);if(!y||!T)return;if(!o){if(p)return;p=!0;try{const w=await ap(()=>import("./charts-runtime-DBCaHPDW.js"),[]);if(!u||!t.active||!i.value)return;o=w.init(i.value,null,{renderer:"canvas",devicePixelRatio:Math.min(window.devicePixelRatio||1,2)}),o.on("click",D=>{var L;(L=D.data)!=null&&L.targetId&&s("select",D.data.targetId)}),r.value=!1}catch(w){r.value=!0,console.error("Local chart unavailable",w);return}finally{p=!1}}const A=getComputedStyle(document.documentElement),E=A.getPropertyValue("--ink").trim()||"#253b46",O=A.getPropertyValue("--ui-muted").trim()||"#627485",I=A.getPropertyValue("--ui-line").trim()||"#e3e9ef",x=JSON.stringify(t.option)+E+O+I;if(x!==f){const w={...t.option,animation:!1,backgroundColor:"transparent",textStyle:{color:E,fontFamily:"system-ui, Microsoft YaHei, sans-serif"},aria:{enabled:!0,description:t.label},tooltip:{trigger:"item",renderMode:"richText",confine:!0,...t.option.tooltip}};for(const D of["xAxis","yAxis"])w[D]&&(w[D]={...w[D],axisLabel:{color:O,...w[D].axisLabel},splitLine:{lineStyle:{color:I}}});w.series=(w.series||[]).map(D=>({...D,label:{color:E,...D.label}})),o.setOption(w,{notMerge:!0,lazyUpdate:!1}),f=x}const v=y+":"+T;v!==h&&(o.resize({width:y,height:T}),h=v)}return Qe(()=>[t.option,t.active],g,{deep:!0,flush:"post"}),Yr(()=>{l=new ResizeObserver(g),l.observe(i.value),a=new MutationObserver(g),a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-density"]}),g()}),ds(()=>{u=!1,cancelAnimationFrame(d),l==null||l.disconnect(),a==null||a.disconnect(),m()}),(y,T)=>(C(),M("div",cp,[c("div",{ref_key:"host",ref:i,class:"local-chart",role:"img","aria-label":n.label,style:Cn({height:n.height+"px"})},null,12,dp),r.value?(C(),M("p",up,"图表暂未加载,可查看下方数据。")):$("",!0)]))}},pp={class:"col-12 col-xl-4"},fp={class:"dashboard-welcome h-100"},hp={class:"dashboard-totals"},mp={class:"insight-scope"},gp={class:"col-12 d-md-none"},bp=["aria-expanded"],yp={class:"col-12 col-md-5 col-xl-3 dashboard-chart-column"},vp={class:"chart-card h-100"},kp={class:"chart-heading"},xp={class:"badge"},wp={key:1,class:"chart-empty"},Sp={class:"chart-legend"},Cp={class:"col-12 col-md-7 col-xl-5 dashboard-chart-column"},Mp={class:"chart-card h-100"},Tp={key:1,class:"chart-empty"},Ep={key:2,class:"chart-data"},Ap={__name:"HomeInsights",setup(n){const e=Q(()=>np(B.value.state.households)),t=q(!1),s=Q(()=>B.value.loggedIn&&B.value.page==="households"),i=Q(()=>(B.value.state.households||[]).map(r=>({label:r.name,count:r.deviceCount||0})).sort((r,o)=>o.count-r.count).slice(0,8));return(r,o)=>(C(),M("section",{class:_e(["dashboard-grid row g-3 mb-4",{"charts-expanded":t.value}]),"aria-label":"已授权场所概览"},[c("div",pp,[c("article",fp,[o[5]||(o[5]=c("span",{class:"insight-kicker"},"一处相连 · 各有归属",-1)),o[6]||(o[6]=c("h2",null,"家与日常,尽在掌握",-1)),o[7]||(o[7]=c("p",null,"从一处灯火,连接生活的每个空间。",-1)),c("div",hp,[c("div",null,[c("strong",null,k(e.value.total),1),o[1]||(o[1]=c("span",null,"家庭与场所",-1))]),c("div",null,[c("strong",null,k(e.value.devices),1),o[2]||(o[2]=c("span",null,"已登记设备",-1))]),c("div",null,[c("strong",null,k(e.value.areas),1),o[3]||(o[3]=c("span",null,"区域空间",-1))])]),c("div",mp,[K(we,{name:"shield"}),o[4]||(o[4]=S(" 仅汇总你有权访问的家庭与场所",-1))])])]),c("div",gp,[c("button",{class:"btn btn-outline-secondary w-100","aria-expanded":t.value,onClick:o[0]||(o[0]=l=>t.value=!t.value)},k(t.value?"收起图表统计":"展开图表统计"),9,bp)]),c("div",yp,[c("article",vp,[c("div",kp,[o[8]||(o[8]=c("h3",null,"空间分布",-1)),c("span",xp,k(e.value.total)+" 处",1)]),e.value.total?(C(),It(Yt,{key:0,option:j(Oa)(e.value.kinds),active:s.value,height:160,label:"场所分布:"+e.value.kinds.map(l=>l.label+l.count+"个").join(",")},null,8,["option","active","label"])):(C(),M("p",wp,"添加家庭或场所后显示分布")),c("div",Sp,[(C(!0),M(J,null,ie(e.value.kinds,l=>(C(),M("span",{key:l.key},[c("i",{style:Cn({background:l.color})},null,4),S(k(l.label)+" ",1),c("b",null,k(l.count),1)]))),128))])])]),c("div",Cp,[c("article",Mp,[o[10]||(o[10]=c("div",{class:"chart-heading"},[c("h3",null,"设备分布"),c("span",{class:"small text-secondary"},"按场所 · 最多显示 8 处")],-1)),i.value.length?(C(),It(Yt,{key:0,option:j(Na)(i.value),active:s.value,height:190,label:"各场所已登记设备:"+i.value.map(l=>l.label+l.count+"台").join(",")},null,8,["option","active","label"])):(C(),M("p",Tp,"暂无已授权场所")),i.value.length?(C(),M("details",Ep,[o[9]||(o[9]=c("summary",null,"查看统计数字",-1)),c("ul",null,[(C(!0),M(J,null,ie(i.value,l=>(C(),M("li",{key:l.label},k(l.label)+":"+k(l.count)+" 台",1))),128))])])):$("",!0)])])],2))}},Op={id:"page-households",class:"page"},Np={class:"section-head"},Ip={class:"count-pill"},Dp=["hidden"],Rp={class:"btn-group",role:"group","aria-label":"场所显示方式"},Lp=["aria-pressed"],Pp=["aria-pressed"],$p=["aria-expanded"],Bp={id:"home-layout-options",class:"home-layout-controls"},zp=["disabled"],_p=["value"],jp=["disabled"],Fp=["value"],Vp={class:"inline-check"},Hp=["disabled"],qp={class:"inline-check"},Wp=["disabled"],Up=["disabled"],Kp=["disabled"],Jp={id:"home-layout-status",role:"status",class:"small text-secondary"},Gp={key:0,class:"group-title"},Yp={class:"home-card-grid"},Xp=["draggable","onDragstart","onDrop"],Zp={class:"home-cover"},Qp=["src","alt"],ef={class:"home-cover-content"},tf={class:"site-heading"},nf={class:"badge"},sf=["data-edit-household"],rf={class:"home-location"},of={class:"card-body"},lf={key:0,class:"home-order-actions"},af=["disabled","aria-label","onClick"],cf=["disabled","aria-label","onClick"],df={class:"home-summary"},uf={class:"home-numbers"},pf={class:"compact-details"},ff={class:"home-card-actions"},hf=["onClick"],mf=["data-leadership"],gf={key:0,class:"empty"},bf={id:"home-global-topology",class:"network-overview"},yf={class:"network-platform"},vf={key:0,class:"chart-network-surface mb-3"},kf={class:"platform-place-grid"},xf=["onClick"],wf={class:"badge"},Sf={class:"home-pagination"},Cf={id:"home-page-info"},Mf=["disabled"],Tf=["disabled"],Ef={__name:"HomeExplorer",setup(n){const e=q({revision:0,columns:2,rows:2,groupCity:!1,order:[]}),t=q(!1),s=q(!1),i=q(0),r=q(!1),o=q("cards"),l=q(!1),a=q(""),d=q("");let u="";Qe(B,I=>{var v;const x=((v=I.user)==null?void 0:v.id)+":"+I.session;u!==x&&(u=x,t.value=!1,s.value=!1,i.value=0,r.value=!1,o.value="cards",l.value=!1,a.value="",d.value=""),!t.value&&!s.value&&(e.value={revision:0,columns:2,rows:2,groupCity:!1,order:[],...I.state.householdLayout})},{immediate:!0});const p=Q(()=>{const I=B.value.state.households||[],x=new Map(I.map(v=>[v.id,v]));return[...new Set([...e.value.order,...I.map(v=>v.id)])].filter(v=>x.has(v)).map(v=>x.get(v))}),f=Q(()=>e.value.columns*e.value.rows),h=Q(()=>Math.max(1,Math.ceil(p.value.length/f.value)));Qe(h,I=>i.value=Math.min(i.value,I-1));const m=Q(()=>{var v;const I=p.value.slice(i.value*f.value,(i.value+1)*f.value);if(!e.value.groupCity)return[{name:"",items:I}];const x=new Map;for(const w of I){const D=[((v=w.geography)==null?void 0:v.country)||w.country,w.province,w.city||"地区待填写"].filter(Boolean).join(" / ");x.has(D)||x.set(D,[]),x.get(D).push(w)}return[...x].map(([w,D])=>({name:w,items:D}))}),g=I=>({home:"家庭",office:"办公场所",factory:"工厂"})[I.kind||"home"]||"场所",b=I=>{var x,v;return((v=(x=te()).address)==null?void 0:v.call(x,I))||[I.province,I.city,I.district].filter(Boolean).join(" · ")||"地区待填写"};function y(){t.value=!0,i.value=0,e.value.groupCity&&(r.value=!1),d.value="布局已调整,保存后下次登录会沿用。"}function T(I,x,v){if(s.value)return;const w=p.value.map(Z=>Z.id),D=w.indexOf(I),L=v?w.indexOf(v):D+x;D<0||L<0||L>=w.length||D===L||(w.splice(D,1),w.splice(L,0,I),e.value.order=w,t.value=!0,i.value=Math.floor(L/f.value))}function A(){t.value=!1,e.value={...B.value.state.householdLayout},i.value=0,d.value=""}async function E(){const I=u;s.value=!0;try{const x=await te().saveLayout({...e.value});if(I!==u)return;e.value=x,t.value=!1,d.value="布局与卡片顺序已保存"}catch(x){!x.stale&&I===u&&(d.value=x.message)}finally{I===u&&(s.value=!1)}}async function O(I,x=!1){await te().enterHome(I.id,x)}return(I,x)=>(C(),M("section",Op,[c("div",Np,[c("div",null,[c("h2",null,[x[12]||(x[12]=S(" 我的空间 ",-1)),c("span",Ip,k(p.value.length),1)]),x[13]||(x[13]=c("p",{class:"description mb-0"}," 家庭、办公与工厂,各自管理成员、区域和设备。 ",-1))]),c("button",{id:"new-household",class:"btn btn-primary",hidden:!j(B).platformAdmin}," + 新建家庭或场所 ",8,Dp)]),K(Ap),c("div",{class:_e(["home-toolbar",{"home-options-open":l.value}])},[c("div",Rp,[c("button",{id:"home-card-view",class:_e(["btn btn-outline-secondary",{active:o.value==="cards"}]),"aria-pressed":o.value==="cards",onClick:x[0]||(x[0]=v=>o.value="cards")},[K(we,{name:"grid"}),x[14]||(x[14]=S(" 卡片",-1))],10,Lp),c("button",{id:"home-topology-view",class:_e(["btn btn-outline-secondary",{active:o.value==="topology"}]),"aria-pressed":o.value==="topology",onClick:x[1]||(x[1]=v=>o.value="topology")},[K(we,{name:"network"}),x[15]||(x[15]=S(" 整体拓扑 ",-1))],10,Pp)]),he(c("button",{class:"btn btn-outline-secondary home-layout-toggle","aria-expanded":l.value,"aria-controls":"home-layout-options",onClick:x[2]||(x[2]=v=>l.value=!l.value)},k(l.value?"收起设置":"布局设置"),9,$p),[[En,o.value==="cards"]]),he(c("div",Bp,[c("label",null,[x[16]||(x[16]=S("每页 ",-1)),he(c("select",{id:"home-columns","onUpdate:modelValue":x[3]||(x[3]=v=>e.value.columns=v),class:"form-select",disabled:s.value,onChange:y},[(C(),M(J,null,ie(4,v=>c("option",{key:v,value:v},k(v)+" 列",9,_p)),64))],40,zp),[[qt,e.value.columns,void 0,{number:!0}]])]),x[19]||(x[19]=c("span",null,"×",-1)),he(c("select",{id:"home-rows","onUpdate:modelValue":x[4]||(x[4]=v=>e.value.rows=v),"aria-label":"每页行数",class:"form-select",disabled:s.value,onChange:y},[(C(),M(J,null,ie(4,v=>c("option",{key:v,value:v},k(v)+" 行",9,Fp)),64))],40,jp),[[qt,e.value.rows,void 0,{number:!0}]]),c("label",Vp,[he(c("input",{id:"home-group-city","onUpdate:modelValue":x[5]||(x[5]=v=>e.value.groupCity=v),type:"checkbox",class:"form-check-input",disabled:s.value,onChange:y},null,40,Hp),[[Fs,e.value.groupCity]]),x[17]||(x[17]=S("按城市分组",-1))]),c("label",qp,[he(c("input",{id:"home-arrange","onUpdate:modelValue":x[6]||(x[6]=v=>r.value=v),type:"checkbox",class:"form-check-input",disabled:e.value.groupCity||s.value},null,8,Wp),[[Fs,r.value]]),x[18]||(x[18]=S("调整顺序",-1))]),c("button",{id:"home-layout-save",class:"btn btn-primary",disabled:!t.value||s.value,onClick:E},k(s.value?"保存中…":"保存布局"),9,Up),c("button",{id:"home-layout-reset",class:"btn btn-outline-secondary",disabled:!t.value||s.value,onClick:A}," 撤销 ",8,Kp)],512),[[En,o.value==="cards"]])],2),c("p",Jp,k(d.value||"布局仅影响你的账号;手机端自动适配为单列。"),1),he(c("div",{id:"household-list",style:Cn({"--home-columns":e.value.columns})},[(C(!0),M(J,null,ie(m.value,v=>(C(),M("section",{key:v.name,class:"home-city-group"},[v.name?(C(),M("h3",Gp,k(v.name),1)):$("",!0),c("div",Yp,[(C(!0),M(J,null,ie(v.items,w=>{var D,L;return C(),M("article",{key:w.id,class:"card home-card",draggable:r.value&&!s.value,onDragstart:Z=>{a.value=w.id,Z.dataTransfer.setData("text/plain",w.id)},onDragend:x[7]||(x[7]=Z=>a.value=""),onDragover:x[8]||(x[8]=Z=>r.value&&a.value&&Z.preventDefault()),onDrop:bt(Z=>{r.value&&a.value&&T(a.value,0,w.id),a.value=""},["prevent"])},[c("div",Zp,[w.coverUrl?(C(),M("img",{key:0,src:w.coverUrl,alt:w.name+"封面",loading:"lazy"},null,8,Qp)):$("",!0),x[20]||(x[20]=c("div",{class:"cover-shade"},null,-1)),c("div",ef,[c("div",tf,[c("span",nf,[S(k(g(w)),1),w.id===j(B).state.familyId?(C(),M(J,{key:0},[S(" · 当前")],64)):$("",!0)]),j(B).admin?(C(),M("button",{key:0,class:"btn btn-sm cover-edit","data-edit-household":w.id}," 编辑 ",8,sf)):$("",!0)]),c("div",null,[c("h3",null,k(w.name),1),c("p",rf,k(b(w)),1)])])]),c("div",of,[r.value?(C(),M("div",lf,[x[21]||(x[21]=c("span",null,"拖动排序",-1)),c("button",{class:"btn btn-sm btn-outline-secondary",disabled:((D=p.value[0])==null?void 0:D.id)===w.id||s.value,"aria-label":w.name+"前移",onClick:Z=>T(w.id,-1)}," ←",8,af),c("button",{class:"btn btn-sm btn-outline-secondary",disabled:((L=p.value.at(-1))==null?void 0:L.id)===w.id||s.value,"aria-label":w.name+"后移",onClick:Z=>T(w.id,1)}," → ",8,cf)])):$("",!0),c("p",df,k(w.note||"成员、空间与设备,独立管理。"),1),c("div",uf,[c("span",null,[c("b",null,k(w.deviceCount||0),1),x[22]||(x[22]=S("设备",-1))]),c("span",null,[c("b",null,k(w.sites||0),1),x[23]||(x[23]=S("区域",-1))]),c("span",null,[c("b",null,k(w.members||0),1),x[24]||(x[24]=S("成员",-1))])]),c("dl",pf,[c("div",null,[c("dt",null,k(w.kind==="office"||w.kind==="factory"?"主要负责人":"一家之主"),1),c("dd",null,k(w.ownerName||"待指定"),1)]),c("div",null,[x[25]||(x[25]=c("dt",null,"备用负责人",-1)),c("dd",null,k(w.successorName||"待指定"),1)])]),c("div",ff,[c("button",{class:"btn btn-primary",onClick:Z=>O(w)},[x[26]||(x[26]=S(" 进入空间 ",-1)),K(we,{name:"arrow"})],8,hf),w.canAssignOwner?(C(),M("button",{key:0,class:"btn btn-link","data-leadership":w.id}," 负责人安排 ",8,mf)):$("",!0)])])],40,Xp)}),128))])]))),128)),p.value.length?$("",!0):(C(),M("div",gf," 登录后查看已授权的家庭与场所。 "))],4),[[En,o.value==="cards"]]),he(c("div",bf,[c("div",yf,[K(we,{name:"network"}),c("div",null,[c("h3",null,k(j(B).brandName||"赵府")+" · 数字管家",1),c("p",null,k(p.value.length)+" 个已授权空间",1)])]),x[28]||(x[28]=c("p",{class:"description"}," 平台与场所的管理关系;进入场所查看内部设备及网络。 ",-1)),p.value.length?(C(),M("div",vf,[K(Yt,{option:j(rp)(p.value,j(B).brandName||"赵府"),active:j(B).loggedIn&&j(B).page==="households"&&o.value==="topology",height:340,label:"平台及已授权场所关系图;点击场所进入内部网络,下面也可通过卡片进入。",onSelect:x[9]||(x[9]=v=>O({id:v},!0))},null,8,["option","active"])])):$("",!0),c("div",kf,[(C(!0),M(J,null,ie(p.value,v=>(C(),M("button",{key:v.id,class:"card platform-place-node",onClick:w=>O(v,!0)},[c("span",wf,k(g(v)),1),c("h3",null,k(v.name),1),c("p",null,k(b(v)),1),c("span",null,k(v.deviceCount||0)+" 台设备",1),c("small",null,k((v.networkAccesses||[]).map(j(Xr)).join(" · ")||"网络待登记"),1),x[27]||(x[27]=c("span",{class:"network-open"},"查看网络拓扑 →",-1))],8,xf))),128))])],512),[[En,o.value==="topology"]]),he(c("div",Sf,[c("span",Cf,"第 "+k(i.value+1)+" / "+k(h.value)+" 页 · 每页最多 "+k(f.value)+" 张",1),c("button",{id:"home-prev",class:"btn btn-outline-secondary",disabled:!i.value,onClick:x[10]||(x[10]=v=>i.value--)}," 上一页",8,Mf),c("button",{id:"home-next",class:"btn btn-outline-secondary",disabled:i.value>=h.value-1,onClick:x[11]||(x[11]=v=>i.value++)}," 下一页 ",8,Tf)],512),[[En,o.value==="cards"]])]))}},Af={key:0,class:"network-status-block"},Of={class:"network-status-title"},Nf=["disabled"],If={key:0,class:"text-danger small",role:"status"},Df={key:0,class:"small text-secondary"},Rf={key:1,class:"small text-secondary"},Lf={key:2,class:"small text-secondary"},Pf={class:"management-links"},$f=["href"],Bf={key:0},zf={class:"network-check-time"},Zr={__name:"NetworkStatus",props:{device:{type:Object,required:!0},active:{type:Boolean,default:!0}},setup(n){const e=n,t=q(null),s=q(!1),i=q("");let r=0,o;const l=Q(()=>[e.device.id,e.device.source,e.device.managementHost,e.device.tailscaleHost,e.device.networkCidr,B.value.state.familyId,B.value.session,B.value.admin,e.active].join("|"));async function a(){const p=r;if(!(s.value||!B.value.admin||!e.active)){s.value=!0,i.value="";try{const f=await te().api("/api/devices/network?source="+encodeURIComponent(e.device.source)+"&id="+encodeURIComponent(e.device.id));p===r&&(t.value=f)}catch(f){p===r&&!f.stale&&(i.value=f.message)}finally{p===r&&(s.value=!1,o=setTimeout(a,35e3))}}}Qe(l,()=>{r++,clearTimeout(o),s.value=!1,t.value=null,i.value="",B.value.admin&&e.active&&a()},{immediate:!0}),Aa(()=>{r++,clearTimeout(o)});const d=Q(()=>t.value?t.value.targets.some(p=>p.reachable)?"网络可达":"未连通":"等待检查");function u(){clearTimeout(o),a()}return(p,f)=>{var h,m;return j(B).admin?(C(),M("div",Af,[c("div",Of,[c("span",null,[c("i",{class:_e(["status-dot",{online:(h=t.value)==null?void 0:h.targets.some(g=>g.reachable)}])},null,2),S(k(s.value?"正在检查…":d.value),1)]),c("button",{class:"btn btn-sm btn-link",disabled:s.value,onClick:u},"检查网络",8,Nf)]),i.value?(C(),M("p",If,k(i.value),1)):$("",!0),t.value?(C(),M(J,{key:1},[(C(!0),M(J,null,ie(t.value.targets,g=>(C(),M("div",{key:g.kind,class:"network-target"},[c("span",null,k(g.kind==="tailscale"?"Tailscale":"设备地址"),1),c("code",null,k(g.host),1),c("span",{class:_e(g.reachable?"text-success":"text-secondary")},k(g.reachable?"服务可达":"未响应"),3)]))),128)),t.value.targets.length?$("",!0):(C(),M("p",Df,"请编辑设备档案,填写 IP 或域名。")),(m=t.value.tailscale)!=null&&m.available?(C(),M("p",Rf,[S("Tailscale 节点"+k(t.value.tailscale.online?"在线":"离线"),1),t.value.tailscale.subnet?(C(),M(J,{key:0},[S(" · "+k(t.value.tailscale.subnetAvailable?"已发布":"未检测到")+" "+k(t.value.tailscale.subnet)+" 路由",1)],64)):$("",!0)])):t.value.tailscale?(C(),M("p",Lf,k(t.value.tailscale.note),1)):$("",!0),c("div",Pf,[(C(!0),M(J,null,ie(t.value.links,g=>(C(),M("a",{key:g.kind,href:g.url,target:"_blank",rel:"noopener noreferrer",class:"btn btn-sm btn-outline-secondary"},[S("打开管理后台 · "+k(g.kind==="tailscale"?"Tailscale":"局域网")+" ↗",1),g.verified?$("",!0):(C(),M("span",Bf,"(待连通)"))],8,$f))),128))]),c("small",zf,"检查于 "+k(new Date(t.value.checkedAt*1e3).toLocaleTimeString("zh-CN"))+" · 从服务器探测,打开后台需当前浏览器也能到达。",1)],64)):$("",!0)])):$("",!0)}}},_f={key:0,class:"display-manager mt-3"},jf={key:0,class:"border rounded-3 p-3 mt-3"},Ff={class:"d-flex justify-content-between align-items-center gap-2 mb-3"},Vf={class:"small text-secondary"},Hf={class:"row g-2 hardware-grid"},qf={class:"col-6"},Wf={class:"col-6"},Uf={class:"col-6"},Kf={class:"col-6"},Jf={class:"small text-secondary mt-3"},Gf={key:0},Yf={key:0,class:"small text-secondary"},Xf={class:"small mb-3"},Zf=["disabled"],Qf={key:1,class:"tv-remote-preview"},eh=["src"],th={class:"small text-secondary"},nh={class:"mt-3"},sh={class:"row g-2 my-2"},ih={class:"col-12"},rh={class:"col-6"},oh={class:"col-6"},lh=["disabled"],ah={key:0,class:"my-3"},ch=["value"],dh=["href"],uh=["disabled","onClick"],ph={key:2,class:"alert alert-success mt-3"},fh={class:"fs-3 font-monospace"},hh={key:3,class:"text-danger mt-2",role:"alert"},mh={__name:"DisplayManager",props:{device:Object},setup(n){const e=n,t=q(!1),s=q(null),i=q([]),r=q(""),o=q(!1),l=q(""),a=q(""),d=q(0);let u,p=0,f="";const h=Q(()=>{var v;return(v=B.value.state.households)==null?void 0:v.find(w=>w.id===B.value.state.familyId)}),m=q(""),g=q(""),b=q(""),y=q(""),T=v=>v+"?deviceId="+encodeURIComponent(e.device.id),A=Q(()=>{var v;return((v=s.value)==null?void 0:v.hardware)||{}}),E=(v,w=1)=>typeof v=="number"?v.toFixed(w):"未提供",O=v=>v?new Date(v*1e3).toLocaleString("zh-CN"):"尚未上报";async function I(){const v=p;if(t.value)try{const w=await te().api(T("/api/displays/hardware"));if(v!==p)return;if(s.value=w,Date.now(){var w;if(p++,clearTimeout(u),l.value="",y.value="",r.value="",a.value="",d.value=0,f&&(URL.revokeObjectURL(f),f=""),v){const D=p;m.value=((w=h.value)==null?void 0:w.city)||"",g.value=m.value==="济南市"?"36.67":"",b.value=m.value==="济南市"?"116.99":"",I();try{const L=await te().api(T("/api/displays"));D===p&&(i.value=L.items)}catch(L){D===p&&(r.value=L.message)}}}),Qe(()=>[B.value.state.familyId,B.value.session,B.value.page,e.device.id].join("|"),()=>t.value=!1),Aa(()=>{p++,clearTimeout(u),f&&URL.revokeObjectURL(f)}),(v,w)=>{var D,L,Z,Re,ce,ue,de,Ge,ht,mt,_,ys,vs,$t;return j(B).admin?(C(),M("div",_f,[c("button",{class:"btn btn-outline-primary btn-sm",onClick:w[0]||(w[0]=G=>t.value=!t.value)},k(t.value?"收起电视管理":"电视管理 · 状态与模拟屏"),1),t.value?(C(),M("section",jf,[c("div",Ff,[c("strong",null,k(n.device.name),1),c("span",{class:_e(["badge",(D=s.value)!=null&&D.online?"text-bg-success":"text-bg-secondary"])},k((L=s.value)!=null&&L.online?"在线 · 心跳正常":(Z=s.value)!=null&&Z.paired?"未收到心跳":"尚未绑定"),3)]),c("p",Vf,"所属:"+k((Re=h.value)==null?void 0:Re.name)+" · 最后心跳 "+k(O((ce=s.value)==null?void 0:ce.lastSeen)),1),c("div",Hf,[c("div",qf,[w[7]||(w[7]=c("span",null,"处理器温度",-1)),c("strong",null,k(E(A.value.temperatureC))+k(A.value.temperatureC!=null?" °C":""),1),c("small",null,k(A.value.temperatureSource||"等待传感器上报"),1)]),c("div",Wf,[w[8]||(w[8]=c("span",null,"整机功率",-1)),c("strong",null,k(E(A.value.powerW))+k(A.value.powerW!=null?" W":""),1),c("small",null,k(A.value.powerSource||"需设备传感器或计量插座"),1)]),c("div",Uf,[w[9]||(w[9]=c("span",null,"可用内存",-1)),c("strong",null,k(E(A.value.memoryAvailableMB,0))+" / "+k(E(A.value.memoryTotalMB,0))+" MB",1)]),c("div",Kf,[w[10]||(w[10]=c("span",null,"可用存储",-1)),c("strong",null,k(E(A.value.storageAvailableGB))+" / "+k(E(A.value.storageTotalGB))+" GB",1)])]),c("p",Jf,[S(k(A.value.model||n.device.model)+" · Android "+k(A.value.osVersion||"—")+" · IP "+k(A.value.ip||n.device.managementHost||"—"),1),w[11]||(w[11]=c("br",null,null,-1)),S(k(A.value.screenWidth||"—")+" × "+k(A.value.screenHeight||"—")+" · "+k(A.value.foreground?"看板在前台":"看板未在前台")+" · "+k(A.value.screenOn?"屏幕亮":"屏幕状态待确认"),1),(ue=s.value)!=null&&ue.online?$("",!0):(C(),M("span",Gf," · 当前数值为最后一次上报"))]),w[22]||(w[22]=c("h4",{class:"fs-6"},"异常与报警",-1)),(Ge=(de=s.value)==null?void 0:de.alerts)!=null&&Ge.some(G=>!G.cleared)?$("",!0):(C(),M("p",Yf,k((ht=s.value)!=null&&ht.online?"当前无活动报警":"连接恢复后继续检查硬件状态"),1)),(C(!0),M(J,null,ie((_=(mt=s.value)==null?void 0:mt.alerts)==null?void 0:_.filter(G=>!G.cleared),G=>(C(),M("div",{key:G.code,class:_e(["alert py-2 small",G.severity==="critical"?"alert-danger":"alert-warning"])},k(G.message)+" · "+k(O(G.opened)),3))),128)),c("details",Xf,[w[12]||(w[12]=c("summary",null,"报警记录与规则",-1)),w[13]||(w[13]=c("p",null,"心跳中断超过 100 秒;处理器 ≥75°C 提醒、≥85°C 严重;可用内存低于 5%;可用存储低于 0.5 GB;看板退出前台。数值来自电视上报。",-1)),(C(!0),M(J,null,ie((ys=s.value)==null?void 0:ys.alerts,(G,Tn)=>(C(),M("div",{key:Tn},k(G.cleared?"已恢复":"处理中")+" · "+k(G.message)+" · "+k(O(G.opened)),1))),128))]),c("button",{class:"btn btn-primary btn-sm",disabled:o.value||!((vs=s.value)!=null&&vs.online),onClick:w[1]||(w[1]=G=>x("preview"))},"查看模拟屏 · 60 秒",8,Zf),w[23]||(w[23]=c("p",{class:"small text-secondary mt-2"},"显示电视当前家庭看板的应用画面,约 20 秒更新一次;退出看板后不显示其他应用。预览仅短时保存在内存。",-1)),a.value?(C(),M("figure",Qf,[c("img",{src:a.value,alt:"电视家庭看板的真实应用画面"},null,8,eh),c("figcaption",th,"画面时间:"+k(O(($t=s.value)==null?void 0:$t.previewAt)),1)])):$("",!0),c("details",nh,[w[18]||(w[18]=c("summary",null,"展示授权与天气设置",-1)),c("div",sh,[c("label",ih,[w[14]||(w[14]=S("天气城市",-1)),he(c("input",{"onUpdate:modelValue":w[2]||(w[2]=G=>m.value=G),class:"form-control",maxlength:"60"},null,512),[[Ji,m.value]])]),c("label",rh,[w[15]||(w[15]=S("纬度",-1)),he(c("input",{"onUpdate:modelValue":w[3]||(w[3]=G=>g.value=G),class:"form-control",type:"number",step:"0.0001",min:"-90",max:"90"},null,512),[[Ji,g.value]])]),c("label",oh,[w[16]||(w[16]=S("经度",-1)),he(c("input",{"onUpdate:modelValue":w[4]||(w[4]=G=>b.value=G),class:"form-control",type:"number",step:"0.0001",min:"-180",max:"180"},null,512),[[Ji,b.value]])])]),w[19]||(w[19]=c("p",{class:"small text-secondary"},"链接有效期一年,仅可展示本家庭概况、设备状态与本人同意共享的家人位置。重新生成会停用旧链接。",-1)),c("button",{class:"btn btn-outline-primary btn-sm",disabled:o.value,onClick:w[5]||(w[5]=G=>x("create"))},"生成 App 配对码",8,lh),l.value?(C(),M("div",ah,[c("label",null,[w[17]||(w[17]=S("本次展示链接(请仅交给这台电视)",-1)),c("input",{class:"form-control",value:l.value,readonly:"",onFocus:w[6]||(w[6]=G=>G.target.select())},null,40,ch)]),c("a",{class:"btn btn-sm btn-outline-secondary mt-2",href:l.value,target:"_blank",rel:"noreferrer"},"打开看板",8,dh)])):$("",!0),(C(!0),M(J,null,ie(i.value.filter(G=>!G.revoked),G=>(C(),M("div",{key:G.id,class:"d-flex gap-2 align-items-center small mt-2"},[c("span",null,"授权至 "+k(O(G.expires_at)),1),c("button",{class:"btn btn-sm btn-outline-danger",disabled:o.value,onClick:Tn=>x("revoke",G.id)},"停用展示权限",8,uh)]))),128))]),y.value&&l.value?(C(),M("div",ph,[w[20]||(w[20]=S("App 配对码:",-1)),c("strong",fh,k(y.value),1),w[21]||(w[21]=c("div",{class:"small"},"在“赵府家庭屏”App 输入,10 分钟内有效,使用一次即失效。App 摄像头画面在本地网络直接播放。",-1))])):$("",!0),r.value?(C(),M("p",hh,k(r.value),1)):$("",!0)])):$("",!0)])):$("",!0)}}},Da=us(mh,[["__scopeId","data-v-53ab224d"]]),gh={key:0,class:"mt-3"},bh={key:0,class:"border rounded p-3 mt-2"},yh={class:"w-100"},vh=["value"],kh={class:"d-flex gap-2 small mb-2"},xh=["disabled"],wh={key:1,class:"small mt-2",role:"status"},Ra={__name:"DeviceTransfer",props:{device:Object},setup(n){const e=n,t=q(!1),s=q(""),i=q(!1),r=q(!1),o=q(""),l=Q(()=>(B.value.state.households||[]).filter(d=>d.id!==B.value.state.familyId));Qe(()=>B.value.state.familyId,()=>{t.value=!1,s.value="",i.value=!1,o.value=""});async function a(){if(!(!i.value||!s.value)){r.value=!0,o.value="";try{await te().api("/api/devices/transfer",{source:e.device.source,id:e.device.id,targetFamilyId:s.value}),te().notify("设备已转移,电视需在新家庭重新授权。"),t.value=!1,await te().refresh()}catch(d){o.value=d.message}finally{r.value=!1}}}return(d,u)=>{var p;return((p=j(B).user)==null?void 0:p.role)==="admin"?(C(),M("div",gh,[c("button",{class:"btn btn-sm btn-outline-secondary",onClick:u[0]||(u[0]=f=>t.value=!t.value)},"转移到其他家庭"),t.value?(C(),M("div",bh,[c("label",yh,[u[4]||(u[4]=S("目标家庭 / 公司 / 工厂",-1)),he(c("select",{"onUpdate:modelValue":u[1]||(u[1]=f=>s.value=f),class:"form-select mt-2"},[u[3]||(u[3]=c("option",{value:""},"请选择",-1)),(C(!0),M(J,null,ie(l.value,f=>(C(),M("option",{key:f.id,value:f.id},k(f.name),9,vh))),128))],512),[[qt,s.value]])]),u[6]||(u[6]=c("p",{class:"small text-secondary mt-2"},"保留设备编号与基本档案。所属区域、负责人和上级设备需重新设置;电视旧展示授权会停用。关联录像机的摄像头需先解除关联。",-1)),c("label",kh,[he(c("input",{"onUpdate:modelValue":u[2]||(u[2]=f=>i.value=f),type:"checkbox"},null,512),[[Fs,i.value]]),u[5]||(u[5]=S("确认将这台设备转移给目标家庭管理",-1))]),c("button",{class:"btn btn-primary btn-sm",disabled:r.value||!i.value||!s.value,onClick:a},"确认转移",8,xh)])):$("",!0),o.value?(C(),M("p",wh,k(o.value),1)):$("",!0)])):$("",!0)}}},Sh={id:"asset-list"},Ch={class:"group-title"},Mh={class:"count-pill"},Th={class:"device-card-grid"},Eh={class:"card-body"},Ah={class:"device-card-heading"},Oh={class:"device-symbol"},Nh={class:"flex-grow-1"},Ih={class:"small text-secondary"},Dh=["onClick"],Rh={class:"device-location"},Lh={class:"compact-details"},Ph={class:"font-monospace"},$h={key:0},Bh={key:0,class:"device-tags"},zh={class:"card-footer device-card-actions"},_h=["onClick"],jh=["onClick"],Fh=["onClick"],Vh={key:0,class:"empty"},Hh={__name:"DeviceCollection",setup(n){const e=i=>(B.value.state.cameras||[]).filter(r=>i.source==="camera"?r.assetId===i.id:r.recorderId===i.id||r.archiveRecorderId===i.id),t=i=>({["data-"+(i.source==="camera"?"edit-asset":i.source==="recorder"?"edit-recorder":"edit-device")]:i.id}),s=i=>/路由|网关|服务器/.test(i.deviceType)||/gl\.inet/i.test(i.brand||"");return(i,r)=>(C(),M("div",Sh,[(C(!0),M(J,null,ie(j(Pe).groups,o=>(C(),M("section",{key:o.key,class:"device-group"},[c("h3",Ch,[S(k(o.labels.join(" / ")||"全部设备")+" ",1),c("span",Mh,k(o.items.length),1)]),c("div",Th,[(C(!0),M(J,null,ie(o.items,l=>{var a,d,u;return C(),M("article",{key:l.source+l.id,class:"card device-card"},[c("div",Eh,[c("div",Ah,[c("div",Oh,[K(we,{name:l.source==="camera"?"camera":s(l)?"router":"devices"},null,8,["name"])]),c("div",Nh,[c("span",Ih,k(l.deviceType),1),c("h3",null,[c("button",{class:"device-title",onClick:p=>j(te)().enterDevice(l.source,l.id)},k(l.name),9,Dh)])]),j(B).admin?(C(),M("button",Nu({key:0,class:"btn btn-sm btn-outline-secondary"},{ref_for:!0},t(l))," 编辑 ",16)):$("",!0)]),c("p",Rh,[S(k(((d=(a=j(te)()).location)==null?void 0:d.call(a,l.siteId))||"区域待填写"),1),l.point?(C(),M(J,{key:0},[S(" · "+k(l.point),1)],64)):$("",!0)]),c("dl",Lh,[c("div",null,[r[0]||(r[0]=c("dt",null,"品牌型号",-1)),c("dd",null,k([l.brand,l.model].filter(Boolean).join(" / ")||"未填写"),1)]),c("div",null,[r[1]||(r[1]=c("dt",null,"设备地址",-1)),c("dd",Ph,k(l.networkHosts.join(" / ")||"未填写"),1)]),c("div",null,[r[2]||(r[2]=c("dt",null,"网络",-1)),c("dd",null,k(j(Xr)(l.networkAccess)),1)]),c("div",null,[r[3]||(r[3]=c("dt",null,"所有人 / 负责人",-1)),c("dd",null,k(l.ownerName||"待指定")+" / "+k(l.managerName||"待指定"),1)]),l.source!=="device"?(C(),M("div",$h,[r[4]||(r[4]=c("dt",null,"镜头通道",-1)),c("dd",null,k(e(l).length)+" 个已配置",1)])):$("",!0)]),(u=l.tags)!=null&&u.length?(C(),M("div",Bh,[(C(!0),M(J,null,ie(l.tags,p=>(C(),M("span",{key:p},k(p),1))),128))])):$("",!0),s(l)?(C(),It(Zr,{key:1,device:l,active:j(B).page==="objects"&&j(Pe).mode==="cards"},null,8,["device","active"])):$("",!0),l.source==="device"&&/电视|显示|大屏/.test(l.deviceType)?(C(),It(Da,{key:2,device:l},null,8,["device"])):$("",!0),K(Ra,{device:l},null,8,["device"])]),c("div",zh,[c("button",{class:"btn btn-sm btn-outline-secondary",onClick:p=>j(te)().enterDevice(l.source,l.id,"device")}," 设备详情",8,_h),l.source!=="device"?(C(),M(J,{key:0},[j(B).admin?(C(),M("button",{key:0,class:"btn btn-sm btn-outline-secondary",onClick:p=>j(te)().enterDevice(l.source,l.id,"cameras")}," 配置镜头",8,jh)):$("",!0),e(l).length?(C(),M("button",{key:1,class:"btn btn-sm btn-primary",onClick:p=>j(te)().enterDevice(l.source,l.id,"live")}," 实时画面 ",8,Fh)):$("",!0)],64)):$("",!0)])])}),128))])]))),128)),j(Pe).devices.length?$("",!0):(C(),M("div",Vh,[K(we,{name:"devices"}),r[5]||(r[5]=c("h3",null,"当前范围没有设备",-1)),r[6]||(r[6]=c("p",null,"调整筛选条件,或添加摄像机、路由器、灯等设备。",-1))]))]))}},qh={key:0,class:"network-diagram"},Wh={class:"diagram-toolbar"},Uh={class:"small text-secondary"},Kh={class:"chart-network-surface"},Jh={__name:"NetworkDiagram",setup(n){const e=q(0),t=Q(()=>ip(Pe.value.rows,te().location)),s=Q(()=>B.value.loggedIn&&B.value.page==="objects"&&Pe.value.mode==="topology");Qe(()=>B.value.session+":"+B.value.state.familyId,()=>e.value++);function i(r){const o=Pe.value.rows.find(l=>l.device.id===r);o&&te().enterDevice(o.device.source,r,"device")}return(r,o)=>j(Pe).rows.length?(C(),M("div",qh,[c("div",Wh,[c("div",null,[o[1]||(o[1]=c("span",{class:"diagram-dot"},null,-1)),o[2]||(o[2]=c("strong",null,"设备连接图",-1)),c("span",Uh,k(j(Pe).rows.length)+" 台设备 · "+k(t.value.series[0].links.length)+" 条已登记连接",1)]),c("button",{class:"btn btn-sm btn-outline-secondary",onClick:o[0]||(o[0]=l=>e.value++)},"重置视图")]),c("div",Kh,[(C(),It(Yt,{key:e.value,option:t.value,active:s.value,height:400,label:"已登记设备连接图,可拖动缩放;下方设备详情提供相同信息及操作。",onSelect:i},null,8,["option","active"]))]),o[3]||(o[3]=c("p",{class:"diagram-note"},"拖动平移、滚轮或双指缩放;点击节点打开档案。未登记上级的设备独立显示;接入方式不代表在线状态。",-1))])):$("",!0)}},Gh={id:"device-topology",hidden:""},Yh={class:"panel network-map"},Xh={class:"network-platform"},Zh={class:"topology-nodes"},Qh={class:"card-body"},em={class:"device-card-heading"},tm={class:"flex-grow-1"},nm={class:"small text-secondary"},sm=["onClick"],im=["onClick"],rm={class:"device-location"},om={class:"network-facts"},lm={key:0},am={key:1},cm={key:2},dm={key:3},um={key:0,class:"empty"},pm={__name:"NetworkMap",setup(n){const e=Q(()=>(B.value.state.households||[]).find(t=>t.id===B.value.state.familyId));return(t,s)=>{var i;return C(),M("div",Gh,[c("section",Yh,[c("div",Xh,[K(we,{name:"network"}),c("div",null,[c("h3",null,k(((i=e.value)==null?void 0:i.name)||"当前场所"),1),c("p",null,k(j(Pe).devices.length)+" 台设备 · 随设备档案自动更新",1)])]),s[7]||(s[7]=c("p",{class:"description"}," 连线来自已确认的上级设备关系。上级未填写时单独列出;不代表已自动发现所有交换机或布线。 ",-1)),K(Jh),s[8]||(s[8]=c("h3",{class:"network-details-heading"},"设备与连接详情",-1)),c("div",Zh,[(C(!0),M(J,null,ie(j(Pe).rows,r=>{var o,l;return C(),M("article",{key:r.device.id,class:_e(["network-node card",{nested:r.depth>0}]),style:Cn({"--depth":Math.min(r.depth,5)})},[c("div",Qh,[c("div",em,[K(we,{name:r.device.source==="camera"?"camera":"router"},null,8,["name"]),c("div",tm,[c("span",nm,k(r.device.deviceType)+" · "+k(j(Xr)(r.device.networkAccess)),1),c("h3",null,[c("button",{class:"device-title",onClick:a=>j(te)().enterDevice(r.device.source,r.device.id)},k(r.device.name),9,sm)])]),c("button",{class:"btn btn-sm btn-outline-secondary",onClick:a=>j(te)().enterDevice(r.device.source,r.device.id,"device")}," 详情 → ",8,im)]),c("p",rm,[S(k(((l=(o=j(te)()).location)==null?void 0:l.call(o,r.device.siteId))||"未指定区域")+" ",1),r.device.point?(C(),M(J,{key:0},[S(" · "+k(r.device.point),1)],64)):$("",!0)]),c("div",om,[c("span",null,[s[0]||(s[0]=S("IP ",-1)),c("b",null,k(r.device.networkHosts.join(" / ")||"待填写"),1)]),r.device.tailscaleHost?(C(),M("span",lm,[s[1]||(s[1]=S("Tailscale ",-1)),c("b",null,k(r.device.tailscaleHost),1)])):$("",!0),r.device.networkCidr?(C(),M("span",am,[s[2]||(s[2]=S("网段 ",-1)),c("b",null,k(r.device.networkCidr),1)])):$("",!0),c("span",null,[s[3]||(s[3]=S("上级 ",-1)),c("b",null,k(r.parentName||"待确认 / 直接接入"),1)]),c("span",null,[s[4]||(s[4]=S("连接 ",-1)),c("b",null,k({wired:"网线",wifi:"Wi-Fi"}[r.device.connectionType]||"待确认"),1)]),r.via.length?(C(),M("span",cm,[s[5]||(s[5]=S("取流经录像机 ",-1)),c("b",null,k(r.via.join("、")),1)])):$("",!0),r.archiveVia.length?(C(),M("span",dm,[s[6]||(s[6]=S("录像归档 ",-1)),c("b",null,k(r.archiveVia.join("、")),1)])):$("",!0)]),/路由|网关|服务器/.test(r.device.deviceType)?(C(),It(Zr,{key:0,device:r.device,active:j(B).page==="objects"&&j(Pe).mode==="topology"},null,8,["device","active"])):$("",!0)])],6)}),128)),j(Pe).rows.length?$("",!0):(C(),M("p",um," 当前范围尚未登记设备。 "))])])])}}},fm={key:0,class:"panel"},hm={__name:"DeviceNetworkPanel",setup(n){return(e,t)=>j(B).admin&&j(B).device&&j(B).page==="device"?(C(),M("section",fm,[t[0]||(t[0]=c("h3",null,"网络状态与管理入口",-1)),j(B).device.source==="device"&&/电视|显示|大屏/.test(j(B).device.deviceType)?(C(),It(Da,{key:0,device:j(B).device},null,8,["device"])):(C(),It(Zr,{key:1,device:j(B).device},null,8,["device"])),K(Ra,{device:j(B).device},null,8,["device"])])):$("",!0)}},mm={key:0,class:"row g-3 mb-4","aria-label":"当前场所设备统计"},gm={class:"col-12 col-lg-7"},bm={class:"chart-card h-100"},ym={class:"chart-heading"},vm={class:"small text-secondary"},km={class:"chart-data"},xm={class:"col-12 col-lg-5"},wm={class:"chart-card h-100"},Sm={class:"chart-legend"},Cm={__name:"ScopeInsights",setup(n){const e=Q(()=>sp(B.value.state)),t=Q(()=>B.value.loggedIn&&B.value.page==="overview");return(s,i)=>t.value&&e.value.total?(C(),M("section",mm,[c("div",gm,[c("article",bm,[c("div",ym,[i[0]||(i[0]=c("h3",null,"设备类型",-1)),c("span",vm,k(e.value.total)+" 台已授权设备",1)]),K(Yt,{option:j(Na)(e.value.types.slice(0,8)),height:220,label:"设备类型:"+e.value.types.map(r=>r.label+r.count+"台").join(",")},null,8,["option","label"]),c("details",km,[i[1]||(i[1]=c("summary",null,"查看全部类型",-1)),c("ul",null,[(C(!0),M(J,null,ie(e.value.types,r=>(C(),M("li",{key:r.label},k(r.label)+":"+k(r.count)+" 台",1))),128))])])])]),c("div",xm,[c("article",wm,[i[2]||(i[2]=c("div",{class:"chart-heading"},[c("h3",null,"网络接入"),c("span",{class:"small text-secondary"},"来自设备档案")],-1)),K(Yt,{option:j(Oa)(e.value.networks),height:190,label:"登记的网络接入方式:"+e.value.networks.map(r=>r.label+r.count+"台").join(",")},null,8,["option","label"]),c("div",Sm,[(C(!0),M(J,null,ie(e.value.networks,(r,o)=>(C(),M("span",{key:r.label},[c("i",{style:Cn({background:j(Xn)[o]})},null,4),S(k(r.label)+" ",1),c("b",null,k(r.count),1)]))),128))]),i[3]||(i[3]=c("p",{class:"small text-secondary mt-2 mb-0"},"接入方式不代表设备在线状态。",-1))])])])):$("",!0)}},Mm={key:0,class:"panel family-locations mb-4","aria-label":"家庭位置共享"},Tm={class:"d-flex flex-wrap justify-content-between gap-2"},Em={class:"text-secondary small"},Am={key:0,class:"alert alert-warning",role:"status"},Om={class:"row g-3"},Nm={class:"col-12 col-lg-8"},Im={class:"col-12 col-lg-4"},Dm={key:0,class:"location-empty"},Rm=["onClick"],Lm={key:0},Pm={class:"mt-3 border-top pt-3"},$m={key:0,class:"alert alert-info"},Bm={key:0},zm={class:"d-flex flex-wrap align-items-center gap-2"},_m=["disabled"],jm={class:"d-flex gap-2 my-3"},Fm=["disabled"],Vm={key:1,class:"alert alert-success mt-3"},Hm={class:"font-monospace fs-3"},qm={key:1,class:"text-danger mt-2",role:"alert"},Wm={__name:"FamilyLocations",setup(n){const e=q(null),t=q(""),s=q(!1),i=q(7),r=q(""),o=q(0),l=q(!1),a=q(""),d=Q(()=>B.value.loggedIn&&B.value.page==="overview"),u=Q(()=>{var E;return(E=B.value.state.households)==null?void 0:E.find(O=>O.id===B.value.state.familyId)});let p,f=0;const h=Q(()=>{var E;return((E=e.value)==null?void 0:E.items)||[]}),m=E=>E?new Date(E*1e3).toLocaleString("zh-CN"):"尚未收到",g=E=>E.status==="stale"?"位置更新中断":E.status==="live"?"位置已更新":"等待手机定位",b=E=>E.position?`${E.position.latitude.toFixed(4)}°, ${E.position.longitude.toFixed(4)}° · 精度约 ${Math.round(E.position.accuracy)} 米`:"尚无有效位置",y=Q(()=>{var O;const E=(O=h.value.find(I=>I.id===a.value))==null?void 0:O.position;return{geo:{map:"world-land",roam:!0,center:E?[E.longitude,E.latitude]:[0,10],zoom:E?5:1,boundingCoords:[[-180,90],[180,-90]],itemStyle:{areaColor:"#d9e4df",borderColor:"#94b2a6"},emphasis:{disabled:!0},silent:!1},tooltip:{show:!1},series:[{type:"scatter",coordinateSystem:"geo",symbolSize:14,label:{show:!0,position:"top",formatter:"{b}"},data:h.value.filter(I=>I.position).map(I=>({name:I.name,targetId:I.id,value:[I.position.longitude,I.position.latitude],itemStyle:{color:I.status==="stale"?"#c18d3e":"#257a68"}}))}]}});async function T(){const E=f;if(d.value)try{const O=await te().api("/api/locations");E===f&&(e.value=O,t.value="")}catch(O){E===f&&(e.value=null,t.value=O.message)}finally{E===f&&d.value&&(p=setTimeout(T,3e4))}}async function A(E){if(l.value)return;l.value=!0,t.value="";const O=f;try{const I=await te().api("/api/locations",{action:E,consent:s.value,days:i.value});if(O!==f)return;r.value=I.code||"",o.value=I.expires||0,E==="stop"&&(s.value=!1),clearTimeout(p),await T()}catch(I){O===f&&(t.value=I.message)}finally{O===f&&(l.value=!1)}}return Qe([d,()=>B.value.state.familyId,()=>B.value.session],()=>{f++,clearTimeout(p),e.value=null,r.value="",a.value="",s.value=!1,l.value=!1,d.value&&T()},{immediate:!0}),ds(()=>{f++,clearTimeout(p)}),(E,O)=>{var I,x,v,w,D;return d.value?(C(),M("section",Mm,[c("div",Tm,[c("div",null,[O[6]||(O[6]=c("h2",null,"家人位置",-1)),c("p",Em,k((I=u.value)==null?void 0:I.name)+" · "+k(h.value.length)+" 位家人正在共享 · 只显示本人同意分享的最新位置",1)]),c("button",{class:"btn btn-sm btn-outline-secondary align-self-start",onClick:O[0]||(O[0]=L=>a.value="")},"查看全球")]),h.value.some(L=>L.status==="stale")?(C(),M("div",Am,k(h.value.filter(L=>L.status==="stale").map(L=>L.name).join("、"))+"的位置超过 15 分钟未更新。请检查手机网络、定位权限或省电设置;这不代表人员失联。",1)):$("",!0),c("div",Om,[c("div",Nm,[K(Yt,{option:y.value,height:360,label:"家庭位置世界平面图,详细位置见右侧列表",onSelect:O[1]||(O[1]=L=>a.value=L)},null,8,["option"]),O[7]||(O[7]=c("p",{class:"small text-secondary mb-0"},"可拖动缩放,点击家人定位。底图:Natural Earth 陆地轮廓(本地资源);定位采用 WGS84 经纬度。",-1))]),c("div",Im,[h.value.length?$("",!0):(C(),M("div",Dm,[...O[8]||(O[8]=[c("span",null,"⌖",-1),c("h3",{class:"fs-5"},"等待家人主动分享",-1),c("p",null,"每位家人使用自己的账号开启,共享关闭时不会采集或展示位置。",-1)])])),(C(!0),M(J,null,ie(h.value,L=>{var Z;return C(),M("button",{key:L.id,class:_e(["location-person w-100 text-start",{"location-selected":a.value===L.id}]),onClick:Re=>a.value=L.id},[c("strong",null,k(L.name),1),c("span",{class:_e(L.status==="stale"?"text-warning-emphasis":"text-success")},k(g(L)),3),c("small",null,k(b(L)),1),c("small",null,"定位时间:"+k(m((Z=L.position)==null?void 0:Z.at)),1),L.signal==="permission_denied"||L.signal==="location_disabled"?(C(),M("small",Lm,"手机定位或权限未开启")):$("",!0)],10,Rm)}),128))])]),c("details",Pm,[O[14]||(O[14]=c("summary",null,"我的位置共享",-1)),O[15]||(O[15]=c("p",{class:"small text-secondary mt-2"},"手机安装配套 App,打开“赵府位置共享”。平台生成配对码后,还需本人在手机上同意并授予定位权限。约每 5 分钟更新,当前家庭成员和已授权家庭电视可见。仅在服务器内存保留最新点,停止后清除,不保存轨迹或写入数据库备份。",-1)),(x=e.value)!=null&&x.canShare?(C(),M(J,{key:1},[(v=e.value)!=null&&v.own?(C(),M("p",Bm,k(e.value.own.enabled?"已开启共享":"手机已绑定,等待本人开启")+" · 有效期至 "+k(m(e.value.own.expires)),1)):$("",!0),c("div",zm,[he(c("select",{"onUpdate:modelValue":O[2]||(O[2]=L=>i.value=L),class:"form-select w-auto","aria-label":"位置共享有效期"},[...O[9]||(O[9]=[c("option",{value:1},"1 天",-1),c("option",{value:7},"7 天",-1),c("option",{value:30},"30 天",-1)])],512),[[qt,i.value,void 0,{number:!0}]]),O[10]||(O[10]=c("a",{class:"btn btn-outline-secondary",href:"https://pro.ucvl.cn/admin/ucvl-home-vision/releases/tag/v0.1.44",target:"_blank",rel:"noreferrer"},"下载配套 App",-1)),(w=e.value)!=null&&w.own||r.value?(C(),M("button",{key:0,class:"btn btn-outline-danger",disabled:l.value,onClick:O[3]||(O[3]=L=>A("stop"))},"停止我的共享",8,_m)):$("",!0)]),c("label",jm,[he(c("input",{type:"checkbox","onUpdate:modelValue":O[4]||(O[4]=L=>s.value=L)},null,512),[[Fs,s.value]]),S("我同意向“"+k((D=u.value)==null?void 0:D.name)+"”的成员和家庭电视共享本人位置,并可随时停止。",1)]),c("button",{class:"btn btn-primary",disabled:l.value||!s.value,onClick:O[5]||(O[5]=L=>A("pair"))},"生成手机配对码",8,Fm),r.value?(C(),M("div",Vm,[O[11]||(O[11]=S("配对码 ",-1)),c("strong",Hm,k(r.value),1),O[12]||(O[12]=S(" · 10 分钟内使用一次",-1)),O[13]||(O[13]=c("br",null,null,-1)),S("共享有效期至 "+k(m(o.value))+",未在手机开启前不采集位置。",1)])):$("",!0)],64)):(C(),M("p",$m,"切换到你账号所属的家庭后可开启;管理员不能代替家人开启位置。"))]),t.value?(C(),M("p",qm,k(t.value),1)):$("",!0)])):$("",!0)}}},Um=us(Wm,[["__scopeId","data-v-7b466f08"]]);function rn(n=0){const e=Math.max(0,Number(n)||0);return e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(1)+" MB":e>=1e3?(e/1e3).toFixed(1)+" KB":e+" B"}function Km(n,e={}){return n.id===e.id?{preparing:"准备上传",uploading:"正在上传",verifying:"云端校验",cleaning:"清理本机"}[e.stage]||"处理中":n.state==="cloud"?n.releasedAt?"已上传 · 本机已清理":"已存网盘":n.state==="expired"?"云端已到期清理":n.error?"等待重试":n.state==="verified"?"待清理本机":"排队中"}function Jm(n,e){return new URLSearchParams({state:n.state,family:n.family,camera:n.camera,page:String(e)}).toString()}const Gm={key:0,class:"panel upload-tasks mb-4","aria-label":"上传任务"},Ym={class:"row g-3 mb-3"},Xm={class:"col-6 col-xl-3"},Zm={class:"upload-metric"},Qm={class:"col-6 col-xl-3"},eg={class:"upload-metric freed"},tg={class:"col-6 col-xl-3"},ng={class:"upload-metric"},sg={class:"col-6 col-xl-3"},ig={class:"upload-metric"},rg={key:0,class:"upload-current mb-3",role:"status"},og={class:"d-flex justify-content-between gap-2"},lg={key:0},ag={class:"small my-2"},cg=["aria-label","aria-valuenow"],dg={key:1,class:"alert alert-warning"},ug={class:"my-2"},pg={class:"d-flex flex-wrap align-items-center gap-2"},fg={class:"small"},hg=["disabled"],mg={key:2,class:"small",role:"status"},gg={key:3,class:"alert alert-danger",role:"alert"},bg={class:"upload-filters mb-3"},yg=["value"],vg=["value"],kg={key:4,class:"py-4 text-center text-secondary"},xg={key:5,class:"py-4 text-center text-secondary"},wg={key:6,class:"upload-list list-unstyled mb-0"},Sg={class:"upload-task-heading"},Cg={class:"small mb-1"},Mg={key:0,class:"small text-danger mb-1"},Tg={class:"small upload-details"},Eg={key:0},Ag={key:7,class:"d-flex flex-wrap justify-content-between gap-2 align-items-center mt-3"},Og={class:"small text-secondary"},Ng={class:"d-flex gap-2"},Ig=["disabled"],Dg=["disabled"],Rg={class:"border-top pt-3 mt-3"},Lg={class:"small mt-2"},Pg={class:"list-unstyled small"},$g={class:"ms-2"},Bg={key:0,class:"text-danger mb-0"},zg={key:0,class:"small text-secondary"},_g={__name:"UploadTasks",setup(n){const e=q(null),t=q(null),s=q(""),i=q(!1),r=q(""),o=q(1),l=q({state:"pending",family:"",camera:""}),a=Q(()=>B.value.loggedIn&&B.value.platformAdmin&&B.value.page==="storage"),d=Q(()=>{var x;return((x=e.value)==null?void 0:x.totals)||{}}),u=Q(()=>B.value.state.storage||{}),p=Q(()=>{var x;return(((x=e.value)==null?void 0:x.cameras)||[]).filter(v=>!l.value.family||v.familyId===l.value.family)}),f=x=>x?new Date(x*1e3).toLocaleString("zh-CN",{hour12:!1}):"—",h=Q(()=>{var x,v;return(v=(x=e.value)==null?void 0:x.active)==null?void 0:v.stage}),m=Q(()=>({preparing:"核对本机片段并准备上传",uploading:"上传文件分片",verifying:"回读网盘文件,核对完整性",cleaning:"校验成功,正在删除本机片段"})[h.value]||"");let g,b=0;async function y(){const x=++b;if(clearTimeout(g),!(!a.value||document.hidden))try{const[v,w]=await Promise.all([te().api("/api/uploads/recordings?"+Jm(l.value,o.value)),te().api("/api/backups")]);if(x!==b)return;e.value=v,o.value=v.page,t.value=w,s.value=""}catch(v){x===b&&(s.value=v.message)}finally{x===b&&a.value&&(g=setTimeout(y,5e3))}}function T(){o.value=1,r.value="",y()}function A(){l.value.camera="",T()}function E(x){o.value+=x,y()}async function O(){if(i.value)return;i.value=!0,r.value="";const x=b;try{if(await te().api("/api/uploads/recordings/retry",{}),x!==b)return;r.value="已安排重试最早的片段,后续片段仍按时间顺序上传。",y()}catch(v){x===b&&(r.value=v.message)}finally{i.value=!1}}function I(){document.hidden?(b++,clearTimeout(g)):a.value&&y()}return Qe([a,()=>B.value.session],()=>{b++,clearTimeout(g),e.value=null,t.value=null,s.value="",r.value="",i.value=!1,o.value=1,l.value={state:"pending",family:"",camera:""},a.value&&y()},{immediate:!0}),document.addEventListener("visibilitychange",I),ds(()=>{b++,clearTimeout(g),document.removeEventListener("visibilitychange",I)}),(x,v)=>{var w,D,L,Z,Re,ce,ue,de,Ge,ht,mt;return a.value?(C(),M("section",Gm,[c("div",{class:"d-flex flex-wrap justify-content-between gap-3 align-items-start mb-3"},[v[5]||(v[5]=c("div",null,[c("span",{class:"eyebrow"},"百度网盘 · 自动归档"),c("h2",{class:"fs-4 mt-1"},"上传任务"),c("p",{class:"small text-secondary mb-0"},"录像按录制时间依次上传,云端校验成功后才清理本机。此页每 5 秒自动更新。")],-1)),c("button",{class:"btn btn-outline-secondary",onClick:y},"刷新任务")]),c("div",Ym,[c("div",Xm,[c("div",Zm,[v[6]||(v[6]=c("span",null,"待上传",-1)),c("strong",null,k(j(rn)(d.value.pendingBytes)),1),c("small",null,k(d.value.pendingCount||0)+" 个片段保留在本机",1)])]),c("div",Qm,[c("div",eg,[v[7]||(v[7]=c("span",null,"累计清理本机录像",-1)),c("strong",null,k(j(rn)(d.value.releasedBytes)),1),c("small",null,"今日清理 "+k(j(rn)(d.value.releasedTodayBytes)),1)])]),c("div",tg,[c("div",ng,[v[8]||(v[8]=c("span",null,"已归档至网盘",-1)),c("strong",null,k(j(rn)(d.value.cloudBytes)),1),c("small",null,k(d.value.cloudCount||0)+" 个未到期片段",1)])]),c("div",sg,[c("div",ig,[v[9]||(v[9]=c("span",null,"服务器磁盘可用",-1)),c("strong",null,k((w=u.value.freeGB)!=null?w:"—")+" GB",1),c("small",null,"临时录像分区上限 "+k((D=u.value.temporaryMaxGB)!=null?D:"—")+" GB",1)])])]),v[28]||(v[28]=c("p",{class:"small text-secondary"},"清理量按已删除录像文件的大小累计;磁盘可用空间也会受系统和其他文件影响,两者并非同一个数值。",-1)),(Z=(L=e.value)==null?void 0:L.active)!=null&&Z.id?(C(),M("div",rg,[c("div",og,[c("strong",null,k(m.value),1),e.value.active.percent!==null?(C(),M("span",lg,k(e.value.active.percent)+"%",1)):$("",!0)]),c("p",ag,k(((Re=e.value.items.find(_=>_.id===e.value.active.id))==null?void 0:Re.cameraName)||"正在处理队首片段")+" · "+k(h.value==="verifying"?"校验完成后才释放空间":"上传完成后还需云端校验"),1),e.value.active.percent!==null?(C(),M("div",{key:0,class:"progress",role:"progressbar","aria-label":m.value,"aria-valuenow":e.value.active.percent,"aria-valuemin":"0","aria-valuemax":"100"},[c("div",{class:"progress-bar",style:Cn({width:e.value.active.percent+"%"})},null,4)],8,cg)):$("",!0)])):(ce=e.value)!=null&&ce.status.error?(C(),M("div",dg,[v[11]||(v[11]=c("strong",null,"队首片段等待重试",-1)),c("p",ug,k(e.value.status.error)+"。本机文件已保留。",1),c("div",pg,[c("span",fg,"预计重试:"+k(f(e.value.status.retryAt)),1),c("button",{class:"btn btn-sm btn-outline-secondary",disabled:i.value,onClick:O},"重试队首任务",8,hg),v[10]||(v[10]=c("button",{class:"btn btn-sm btn-outline-secondary","data-page":"settings","data-settings-section":"baidu"},"检查网盘连接",-1))])])):$("",!0),r.value?(C(),M("p",mg,k(r.value),1)):$("",!0),s.value?(C(),M("p",gg,k(s.value)+" · 当前列表可能尚未更新。",1)):$("",!0),c("div",bg,[c("label",null,[v[13]||(v[13]=S("任务状态",-1)),he(c("select",{"onUpdate:modelValue":v[0]||(v[0]=_=>l.value.state=_),class:"form-select",onChange:T},[...v[12]||(v[12]=[ye('待处理 等待重试 已上传 已到期清理 全部任务 ',5)])],544),[[qt,l.value.state]])]),c("label",null,[v[15]||(v[15]=S("家庭或场所",-1)),he(c("select",{"onUpdate:modelValue":v[1]||(v[1]=_=>l.value.family=_),class:"form-select",onChange:A},[v[14]||(v[14]=c("option",{value:""},"全部家庭或场所",-1)),(C(!0),M(J,null,ie(((ue=e.value)==null?void 0:ue.families)||[],_=>(C(),M("option",{key:_.id,value:_.id},k(_.name),9,yg))),128))],544),[[qt,l.value.family]])]),c("label",null,[v[17]||(v[17]=S("摄像机",-1)),he(c("select",{"onUpdate:modelValue":v[2]||(v[2]=_=>l.value.camera=_),class:"form-select",onChange:T},[v[16]||(v[16]=c("option",{value:""},"全部摄像机",-1)),(C(!0),M(J,null,ie(p.value,_=>(C(),M("option",{key:_.id+":"+_.familyId,value:_.id},k(_.name),9,vg))),128))],544),[[qt,l.value.camera]])])]),e.value?e.value.items.length?(C(),M("ol",wg,[(C(!0),M(J,null,ie(e.value.items,_=>(C(),M("li",{key:_.id,class:"upload-task"},[c("div",Sg,[c("strong",null,k(_.cameraName),1),c("span",{class:_e(["badge",_.error?"text-bg-warning":_.state==="cloud"?"text-bg-success":"text-bg-light"])},k(j(Km)(_,e.value.active)),3)]),c("p",Cg,k(_.familyName)+" · "+k(f(_.started))+" · "+k(Math.round(_.duration))+" 秒 · "+k(j(rn)(_.size)),1),_.error&&_.id!==e.value.active.id?(C(),M("p",Mg,k(_.error)+" · 已尝试 "+k(_.attempts)+" 次",1)):$("",!0),c("details",null,[v[25]||(v[25]=c("summary",{class:"small"},"文件与任务详情",-1)),c("dl",Tg,[c("div",null,[v[18]||(v[18]=c("dt",null,"文件名称",-1)),c("dd",null,k(_.name),1)]),c("div",null,[v[19]||(v[19]=c("dt",null,"摄像机编号",-1)),c("dd",null,k(_.cameraId),1)]),c("div",null,[v[20]||(v[20]=c("dt",null,"保存位置",-1)),c("dd",null,k(_.remotePath||"上传时按家庭 / 摄像机 / 日期自动建立目录"),1)]),c("div",null,[v[21]||(v[21]=c("dt",null,"云端校验时间",-1)),c("dd",null,k(f(_.verifiedAt)),1)]),c("div",null,[v[22]||(v[22]=c("dt",null,"本机清理时间",-1)),c("dd",null,k(f(_.releasedAt)),1)]),c("div",null,[v[23]||(v[23]=c("dt",null,"清理文件大小",-1)),c("dd",null,k(j(rn)(_.releasedBytes)),1)]),_.retryAt&&_.error?(C(),M("div",Eg,[v[24]||(v[24]=c("dt",null,"下一次重试",-1)),c("dd",null,k(f(_.retryAt)),1)])):$("",!0)])])]))),128))])):(C(),M("div",xg,"当前筛选下暂无任务。正在录制的片段完成后才会进入队列。")):(C(),M("div",kg,"正在读取上传队列…")),e.value?(C(),M("div",Ag,[c("span",Og,"共 "+k(e.value.total)+" 个任务 · 第 "+k(e.value.page)+" / "+k(e.value.pages)+" 页 · 更新于 "+k(f(e.value.updatedAt)),1),c("div",Ng,[c("button",{class:"btn btn-sm btn-outline-secondary",disabled:o.value<=1,onClick:v[3]||(v[3]=_=>E(-1))},"上一页",8,Ig),c("button",{class:"btn btn-sm btn-outline-secondary",disabled:o.value>=e.value.pages,onClick:v[4]||(v[4]=_=>E(1))},"下一页",8,Dg)])])):$("",!0),c("details",Rg,[v[26]||(v[26]=c("summary",null,"数据库备份上传",-1)),c("p",Lg,k((de=t.value)!=null&&de.running?t.value.stage:"备份任务未在执行")+"。数据库副本使用独立保留策略,不计入上方录像清理量。",1),c("ul",Pg,[(C(!0),M(J,null,ie((((Ge=t.value)==null?void 0:Ge.history)||[]).filter(_=>_.baiduRequested).slice(0,5),_=>(C(),M("li",{key:_.file||_.at,class:"py-2 border-bottom"},[c("strong",null,k(_.file||"数据库备份"),1),c("span",$g,k(_.baiduOk?"已上传并校验":"上传未完成"),1),_.error?(C(),M("p",Bg,k(_.error),1)):$("",!0)]))),128))]),(mt=(ht=t.value)==null?void 0:ht.history)!=null&&mt.some(_=>_.baiduRequested)?$("",!0):(C(),M("p",zg,"尚无网盘备份记录。")),v[27]||(v[27]=c("button",{class:"btn btn-sm btn-outline-secondary","data-page":"settings","data-settings-section":"backup"},"打开备份设置",-1))])])):$("",!0)}}},jg=us(_g,[["__scopeId","data-v-91adb6bb"]]);var Bo=Object.defineProperty,Fg=(n,e)=>{let t={};for(var s in n)Bo(t,s,{get:n[s],enumerable:!0});return Bo(t,Symbol.toStringTag,{value:"Module"}),t};function xe(n){this.content=n}xe.prototype={constructor:xe,find:function(n){for(var e=0;e>1}};xe.from=function(n){if(n instanceof xe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xe(e)};function La(n,e,t){for(let s=0;;s++){if(s==n.childCount||s==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(s),r=e.child(s);if(i==r){t+=i.nodeSize;continue}if(!i.sameMarkup(r))return t;if(i.isText&&i.text!=r.text){let o=i.text,l=r.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a0&&f>0&&d[p-1]==u[f-1];)p--,f--,t--,s--;return p&&f&&p=56320&&n<57344}function Ba(n){return n>=55296&&n<56320}class N{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let s=0;se&&s(a,i+l,r||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),s,i+u)}l=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,s,i){let r="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let d=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&s&&(o?o=!1:r+=s),r+=d},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,s=e.firstChild,i=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(s)&&(i[i.length-1]=t.withText(t.text+s.text),r=1);re)for(let r=0,o=0;oe&&((ot)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),s.push(l),i+=l.nodeSize),o=a}return new N(s,i)}cutByIndex(e,t){return e==t?N.empty:e==0&&t==this.content.length?this:new N(this.content.slice(e,t))}replaceChild(e,t){let s=this.content[e];if(s==t)return this;let i=this.content.slice(),r=this.size+t.nodeSize-s.nodeSize;return i[e]=t,new N(i,r)}addToStart(e){return new N([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new N(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,s=0;;t++){let i=this.child(t),r=s+i.nodeSize;if(r>=e)return r==e?ks(t+1,r):ks(t,s);s=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return N.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return N.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return N.empty;let t,s=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),s=!0),t&&t.push(r)}}return t||(t=e.slice()),s||t.push(this),t}removeFromSet(e){for(let t=0;ts.type.rank-i.type.rank),t}};ee.none=[];class Zn extends Error{}class P{constructor(e,t,s){this.content=e,this.openStart=t,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let s=_a(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return s&&new P(s,this.openStart,this.openEnd)}removeBetween(e,t){return new P(za(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return P.empty;let s=t.openStart||0,i=t.openEnd||0;if(typeof s!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new P(N.fromJSON(e,t.content),s,i)}static maxOpen(e,t=!0){let s=0,i=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)s++;for(let r=e.lastChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.lastChild)i++;return new P(e,s,i)}}P.empty=new P(N.empty,0,0);function za(n,e,t){let{index:s,offset:i}=n.findIndex(e),r=n.maybeChild(s),{index:o,offset:l}=n.findIndex(t);if(i==e||r.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(s!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(s,r.copy(za(r.content,e-i-1,t-i-1)))}function _a(n,e,t,s,i,r){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return r&&s<=0&&i<=0&&!r.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let d=_a(a.content,e-l-1,t,o==0?s-1:0,o==n.childCount-1?i-1:0,a);return d&&n.replaceChild(o,a.copy(d))}function Vg(n,e,t){if(t.openStart>n.depth)throw new Zn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Zn("Inconsistent open depths");return ja(n,e,t,0)}function ja(n,e,t,s){let i=n.index(s),r=n.node(s);if(i==e.index(s)&&s=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function zn(n,e,t,s){let i=(e||n).node(t),r=0,o=e?e.index(t):i.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(Wt(n.nodeAfter,s),r++));for(let l=r;li&&yr(n,e,i+1),o=s.depth>i&&yr(t,s,i+1),l=[];return zn(null,n,i,l),r&&o&&e.index(i)==t.index(i)?(Fa(r,o),Wt(Ut(r,Va(n,e,t,s,i+1)),l)):(r&&Wt(Ut(r,qs(n,e,i+1)),l),zn(e,t,i,l),o&&Wt(Ut(o,qs(t,s,i+1)),l)),zn(s,null,i,l),new N(l)}function qs(n,e,t){let s=[];if(zn(null,n,t,s),n.depth>t){let i=yr(n,e,t+1);Wt(Ut(i,qs(n,e,t+1)),s)}return zn(e,null,t,s),new N(s)}function Hg(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)i=e.node(r).copy(N.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Qn{constructor(e,t,s){this.pos=e,this.path=t,this.parentOffset=s,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],i=e.child(t);return s?e.child(t).cut(s):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let s=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let r=0;r0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;s--)if(e.pos<=this.end(s)&&(!t||t(this.node(s))))return new Ws(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let s=[],i=0,r=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(r),d=r-a;if(s.push(o,l,i+a),!d||(o=o.child(l),o.isText))break;r=d-1,i+=a+1}return new Qn(t,s,r)}static resolveCached(e,t){let s=zo.get(e);if(s)for(let r=0;re&&this.nodesBetween(e,t,r=>(s.isInSet(r.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ha(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,s=N.empty,i=0,r=s.childCount){let o=this.contentMatchAt(e).matchFragment(s,i,r),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;at.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let s;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,s)}let i=N.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,s)}};Kt.prototype.text=void 0;class Us extends Kt{constructor(e,t,s,i){if(super(e,t,null,i),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ha(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Us(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Us(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ha(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function _o(n,e,t,s){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${s}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}class Xt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let s=new Kg(e,t);if(s.next==null)return Xt.empty;let i=qa(s);s.next&&s.err("Unexpected trailing text");let r=eb(Qg(i));return tb(r,s),r}matchType(e){for(let t=0;td.createAndFill()));for(let d=0;d=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(s){e.push(s);for(let i=0;i{let r=i+(s.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(s.next[o].next);return r}).join(`
+`)}}Xt.empty=new Xt(!0);class Kg{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function qa(n){let e=[];do e.push(Jg(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Jg(n){let e=[];do e.push(Gg(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Gg(n){let e=Zg(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Yg(n,e);else break;return e}function jo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Yg(n,e){let t=jo(n),s=t;return n.eat(",")&&(n.next!="}"?s=jo(n):s=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:s,expr:e}}function Xg(n,e){let t=n.nodeTypes,s=t[e];if(s)return[s];let i=[];for(let r in t){let o=t[r];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Zg(n){if(n.eat("(")){let e=qa(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Xg(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Qg(n){let e=[[]];return i(r(n,0),t()),e;function t(){return e.push([])-1}function s(o,l,a){let d={term:a,to:l};return e[o].push(d),d}function i(o,l){o.forEach(a=>a.to=l)}function r(o,l){if(o.type=="choice")return o.exprs.reduce((a,d)=>a.concat(r(d,l)),[]);if(o.type=="seq")for(let a=0;;a++){let d=r(o.exprs[a],l);if(a==o.exprs.length-1)return d;i(d,l=t())}else if(o.type=="star"){let a=t();return s(l,a),i(r(o.expr,a),a),[s(a)]}else if(o.type=="plus"){let a=t();return i(r(o.expr,l),a),i(r(o.expr,a),a),[s(a)]}else{if(o.type=="opt")return[s(l)].concat(r(o.expr,l));if(o.type=="range"){let a=l;for(let d=0;d{n[o].forEach(({term:l,to:a})=>{if(!l)return;let d;for(let u=0;u{d||i.push([l,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let r=e[s.join(",")]=new Xt(s.indexOf(n.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ka(this.attrs,e)}create(e=null,t,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Kt(this,this.computeAttrs(e),N.from(t),ee.setFrom(s))}createChecked(e=null,t,s){return t=N.from(t),this.checkContent(t),new Kt(this,this.computeAttrs(e),t,ee.setFrom(s))}createAndFill(e=null,t,s){if(e=this.computeAttrs(e),t=N.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),r=i&&i.fillBefore(N.empty,!0);return r?new Kt(this,e,t.append(r),ee.setFrom(s)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;ts[r]=new Ga(r,t,o));let i=t.spec.topNode||"doc";if(!s[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let r in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function nb(n,e,t){let s=t.split("|");return i=>{let r=i===null?"null":typeof i;if(s.indexOf(r)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${n}, got ${r}`)}}class sb{constructor(e,t,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?nb(e,t,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class Ii{constructor(e,t,s,i){this.name=e,this.rank=t,this.schema=s,this.spec=i,this.attrs=Ja(e,i.attrs),this.excluded=null;let r=Ua(this.attrs);this.instance=r?new ee(this,r):null}create(e=null){return!e&&this.instance?this.instance:new ee(this,Ka(this.attrs,e))}static compile(e,t){let s=Object.create(null),i=0;return e.forEach((r,o)=>s[r]=new Ii(r,i++,t,o)),s}removeFromSet(e){for(var t=0;t-1}}class Ps{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=xe.from(e.nodes),t.marks=xe.from(e.marks||{}),this.nodes=Vo.compile(this.spec.nodes,this),this.marks=Ii.compile(this.spec.marks,this);let s=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let r=this.nodes[i],o=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=s[o]||(s[o]=Xt.parse(o,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?Ho(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let i in this.marks){let r=this.marks[i],o=r.spec.excludes;r.excluded=o==null?[r]:o==""?[]:Ho(this,o.split(" "))}this.nodeFromJSON=i=>Kt.fromJSON(this,i),this.markFromJSON=i=>ee.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,s,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Vo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,s,i)}text(e,t){let s=this.nodes.text;return new Us(s,s.defaultAttrs,e,ee.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ho(n,e){let t=[];for(let s=0;s-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return t}function ib(n){return n.tag!=null}function rb(n){return n.style!=null}class Mt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let s=this.matchedStyles=[];t.forEach(i=>{if(ib(i))this.tags.push(i);else if(rb(i)){let r=/[^=]*/.exec(i.style)[0];s.indexOf(r)<0&&s.push(r),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let r=e.nodes[i.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let s=new Wo(this,t,!1);return s.addAll(e,ee.none,t.from,t.to),s.finish()}parseSlice(e,t={}){let s=new Wo(this,t,!0);return s.addAll(e,ee.none,t.from,t.to),P.maxOpen(s.finish())}matchTag(e,t,s){for(let i=s?this.tags.indexOf(s)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function s(i){let r=i.priority==null?50:i.priority,o=0;for(;o{s(o=Uo(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let r=e.nodes[i].spec.parseDOM;r&&r.forEach(o=>{s(o=Uo(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Mt(e,Mt.schemaRules(e)))}}const Ya={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ob={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Xa={ol:!0,ul:!0},es=1,kr=2,_n=4;function qo(n,e,t){return e!=null?(e?es:0)|(e==="full"?kr:0):n&&n.whitespace=="pre"?es|kr:t&~_n}class xs{constructor(e,t,s,i,r,o){this.type=e,this.attrs=t,this.marks=s,this.solid=i,this.options=o,this.content=[],this.activeMarks=ee.none,this.match=r||(o&_n?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(N.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let s=this.type.contentMatch,i;return(i=s.findWrapping(e.type))?(this.match=s,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&es)){let s=this.content[this.content.length-1],i;if(s&&s.isText&&(i=/[ \t\r\n\u000c]+$/.exec(s.text))){let r=s;s.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-i[0].length))}}let t=N.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(N.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ya.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Wo{constructor(e,t,s){this.parser=e,this.options=t,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let i=t.topNode,r,o=qo(null,t.preserveWhitespace,0)|(s?_n:0);i?r=new xs(i.type,i.attrs,ee.none,!0,t.topMatch||i.type.contentMatch,o):s?r=new xs(null,null,ee.none,!0,null,o):r=new xs(e.schema.topNodeType,null,ee.none,!0,null,o),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let s=e.nodeValue,i=this.top,r=i.options&kr?"full":this.localPreserveWS||(i.options&es)>0,{schema:o}=this.parser;if(r==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(r)if(r==="full")s=s.replace(/\r\n?/g,`
+`);else if(o.linebreakReplacement&&/[\r\n]/.test(s)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=s.split(/\r?\n|\r/);for(let a=0;a!a.clearMark(d)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,s,i){let r,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),s,e.nodeName=="BR")||this.leafFallback(e,s);else{let a=this.enter(o,t.attrs||null,s,t.preserveWhitespace);a&&(r=!0,s=a)}else{let a=this.parser.schema.marks[t.mark];s=s.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,s,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,s,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,s),this.findAround(e,a,!1)}r&&this.sync(l)&&this.open--}addAll(e,t,s,i){let r=s||0;for(let o=s?e.childNodes[s]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o,t);this.findAtPoint(e,r)}findPlace(e,t,s){let i,r;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],d=a.findWrapping(e);if(d&&(!i||i.length>d.length+l)&&(i=d,r=a,!d.length))break;if(a.solid){if(s)break;l+=2}}if(!i)return null;this.sync(r);for(let o=0;o(o.type?o.type.allowsMarkType(d.type):Ko(d.type,e))?(a=d.addToSet(a),!1):!0),this.nodes.push(new xs(e,t,a,i,null,l)),this.open++,s}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=es)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let s=this.nodes[t].content;for(let i=s.length-1;i>=0;i--)e+=s[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let s=0;s-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),s=this.options.context,i=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),r=-(s?s.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let d=t[l];if(d==""){if(l==t.length-1||l==0)continue;for(;a>=r;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:s&&a>=r?s.node(a-r).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let t in this.parser.schema.nodes){let s=this.parser.schema.nodes[t];if(s.isTextblock&&s.defaultAttrs)return s}}}function lb(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&Xa.hasOwnProperty(s)&&t?(t.appendChild(e),e=t):s=="li"?t=e:s&&(t=null)}}function ab(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Uo(n){let e={};for(let t in n)e[t]=n[t];return e}function Ko(n,e){let t=e.schema.nodes;for(let s in t){let i=t[s];if(!i.allowsMarkType(n))continue;let r=[],o=l=>{r.push(l);for(let a=0;a{if(r.length||o.marks.length){let l=0,a=0;for(;l=0;i--){let r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(s),s=r.dom)}return s}serializeMark(e,t,s={}){let i=this.marks[e.type.name];return i&&$s(ws(s),i(e,t),null,e.attrs)}static renderSpec(e,t,s=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:$s(e,t,s,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new nn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Jo(e.nodes);return t.text||(t.text=s=>s.text),t}static marksFromSchema(e){return Jo(e.marks)}}function Jo(n){let e={};for(let t in n){let s=n[t].spec.toDOM;s&&(e[t]=s)}return e}function ws(n){return n.document||window.document}const Go=new WeakMap;function cb(n){let e=Go.get(n);return e===void 0&&Go.set(n,e=db(n)),e}function db(n){let e=null;function t(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let p in d)if(d[p]!=null){let f=p.indexOf(" ");f>0?a.setAttributeNS(p.slice(0,f),p.slice(f+1),d[p]):p=="style"&&a.style?a.style.cssText=d[p]:a.setAttribute(p,d[p])}}for(let p=u;pu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(n.createTextNode(f));else{let{dom:h,contentDOM:m}=$s(n,f,t,s);if(a.appendChild(h),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const Za=65535,Qa=Math.pow(2,16);function ub(n,e){return n+e*Qa}function Yo(n){return n&Za}function pb(n){return(n-(n&Za))/Qa}const ec=1,tc=2,Bs=4,nc=8;class xr{constructor(e,t,s){this.pos=e,this.delInfo=t,this.recover=s}get deleted(){return(this.delInfo&nc)>0}get deletedBefore(){return(this.delInfo&(ec|Bs))>0}get deletedAfter(){return(this.delInfo&(tc|Bs))>0}get deletedAcross(){return(this.delInfo&Bs)>0}}class ze{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ze.empty)return ze.empty}recover(e){let t=0,s=Yo(e);if(!this.inverted)for(let i=0;ie)break;let d=this.ranges[l+r],u=this.ranges[l+o],p=a+d;if(e<=p){let f=d?e==a?-1:e==p?1:t:t,h=a+i+(f<0?0:u);if(s)return h;let m=e==(t<0?a:p)?null:ub(l/3,e-a),g=0;return d&&(g|=e==a?tc:e==p?ec:Bs,(t<0?e!=a:e!=p)&&(g|=nc)),new xr(h,g,m)}i+=u-d}return s?e+i:new xr(e+i,0,null)}touches(e,t){let s=0,i=Yo(t),r=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;le)break;let d=this.ranges[l+r],u=a+d;if(e<=u&&l==i*3)return!0;s+=this.ranges[l+o]-d}return!1}forEach(e){let t=this.inverted?2:1,s=this.inverted?1:2;for(let i=0,r=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?s-i-1:void 0)}}invert(){let e=new ts;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let s=this.from;sr&&a!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return pe.fromReplace(e,this.from,this.to,r)}invert(){return new Ke(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new St(t.pos,s.pos,this.mark)}merge(e){return e instanceof St&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new St(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new St(t.from,t.to,e.markFromJSON(t.mark))}}Oe.jsonID("addMark",St);class Ke extends Oe{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=new P(Qr(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return pe.fromReplace(e,this.from,this.to,s)}invert(){return new St(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Ke(t.pos,s.pos,this.mark)}merge(e){return e instanceof Ke&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ke(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ke(t.from,t.to,e.markFromJSON(t.mark))}}Oe.jsonID("removeMark",Ke);class Ct extends Oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at mark step's position");let s=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return pe.fromReplace(e,this.pos,this.pos+1,new P(N.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let s=this.mark.addToSet(t.marks);if(s.length==t.marks.length){for(let i=0;is.pos?null:new ve(t.pos,s.pos,i,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ve(t.from,t.to,t.gapFrom,t.gapTo,P.fromJSON(e,t.slice),t.insert,!!t.structure)}}Oe.jsonID("replaceAround",ve);function wr(n,e,t){let s=n.resolve(e),i=t-e,r=s.depth;for(;i>0&&r>0&&s.indexAfter(r)==s.node(r).childCount;)r--,i--;if(i>0){let o=s.node(r).maybeChild(s.indexAfter(r));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function fb(n,e,t,s){let i=[],r=[],o,l;n.doc.nodesBetween(e,t,(a,d,u)=>{if(!a.isInline)return;let p=a.marks;if(!s.isInSet(p)&&u.type.allowsMarkType(s.type)){let f=Math.max(d,e),h=Math.min(d+a.nodeSize,t),m=s.addToSet(p);for(let g=0;gn.step(a)),r.forEach(a=>n.step(a))}function hb(n,e,t,s){let i=[],r=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;r++;let a=null;if(s instanceof Ii){let d=o.marks,u;for(;u=s.isInSet(d);)(a||(a=[])).push(u),d=u.removeFromSet(d)}else s?s.isInSet(o.marks)&&(a=[s]):a=o.marks;if(a&&a.length){let d=Math.min(l+o.nodeSize,t);for(let u=0;un.step(new Ke(o.from,o.to,o.style)))}function eo(n,e,t,s=t.contentMatch,i=!0){let r=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a=0;a--)n.step(o[a])}function mb(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Mn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let s=n.depth,i=0,r=0;;--s){let o=n.$from.node(s),l=n.$from.index(s)+i,a=n.$to.indexAfter(s)-r;if(st;m--)g||s.index(m)>0?(g=!0,u=N.from(s.node(m).copy(u)),p++):a--;let f=N.empty,h=0;for(let m=r,g=!1;m>t;m--)g||i.after(m+1)=0;o--){if(s.size){let l=t[o].type.contentMatch.matchFragment(s);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=N.from(t[o].type.create(t[o].attrs,s))}let i=e.start,r=e.end;n.step(new ve(i,r,i,r,new P(s,0,0),t.length,!0))}function kb(n,e,t,s,i){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(s,a)&&xb(n.doc,n.mapping.slice(r).map(l),s)){let d=null;if(s.schema.linebreakReplacement){let h=s.whitespace=="pre",m=!!s.contentMatch.matchType(s.schema.linebreakReplacement);h&&!m?d=!1:!h&&m&&(d=!0)}d===!1&&ic(n,o,l,r),eo(n,n.mapping.slice(r).map(l,1),s,void 0,d===null);let u=n.mapping.slice(r),p=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new ve(p,f,p+1,f-1,new P(N.from(s.create(a,null,o.marks)),0,0),1,!0)),d===!0&&sc(n,o,l,r),!1}})}function sc(n,e,t,s){e.forEach((i,r)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(s).map(t+1+r+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ic(n,e,t,s){e.forEach((i,r)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(s).map(t+1+r);n.replaceWith(o,o+1,e.type.schema.text(`
+`))}})}function xb(n,e,t){let s=n.resolve(e),i=s.index();return s.parent.canReplaceWith(i,i+1,t)}function wb(n,e,t,s,i){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let o=t.create(s,null,i||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,o);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ve(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new P(N.from(o),0,0),1,!0))}function dt(n,e,t=1,s){let i=n.resolve(e),r=i.depth-t,o=s&&s[s.length-1]||i.parent;if(r<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,u=t-2;d>r;d--,u--){let p=i.node(d),f=i.index(d);if(p.type.spec.isolating)return!1;let h=p.content.cutByIndex(f,p.childCount),m=s&&s[u+1];m&&(h=h.replaceChild(0,m.type.create(m.attrs)));let g=s&&s[u]||p;if(!p.canReplace(f+1,p.childCount)||!g.type.validContent(h))return!1}let l=i.indexAfter(r),a=s&&s[0];return i.node(r).canReplaceWith(l,l,a?a.type:i.node(r+1).type)}function Sb(n,e,t=1,s){let i=n.doc.resolve(e),r=N.empty,o=N.empty;for(let l=i.depth,a=i.depth-t,d=t-1;l>a;l--,d--){r=N.from(i.node(l).copy(r));let u=s&&s[d];o=N.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new oe(e,e,new P(r.append(o),t,t),!0))}function Lt(n,e){let t=n.resolve(e),s=t.index();return rc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(s,s+1)}function Cb(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:s}=n.type.schema;for(let i=0;i0?(r=s.node(i+1),l++,o=s.node(i).maybeChild(l)):(r=s.node(i).maybeChild(l-1),o=s.node(i+1)),r&&!r.isTextblock&&rc(r,o)&&s.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?s.before(i):s.after(i)}}function Mb(n,e,t){let s=null,{linebreakReplacement:i}=n.doc.type.schema,r=n.doc.resolve(e-t),o=r.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",p=!!o.contentMatch.matchType(i);u&&!p?s=!1:!u&&p&&(s=!0)}let l=n.steps.length;if(s===!1){let u=n.doc.resolve(e+t);ic(n,u.node(),u.before(),l)}o.inlineContent&&eo(n,e+t-1,o,r.node().contentMatchAt(r.index()),s==null);let a=n.mapping.slice(l),d=a.map(e-t);if(n.step(new oe(d,a.map(e+t,-1),P.empty,!0)),s===!0){let u=n.doc.resolve(d);sc(n,u.node(),u.before(),n.steps.length)}return n}function Tb(n,e,t){let s=n.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),t))return e;if(s.parentOffset==0)for(let i=s.depth-1;i>=0;i--){let r=s.index(i);if(s.node(i).canReplaceWith(r,r,t))return s.before(i+1);if(r>0)return null}if(s.parentOffset==s.parent.content.size)for(let i=s.depth-1;i>=0;i--){let r=s.indexAfter(i);if(s.node(i).canReplaceWith(r,r,t))return s.after(i+1);if(r=0;o--){let l=o==s.depth?0:s.pos<=(s.start(o+1)+s.end(o+1))/2?-1:1,a=s.index(o)+(l>0?1:0),d=s.node(o),u=!1;if(r==1)u=d.canReplace(a,a,i);else{let p=d.contentMatchAt(a).findWrapping(i.firstChild.type);u=p&&d.canReplaceWith(a,a,p[0])}if(u)return l==0?s.pos:l<0?s.before(o+1):s.after(o+1)}return null}function Ri(n,e,t=e,s=P.empty){if(e==t&&!s.size)return null;let i=n.resolve(e),r=n.resolve(t);return lc(i,r,s)?new oe(e,t,s):new Eb(i,r,s).fit()}function lc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Eb{constructor(e,t,s){this.$from=e,this.$to=t,this.unplaced=s,this.frontier=[],this.placed=N.empty;for(let i=0;i<=e.depth;i++){let r=e.node(i);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=N.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,s=this.$from,i=this.close(e<0?this.$to:s.doc.resolve(e));if(!i)return null;let r=this.placed,o=s.depth,l=i.depth;for(;o&&l&&r.childCount==1;)r=r.firstChild.content,o--,l--;let a=new P(r,o,l);return e>-1?new ve(s.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||s.pos!=this.$to.pos?new oe(s.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,s=0,i=this.unplaced.openEnd;s1&&(i=0),r.type.spec.isolating&&i<=s){e=s;break}t=r.content}for(let t=1;t<=2;t++)for(let s=t==1?e:this.unplaced.openStart;s>=0;s--){let i,r=null;s?(r=Zo(this.unplaced.content,s-1).firstChild,i=r.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:d}=this.frontier[l],u,p=null;if(t==1&&(o?d.matchType(o.type)||(p=d.fillBefore(N.from(o),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:s,frontierDepth:l,parent:r,inject:p};if(t==2&&o&&(u=d.findWrapping(o.type)))return{sliceDepth:s,frontierDepth:l,parent:r,wrap:u};if(r&&d.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:s}=this.unplaced;return Qo(e,-1)<=t?!1:(this.unplaced.size>1&&Qo(e,1)>s&&s++,this.unplaced=new P(e,t+1,s),!0)}dropNode(){let{content:e,openStart:t,openEnd:s}=this.unplaced,i=Zo(e,t);if(i.childCount<=1&&t>0){let r=e.size-t<=t+i.size;this.unplaced=new P(Rn(e,t-1,1),t-1,r?t-1:s)}else this.unplaced=new P(Rn(e,t,1),t,s)}placeNodes({sliceDepth:e,frontierDepth:t,parent:s,inject:i,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let g=0;g1||a==0||g.content.size)&&(p=b,u.push(ac(g.mark(f.allowedMarks(g.marks)),d==1?a:0,d==l.childCount?h:-1)))}let m=d==l.childCount;m||(h=-1),this.placed=Ln(this.placed,t,N.from(u)),this.frontier[t].match=p,m&&h<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,b=l;g1&&i==this.$to.end(--s);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:s,type:i}=this.frontier[t],r=t=0;l--){let{match:a,type:d}=this.frontier[l],u=Xi(e,l,d,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ln(this.placed,t.depth,t.fit)),e=t.move;for(let s=t.depth+1;s<=e.depth;s++){let i=e.node(s),r=i.type.contentMatch.fillBefore(i.content,!0,e.index(s));this.openFrontierNode(i.type,i.attrs,r)}return e}openFrontierNode(e,t=null,s){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ln(this.placed,this.depth,N.from(e.create(t,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(N.empty,!0);t.childCount&&(this.placed=Ln(this.placed,this.frontier.length,t))}}function Rn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Rn(n.firstChild.content,e-1,t)))}function Ln(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Ln(n.lastChild.content,e-1,t)))}function Zo(n,e){for(let t=0;t1&&(s=s.replaceChild(0,ac(s.firstChild,e-1,s.childCount==1?t-1:0))),e>0&&(s=n.type.contentMatch.fillBefore(s).append(s),t<=0&&(s=s.append(n.type.contentMatch.matchFragment(s).fillBefore(N.empty,!0)))),n.copy(s)}function Xi(n,e,t,s,i){let r=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==r.childCount&&!t.compatibleContent(r.type))return null;let l=s.fillBefore(r.content,!0,o);return l&&!Ab(t,r.content,o)?l:null}function Ab(n,e,t){for(let s=t;s0;f--,h--){let m=i.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),d=[],u=s.openStart;for(let f=s.content,h=0;;h++){let m=f.firstChild;if(d.push(m),h==s.openStart)break;f=m.content}for(let f=u-1;f>=0;f--){let h=d[f],m=Ob(h.type);if(m&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(m||!h.type.isTextblock)break}for(let f=s.openStart;f>=0;f--){let h=(f+u+1)%(s.openStart+1),m=d[h];if(m)for(let g=0;g=0&&(n.replace(e,t,s),!(n.steps.length>p));f--){let h=o[f];h<0||(e=i.before(h),t=r.after(h))}}function cc(n,e,t,s,i){if(es){let r=i.contentMatchAt(0),o=r.fillBefore(n).append(n);n=o.append(r.matchFragment(o).fillBefore(N.empty,!0))}return n}function Ib(n,e,t,s){if(!s.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Tb(n.doc,e,s.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new P(N.from(s),0,0))}function Db(n,e,t){let s=n.doc.resolve(e),i=n.doc.resolve(t);if(s.parent.isTextblock&&i.parent.isTextblock&&s.start()!=i.start()&&s.parentOffset==0&&i.parentOffset==0){let o=s.sharedDepth(t),l=!1;for(let a=s.depth;a>o;a--)s.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=s.depth;a>0&&e==s.start(a);a--)e=s.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);s=n.doc.resolve(e),i=n.doc.resolve(t)}}let r=dc(s,i);for(let o=0;o0&&(a||s.node(l-1).canReplace(s.index(l-1),i.indexAfter(l-1))))return n.delete(s.before(l),i.after(l))}for(let o=1;o<=s.depth&&o<=i.depth;o++)if(e-s.start(o)==s.depth-o&&t>s.end(o)&&i.end(o)-t!=i.depth-o&&s.start(o-1)==i.start(o-1)&&s.node(o-1).canReplace(s.index(o-1),i.index(o-1)))return n.delete(s.before(o),t);n.delete(e,t)}function dc(n,e){let t=[],s=Math.min(n.depth,e.depth);for(let i=s;i>=0;i--){let r=n.start(i);if(re.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(r==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==r-1)&&t.push(i)}return t}class mn extends Oe{constructor(e,t,s){super(),this.pos=e,this.attr=t,this.value=s}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at attribute step's position");let s=Object.create(null);for(let r in t.attrs)s[r]=t.attrs[r];s[this.attr]=this.value;let i=t.type.create(s,null,t.marks);return pe.fromReplace(e,this.pos,this.pos+1,new P(N.from(i),0,t.isLeaf?0:1))}getMap(){return ze.empty}invert(e){return new mn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new mn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new mn(t.pos,t.attr,t.value)}}Oe.jsonID("attr",mn);class ns extends Oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let s=e.type.create(t,e.content,e.marks);return pe.ok(s)}getMap(){return ze.empty}invert(e){return new ns(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ns(t.attr,t.value)}}Oe.jsonID("docAttr",ns);let bn=class extends Error{};bn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};bn.prototype=Object.create(Error.prototype);bn.prototype.constructor=bn;bn.prototype.name="TransformError";class uc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ts}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new bn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let s=0;s{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,s=P.empty){let i=Ri(this.doc,e,t,s);return i&&this.step(i),this}replaceWith(e,t,s){return this.replace(e,t,new P(N.from(s),0,0))}delete(e,t){return this.replace(e,t,P.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,s){return Nb(this,e,t,s),this}replaceRangeWith(e,t,s){return Ib(this,e,t,s),this}deleteRange(e,t){return Db(this,e,t),this}lift(e,t){return gb(this,e,t),this}join(e,t=1){return Mb(this,e,t),this}wrap(e,t){return vb(this,e,t),this}setBlockType(e,t=e,s,i=null){return kb(this,e,t,s,i),this}setNodeMarkup(e,t,s=null,i){return wb(this,e,t,s,i),this}setNodeAttribute(e,t,s){return this.step(new mn(e,t,s)),this}setDocAttribute(e,t){return this.step(new ns(e,t)),this}addNodeMark(e,t){return this.step(new Ct(e,t)),this}removeNodeMark(e,t){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(t instanceof ee)t.isInSet(s.marks)&&this.step(new Zt(e,t));else{let i=s.marks,r,o=[];for(;r=t.isInSet(i);)o.push(new Zt(e,r)),i=r.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,s){return Sb(this,e,t,s),this}addMark(e,t,s){return fb(this,e,t,s),this}removeMark(e,t,s){return hb(this,e,t,s),this}clearIncompatible(e,t,s){return eo(this,e,t,s),this}}const Zi=Object.create(null);class W{constructor(e,t,s){this.$anchor=e,this.$head=t,this.ranges=s||[new Rb(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let o=t<0?dn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,s):dn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,s);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new je(e.node(0))}static atStart(e){return dn(e,e,0,0,1)||new je(e)}static atEnd(e){return dn(e,e,e.content.size,e.childCount,-1)||new je(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=Zi[t.type];if(!s)throw new RangeError(`No selection type ${t.type} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in Zi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Zi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return V.between(this.$anchor,this.$head).getBookmark()}}W.prototype.visible=!0;class Rb{constructor(e,t){this.$from=e,this.$to=t}}let el=!1;function tl(n){!el&&!n.parent.inlineContent&&(el=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class V extends W{constructor(e,t=e){tl(e),tl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let s=e.resolve(t.map(this.head));if(!s.parent.inlineContent)return W.near(s);let i=e.resolve(t.map(this.anchor));return new V(i.parent.inlineContent?i:s,s)}replace(e,t=P.empty){if(super.replace(e,t),t==P.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof V&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Li(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new V(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,s=t){let i=e.resolve(t);return new this(i,s==t?i:e.resolve(s))}static between(e,t,s){let i=e.pos-t.pos;if((!s||i)&&(s=i>=0?1:-1),!t.parent.inlineContent){let r=W.findFrom(t,s,!0)||W.findFrom(t,-s,!0);if(r)t=r.$head;else return W.near(t,s)}return e.parent.inlineContent||(i==0?e=t:(e=(W.findFrom(e,-s,!0)||W.findFrom(e,s,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let l=e.child(o);if(l.isAtom){if(!r&&H.isSelectable(l))return H.create(n,t-(i<0?l.nodeSize:0))}else{let a=dn(n,l,t+i,i<0?l.childCount:0,i,r);if(a)return a}t+=l.nodeSize*i}return null}function nl(n,e,t){let s=n.steps.length-1;if(s{o==null&&(o=u)}),n.setSelection(W.near(n.doc.resolve(o),t))}const sl=1,Ss=2,il=4;class Pb extends uc{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ss,this}ensureMarks(e){return ee.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ss)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Ss,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let s=this.selection;return t&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||ee.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,s){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(s==null&&(s=t),!e)return this.deleteRange(t,s);let r=this.storedMarks;if(!r){let o=this.doc.resolve(t);r=s==t?o.marks():o.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(t,s,i.text(e,r)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(W.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=il,this}get scrolledIntoView(){return(this.updated&il)>0}}function rl(n,e){return!e||!n?n:n.bind(e)}class Pn{constructor(e,t,s){this.name=e,this.init=rl(t.init,s),this.apply=rl(t.apply,s)}}const $b=[new Pn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Pn("selection",{init(n,e){return n.selection||W.atStart(e.doc)},apply(n){return n.selection}}),new Pn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,s){return s.selection.$cursor?n.storedMarks:null}}),new Pn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Qi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=$b.slice(),t&&t.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new Pn(s.key,s.spec.state,s))})}}class lt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let s=0;ss.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[s],r=i.spec.state;r&&r.toJSON&&(t[s]=r.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,s){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Qi(e.schema,e.plugins),r=new lt(i);return i.fields.forEach(o=>{if(o.name=="doc")r.doc=Kt.fromJSON(e.schema,t.doc);else if(o.name=="selection")r.selection=W.fromJSON(r.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let l in s){let a=s[l],d=a.spec.state;if(a.key==o.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[o.name]=d.fromJSON.call(a,e,t[l],r);return}}r[o.name]=o.init(e,r)}}),r}}function pc(n,e,t){for(let s in n){let i=n[s];i instanceof Function?i=i.bind(e):s=="handleDOMEvents"&&(i=pc(i,e,{})),t[s]=i}return t}class se{constructor(e){this.spec=e,this.props={},e.props&&pc(e.props,this,this.props),this.key=e.key?e.key.key:fc("plugin")}getState(e){return e[this.key]}}const er=Object.create(null);function fc(n){return n in er?n+"$"+ ++er[n]:(er[n]=0,n+"$")}class fe{constructor(e="key"){this.key=fc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const hc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function mc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const gc=(n,e,t)=>{let s=mc(n,t);if(!s)return!1;let i=so(s);if(!i){let o=s.blockRange(),l=o&&Mn(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let r=i.nodeBefore;if(Mc(n,i,e,-1))return!0;if(s.parent.content.size==0&&(yn(r,"end")||H.isSelectable(r)))for(let o=s.depth;;o--){let l=Ri(n.doc,s.before(o),s.after(o),P.empty);if(l&&l.slice.size1)break}return r.isAtom&&i.depth==s.depth-1?(e&&e(n.tr.delete(i.pos-r.nodeSize,i.pos).scrollIntoView()),!0):!1},Bb=(n,e,t)=>{let s=mc(n,t);if(!s)return!1;let i=so(s);return i?bc(n,i,e):!1},zb=(n,e,t)=>{let s=vc(n,t);if(!s)return!1;let i=io(s);return i?bc(n,i,e):!1};function bc(n,e,t){let s=e.nodeBefore,i=s,r=e.pos-1;for(;!i.isTextblock;r--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let d=Ri(n.doc,r,a,P.empty);if(!d||d.from!=r||d instanceof oe&&d.slice.size>=a-r)return!1;if(t){let u=n.tr.step(d);u.setSelection(V.create(u.doc,r)),t(u.scrollIntoView())}return!0}function yn(n,e,t=!1){for(let s=n;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(t&&s.childCount!=1)return!1}return!1}const yc=(n,e,t)=>{let{$head:s,empty:i}=n.selection,r=s;if(!i)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):s.parentOffset>0)return!1;r=so(s)}let o=r&&r.nodeBefore;return!o||!H.isSelectable(o)?!1:(e&&e(n.tr.setSelection(H.create(n.doc,r.pos-o.nodeSize)).scrollIntoView()),!0)};function so(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function vc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let s=vc(n,t);if(!s)return!1;let i=io(s);if(!i)return!1;let r=i.nodeAfter;if(Mc(n,i,e,1))return!0;if(s.parent.content.size==0&&(yn(r,"start")||H.isSelectable(r))){let o=Ri(n.doc,s.before(),s.after(),P.empty);if(o&&o.slice.size{let{$head:s,empty:i}=n.selection,r=s;if(!i)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):s.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,s=t instanceof H,i;if(s){if(t.node.isTextblock||!Lt(n.doc,t.from))return!1;i=t.from}else if(i=Di(n.doc,t.from,-1),i==null)return!1;if(e){let r=n.tr.join(i);s&&r.setSelection(H.create(r.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(r.scrollIntoView())}return!0},jb=(n,e)=>{let t=n.selection,s;if(t instanceof H){if(t.node.isTextblock||!Lt(n.doc,t.to))return!1;s=t.to}else if(s=Di(n.doc,t.to,1),s==null)return!1;return e&&e(n.tr.join(s).scrollIntoView()),!0},Fb=(n,e)=>{let{$from:t,$to:s}=n.selection,i=t.blockRange(s),r=i&&Mn(i);return r==null?!1:(e&&e(n.tr.lift(i,r).scrollIntoView()),!0)},wc=(n,e)=>{let{$head:t,$anchor:s}=n.selection;return!t.parent.type.spec.code||!t.sameParent(s)?!1:(e&&e(n.tr.insertText(`
+`).scrollIntoView()),!0)};function ro(n){for(let e=0;e{let{$head:t,$anchor:s}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(s))return!1;let i=t.node(-1),r=t.indexAfter(-1),o=ro(i.contentMatchAt(r));if(!o||!i.canReplaceWith(r,r,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(W.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Sc=(n,e)=>{let t=n.selection,{$from:s,$to:i}=t;if(t instanceof je||s.parent.inlineContent||i.parent.inlineContent)return!1;let r=ro(i.parent.contentMatchAt(i.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let o=(!s.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let r=t.before();if(dt(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let s=t.blockRange(),i=s&&Mn(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)};function Hb(n){return(e,t)=>{if(e.selection instanceof H&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!dt(e.doc,h.pos)?!1:(t&&t(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let s=e.tr;!e.selection.empty&&(e.selection instanceof V||e.selection instanceof je)&&s.deleteSelection();let{$from:i}=s.selection,r=s.steps.length,o=[],l,a,d=!1,u=!1;for(let h=i.depth;;h--)if(i.node(h).isBlock){d=i.end(h)==i.pos+(i.depth-h),u=i.start(h)==i.pos-(i.depth-h),a=ro(i.node(h-1).contentMatchAt(i.indexAfter(h-1))),o.unshift(d&&a?{type:a}:null),l=h;break}else{if(h==1)return!1;o.unshift(null)}let p=i.pos,f=dt(s.doc,p,o.length,o);if(f||(o[0]=a?{type:a}:null,f=dt(s.doc,p,o.length,o)),!f)return!1;if(s.split(p,o.length,o),!d&&u&&i.node(l).type!=a){let h=s.mapping.slice(r),m=h.map(i.before(l)),g=s.doc.resolve(m);a&&i.node(l-1).canReplaceWith(g.index(),g.index()+1,a)&&s.setNodeMarkup(h.map(i.before(l)),a)}return t&&t(s.scrollIntoView()),!0}}const qb=Hb(),Wb=(n,e)=>{let{$from:t,to:s}=n.selection,i,r=t.sharedDepth(s);return r==0?!1:(i=t.before(r),e&&e(n.tr.setSelection(H.create(n.doc,i))),!0)};function Ub(n,e,t){let s=e.nodeBefore,i=e.nodeAfter,r=e.index();return!s||!i||!s.type.compatibleContent(i.type)?!1:!s.content.size&&e.parent.canReplace(r-1,r)?(t&&t(n.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(r,r+1)||!(i.isTextblock||Lt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Mc(n,e,t,s){let i=e.nodeBefore,r=e.nodeAfter,o,l,a=i.type.spec.isolating||r.type.spec.isolating;if(!a&&Ub(n,e,t))return!0;let d=!a&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(r.type))&&l.matchType(o[0]||r.type).validEnd){if(t){let h=e.pos+r.nodeSize,m=N.empty;for(let y=o.length-1;y>=0;y--)m=N.from(o[y].create(null,m));m=N.from(i.copy(m));let g=n.tr.step(new ve(e.pos-1,h,e.pos,h,new P(m,1,0),o.length,!0)),b=g.doc.resolve(h+2*o.length);b.nodeAfter&&b.nodeAfter.type==i.type&&Lt(g.doc,b.pos)&&g.join(b.pos),t(g.scrollIntoView())}return!0}let u=r.type.spec.isolating||s>0&&a?null:W.findFrom(e,1),p=u&&u.$from.blockRange(u.$to),f=p&&Mn(p);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(p,f).scrollIntoView()),!0;if(d&&yn(r,"start",!0)&&yn(i,"end")){let h=i,m=[];for(;m.push(h),!h.isTextblock;)h=h.lastChild;let g=r,b=1;for(;!g.isTextblock;g=g.firstChild)b++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let y=N.empty;for(let A=m.length-1;A>=0;A--)y=N.from(m[A].copy(y));let T=n.tr.step(new ve(e.pos-m.length,e.pos+r.nodeSize,e.pos+b,e.pos+r.nodeSize-b,new P(y,m.length,0),0,!0));t(T.scrollIntoView())}return!0}}return!1}function Tc(n){return function(e,t){let s=e.selection,i=n<0?s.$from:s.$to,r=i.depth;for(;i.node(r).isInline;){if(!r)return!1;r--}return i.node(r).isTextblock?(t&&t(e.tr.setSelection(V.create(e.doc,n<0?i.start(r):i.end(r)))),!0):!1}}const Kb=Tc(-1),Jb=Tc(1);function Gb(n,e=null){return function(t,s){let{$from:i,$to:r}=t.selection,o=i.blockRange(r),l=o&&to(o,n,e);return l?(s&&s(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function ol(n,e=null){return function(t,s){let i=!1;for(let r=0;r{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(d),p=u.index();i=u.parent.canReplaceWith(p,p+1,n)}})}if(!i)return!1;if(s){let r=t.tr;for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);r=new Ws(a,a,e.depth),e.endIndex=0;u--)r=N.from(t[u].type.create(t[u].attrs,r));n.step(new ve(e.start-(s?2:0),e.end,e.start,e.end,new P(r,0,0),t.length,!0));let o=0;for(let u=0;uo.childCount>0&&o.firstChild.type==n);return r?t?s.node(r.depth-1).type==n?ey(e,t,n,r):ty(e,t,r):!0:!1}}function ey(n,e,t,s){let i=n.tr,r=s.end,o=s.$to.end(s.depth);rg;m--)h-=i.child(m).nodeSize,s.delete(h-1,h+1);let r=s.doc.resolve(t.start),o=r.nodeAfter;if(s.mapping.map(t.end)!=t.start+r.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,d=r.node(-1),u=r.index(-1);if(!d.canReplace(u+(l?0:1),u+1,o.content.append(a?N.empty:N.from(i))))return!1;let p=r.pos,f=p+o.nodeSize;return s.step(new ve(p-(l?1:0),f+(a?1:0),p+1,f-1,new P((l?N.empty:N.from(i.copy(N.empty))).append(a?N.empty:N.from(i.copy(N.empty))),l?0:1,a?0:1),l?0:1)),e(s.scrollIntoView()),!0}function ny(n){return function(e,t){let{$from:s,$to:i}=e.selection,r=s.blockRange(i,d=>d.childCount>0&&d.firstChild.type==n);if(!r)return!1;let o=r.startIndex;if(o==0)return!1;let l=r.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let d=a.lastChild&&a.lastChild.type==l.type,u=N.from(d?n.create():null),p=new P(N.from(n.create(null,N.from(l.type.create(null,u)))),d?3:1,0),f=r.start,h=r.end;t(e.tr.step(new ve(f-(d?3:1),h,f,h,p,1,!0)).scrollIntoView())}return!0}}const Se=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},vn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Sr=null;const ot=function(n,e,t){let s=Sr||(Sr=document.createRange());return s.setEnd(n,t==null?n.nodeValue.length:t),s.setStart(n,e||0),s},sy=function(){Sr=null},Qt=function(n,e,t,s){return t&&(ll(n,e,t,s,-1)||ll(n,e,t,s,1))},iy=/^(img|br|input|textarea|hr)$/i;function ll(n,e,t,s,i){for(var r;;){if(n==t&&e==s)return!0;if(e==(i<0?0:Ee(n))){let o=n.parentNode;if(!o||!F(o)||ps(n)||iy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Se(n)+(i<0?0:1),n=o}else if(F(n)){let o=n.childNodes[e+(i<0?-1:0)];if(F(o)&&o.contentEditable=="false")if(!((r=o.pmViewDesc)===null||r===void 0)&&r.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?Ee(n):0}else return!1}}function Ee(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function F(n){return n.nodeType==1}function me(n){return n.nodeType==3}function en(n,e){return e?n.contains(F(e)?e:e.parentNode):!1}function ry(n,e){for(;;){if(me(n)&&e)return n;if(F(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Ee(n)}else if(n.parentNode&&!ps(n))e=Se(n),n=n.parentNode;else return null}}function oy(n,e){for(;;){if(me(n)&&e2),qe=kn||(et?/Mac/.test(et.platform):!1),Oc=et?/Win/.test(et.platform):!1,at=/Android \d/.test(Pt),$i=!!al&&"webkitFontSmoothing"in al.documentElement.style,dy=$i?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function uy(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function tt(n,e){return typeof n=="number"?n:n[e]}function py(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,s=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*s}}function cl(n,e,t){if(!Er(e)&&e.left==0)return;let s=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(!F(o)){o=vn(o);continue}let l=o==r.body,a=l?uy(r):py(o),d=0,u=0;if(e.topa.bottom-tt(s,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+tt(i,"top")-a.top:e.bottom-a.bottom+tt(i,"bottom")),e.lefta.right-tt(s,"right")&&(d=e.right-a.right+tt(i,"right")),d||u)if(l)r.defaultView.scrollBy(d,u);else{let f=o.scrollLeft,h=o.scrollTop;u&&(o.scrollTop+=u),d&&(o.scrollLeft+=d);let m=o.scrollLeft-f,g=o.scrollTop-h;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let p=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:vn(o)}}function fy(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),s,i;for(let r=(e.left+e.right)/2,o=t+1;o=t-20){s=l,i=a.top;break}}return{refDOM:s,refTop:i,stack:Nc(n.dom)}}function Nc(n){let e=[],t=n.ownerDocument;for(let s=n;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),n!=t);s=vn(s));return e}function hy({refDOM:n,refTop:e,stack:t}){let s=n?n.getBoundingClientRect().top:0;Ic(t,s==0?0:s-e)}function Ic(n,e){for(let t=0;t=l){o=Math.max(m.bottom,o),l=Math.min(m.top,l);let g=m.left>e.left?m.left-e.left:m.right=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!a&&m.left<=e.left&&m.right>=e.left&&(a=u,d={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(r=p+1)}}return!t&&a&&(t=a,i=d,s=0),t&&me(t)?gy(t,i):!t||s?{node:n,offset:r}:Dc(t,i)}function gy(n,e){let t=n.nodeValue.length,s=document.createRange(),i;for(let r=0;r=(o.left+o.right)/2?1:0)};break}}return s.detach(),i||{node:n,offset:0}}function lo(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function by(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(s,i,r)}function vy(n,e,t,s){let i=-1;for(let r=e,o=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!0),a;if(!l)return null;if(F(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>s.left||a.top>s.top?i=l.posBefore:(!o&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function Rc(n,e,t){let s=n.childNodes.length;if(s&&t.tope.top&&i++}let d;$i&&i&&F(s)&&F(d=s.childNodes[i-1])&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&i--,s==n.dom&&i==s.childNodes.length-1&&F(s.lastChild)&&e.top>s.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||!F(s)||s.childNodes[i-1].nodeName!="BR")&&(l=vy(n,s,i,e))}l==null&&(l=yy(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Er(n){return n.top=0&&i==s.nodeValue.length?(a--,u=1):t<0?a--:d++,An(yt(ot(s,a,d),u),u<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&i&&(t<0||i==Ee(s))){let a=s.childNodes[i-1];if(F(a))return tr(a.getBoundingClientRect(),!1)}if(r==null&&i=0)}if(r==null&&i&&(t<0||i==Ee(s))){let a=s.childNodes[i-1],d=me(a)?ot(a,Ee(a)-(o?0:1)):F(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(d)return An(yt(d,1),!1)}if(r==null&&i=0)}function An(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function tr(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Pc(n,e,t){let s=n.state,i=n.root.activeElement;s!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{s!=e&&n.updateState(s),i!=n.dom&&i&&i.focus()}}function wy(n,e,t){let s=e.selection,i=t=="up"?s.$from:s.$to;return Pc(n,e,()=>{let{node:r}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let o=Lc(n,i.pos,1);for(let l=r.firstChild;l;l=l.nextSibling){let a;if(F(l))a=l.getClientRects();else if(me(l))a=ot(l,0,l.nodeValue.length).getClientRects();else continue;for(let d=0;du.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const Sy=/[\u0590-\u08ac]/;function Cy(n,e,t){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let i=s.parentOffset,r=!i,o=i==s.parent.content.size,l=n.domSelection();return l?!Sy.test(s.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:o:Pc(n,e,()=>{let{focusNode:a,focusOffset:d,anchorNode:u,anchorOffset:p}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=s.depth?n.docView.domAfterPos(s.before()):n.dom,{focusNode:m,focusOffset:g}=n.domSelectionRange(),b=m&&!en(h,m)||a==m&&d==g;try{l.collapse(u,p),a&&(a!=u||d!=p)&&l.extend&&l.extend(a,d)}catch(y){}return f!=null&&(l.caretBidiLevel=f),b}):s.pos==s.start()||s.pos==s.end()}let dl=null,ul=null,pl=!1;function My(n,e,t){return dl==e&&ul==t?pl:(dl=e,ul=t,pl=t=="up"||t=="down"?wy(n,e,t):Cy(n,e,t))}const We=0,fl=1,_t=2,Je=3;class fs{constructor(e,t,s,i){this.parent=e,this.children=t,this.dom=s,this.contentDOM=i,this.dirty=We,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,s){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tSe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(t==0)for(let r=e;;r=r.parentNode){if(r==this.dom){i=!1;break}if(r.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){i=!0;break}if(r.nextSibling)break}}return(i==null?s>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let s=!0,i=e;i;i=i.parentNode){let r=this.getDesc(i),o;if(r&&(!t||r.node))if(s&&(o=r.nodeDOM)&&!(F(o)?en(o,e):o==e))s=!1;else return r}}getDesc(e){let t=e.pmViewDesc;for(let s=t;s;s=s.parent)if(s==this)return t}posFromDOM(e,t,s){for(let i=e;i;i=i.parentNode){let r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,s)}return-1}descAt(e){for(let t=0,s=0;te){i=e-r;break}r=l}if(i)return this.children[s].domFromPos(i-this.children[s].border,t);for(;s>0;s--){let r=this.children[s-1];if(r.size||!(r instanceof Bc||r instanceof $c&&r.side>=0))break}if(t<=0){let r,o=!0;for(;r=s?this.children[s-1]:null,!(!r||r.dom.parentNode==this.contentDOM);s--,o=!1);return r&&t&&o&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?Se(r.dom)+1:0}}else{let r,o=!0;for(;r=s=u&&t<=d-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=o;for(let p=l;p>0;p--){let f=this.children[p-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Se(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(d>t||l==this.children.length-1)){t=d;for(let u=l+1;um&&ot){let m=l;l=a,a=m}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),d.removeAllRanges(),d.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let s=0,i=0;i=s:es){let l=s+r.border,a=o-r.border;if(e>=l&&t<=a){this.dirty=e==s||t==o?_t:fl,e==l&&t==a&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=Je:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?_t:Je}s=o}this.dirty=_t}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let s=e==1?_t:fl;t.dirty{if(!r)return i;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){let l=F(o)?o:document.createElement("span");l!=o&&l.appendChild(o),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==We&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Ty extends fs{constructor(e,t,s,i){super(e,[],t,null),this.textDOM=s,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Et extends fs{constructor(e,t,s,i,r){super(e,[],s,i),this.mark=t,this.spec=r}static create(e,t,s,i){let r=i.nodeViews[t.type.name],o=r&&r(t,i,s);return(!o||!o.dom)&&(o=nn.renderSpec(document,t.type.spec.toDOM(t,s),null,t.attrs)),new Et(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Je||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Je&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=We){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty0&&(r=Or(r,0,e,s));for(let l=0;l{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},s,i),u=d&&d.dom,p=d&&d.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(!me(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:p}=nn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=jc(u,s,t),d?a=new Ey(e,t,s,i,u,p||null,f,d):t.isText?new Bi(e,t,s,i,u,f):new At(e,t,s,i,u,p||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let s=this.children.length-1;s>=0;s--){let i=this.children[s];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let s=e&&e.find(i=>F(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));s?t.contentElement=s:t.getContent=()=>N.empty}}return t}matchesNode(e,t,s){return this.dirty==We&&e.eq(this.node)&&Ks(t,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let s=this.node.inlineContent,i=t,r=e.composing?this.localCompositionInfo(e,t):null,o=r&&r.pos>-1?r:null,l=r&&r.pos<0,a=new Oy(this,o&&o.node,e),d=this.node.inlineContent,u=d&&this.node.isBlock;Dy(this.node,this.innerDeco,(p,f,h)=>{p.spec.marks?a.syncToMarks(p.spec.marks,s,e,f):p.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?ee.none:this.node.child(f).marks,s,e,f),a.placeWidget(p,e,i)},(p,f,h,m)=>{a.syncToMarks(p.marks,s,e,m),u&&p.isAtom&&!p.isText&&a.addHackNode("IMG",a.top);let g;a.findNodeMatch(p,f,h,m)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(p,f,h,g,e)||a.updateNextNode(p,f,h,e,m,i)||a.addNode(p,f,h,e,i),i+=p.nodeSize,d&&(u=p.isAtom&&!p.isText)}),a.syncToMarks([],s,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==_t)&&(o&&this.protectLocalComposition(e,o),zc(this.contentDOM,this.children,e),kn&&Ry(this.dom))}localCompositionInfo(e,t){let{from:s,to:i}=e.state.selection;if(!(e.state.selection instanceof V)||st+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let o=r.nodeValue,l=Ly(this.node.content,o,s-t,i-t);return l<0?null:{node:r,pos:l,text:o}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:s,text:i}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let o=new Ty(this,r,t,i);e.input.compositionNodes.push(o),this.children=Or(this.children,s,s+i.length,e,o)}update(e,t,s,i){return this.dirty==Je||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,s,i),!0)}updateInner(e,t,s,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=We}updateOuterDeco(e){if(Ks(e,this.outerDeco))return;let t=!F(this.nodeDOM),s=this.dom;this.dom=_c(this.dom,this.nodeDOM,Ar(this.outerDeco,this.node,t),Ar(e,this.node,t)),this.dom!=s&&(s.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){F(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){F(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function hl(n,e,t,s,i){jc(s,e,n);let r=new At(void 0,n,e,t,s,s,s);return r.contentDOM&&r.updateChildren(i,0),r}class Bi extends At{constructor(e,t,s,i,r,o){super(e,t,s,i,r,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,s,i){return this.dirty==Je||this.dirty!=We&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=We||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=We,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,s){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,s){let i=this.node.cut(e,t),r=document.createTextNode(i.text);return new Bi(this.parent,i,this.outerDeco,this.innerDeco,r,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Je)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Bc extends fs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==We&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ey extends At{constructor(e,t,s,i,r,o,l,a){super(e,t,s,i,r,o,l),this.spec=a}update(e,t,s,i){if(this.dirty==Je)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,s);return r&&this.updateInner(e,t,s,i),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,s,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,s,i){this.spec.setSelection?this.spec.setSelection(e,t,s.root):super.setSelection(e,t,s,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function zc(n,e,t){let s=n.firstChild,i=!1;for(let r=0;r>1,l=Math.min(o,e.length);for(;r-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Et.create(this.top,e[o],t,s);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,s,i){let r=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,s))r=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(s){let d=t.children[s-1];if(d instanceof Et)t=d,s=d.children.length;else{l=d,s--;break}}else{if(t==e)break e;s=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,r.set(l,i),o.push(l)}}return{index:i,matched:r,matches:o.reverse()}}function Iy(n,e){return n.type.side-e.type.side}function Dy(n,e,t,s){let i=e.locals(n),r=0;if(i.length==0){for(let d=0;dr;)l.push(i[o++]);let m=r+f.nodeSize;if(f.isText){let b=m;o!b.inline):l.slice();s(f,g,e.forChild(r,f),h),r=m}}function Ry(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Ly(n,e,t,s){for(let i=0,r=0;i=t){if(r>=s&&a.slice(s-e.length-l,s-l)==e)return s-e.length;let d=l=0&&d+e.length+l>=t)return l+d;if(t==s&&a.length>=s+e.length-l&&a.slice(s-l,s-l+e.length)==e)return s}}return-1}function Or(n,e,t,s,i){let r=[];for(let o=0,l=0;o=t||u<=e?r.push(a):(dt&&r.push(a.slice(t-d,a.size,s)))}return r}function ao(n,e=null){let t=n.domSelectionRange(),s=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),r=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=s.resolve(o),a,d;if(Pi(t)){for(a=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&H.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&ly(t.focusNode,t.focusOffset,i.dom))){let p=i.posBefore;d=new H(o==p?l:s.resolve(p))}else if(Fe&&e=="key"&&o>n.state.selection.to&&F(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&i&&i.posAtStart>n.state.selection.to)for(let p=t.focusNode;;p=p.parentNode){if(getComputedStyle(p).overflow!="visible"){d=W.findFrom(s.resolve(i.posAtStart),1);break}if(p==i.dom||p.nextSibling||!p.parentNode||!F(p.parentNode))break}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=o,f=o;for(let h=0;h{(t.anchorNode!=s||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Fc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function $y(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,s=t.nodeName=="IMG";s?e.collapse(t.parentNode,Se(t)+1):e.collapse(t,0),!s&&!n.state.selection.visible&&$e&&Tt<=11&&(t.disabled=!0,t.disabled=!1)}function Vc(n,e){if(e instanceof H){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(vl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else vl(n)}function vl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function co(n,e,t,s){return n.someProp("createSelectionBetween",i=>i(n,e,t))||V.between(e,t,s)}function kl(n){return n.editable&&!n.hasFocus()?!1:Hc(n)}function Hc(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return en(n.dom,e.anchorNode)&&(n.editable||en(n.dom,e.focusNode))}catch(t){return!1}}function By(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Qt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Nr(n,e){let{$anchor:t,$head:s}=n.selection,i=e>0?t.max(s):t.min(s),r=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return r&&W.findFrom(r,e)}function vt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function xl(n,e,t){let s=n.state.selection;if(s instanceof V)if(t.indexOf("s")>-1){let{$head:i}=s,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+r.nodeSize*(e<0?-1:1));return vt(n,new V(s.$anchor,o))}else if(s.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Nr(n.state,e);return i&&i instanceof H?vt(n,i):!1}else if(!(qe&&t.indexOf("m")>-1)){let i=s.$head,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!r||r.isText)return!1;let l=e<0?i.pos-r.nodeSize:i.pos;return r.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?H.isSelectable(r)?vt(n,new H(e<0?n.state.doc.resolve(i.pos-r.nodeSize):i)):vt(n,new V(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1}}else return!1;else{if(s instanceof H&&s.node.isInline)return vt(n,new V(e>0?s.$to:s.$from));{let i=Nr(n.state,e);return i?vt(n,i):!1}}}function Fn(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):F(n)&&n.contentEditable=="false"}function ln(n,e){return e<0?zy(n):_y(n)}function zy(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let i,r,o=!1;for(Fe&&F(t)&&s0){if(!F(t))break;let l=t.childNodes[s-1];if(Fn(l,-1))i=t,r=--s;else if(me(l))t=l,s=t.nodeValue.length;else break}else{if(qc(t))break;{let l=t.previousSibling;for(;l&&Fn(l,-1);)i=t.parentNode,r=Se(l),l=l.previousSibling;if(l)t=l,s=Ee(t);else{if(t=t.parentNode,t==n.dom)break;s=0}}}o?Ir(n,t,s):i&&Ir(n,i,r)}function _y(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let i=Ee(t),r,o;for(;;)if(s{n.state==i&&ut(n)},50)}function wl(n,e){let t=n.state.doc.resolve(e);if(!(Me||Oc)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),o=(r.top+r.bottom)/2;if(o>i.top&&o1)return r.lefti.top&&o1)return r.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Sl(n,e,t){let s=n.state.selection;if(s instanceof V&&!s.empty||t.indexOf("s")>-1||qe&&t.indexOf("m")>-1)return!1;let{$from:i,$to:r}=s;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Nr(n.state,e);if(o&&o instanceof H)return vt(n,o)}if(!i.parent.inlineContent){let o=e<0?i:r,l=s instanceof je?W.near(o,e):W.findFrom(o,e);return l?vt(n,l):!1}return!1}function Cl(n,e){if(!(n.state.selection instanceof V))return!0;let{$head:t,$anchor:s,empty:i}=n.state.selection;if(!t.sameParent(s))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let o=n.state.tr;return e<0?o.delete(t.pos-r.nodeSize,t.pos):o.delete(t.pos,t.pos+r.nodeSize),n.dispatch(o),!0}return!1}function Ml(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Vy(n){if(!Ae||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&F(e)&&t==0&&e.firstChild&&F(e.firstChild)&&e.firstChild.contentEditable=="false"){let s=e.firstChild;Ml(n,s,"true"),setTimeout(()=>Ml(n,s,"false"),20)}return!1}function Hy(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function qy(n,e){let t=e.keyCode,s=Hy(e);if(t==8||qe&&t==72&&s=="c")return Cl(n,-1)||ln(n,-1);if(t==46&&!e.shiftKey||qe&&t==68&&s=="c")return Cl(n,1)||ln(n,1);if(t==13||t==27)return!0;if(t==37||qe&&t==66&&s=="c"){let i=t==37?wl(n,n.state.selection.from)=="ltr"?-1:1:-1;return xl(n,i,s)||ln(n,i)}else if(t==39||qe&&t==70&&s=="c"){let i=t==39?wl(n,n.state.selection.from)=="ltr"?1:-1:1;return xl(n,i,s)||ln(n,i)}else{if(t==38||qe&&t==80&&s=="c")return Sl(n,-1,s)||ln(n,-1);if(t==40||qe&&t==78&&s=="c")return Vy(n)||Sl(n,1,s)||ln(n,1);if(s==(qe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function uo(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:s,openStart:i,openEnd:r}=e;for(;i>1&&r>1&&s.childCount==1&&s.firstChild.childCount==1;){i--,r--;let h=s.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),s=h.content}let o=n.someProp("clipboardSerializer")||nn.fromSchema(n.state.schema),l=Yc(),a=l.createElement("div");a.appendChild(o.serializeFragment(s,{document:l}));let d=a.firstChild,u,p=0;for(;d&&F(d)&&(u=Gc[d.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let m=l.createElement(u[h]);for(;a.firstChild;)m.appendChild(a.firstChild);a.appendChild(m),p++}d=a.firstChild}d&&F(d)&&d.setAttribute("data-pm-slice",`${i} ${r}${p?` -${p}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
+
+`);return{dom:a,text:f,slice:e}}function Wc(n,e,t,s,i){let r=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(s||r||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,r||s,n)}),r)return l=new P(N.from(n.state.schema.text(e.replace(/\r\n?/g,`
+`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let p=n.someProp("clipboardTextParser",f=>f(e,i,s,n));if(p)l=p;else{let f=i.marks(),{schema:h}=n.state,m=nn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let b=o.appendChild(document.createElement("p"));g&&b.appendChild(m.serializeNode(h.text(g,f)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),o=Jy(t),$i&&Gy(o);let d=o&&o.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let p=+u[3];p>0;p--){let f=o.firstChild;for(;f&&!F(f);)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Mt.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Wy.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Yy(Tl(l,+u[1],+u[2]),u[4]);else if(l=P.maxOpen(Uy(l.content,i),!0),l.openStart||l.openEnd){let p=0,f=0;for(let h=l.content.firstChild;p{l=p(l,n,a)}),l}const Wy=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Uy(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),r,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),d;if(!a)return o=null;if(d=o.length&&r.length&&Kc(a,r,l,o[o.length-1],0))o[o.length-1]=d;else{o.length&&(o[o.length-1]=Jc(o[o.length-1],r.length));let u=Uc(l,a);o.push(u),i=i.matchType(u.type),r=a}}),o)return N.from(o)}return n}function Uc(n,e,t=0){for(let s=e.length-1;s>=t;s--)n=e[s].create(null,N.from(n));return n}function Kc(n,e,t,s,i){if(i1&&(r=0),i=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,r<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(N.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Tl(n,e,t){return et})}return On.createHTML(n)}function Jy(n){let e=/^(\s* ]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Yc(),s=t.body,i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&Gc[i[1].toLowerCase()])&&(n=r.map(o=>"<"+o+">").join("")+n+r.map(o=>""+o+">").reverse().join("")),s.innerHTML=Ky(n),r)for(let o=0;o=0;l-=2){let a=t.nodes[s[l]];if(!a||a.hasRequiredAttrs())break;try{i=N.from(a.create(s[l+1],i))}catch(d){break}r++,o++}return new P(i,r,o)}const Ie={},De={},Xy={touchstart:!0,touchmove:!0};class Zy{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Qy(n){for(let e in Ie){let t=Ie[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=s=>{tv(n,s)&&!po(n,s)&&(n.editable||!(s.type in De))&&t(n,s)},Xy[e]?{passive:!0}:void 0)}Ae&&n.dom.addEventListener("input",()=>null),Rr(n)}function ct(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function ev(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Rr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=s=>po(n,s))})}function po(n,e){return n.someProp("handleDOMEvents",t=>{let s=t[e.type];return s?s(n,e)||e.defaultPrevented:!1})}function tv(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function nv(n,e){!po(n,e)&&Ie[e.type]&&(n.editable||!(e.type in De))&&Ie[e.type](n,e)}De.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!ed(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(at&&Me&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),kn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let s=Date.now();n.input.lastIOSEnter=s,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==s&&(n.someProp("handleKeyDown",i=>i(n,zt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",s=>s(n,t))||qy(n,t)?t.preventDefault():ct(n,"key")};De.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};De.keypress=(n,e)=>{let t=e;if(ed(n)||!t.charCode||t.ctrlKey&&!t.altKey||qe&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let s=n.state.selection;if(!(s instanceof V)||!s.$from.sameParent(s.$to)){let i=String.fromCharCode(t.charCode),r=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,s.$from.pos,s.$to.pos,i,r))&&n.dispatch(r()),t.preventDefault()}};function hs(n){return{left:n.clientX,top:n.clientY}}function sv(n,e){let t=e.x-n.clientX,s=e.y-n.clientY;return t*t+s*s<100}function fo(n,e,t,s,i){if(s==-1)return!1;let r=n.state.doc.resolve(s);for(let o=r.depth+1;o>0;o--)if(n.someProp(e,l=>o>r.depth?l(n,t,r.nodeAfter,r.before(o),i,!0):l(n,t,r.node(o),r.before(o),i,!1)))return!0;return!1}function ms(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let s=n.state.tr.setSelection(e);s.setMeta("pointer",!0),n.dispatch(s)}function iv(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),s=t.nodeAfter;return s&&s.isAtom&&H.isSelectable(s)?(ms(n,new H(t)),!0):!1}function rv(n,e){if(e==-1)return!1;let t=n.state.selection,s,i;t instanceof H&&(s=t.node);let r=n.state.doc.resolve(e);for(let o=r.depth+1;o>0;o--){let l=o>r.depth?r.nodeAfter:r.node(o);if(H.isSelectable(l)){s&&t.$from.depth>0&&o>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?i=r.before(t.$from.depth):i=r.before(o);break}}return i!=null?(ms(n,H.create(n.state.doc,i)),!0):!1}function ov(n,e,t,s,i){return fo(n,"handleClickOn",e,t,s)||n.someProp("handleClick",r=>r(n,e,s))||(i?rv(n,t):iv(n,t))}function lv(n,e,t,s){return fo(n,"handleDoubleClickOn",e,t,s)||n.someProp("handleDoubleClick",i=>i(n,e,s))}function av(n,e,t,s){return fo(n,"handleTripleClickOn",e,t,s)||n.someProp("handleTripleClick",i=>i(n,e,s))||cv(n,t,s)}function cv(n,e,t){if(t.button!=0)return!1;let s=Xc(n,e,!0),i=n.state.doc;return s?(ms(n,s),s instanceof V&&i.eq(n.state.doc)&&(n.input.mouseDown=new uv(n,s)),!0):!1}function Xc(n,e,t){let s=n.state.doc;if(e==-1)return s.inlineContent?V.create(s,0,s.content.size):null;let i=s.resolve(e);for(let r=i.depth+1;r>0;r--){let o=r>i.depth?i.nodeAfter:i.node(r),l=i.before(r);if(o.inlineContent)return V.create(s,l+1,l+1+o.content.size);if(t&&H.isSelectable(o))return H.create(s,l)}return null}function ho(n){return Js(n)}const Zc=qe?"metaKey":"ctrlKey";Ie.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let s=ho(n),i=Date.now(),r="singleClick";i-n.input.lastClick.time<500&&sv(t,n.input.lastClick)&&!t[Zc]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:r,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(hs(t));o&&(r=="singleClick"?n.input.mouseDown=new dv(n,o,t,!!s):(r=="doubleClick"?lv:av)(n,o.pos,o.inside,t)?t.preventDefault():ct(n,"pointer"))};class Qc{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class dv extends Qc{constructor(e,t,s,i){super(e),this.pos=t,this.event=s,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!s[Zc],this.allowDefault=s.shiftKey;let r,o;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);r=u.parent,o=u.depth?u.before():0}const l=i?null:s.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&F(a.nodeDOM)?a.nodeDOM:null;let{selection:d}=e.state;s.button==0&&(r.type.spec.draggable&&r.type.spec.selectable!==!1||d instanceof H&&d.from<=o&&d.to>o)&&(this.mightDrag={node:r,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Fe&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),ct(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||ut(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(hs(e))),this.updateAllowDefault(e),this.allowDefault||!t?ct(this.view,"pointer"):ov(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ae&&this.mightDrag&&!this.mightDrag.node.isAtom||Me&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(ms(this.view,W.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ct(this.view,"pointer")}move(e){this.updateAllowDefault(e),ct(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class uv extends Qc{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),ct(this.view,"pointer");let t=this.view.posAtCoords(hs(e)),s=t&&Xc(this.view,t.inside,!1);if(!s)return;let{doc:i}=this.view.state,r=this.startSelection,[o,l]=s.from{n.input.lastTouch=Date.now(),ho(n),ct(n,"pointer")};Ie.touchmove=n=>{n.input.lastTouch=Date.now(),ct(n,"pointer")};Ie.contextmenu=n=>ho(n);function ed(n,e){return n.composing?!0:Ae&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const pv=at?5e3:-1;De.compositionstart=De.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof V&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)||Me&&Oc&&fv(n)))n.markCursor=n.state.storedMarks||t.marks(),Js(n,!0),n.markCursor=null;else if(Js(n,!e.selection.empty),Fe&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let s=n.domSelectionRange();for(let i=s.focusNode,r=s.focusOffset;i&&F(i)&&r!=0;){let o=r<0?i.lastChild:i.childNodes[r-1];if(!o)break;if(me(o)){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,r=-1}}n.input.composing=!0}td(n,pv)};function fv(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||!F(e)||t>=e.childNodes.length)return!1;let s=e.childNodes[t];return F(s)&&s.contentEditable=="false"}De.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,td(n,20))};function td(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Js(n),e))}function nd(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function hv(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=ry(e.focusNode,e.focusOffset),s=oy(e.focusNode,e.focusOffset);if(t&&s&&t!=s){let i=s.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||s==r)return r;if(!i||!i.isText(s.nodeValue))return s;if(n.input.compositionNode==s){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return s}}return t||s}function Js(n,e=!1){if(!(at&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),nd(n),e||n.docView&&n.docView.dirty){let t=ao(n),s=n.state.selection;return t&&!t.eq(s)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!s.$from.node(s.$from.sharedDepth(s.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function mv(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let s=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),s.removeAllRanges(),s.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const ss=$e&&Tt<15||kn&&dy<604;Ie.copy=De.cut=(n,e)=>{let t=e,s=n.state.selection,i=t.type=="cut";if(s.empty)return;let r=ss?null:t.clipboardData,o=s.content(),{dom:l,text:a}=uo(n,o);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",a)):mv(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function gv(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function bv(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,s=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),s.parentNode&&s.parentNode.removeChild(s),t?is(n,s.value,null,i,e):is(n,s.textContent,s.innerHTML,i,e)},50)}function is(n,e,t,s,i){let r=Wc(n,e,t,s,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,r||P.empty)))return!0;if(!r)return!1;let o=gv(r),l=o?n.state.tr.replaceSelectionWith(o,s):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function sd(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}De.paste=(n,e)=>{let t=e;if(n.composing&&!at)return;let s=ss?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;s&&is(n,sd(s),s.getData("text/html"),i,t)?t.preventDefault():bv(n,t)};class id{constructor(e,t,s){this.slice=e,this.move=t,this.node=s}}const yv=qe?"altKey":"ctrlKey";function rd(n,e){let t;return n.someProp("dragCopies",s=>{t=t||s(e)}),t!=null?!t:!e[yv]}Ie.dragstart=(n,e)=>{let t=e,s=n.input.mouseDown;if(s&&s.done(),!t.dataTransfer)return;let i=n.state.selection,r=i.empty?null:n.posAtCoords(hs(t)),o;if(!(r&&r.pos>=i.from&&r.pos<=(i instanceof H?i.to-1:i.to))){if(s&&s.mightDrag)o=H.create(n.state.doc,s.mightDrag.pos);else if(t.target&&F(t.target)){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(o=H.create(n.state.doc,p.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:d,slice:u}=uo(n,l);(!t.dataTransfer.files.length||!Me||Ac>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ss?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",ss||t.dataTransfer.setData("text/plain",d),n.dragging=new id(u,rd(n,t),o)};Ie.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};De.dragover=De.dragenter=(n,e)=>e.preventDefault();De.drop=(n,e)=>{try{vv(n,e,n.dragging)}finally{n.dragging=null}};function vv(n,e,t){if(!e.dataTransfer)return;let s=n.posAtCoords(hs(e));if(!s)return;let i=n.state.doc.resolve(s.pos),r=t&&t.slice;r?n.someProp("transformPasted",h=>{r=h(r,n,!1)}):r=Wc(n,sd(e.dataTransfer),ss?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&rd(n,e));if(n.someProp("handleDrop",h=>h(n,e,r||P.empty,o))){e.preventDefault();return}if(!r)return;e.preventDefault();let l=r?oc(n.state.doc,i.pos,r):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(o){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let d=a.mapping.map(l),u=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,p=a.doc;if(u?a.replaceRangeWith(d,d,r.content.firstChild):a.replaceRange(d,d,r),a.doc.eq(p))return;let f=a.doc.resolve(d);if(u&&H.isSelectable(r.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(r.content.firstChild))a.setSelection(new H(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((m,g,b,y)=>h=y),a.setSelection(co(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Ie.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ut(n)},20))};Ie.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ie.beforeinput=(n,e)=>{if(at&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:s}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=s||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",r=>r(n,zt(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in De)Ie[n]=De[n];function rs(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Gs{constructor(e,t){this.toDOM=e,this.spec=t||Jt,this.side=this.spec.side||0}map(e,t,s,i){let{pos:r,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Ne(r-s,r-s,this)}valid(){return!0}eq(e){return this==e||e instanceof Gs&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&rs(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ot{constructor(e,t){this.attrs=e,this.spec=t||Jt}map(e,t,s,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-s,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-s;return r>=o?null:new Ne(r,o,this)}valid(e,t){return t.from=e&&(!r||r(l.spec))&&s.push(l.copy(l.from+i,l.to+i))}for(let o=0;oe){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,s,i+l,r)}}map(e,t,s){return this==Te||e.maps.length==0?this:this.mapInner(e,t,0,0,s||Jt)}mapInner(e,t,s,i,r){let o;for(let l=0;l{let d=a+s,u;if(u=ld(t,l,d)){for(i||(i=this.children.slice());rl&&p.to=e){this.children[l]==e&&(s=this.children[l+2]);break}let r=e+1,o=r+t.content.size;for(let l=0;lr&&a.type instanceof Ot){let d=Math.max(r,a.from)-r,u=Math.min(o,a.to)-r;di.map(e,t,Jt));return wt.from(s)}forChild(e,t){if(t.isLeaf)return Y.empty;let s=[];for(let i=0;it instanceof Y)?e:e.reduce((t,s)=>t.concat(s instanceof Y?s:s.members),[]))}}forEachSet(e){for(let t=0;t{let b=g-m-(h-f);for(let y=0;yT+u-p)continue;let A=l[y]+u-p;h>=A?l[y+1]=f<=A?-2:-1:f>=u&&b&&(l[y]+=b,l[y+1]+=b)}p+=b}),u=t.maps[d].map(u,-1)}let a=!1;for(let d=0;d=s.content.size){a=!0;continue}let f=t.map(n[d+1]+r,-1),h=f-i,{index:m,offset:g}=s.content.findIndex(p),b=s.maybeChild(m);if(b&&g==p&&g+b.nodeSize==h){let y=l[d+2].mapInner(t,b,u+1,n[d]+r+1,o);y!=Te?(l[d]=p,l[d+1]=h,l[d+2]=y):(l[d+1]=-2,a=!0)}else a=!0}if(a){let d=xv(l,n,e,t,i,r,o),u=Ys(d,s,0,o);e=u.local;for(let p=0;pt&&o.to{let d=ld(n,l,a+t);if(d){r=!0;let u=Ys(d,l,t+a+1,s);u!=Te&&i.push(a,a+l.nodeSize,u)}});let o=od(r?ad(n):n,-t).sort(Gt);for(let l=0;l0;)e++;n.splice(e,0,t)}function sr(n){let e=[];return n.someProp("decorations",t=>{let s=t(n.state);s&&s!=Te&&e.push(s)}),n.cursorWrapper&&e.push(Y.create(n.state.doc,[n.cursorWrapper.deco])),wt.from(e)}const wv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Sv=$e&&Tt<=11;class Cv{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Mv{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Cv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Ae&&e.composing&&s.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Sv&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,wv)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(kl(this.view)){if(this.suppressingSelectionUpdates)return ut(this.view);if($e&&Tt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,s;for(let r=e.focusNode;r;r=vn(r))t.add(r);for(let r=e.anchorNode;r;r=vn(r))if(t.has(r)){s=r;break}let i=s&&this.view.docView.nearestDesc(s);if(i&&i.ignoreMutation({type:"selection",target:me(s)?s.parentNode:s}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let s=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&kl(e)&&!this.ignoreSelectionChange(s),r=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;uu.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Me&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let p=u.nextSibling;for(;p&&F(p);){if(p.contentEditable=="false"){u.parentNode.removeChild(u);break}p=p.firstChild}}}else if(Fe&&a.length){let u=a.filter(p=>p.nodeName=="BR");if(u.length==2){let[p,f]=u;p.parentNode&&p.parentNode.parentNode==f.parentNode?f.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!p||Av(e,p)!=h)&&f.remove()}}}let d=null;r<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(r>-1&&(e.docView.markDirty(r,o),Tv(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Ov(e,a)),this.handleDOMChange(r,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||ut(e),this.currentSelection.set(s))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;ur;y--){let T=i.childNodes[y-1],A=T.pmViewDesc;if(T.nodeName=="BR"&&!A){o=y;break}if(!A||A.size)break}let f=n.state.doc,h=n.someProp("domParser")||Mt.fromSchema(n.state.schema),m=f.resolve(l),g=null,b=h.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:r,to:o,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Iv(s),context:m});if(u&&u[0].pos!=null){let y=u[0].pos,T=u[1]&&u[1].pos;T==null&&(T=y),g={anchor:y+l,head:T+l}}return{doc:b,sel:g,from:l,to:a}}const Iv=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(Ae&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let s=document.createElement("div");return s.appendChild(document.createElement("li")),{skip:s}}else if(e.parentNode.lastChild==e||Ae&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Dv=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Rv(n,e,t,s,i){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let x=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,v=ao(n,x);if(v&&!n.state.selection.eq(v)){if(Me&&at&&n.input.lastKeyCode===13&&Date.now()-100D(n,zt(13,"Enter"))))return;let w=n.state.tr.setSelection(v);x=="pointer"?w.setMeta("pointer",!0):x=="key"&&w.scrollIntoView(),r&&w.setMeta("composition",r),n.dispatch(w)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,d=Nv(n,e,t,i),u=n.state.doc,p=u.slice(d.from,d.to),f,h;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||at)&&i.some(x=>F(x)&&!Dv.test(x.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",x=>x(n,zt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(s&&a instanceof V&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))m={start:a.from,endA:a.to,endB:a.to};else{if(d.sel){let x=Il(n,n.state.doc,d.sel);if(x&&!x.eq(n.state.selection)){let v=n.state.tr.setSelection(x);r&&v.setMeta("composition",r),n.dispatch(v)}}return}n.state.selection.fromn.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?m.start=n.state.selection.from:m.endA=n.state.selection.to-2&&n.state.selection.to<=d.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),$e&&Tt<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>d.from&&d.doc.textBetween(m.start-d.from-1,m.start-d.from+1)==" "&&(m.start--,m.endA--,m.endB--);let g=d.doc.resolveNoCache(m.start-d.from),b=d.doc.resolveNoCache(m.endB-d.from),y=u.resolve(m.start),T=g.sameParent(b)&&g.parent.inlineContent&&y.end()>=m.endA;if((kn&&n.input.lastIOSEnter>Date.now()-225&&(!T||i.some(x=>x.nodeName=="DIV"||x.nodeName=="P"))||!T&&$v(d.doc,g.pos,b.pos))&&n.someProp("handleKeyDown",x=>x(n,zt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&Pv(u,m.start,m.endA,g,b)&&n.someProp("handleKeyDown",x=>x(n,zt(8,"Backspace")))){at&&Me&&n.domObserver.suppressSelectionUpdates();return}Me&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),at&&!T&&g.start()!=b.start()&&b.parentOffset==0&&g.depth==b.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==m.endA&&(m.endB-=2,b=d.doc.resolveNoCache(m.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(x){return x(n,zt(13,"Enter"))})},20));let A=m.start,E=m.endA,O=x=>{let v=x||n.state.tr.replace(A,E,d.doc.slice(m.start-d.from,m.endB-d.from));if(d.sel){let w=Il(n,v.doc,d.sel);w&&!(Me&&n.composing&&w.empty&&(m.start!=m.endB||n.input.lastChromeDeleteut(n),20));let x=O(n.state.tr.delete(A,E)),v=u.resolve(m.start).marksAcross(u.resolve(m.endA));v&&x.ensureMarks(v),n.dispatch(x)}else if(m.endA==m.endB&&(I=Lv(g.parent.content.cut(g.parentOffset,b.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let x=O(n.state.tr);I.type=="add"?x.addMark(A,E,I.mark):x.removeMark(A,E,I.mark),n.dispatch(x)}else if(g.parent.child(g.index()).isText&&g.index()==b.index()-(b.textOffset?0:1)){let x=g.parent.textBetween(g.parentOffset,b.parentOffset),v=()=>O(n.state.tr.insertText(x,A,E));n.someProp("handleTextInput",w=>w(n,A,E,x,v))||n.dispatch(v())}else n.dispatch(O());else n.dispatch(O())}function Il(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:co(n,e.resolve(t.anchor),e.resolve(t.head))}function Lv(n,e){let t=n.firstChild.marks,s=e.firstChild.marks,i=t,r=s,o,l,a;for(let u=0;uu.mark(l.addToSet(u.marks));else if(i.length==0&&r.length==1)l=r[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let d=[];for(let u=0;ut||ir(o,!0,!1){r.isTextblock&&o>=e&&o0&&(e||n.indexAfter(s)==n.node(s).childCount);)s--,i++,e=!1;if(t){let r=n.node(s).maybeChild(n.indexAfter(s));for(;r&&!r.isLeaf;)r=r.firstChild,i++}return i}function Bv(n,e,t,s,i){let r=n.findDiffStart(e,t),o=t+n.size,l=t+e.size;if(r==null)return null;let{a,b:d}=n.findDiffEnd(e,o,l);if(i=="end"){let u=Math.max(0,r-Math.min(a,d));s-=a+u-r}if(a=a?r-s:0;r-=u,d=r+(d-a),a=r}else if(d=d?r-s:0;r-=u,a=r+(a-d),d=r}return{start:r,endA:a,endB:d}}class cd{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Zy,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach($l),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Ll(this),Rl(this),this.nodeViews=Pl(this),this.docView=hl(this.state.doc,Dl(this),sr(this),this.dom,this),this.domObserver=new Mv(this,(s,i,r,o)=>Rv(this,s,i,r,o)),this.domObserver.start(),Qy(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Rr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach($l),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let s in this._props)t[s]=this._props[s];t.state=this.state;for(let s in e)t[s]=e[s];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var s;let i=this.state,r=!1,o=!1;e.storedMarks&&this.composing&&(nd(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Pl(this);_v(h,this.nodeViews)&&(this.nodeViews=h,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Rr(this),this.editable=Ll(this),Rl(this);let a=sr(this),d=Dl(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",p=r||!this.docView.matchesNode(e.doc,d,a);(p||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&fy(this);if(o){this.domObserver.stop();let h=p&&($e||Me)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&zv(i.selection,e.selection);if(p){let g=Me?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=hv(this)),(r||!this.docView.update(e.doc,d,a,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=hl(e.doc,d,a,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let m=this.input.mouseDown;h||!(m&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&By(this)&&m.delaySelUpdate())?ut(this,h):(Vc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((s=this.dragging)===null||s===void 0)&&s.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&hy(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!en(this.dom,e))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof H){let t=this.docView.domAfterPos(this.state.selection.from);F(t)&&cl(this,t.getBoundingClientRect(),e)}else cl(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&rt.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return ky(this,e)}coordsAtPos(e,t=1){return Lc(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,s=-1){let i=this.docView.posFromDOM(e,t,s);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return My(this,t||this.state,e)}pasteHTML(e,t){return is(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return is(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return uo(this,e)}destroy(){this.docView&&(ev(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],sr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,sy())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return nv(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?Ae&&this.root.nodeType===11&&ay(this.dom.ownerDocument)==this.dom&&Ev(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}cd.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Dl(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let s in t)s=="class"?e.class+=" "+t[s]:s=="style"?e.style=(e.style?e.style+";":"")+t[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(t[s]))}),e.translate||(e.translate="no"),[Ne.node(0,n.state.doc.content.size,e)]}function Rl(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ne.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ll(n){return!n.someProp("editable",e=>e(n.state)===!1)}function zv(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Pl(n){let e=Object.create(null);function t(s){for(let i in s)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=s[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function _v(n,e){let t=0,s=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)s++;return t!=s}function $l(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Dt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Xs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},jv=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Fv=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ce=0;Ce<10;Ce++)Dt[48+Ce]=Dt[96+Ce]=String(Ce);for(var Ce=1;Ce<=24;Ce++)Dt[Ce+111]="F"+Ce;for(var Ce=65;Ce<=90;Ce++)Dt[Ce]=String.fromCharCode(Ce+32),Xs[Ce]=String.fromCharCode(Ce);for(var rr in Dt)Xs.hasOwnProperty(rr)||(Xs[rr]=Dt[rr]);function Vv(n){var e=jv&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Fv&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Xs:Dt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Hv=typeof navigator!="undefined"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),qv=typeof navigator!="undefined"&&/Win/.test(navigator.platform);function Wv(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let s,i,r,o;for(let l=0;l=t?ke.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ke.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ke.prototype.forEach=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length),t<=s?this.forEachInner(e,t,s,0):this.forEachInvertedInner(e,t,s,0)};ke.prototype.map=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length);var i=[];return this.forEach(function(r,o){return i.push(e(r,o))},t,s),i};ke.from=function(e){return e instanceof ke?e:e&&e.length?new ud(e):ke.empty};var ud=(function(n){function e(s){n.call(this),this.values=s}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,r){return i==0&&r==this.length?this:new e(this.values.slice(i,r))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,r,o,l){for(var a=r;a=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Zs)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Zs)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ke);ke.empty=new ud([]);var Jv=(function(n){function e(t,s){n.call(this),this.left=t,this.right=s,this.length=t.length+s.length,this.depth=Math.max(t.depth,s.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(s){return sl&&this.right.forEachInner(s,Math.max(i-l,0),Math.min(this.length,r)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,r,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(s,i-l,Math.max(r,l)-l,o+l)===!1||r=r?this.right.slice(s-r,i-r):this.left.slice(s,r).append(this.right.slice(0,i-r))},e.prototype.leafAppend=function(s){var i=this.right.leafAppend(s);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(s){var i=this.left.leafPrepend(s);if(i)return new e(i,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e})(ke);const Gv=500;class Ue{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let i,r;t&&(i=this.remapping(s,this.items.length),r=i.maps.length);let o=e.tr,l,a,d=[],u=[];return this.items.forEach((p,f)=>{if(!p.step){i||(i=this.remapping(s,f+1),r=i.maps.length),r--,u.push(p);return}if(i){u.push(new Ye(p.map));let h=p.step.map(i.slice(r)),m;h&&o.maybeStep(h).doc&&(m=o.mapping.maps[o.mapping.maps.length-1],d.push(new Ye(m,void 0,void 0,d.length+u.length))),r--,m&&i.appendMap(m,r)}else o.maybeStep(p.step);if(p.selection)return l=i?p.selection.map(i.slice(r)):p.selection,a=new Ue(this.items.slice(0,s).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,s,i){let r=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;uXv&&(l=Yv(l,d),o-=d),new Ue(l.append(r),o)}remapping(e,t){let s=new ts;return this.items.forEach((i,r)=>{let o=i.mirrorOffset!=null&&r-i.mirrorOffset>=e?s.maps.length-i.mirrorOffset:void 0;s.appendMap(i.map,o)},e,t),s}addMaps(e){return this.eventCount==0?this:new Ue(this.items.append(e.map(t=>new Ye(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let s=[],i=this.items.length-t,r=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=r.getMirror(--a);if(h==null)return;o=Math.min(o,h);let m=r.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),b=f.selection&&f.selection.map(r.slice(a+1,h));b&&l++,s.push(new Ye(m,g,b))}else s.push(new Ye(m))},i);let d=[];for(let f=t;fGv&&(p=p.compress(this.items.length-s.length)),p}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),s=t.maps.length,i=[],r=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&r++;else if(o.step){let a=o.step.map(t.slice(s)),d=a&&a.getMap();if(s--,d&&t.appendMap(d,s),a){let u=o.selection&&o.selection.map(t.slice(s));u&&r++;let p=new Ye(d.invert(),a,u),f,h=i.length-1;(f=i.length&&i[h].merge(p))?i[h]=f:i.push(p)}}else o.map&&s--},this.items.length,0),new Ue(ke.from(i.reverse()),r)}}Ue.empty=new Ue(ke.empty,0);function Yv(n,e){let t;return n.forEach((s,i)=>{if(s.selection&&e--==0)return t=i,!1}),n.slice(t)}class Ye{constructor(e,t,s,i){this.map=e,this.step=t,this.selection=s,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ye(t.getMap().invert(),t,this.selection)}}}class kt{constructor(e,t,s,i,r){this.done=e,this.undone=t,this.prevRanges=s,this.prevTime=i,this.prevComposition=r}}const Xv=20;function Zv(n,e,t,s){let i=t.getMeta(Nt),r;if(i)return i.historyState;t.getMeta(pd)&&(n=new kt(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Nt))return o.getMeta(Nt).redo?new kt(n.done.addTransform(t,void 0,s,zs(e)),n.undone,Bl(t.mapping.maps),n.prevTime,n.prevComposition):new kt(n.done,n.undone.addTransform(t,void 0,s,zs(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-s.newGroupDelay||!Qv(t,n.prevRanges)),d=o?lr(n.prevRanges,t.mapping):Bl(t.mapping.maps);return new kt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,s,zs(e)),Ue.empty,d,t.time,l==null?n.prevComposition:l)}else return(r=t.getMeta("rebased"))?new kt(n.done.rebased(t,r),n.undone.rebased(t,r),lr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new kt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),lr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Qv(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((s,i)=>{for(let r=0;r=e[r]&&(t=!0)}),t}function Bl(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((s,i,r,o)=>e.push(r,o));return e}function lr(n,e){if(!n)return null;let t=[];for(let s=0;s{let i=Nt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(s){let r=e0(i,t,n);r&&s(e?r.scrollIntoView():r)}return!0}}const hd=fd(!1,!0),md=fd(!0,!0);function s0(n){return n.getMeta(Nt)!=null}function zi(n){const{state:e,transaction:t}=n;let{selection:s}=t,{doc:i}=t,{storedMarks:r}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return r},get selection(){return s},get doc(){return i},get tr(){return s=t.selection,i=t.doc,r=t.storedMarks,t}}}var gn=class gd{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:s}=this,{view:i}=t,{tr:r}=s,o=this.buildProps(r);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{const p=a(...u)(o);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(r),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:s,editor:i,state:r}=this,{view:o}=i,l=[],a=!!e,d=e||r.tr,u=()=>(!a&&t&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(d),l.every(f=>f===!0)),p={...Object.fromEntries(Object.entries(s).map(([f,h])=>[f,(...g)=>{const b=this.buildProps(d,t),y=h(...g)(b);return l.push(y),p}])),run:u};return p}static createFakeChain(){const e=new Proxy({},{get:(t,s)=>{if(s!=="then")return s==="run"?()=>!1:()=>e}});return e}createCan(e){const{rawCommands:t,state:s}=this,i=!1,r=e||s.tr,o=this.buildProps(r,i);return{...Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...d)=>a(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(r,i)}}static createFallbackCan(){const e=gd.createFakeChain();return new Proxy({chain:()=>e},{get:(t,s)=>{if(s!=="then")return s==="chain"?t.chain:()=>!1}})}buildProps(e,t=!0){const{rawCommands:s,editor:i,state:r}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:zi({state:r,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(s).map(([a,d])=>[a,(...u)=>d(...u)(l)]))}};return l}};const i0=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{if(!n.isDestroyed){var t;e.dom.blur(),(t=window)===null||t===void 0||(t=t.getSelection())===null||t===void 0||t.removeAllRanges()}}),!0),r0=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),o0=()=>({state:n,tr:e,dispatch:t})=>{const{selection:s}=e,{ranges:i}=s;return t&&i.forEach(({$from:r,$to:o})=>{n.doc.nodesBetween(r.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:d,mapping:u}=e,p=d.resolve(u.map(a)),f=d.resolve(u.map(a+l.nodeSize)),h=p.blockRange(f);if(!h)return;const m=Mn(h);if(l.type.isTextblock){const{defaultType:g}=p.parent.contentMatchAt(p.index());e.setNodeMarkup(h.start,g)}(m||m===0)&&e.lift(h,m)})}),!0},l0=n=>e=>n(e),a0=()=>({state:n,dispatch:e})=>Sc(n,e),c0=(n,e)=>({editor:t,tr:s})=>{const{state:i}=t,r=i.doc.slice(n.from,n.to);s.deleteRange(n.from,n.to);const o=s.mapping.map(e);return s.insert(o,r.content),s.setSelection(new V(s.doc.resolve(Math.max(o-1,0)))),!0},d0=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,s=t.$anchor.node();if(s.content.size>0)return!1;const i=n.selection.$anchor;for(let r=i.depth;r>0;r-=1)if(i.node(r).type===s.type){if(e){const o=i.before(r),l=i.after(r);n.delete(o,l).scrollIntoView()}return!0}return!1};function ge(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}const u0=n=>({tr:e,state:t,dispatch:s})=>{const i=ge(n,t.schema),r=e.selection.$anchor;for(let o=r.depth;o>0;o-=1)if(r.node(o).type===i){if(s){const l=r.before(o),a=r.after(o);e.delete(l,a).scrollIntoView()}return!0}return!1},p0=n=>({tr:e,dispatch:t})=>{const{from:s,to:i}=n;return t&&e.delete(s,i),!0},f0=n=>n.content?/^text(\*|\+)/.test(n.content):!1,_l=(n,e,t)=>{if(!n.parent.isInline||t==="left"&&n.pos>n.start()||t==="right"&&n.pos({from:_l(n,t,"left"),to:_l(e,t,"right")}),m0=()=>({state:n,dispatch:e})=>{if(n.selection.empty)return!1;if(e){const t=n.tr,{ranges:s}=n.selection,i=t.steps.length;s.forEach(r=>{const o=t.mapping.slice(i),l=t.doc.resolve(o.map(r.$from.pos)),a=t.doc.resolve(o.map(r.$to.pos)),{from:d,to:u}=h0(l,a,n.schema);t.deleteRange(d,u)}),t.selection.empty||t.setSelection(V.near(t.doc.resolve(t.selection.from))),t.scrollIntoView(),e(t)}return!0},g0=()=>({commands:n})=>n.keyboardShortcut("Enter"),b0=()=>({state:n,dispatch:e})=>Vb(n,e);function bo(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Qs(n,e,t={strict:!0}){const s=Object.keys(e);return s.length?s.every(i=>t.strict?e[i]===n[i]:bo(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function bd(n,e,t={}){return n.find(s=>s.type===e&&Qs(Object.fromEntries(Object.keys(t).map(i=>[i,s.attrs[i]])),t))}function jl(n,e,t={}){return!!bd(n,e,t)}function yo(n,e,t){if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(a=>a.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(a=>a.type===e))return;if(!t){const a=s.node.marks.find(d=>d.type===e);a&&(t=a.attrs)}if(!bd([...s.node.marks],e,t))return;let i=s.index,r=n.start()+s.offset,o=i+1,l=r+s.node.nodeSize;for(;i>0&&jl([...n.parent.child(i-1).marks],e,t);)i-=1,r-=n.parent.child(i).nodeSize;for(;o({tr:t,state:s,dispatch:i})=>{const r=ft(n,s.schema),{doc:o,selection:l}=t,{$from:a,from:d,to:u}=l;if(i){const p=yo(a,r,e);if(p&&p.from<=d&&p.to>=u){const f=V.create(o,p.from,p.to);t.setSelection(f)}}return!0},v0=n=>e=>{const t=typeof n=="function"?n(e):n;for(let s=0;s({editor:t,view:s,tr:i,dispatch:r})=>{e={scrollIntoView:!0,...e};const o=()=>{(ei()||Fl())&&s.dom.focus(),k0()&&!ei()&&!Fl()&&s.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(s.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};try{if(s.hasFocus()&&n===null||n===!1)return!0}catch(d){return!1}if(r&&n===null&&!yd(t.state.selection))return o(),!0;const l=Lr(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return r&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},w0=(n,e)=>t=>n.every((s,i)=>e(s,{...t,index:i})),S0=(n,e)=>({tr:t,commands:s})=>s.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),vd=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const s=e[t];s.nodeType===3&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?n.removeChild(s):s.nodeType===1&&vd(s)}return n};function Cs(n){if(typeof window=="undefined")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return vd(t)}function kd(n){return typeof(n==null?void 0:n.nodesBetween)=="function"}function xn(n,e,t){if(kd(n))return n;const s=typeof n=="object"&&n!==null;t={slice:!0,parseOptions:{},...t};const i=typeof n=="string";if(s)try{if(Array.isArray(n)&&n.length>0)return N.fromArray(n.map(o=>e.nodeFromJSON(o)));const r=e.nodeFromJSON(n);return t.errorOnInvalidContent&&r.check(),r}catch(r){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",r),xn("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Ps({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(o=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?Mt.fromSchema(a).parseSlice(Cs(n),t.parseOptions):Mt.fromSchema(a).parse(Cs(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const r=Mt.fromSchema(e);return t.slice?r.parseSlice(Cs(n),t.parseOptions).content:r.parse(Cs(n),t.parseOptions)}return xn("",e,t)}function xd(n){return!("type"in n)}function wd(n,e,t){const s=n.steps.length-1;if(s{o===0&&(o=u)}),n.setSelection(W.near(n.doc.resolve(o),t))}const C0=(n,e,t)=>({tr:s,dispatch:i,editor:r})=>{if(i){t={parseOptions:r.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=b=>{r.emit("contentError",{editor:r,error:b,disableCollaboration:()=>{"collaboration"in r.storage&&typeof r.storage.collaboration=="object"&&r.storage.collaboration&&(r.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!r.options.enableContentCheck&&r.options.emitContentError)try{xn(e,r.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(b){a(b)}try{var o;l=xn(e,r.schema,{parseOptions:d,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:r.options.enableContentCheck})}catch(b){return a(b),!1}let{from:u,to:p}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;const m=xd(l)?l.content:[l];if(m.forEach(b=>{b.check(),f=f?b.isText&&b.marks.length===0:!1,h=h?b.isBlock:!1}),u===p&&h){const{parent:b}=s.doc.resolve(u);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(u-=1,p+=1)}let g;if(f)Array.isArray(e)?g=e.map(b=>b.text||"").join(""):kd(e)?g=m.map(b=>{var y;return(y=b.text)!==null&&y!==void 0?y:""}).join(""):typeof e=="object"&&e&&e.text?g=e.text:g=e,s.insertText(g,u,p);else{g=N.from(m);const b=s.doc.resolve(u),y=b.node(),T=b.parentOffset===0,A=y.isText||y.isTextblock,E=y.content.size>0;T&&A&&E&&h&&(u=Math.max(0,u-1)),s.replaceWith(u,p,m)}t.updateSelection&&wd(s,s.steps.length-1,-1),t.applyInputRules&&s.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&s.setMeta("applyPasteRules",{from:u,text:g})}return!0};function Sd(n){for(let e=0;e({tr:e,dispatch:t,editor:s})=>{const{pos:i,attrs:r,content:o,updateSelection:l=!0}=n;let a;typeof i=="number"?a=e.doc.resolve(i):i?a=i:a=e.selection.$from;const d=Sd(a.parent.contentMatchAt(a.index()));if(!d)return!1;const u=Object.keys(d.spec.attrs||{}),p=r?Object.fromEntries(Object.entries(r).filter(([h])=>u.includes(h))):{};let f;if(o){const h=xn(o,s.schema);f=d.createAndFill(p,h)}else f=d.createAndFill(p);return f?(t&&(e.insert(a.pos,f),l&&wd(e,e.steps.length-1,-1)),!0):!1},T0=()=>({state:n,dispatch:e})=>_b(n,e),E0=()=>({state:n,dispatch:e})=>jb(n,e),A0=()=>({state:n,dispatch:e})=>gc(n,e),O0=()=>({state:n,dispatch:e})=>kc(n,e),Cd=(n,e)=>{const t=n.resolve(e),s=t.nodeBefore,i=t.nodeAfter;return!s||!i?!1:!s.type.spec.isolating&&!i.type.spec.isolating},N0=()=>({state:n,dispatch:e,tr:t})=>{try{const s=Di(n.doc,n.selection.$from.pos,-1);return s==null||!Cd(n.doc,s)?!1:(t.join(s,2),e&&e(t),!0)}catch(s){return!1}},I0=()=>({state:n,dispatch:e,tr:t})=>{try{const s=Di(n.doc,n.selection.$from.pos,1);return s==null||!Cd(n.doc,s)?!1:(t.join(s,2),e&&e(t),!0)}catch(s){return!1}},D0=()=>({state:n,dispatch:e})=>Bb(n,e),R0=()=>({state:n,dispatch:e})=>zb(n,e);function Md(){return typeof navigator!="undefined"?/Mac/.test(navigator.platform):!1}function L0(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let s,i,r,o;for(let l=0;l