BossBey File Manager
PHP:
8.2.30
OS:
Linux
User:
imagivibe
Root
/
home
/
imagivibe
/
www
/
app.imagivibe.com
/
public
/
build
/
assets
📤 Upload
📝 New File
📁 New Folder
Close
Editing: app-C2VfCkRN.js
import{e as Z,L as QM}from"./livewire.esm-CvVQJolS.js";import{f as eO,m as tO}from"./fetch-D1QFtid7.js";import{c as nO}from"./clipboard-CBCTDmBy.js";import{R as O0,f as iO}from"./lib.modern-DJaFKjpz.js";const rO="modulepreload",sO=function(n){return"/build/"+n},xy={},Cy=function(e,t,i){let r=Promise.resolve();if(t&&t.length>0){let c=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");r=c(t.map(h=>{if(h=sO(h),h in xy)return;xy[h]=!0;const d=h.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":rO,d||(m.as="script"),m.crossOrigin="",m.href=h,l&&m.setAttribute("nonce",l),document.head.appendChild(m),d)return new Promise((g,v)=>{m.addEventListener("load",g),m.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return r.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};typeof window.pusherConfig<"u"?Cy(async()=>{const{default:n}=await import("./echo-DCHnC3kb.js");return{default:n}},[]).then(({default:n})=>{Cy(async()=>{const{default:e}=await import("./pusher-COAX6J-G.js").then(t=>t.p);return{default:e}},[]).then(({default:e})=>{window.Pusher=e;let t=window.pusherConfig;window.Echo=new n({broadcaster:"pusher",key:t.key,cluster:t.cluster,wsHost:t.wsHost??`ws-${t.cluster}.pusher.com`,wsPort:t.port??80,wssPort:t.port??443,forceTLS:(t.scheme??"https")==="https",enabledTransports:["ws","wss"]})}).catch(e=>console.log("Failed to load Pusher:",e))}).catch(n=>console.log("Failed to load Echo:",n)):console.log("window.pusherConfig is not defined.");function Ey(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function fi(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ey(Object(t),!0).forEach(function(i){oO(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Ey(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function Ql(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ql=function(e){return typeof e}:Ql=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ql(n)}function oO(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Vi(){return Vi=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},Vi.apply(this,arguments)}function aO(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,s;for(s=0;s<i.length;s++)r=i[s],!(e.indexOf(r)>=0)&&(t[r]=n[r]);return t}function lO(n,e){if(n==null)return{};var t=aO(n,e),i,r;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(r=0;r<s.length;r++)i=s[r],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}var cO="1.15.2";function $i(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var Wi=$i(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Aa=$i(/Edge/i),Ty=$i(/firefox/i),jo=$i(/safari/i)&&!$i(/chrome/i)&&!$i(/android/i),I0=$i(/iP(ad|od|hone)/i),D0=$i(/chrome/i)&&$i(/android/i),_0={capture:!1,passive:!1};function Le(n,e,t){n.addEventListener(e,t,!Wi&&_0)}function Re(n,e,t){n.removeEventListener(e,t,!Wi&&_0)}function mc(n,e){if(e){if(e[0]===">"&&(e=e.substring(1)),n)try{if(n.matches)return n.matches(e);if(n.msMatchesSelector)return n.msMatchesSelector(e);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(e)}catch{return!1}return!1}}function uO(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function jn(n,e,t,i){if(n){t=t||document;do{if(e!=null&&(e[0]===">"?n.parentNode===t&&mc(n,e):mc(n,e))||i&&n===t)return n;if(n===t)break}while(n=uO(n))}return null}var ky=/\s+/g;function mn(n,e,t){if(n&&e)if(n.classList)n.classList[t?"add":"remove"](e);else{var i=(" "+n.className+" ").replace(ky," ").replace(" "+e+" "," ");n.className=(i+(t?" "+e:"")).replace(ky," ")}}function ue(n,e,t){var i=n&&n.style;if(i){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(t=n.currentStyle),e===void 0?t:t[e];!(e in i)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),i[e]=t+(typeof t=="string"?"":"px")}}function Vs(n,e){var t="";if(typeof n=="string")t=n;else do{var i=ue(n,"transform");i&&i!=="none"&&(t=i+" "+t)}while(!e&&(n=n.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(t)}function R0(n,e,t){if(n){var i=n.getElementsByTagName(e),r=0,s=i.length;if(t)for(;r<s;r++)t(i[r],r);return i}return[]}function ci(){var n=document.scrollingElement;return n||document.documentElement}function mt(n,e,t,i,r){if(!(!n.getBoundingClientRect&&n!==window)){var s,o,l,c,h,d,p;if(n!==window&&n.parentNode&&n!==ci()?(s=n.getBoundingClientRect(),o=s.top,l=s.left,c=s.bottom,h=s.right,d=s.height,p=s.width):(o=0,l=0,c=window.innerHeight,h=window.innerWidth,d=window.innerHeight,p=window.innerWidth),(e||t)&&n!==window&&(r=r||n.parentNode,!Wi))do if(r&&r.getBoundingClientRect&&(ue(r,"transform")!=="none"||t&&ue(r,"position")!=="static")){var m=r.getBoundingClientRect();o-=m.top+parseInt(ue(r,"border-top-width")),l-=m.left+parseInt(ue(r,"border-left-width")),c=o+s.height,h=l+s.width;break}while(r=r.parentNode);if(i&&n!==window){var g=Vs(r||n),v=g&&g.a,w=g&&g.d;g&&(o/=w,l/=v,p/=v,d/=w,c=o+d,h=l+p)}return{top:o,left:l,bottom:c,right:h,width:p,height:d}}}function Ay(n,e,t){for(var i=mr(n,!0),r=mt(n)[e];i;){var s=mt(i)[t],o=void 0;if(o=r>=s,!o)return i;if(i===ci())break;i=mr(i,!1)}return!1}function js(n,e,t,i){for(var r=0,s=0,o=n.children;s<o.length;){if(o[s].style.display!=="none"&&o[s]!==he.ghost&&(i||o[s]!==he.dragged)&&jn(o[s],t.draggable,n,!1)){if(r===e)return o[s];r++}s++}return null}function Wf(n,e){for(var t=n.lastElementChild;t&&(t===he.ghost||ue(t,"display")==="none"||e&&!mc(t,e));)t=t.previousElementSibling;return t||null}function Nn(n,e){var t=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==he.clone&&(!e||mc(n,e))&&t++;return t}function My(n){var e=0,t=0,i=ci();if(n)do{var r=Vs(n),s=r.a,o=r.d;e+=n.scrollLeft*s,t+=n.scrollTop*o}while(n!==i&&(n=n.parentNode));return[e,t]}function hO(n,e){for(var t in n)if(n.hasOwnProperty(t)){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===n[t][i])return Number(t)}return-1}function mr(n,e){if(!n||!n.getBoundingClientRect)return ci();var t=n,i=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var r=ue(t);if(t.clientWidth<t.scrollWidth&&(r.overflowX=="auto"||r.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(r.overflowY=="auto"||r.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return ci();if(i||e)return t;i=!0}}while(t=t.parentNode);return ci()}function dO(n,e){if(n&&e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function id(n,e){return Math.round(n.top)===Math.round(e.top)&&Math.round(n.left)===Math.round(e.left)&&Math.round(n.height)===Math.round(e.height)&&Math.round(n.width)===Math.round(e.width)}var Xo;function N0(n,e){return function(){if(!Xo){var t=arguments,i=this;t.length===1?n.call(i,t[0]):n.apply(i,t),Xo=setTimeout(function(){Xo=void 0},e)}}}function fO(){clearTimeout(Xo),Xo=void 0}function P0(n,e,t){n.scrollLeft+=e,n.scrollTop+=t}function L0(n){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(n).cloneNode(!0):t?t(n).clone(!0)[0]:n.cloneNode(!0)}function F0(n,e,t){var i={};return Array.from(n.children).forEach(function(r){var s,o,l,c;if(!(!jn(r,e.draggable,n,!1)||r.animated||r===t)){var h=mt(r);i.left=Math.min((s=i.left)!==null&&s!==void 0?s:1/0,h.left),i.top=Math.min((o=i.top)!==null&&o!==void 0?o:1/0,h.top),i.right=Math.max((l=i.right)!==null&&l!==void 0?l:-1/0,h.right),i.bottom=Math.max((c=i.bottom)!==null&&c!==void 0?c:-1/0,h.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var wn="Sortable"+new Date().getTime();function pO(){var n=[],e;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(r){if(!(ue(r,"display")==="none"||r===he.ghost)){n.push({target:r,rect:mt(r)});var s=fi({},n[n.length-1].rect);if(r.thisAnimationDuration){var o=Vs(r,!0);o&&(s.top-=o.f,s.left-=o.e)}r.fromRect=s}})}},addAnimationState:function(i){n.push(i)},removeAnimationState:function(i){n.splice(hO(n,{target:i}),1)},animateAll:function(i){var r=this;if(!this.options.animation){clearTimeout(e),typeof i=="function"&&i();return}var s=!1,o=0;n.forEach(function(l){var c=0,h=l.target,d=h.fromRect,p=mt(h),m=h.prevFromRect,g=h.prevToRect,v=l.rect,w=Vs(h,!0);w&&(p.top-=w.f,p.left-=w.e),h.toRect=p,h.thisAnimationDuration&&id(m,p)&&!id(d,p)&&(v.top-p.top)/(v.left-p.left)===(d.top-p.top)/(d.left-p.left)&&(c=gO(v,m,g,r.options)),id(p,d)||(h.prevFromRect=d,h.prevToRect=p,c||(c=r.options.animation),r.animate(h,v,p,c)),c&&(s=!0,o=Math.max(o,c),clearTimeout(h.animationResetTimer),h.animationResetTimer=setTimeout(function(){h.animationTime=0,h.prevFromRect=null,h.fromRect=null,h.prevToRect=null,h.thisAnimationDuration=null},c),h.thisAnimationDuration=c)}),clearTimeout(e),s?e=setTimeout(function(){typeof i=="function"&&i()},o):typeof i=="function"&&i(),n=[]},animate:function(i,r,s,o){if(o){ue(i,"transition",""),ue(i,"transform","");var l=Vs(this.el),c=l&&l.a,h=l&&l.d,d=(r.left-s.left)/(c||1),p=(r.top-s.top)/(h||1);i.animatingX=!!d,i.animatingY=!!p,ue(i,"transform","translate3d("+d+"px,"+p+"px,0)"),this.forRepaintDummy=mO(i),ue(i,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),ue(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){ue(i,"transition",""),ue(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},o)}}}}function mO(n){return n.offsetWidth}function gO(n,e,t,i){return Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*i.animation}var ks=[],rd={initializeByDefault:!0},Ma={mount:function(e){for(var t in rd)rd.hasOwnProperty(t)&&!(t in e)&&(e[t]=rd[t]);ks.forEach(function(i){if(i.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),ks.push(e)},pluginEvent:function(e,t,i){var r=this;this.eventCanceled=!1,i.cancel=function(){r.eventCanceled=!0};var s=e+"Global";ks.forEach(function(o){t[o.pluginName]&&(t[o.pluginName][s]&&t[o.pluginName][s](fi({sortable:t},i)),t.options[o.pluginName]&&t[o.pluginName][e]&&t[o.pluginName][e](fi({sortable:t},i)))})},initializePlugins:function(e,t,i,r){ks.forEach(function(l){var c=l.pluginName;if(!(!e.options[c]&&!l.initializeByDefault)){var h=new l(e,t,e.options);h.sortable=e,h.options=e.options,e[c]=h,Vi(i,h.defaults)}});for(var s in e.options)if(e.options.hasOwnProperty(s)){var o=this.modifyOption(e,s,e.options[s]);typeof o<"u"&&(e.options[s]=o)}},getEventProperties:function(e,t){var i={};return ks.forEach(function(r){typeof r.eventProperties=="function"&&Vi(i,r.eventProperties.call(t[r.pluginName],e))}),i},modifyOption:function(e,t,i){var r;return ks.forEach(function(s){e[s.pluginName]&&s.optionListeners&&typeof s.optionListeners[t]=="function"&&(r=s.optionListeners[t].call(e[s.pluginName],i))}),r}};function yO(n){var e=n.sortable,t=n.rootEl,i=n.name,r=n.targetEl,s=n.cloneEl,o=n.toEl,l=n.fromEl,c=n.oldIndex,h=n.newIndex,d=n.oldDraggableIndex,p=n.newDraggableIndex,m=n.originalEvent,g=n.putSortable,v=n.extraEventProperties;if(e=e||t&&t[wn],!!e){var w,S=e.options,E="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!Wi&&!Aa?w=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(w=document.createEvent("Event"),w.initEvent(i,!0,!0)),w.to=o||t,w.from=l||t,w.item=r||t,w.clone=s,w.oldIndex=c,w.newIndex=h,w.oldDraggableIndex=d,w.newDraggableIndex=p,w.originalEvent=m,w.pullMode=g?g.lastPutMode:void 0;var k=fi(fi({},v),Ma.getEventProperties(i,e));for(var I in k)w[I]=k[I];t&&t.dispatchEvent(w),S[E]&&S[E].call(e,w)}}var vO=["evt"],tn=function(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=i.evt,s=lO(i,vO);Ma.pluginEvent.bind(he)(e,t,fi({dragEl:q,parentEl:rt,ghostEl:ye,rootEl:je,nextEl:Wr,lastDownEl:ec,cloneEl:Ze,cloneHidden:hr,dragStarted:Lo,putSortable:kt,activeSortable:he.active,originalEvent:r,oldIndex:Bs,oldDraggableIndex:Yo,newIndex:yn,newDraggableIndex:or,hideGhostForTarget:H0,unhideGhostForTarget:V0,cloneNowHidden:function(){hr=!0},cloneNowShown:function(){hr=!1},dispatchSortableEvent:function(l){Wt({sortable:t,name:l,originalEvent:r})}},s))};function Wt(n){yO(fi({putSortable:kt,cloneEl:Ze,targetEl:q,rootEl:je,oldIndex:Bs,oldDraggableIndex:Yo,newIndex:yn,newDraggableIndex:or},n))}var q,rt,ye,je,Wr,ec,Ze,hr,Bs,yn,Yo,or,Ml,kt,Rs=!1,gc=!1,yc=[],$r,qn,sd,od,Oy,Iy,Lo,As,Jo,Zo=!1,Ol=!1,tc,Pt,ad=[],Yd=!1,vc=[],gu=typeof document<"u",Il=I0,Dy=Aa||Wi?"cssFloat":"float",bO=gu&&!D0&&!I0&&"draggable"in document.createElement("div"),$0=(function(){if(gu){if(Wi)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}})(),B0=function(e,t){var i=ue(e),r=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),s=js(e,0,t),o=js(e,1,t),l=s&&ue(s),c=o&&ue(o),h=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+mt(s).width,d=c&&parseInt(c.marginLeft)+parseInt(c.marginRight)+mt(o).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&l.float&&l.float!=="none"){var p=l.float==="left"?"left":"right";return o&&(c.clear==="both"||c.clear===p)?"vertical":"horizontal"}return s&&(l.display==="block"||l.display==="flex"||l.display==="table"||l.display==="grid"||h>=r&&i[Dy]==="none"||o&&i[Dy]==="none"&&h+d>r)?"vertical":"horizontal"},wO=function(e,t,i){var r=i?e.left:e.top,s=i?e.right:e.bottom,o=i?e.width:e.height,l=i?t.left:t.top,c=i?t.right:t.bottom,h=i?t.width:t.height;return r===l||s===c||r+o/2===l+h/2},SO=function(e,t){var i;return yc.some(function(r){var s=r[wn].options.emptyInsertThreshold;if(!(!s||Wf(r))){var o=mt(r),l=e>=o.left-s&&e<=o.right+s,c=t>=o.top-s&&t<=o.bottom+s;if(l&&c)return i=r}}),i},z0=function(e){function t(s,o){return function(l,c,h,d){var p=l.options.group.name&&c.options.group.name&&l.options.group.name===c.options.group.name;if(s==null&&(o||p))return!0;if(s==null||s===!1)return!1;if(o&&s==="clone")return s;if(typeof s=="function")return t(s(l,c,h,d),o)(l,c,h,d);var m=(o?l:c).options.group.name;return s===!0||typeof s=="string"&&s===m||s.join&&s.indexOf(m)>-1}}var i={},r=e.group;(!r||Ql(r)!="object")&&(r={name:r}),i.name=r.name,i.checkPull=t(r.pull,!0),i.checkPut=t(r.put),i.revertClone=r.revertClone,e.group=i},H0=function(){!$0&&ye&&ue(ye,"display","none")},V0=function(){!$0&&ye&&ue(ye,"display","")};gu&&!D0&&document.addEventListener("click",function(n){if(gc)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),gc=!1,!1},!0);var Br=function(e){if(q){e=e.touches?e.touches[0]:e;var t=SO(e.clientX,e.clientY);if(t){var i={};for(var r in e)e.hasOwnProperty(r)&&(i[r]=e[r]);i.target=i.rootEl=t,i.preventDefault=void 0,i.stopPropagation=void 0,t[wn]._onDragOver(i)}}},xO=function(e){q&&q.parentNode[wn]._isOutsideThisEl(e.target)};function he(n,e){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=e=Vi({},e),n[wn]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(n.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return B0(n,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(o,l){o.setData("Text",l.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:he.supportPointer!==!1&&"PointerEvent"in window&&!jo,emptyInsertThreshold:5};Ma.initializePlugins(this,n,t);for(var i in t)!(i in e)&&(e[i]=t[i]);z0(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]=="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=e.forceFallback?!1:bO,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Le(n,"pointerdown",this._onTapStart):(Le(n,"mousedown",this._onTapStart),Le(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(Le(n,"dragover",this),Le(n,"dragenter",this)),yc.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Vi(this,pO())}he.prototype={constructor:he,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(As=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,q):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,i=this.el,r=this.options,s=r.preventOnFilter,o=e.type,l=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,c=(l||e).target,h=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||c,d=r.filter;if(IO(i),!q&&!(/mousedown|pointerdown/.test(o)&&e.button!==0||r.disabled)&&!h.isContentEditable&&!(!this.nativeDraggable&&jo&&c&&c.tagName.toUpperCase()==="SELECT")&&(c=jn(c,r.draggable,i,!1),!(c&&c.animated)&&ec!==c)){if(Bs=Nn(c),Yo=Nn(c,r.draggable),typeof d=="function"){if(d.call(this,e,c,this)){Wt({sortable:t,rootEl:h,name:"filter",targetEl:c,toEl:i,fromEl:i}),tn("filter",t,{evt:e}),s&&e.cancelable&&e.preventDefault();return}}else if(d&&(d=d.split(",").some(function(p){if(p=jn(h,p.trim(),i,!1),p)return Wt({sortable:t,rootEl:p,name:"filter",targetEl:c,fromEl:i,toEl:i}),tn("filter",t,{evt:e}),!0}),d)){s&&e.cancelable&&e.preventDefault();return}r.handle&&!jn(h,r.handle,i,!1)||this._prepareDragStart(e,l,c)}}},_prepareDragStart:function(e,t,i){var r=this,s=r.el,o=r.options,l=s.ownerDocument,c;if(i&&!q&&i.parentNode===s){var h=mt(i);if(je=s,q=i,rt=q.parentNode,Wr=q.nextSibling,ec=i,Ml=o.group,he.dragged=q,$r={target:q,clientX:(t||e).clientX,clientY:(t||e).clientY},Oy=$r.clientX-h.left,Iy=$r.clientY-h.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,q.style["will-change"]="all",c=function(){if(tn("delayEnded",r,{evt:e}),he.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!Ty&&r.nativeDraggable&&(q.draggable=!0),r._triggerDragStart(e,t),Wt({sortable:r,name:"choose",originalEvent:e}),mn(q,o.chosenClass,!0)},o.ignore.split(",").forEach(function(d){R0(q,d.trim(),ld)}),Le(l,"dragover",Br),Le(l,"mousemove",Br),Le(l,"touchmove",Br),Le(l,"mouseup",r._onDrop),Le(l,"touchend",r._onDrop),Le(l,"touchcancel",r._onDrop),Ty&&this.nativeDraggable&&(this.options.touchStartThreshold=4,q.draggable=!0),tn("delayStart",this,{evt:e}),o.delay&&(!o.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Aa||Wi))){if(he.eventCanceled){this._onDrop();return}Le(l,"mouseup",r._disableDelayedDrag),Le(l,"touchend",r._disableDelayedDrag),Le(l,"touchcancel",r._disableDelayedDrag),Le(l,"mousemove",r._delayedDragTouchMoveHandler),Le(l,"touchmove",r._delayedDragTouchMoveHandler),o.supportPointer&&Le(l,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(c,o.delay)}else c()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){q&&ld(q),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Re(e,"mouseup",this._disableDelayedDrag),Re(e,"touchend",this._disableDelayedDrag),Re(e,"touchcancel",this._disableDelayedDrag),Re(e,"mousemove",this._delayedDragTouchMoveHandler),Re(e,"touchmove",this._delayedDragTouchMoveHandler),Re(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?Le(document,"pointermove",this._onTouchMove):t?Le(document,"touchmove",this._onTouchMove):Le(document,"mousemove",this._onTouchMove):(Le(q,"dragend",this),Le(je,"dragstart",this._onDragStart));try{document.selection?nc(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(Rs=!1,je&&q){tn("dragStarted",this,{evt:t}),this.nativeDraggable&&Le(document,"dragover",xO);var i=this.options;!e&&mn(q,i.dragClass,!1),mn(q,i.ghostClass,!0),he.active=this,e&&this._appendGhost(),Wt({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(qn){this._lastX=qn.clientX,this._lastY=qn.clientY,H0();for(var e=document.elementFromPoint(qn.clientX,qn.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(qn.clientX,qn.clientY),e!==t);)t=e;if(q.parentNode[wn]._isOutsideThisEl(e),t)do{if(t[wn]){var i=void 0;if(i=t[wn]._onDragOver({clientX:qn.clientX,clientY:qn.clientY,target:e,rootEl:t}),i&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);V0()}},_onTouchMove:function(e){if($r){var t=this.options,i=t.fallbackTolerance,r=t.fallbackOffset,s=e.touches?e.touches[0]:e,o=ye&&Vs(ye,!0),l=ye&&o&&o.a,c=ye&&o&&o.d,h=Il&&Pt&&My(Pt),d=(s.clientX-$r.clientX+r.x)/(l||1)+(h?h[0]-ad[0]:0)/(l||1),p=(s.clientY-$r.clientY+r.y)/(c||1)+(h?h[1]-ad[1]:0)/(c||1);if(!he.active&&!Rs){if(i&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<i)return;this._onDragStart(e,!0)}if(ye){o?(o.e+=d-(sd||0),o.f+=p-(od||0)):o={a:1,b:0,c:0,d:1,e:d,f:p};var m="matrix(".concat(o.a,",").concat(o.b,",").concat(o.c,",").concat(o.d,",").concat(o.e,",").concat(o.f,")");ue(ye,"webkitTransform",m),ue(ye,"mozTransform",m),ue(ye,"msTransform",m),ue(ye,"transform",m),sd=d,od=p,qn=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!ye){var e=this.options.fallbackOnBody?document.body:je,t=mt(q,!0,Il,!0,e),i=this.options;if(Il){for(Pt=e;ue(Pt,"position")==="static"&&ue(Pt,"transform")==="none"&&Pt!==document;)Pt=Pt.parentNode;Pt!==document.body&&Pt!==document.documentElement?(Pt===document&&(Pt=ci()),t.top+=Pt.scrollTop,t.left+=Pt.scrollLeft):Pt=ci(),ad=My(Pt)}ye=q.cloneNode(!0),mn(ye,i.ghostClass,!1),mn(ye,i.fallbackClass,!0),mn(ye,i.dragClass,!0),ue(ye,"transition",""),ue(ye,"transform",""),ue(ye,"box-sizing","border-box"),ue(ye,"margin",0),ue(ye,"top",t.top),ue(ye,"left",t.left),ue(ye,"width",t.width),ue(ye,"height",t.height),ue(ye,"opacity","0.8"),ue(ye,"position",Il?"absolute":"fixed"),ue(ye,"zIndex","100000"),ue(ye,"pointerEvents","none"),he.ghost=ye,e.appendChild(ye),ue(ye,"transform-origin",Oy/parseInt(ye.style.width)*100+"% "+Iy/parseInt(ye.style.height)*100+"%")}},_onDragStart:function(e,t){var i=this,r=e.dataTransfer,s=i.options;if(tn("dragStart",this,{evt:e}),he.eventCanceled){this._onDrop();return}tn("setupClone",this),he.eventCanceled||(Ze=L0(q),Ze.removeAttribute("id"),Ze.draggable=!1,Ze.style["will-change"]="",this._hideClone(),mn(Ze,this.options.chosenClass,!1),he.clone=Ze),i.cloneId=nc(function(){tn("clone",i),!he.eventCanceled&&(i.options.removeCloneOnHide||je.insertBefore(Ze,q),i._hideClone(),Wt({sortable:i,name:"clone"}))}),!t&&mn(q,s.dragClass,!0),t?(gc=!0,i._loopId=setInterval(i._emulateDragOver,50)):(Re(document,"mouseup",i._onDrop),Re(document,"touchend",i._onDrop),Re(document,"touchcancel",i._onDrop),r&&(r.effectAllowed="move",s.setData&&s.setData.call(i,r,q)),Le(document,"drop",i),ue(q,"transform","translateZ(0)")),Rs=!0,i._dragStartId=nc(i._dragStarted.bind(i,t,e)),Le(document,"selectstart",i),Lo=!0,jo&&ue(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,i=e.target,r,s,o,l=this.options,c=l.group,h=he.active,d=Ml===c,p=l.sort,m=kt||h,g,v=this,w=!1;if(Yd)return;function S(Oe,Yt){tn(Oe,v,fi({evt:e,isOwner:d,axis:g?"vertical":"horizontal",revert:o,dragRect:r,targetRect:s,canSort:p,fromSortable:m,target:i,completed:k,onMove:function(_t,ao){return Dl(je,t,q,r,_t,mt(_t),e,ao)},changed:I},Yt))}function E(){S("dragOverAnimationCapture"),v.captureAnimationState(),v!==m&&m.captureAnimationState()}function k(Oe){return S("dragOverCompleted",{insertion:Oe}),Oe&&(d?h._hideClone():h._showClone(v),v!==m&&(mn(q,kt?kt.options.ghostClass:h.options.ghostClass,!1),mn(q,l.ghostClass,!0)),kt!==v&&v!==he.active?kt=v:v===he.active&&kt&&(kt=null),m===v&&(v._ignoreWhileAnimating=i),v.animateAll(function(){S("dragOverAnimationComplete"),v._ignoreWhileAnimating=null}),v!==m&&(m.animateAll(),m._ignoreWhileAnimating=null)),(i===q&&!q.animated||i===t&&!i.animated)&&(As=null),!l.dragoverBubble&&!e.rootEl&&i!==document&&(q.parentNode[wn]._isOutsideThisEl(e.target),!Oe&&Br(e)),!l.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),w=!0}function I(){yn=Nn(q),or=Nn(q,l.draggable),Wt({sortable:v,name:"change",toEl:t,newIndex:yn,newDraggableIndex:or,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),i=jn(i,l.draggable,t,!0),S("dragOver"),he.eventCanceled)return w;if(q.contains(e.target)||i.animated&&i.animatingX&&i.animatingY||v._ignoreWhileAnimating===i)return k(!1);if(gc=!1,h&&!l.disabled&&(d?p||(o=rt!==je):kt===this||(this.lastPutMode=Ml.checkPull(this,h,q,e))&&c.checkPut(this,h,q,e))){if(g=this._getDirection(e,i)==="vertical",r=mt(q),S("dragOverValid"),he.eventCanceled)return w;if(o)return rt=je,E(),this._hideClone(),S("revert"),he.eventCanceled||(Wr?je.insertBefore(q,Wr):je.appendChild(q)),k(!0);var R=Wf(t,l.draggable);if(!R||kO(e,g,this)&&!R.animated){if(R===q)return k(!1);if(R&&t===e.target&&(i=R),i&&(s=mt(i)),Dl(je,t,q,r,i,s,e,!!i)!==!1)return E(),R&&R.nextSibling?t.insertBefore(q,R.nextSibling):t.appendChild(q),rt=t,I(),k(!0)}else if(R&&TO(e,g,this)){var N=js(t,0,l,!0);if(N===q)return k(!1);if(i=N,s=mt(i),Dl(je,t,q,r,i,s,e,!1)!==!1)return E(),t.insertBefore(q,N),rt=t,I(),k(!0)}else if(i.parentNode===t){s=mt(i);var V=0,U,W=q.parentNode!==t,G=!wO(q.animated&&q.toRect||r,i.animated&&i.toRect||s,g),Y=g?"top":"left",le=Ay(i,"top","top")||Ay(q,"top","top"),ke=le?le.scrollTop:void 0;As!==i&&(U=s[Y],Zo=!1,Ol=!G&&l.invertSwap||W),V=AO(e,i,s,g,G?1:l.swapThreshold,l.invertedSwapThreshold==null?l.swapThreshold:l.invertedSwapThreshold,Ol,As===i);var we;if(V!==0){var pe=Nn(q);do pe-=V,we=rt.children[pe];while(we&&(ue(we,"display")==="none"||we===ye))}if(V===0||we===i)return k(!1);As=i,Jo=V;var _e=i.nextElementSibling,de=!1;de=V===1;var ce=Dl(je,t,q,r,i,s,e,de);if(ce!==!1)return(ce===1||ce===-1)&&(de=ce===1),Yd=!0,setTimeout(EO,30),E(),de&&!_e?t.appendChild(q):i.parentNode.insertBefore(q,de?_e:i),le&&P0(le,0,ke-le.scrollTop),rt=q.parentNode,U!==void 0&&!Ol&&(tc=Math.abs(U-mt(i)[Y])),I(),k(!0)}if(t.contains(q))return k(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Re(document,"mousemove",this._onTouchMove),Re(document,"touchmove",this._onTouchMove),Re(document,"pointermove",this._onTouchMove),Re(document,"dragover",Br),Re(document,"mousemove",Br),Re(document,"touchmove",Br)},_offUpEvents:function(){var e=this.el.ownerDocument;Re(e,"mouseup",this._onDrop),Re(e,"touchend",this._onDrop),Re(e,"pointerup",this._onDrop),Re(e,"touchcancel",this._onDrop),Re(document,"selectstart",this)},_onDrop:function(e){var t=this.el,i=this.options;if(yn=Nn(q),or=Nn(q,i.draggable),tn("drop",this,{evt:e}),rt=q&&q.parentNode,yn=Nn(q),or=Nn(q,i.draggable),he.eventCanceled){this._nulling();return}Rs=!1,Ol=!1,Zo=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Jd(this.cloneId),Jd(this._dragStartId),this.nativeDraggable&&(Re(document,"drop",this),Re(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),jo&&ue(document.body,"user-select",""),ue(q,"transform",""),e&&(Lo&&(e.cancelable&&e.preventDefault(),!i.dropBubble&&e.stopPropagation()),ye&&ye.parentNode&&ye.parentNode.removeChild(ye),(je===rt||kt&&kt.lastPutMode!=="clone")&&Ze&&Ze.parentNode&&Ze.parentNode.removeChild(Ze),q&&(this.nativeDraggable&&Re(q,"dragend",this),ld(q),q.style["will-change"]="",Lo&&!Rs&&mn(q,kt?kt.options.ghostClass:this.options.ghostClass,!1),mn(q,this.options.chosenClass,!1),Wt({sortable:this,name:"unchoose",toEl:rt,newIndex:null,newDraggableIndex:null,originalEvent:e}),je!==rt?(yn>=0&&(Wt({rootEl:rt,name:"add",toEl:rt,fromEl:je,originalEvent:e}),Wt({sortable:this,name:"remove",toEl:rt,originalEvent:e}),Wt({rootEl:rt,name:"sort",toEl:rt,fromEl:je,originalEvent:e}),Wt({sortable:this,name:"sort",toEl:rt,originalEvent:e})),kt&&kt.save()):yn!==Bs&&yn>=0&&(Wt({sortable:this,name:"update",toEl:rt,originalEvent:e}),Wt({sortable:this,name:"sort",toEl:rt,originalEvent:e})),he.active&&((yn==null||yn===-1)&&(yn=Bs,or=Yo),Wt({sortable:this,name:"end",toEl:rt,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){tn("nulling",this),je=q=rt=ye=Wr=Ze=ec=hr=$r=qn=Lo=yn=or=Bs=Yo=As=Jo=kt=Ml=he.dragged=he.ghost=he.clone=he.active=null,vc.forEach(function(e){e.checked=!0}),vc.length=sd=od=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":q&&(this._onDragOver(e),CO(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,i=this.el.children,r=0,s=i.length,o=this.options;r<s;r++)t=i[r],jn(t,o.draggable,this.el,!1)&&e.push(t.getAttribute(o.dataIdAttr)||OO(t));return e},sort:function(e,t){var i={},r=this.el;this.toArray().forEach(function(s,o){var l=r.children[o];jn(l,this.options.draggable,r,!1)&&(i[s]=l)},this),t&&this.captureAnimationState(),e.forEach(function(s){i[s]&&(r.removeChild(i[s]),r.appendChild(i[s]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return jn(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var i=this.options;if(t===void 0)return i[e];var r=Ma.modifyOption(this,e,t);typeof r<"u"?i[e]=r:i[e]=t,e==="group"&&z0(i)},destroy:function(){tn("destroy",this);var e=this.el;e[wn]=null,Re(e,"mousedown",this._onTapStart),Re(e,"touchstart",this._onTapStart),Re(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(Re(e,"dragover",this),Re(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),yc.splice(yc.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!hr){if(tn("hideClone",this),he.eventCanceled)return;ue(Ze,"display","none"),this.options.removeCloneOnHide&&Ze.parentNode&&Ze.parentNode.removeChild(Ze),hr=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(hr){if(tn("showClone",this),he.eventCanceled)return;q.parentNode==je&&!this.options.group.revertClone?je.insertBefore(Ze,q):Wr?je.insertBefore(Ze,Wr):je.appendChild(Ze),this.options.group.revertClone&&this.animate(q,Ze),ue(Ze,"display",""),hr=!1}}};function CO(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function Dl(n,e,t,i,r,s,o,l){var c,h=n[wn],d=h.options.onMove,p;return window.CustomEvent&&!Wi&&!Aa?c=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(c=document.createEvent("Event"),c.initEvent("move",!0,!0)),c.to=e,c.from=n,c.dragged=t,c.draggedRect=i,c.related=r||e,c.relatedRect=s||mt(e),c.willInsertAfter=l,c.originalEvent=o,n.dispatchEvent(c),d&&(p=d.call(h,c,o)),p}function ld(n){n.draggable=!1}function EO(){Yd=!1}function TO(n,e,t){var i=mt(js(t.el,0,t.options,!0)),r=F0(t.el,t.options,ye),s=10;return e?n.clientX<r.left-s||n.clientY<i.top&&n.clientX<i.right:n.clientY<r.top-s||n.clientY<i.bottom&&n.clientX<i.left}function kO(n,e,t){var i=mt(Wf(t.el,t.options.draggable)),r=F0(t.el,t.options,ye),s=10;return e?n.clientX>r.right+s||n.clientY>i.bottom&&n.clientX>i.left:n.clientY>r.bottom+s||n.clientX>i.right&&n.clientY>i.top}function AO(n,e,t,i,r,s,o,l){var c=i?n.clientY:n.clientX,h=i?t.height:t.width,d=i?t.top:t.left,p=i?t.bottom:t.right,m=!1;if(!o){if(l&&tc<h*r){if(!Zo&&(Jo===1?c>d+h*s/2:c<p-h*s/2)&&(Zo=!0),Zo)m=!0;else if(Jo===1?c<d+tc:c>p-tc)return-Jo}else if(c>d+h*(1-r)/2&&c<p-h*(1-r)/2)return MO(e)}return m=m||o,m&&(c<d+h*s/2||c>p-h*s/2)?c>d+h/2?1:-1:0}function MO(n){return Nn(q)<Nn(n)?1:-1}function OO(n){for(var e=n.tagName+n.className+n.src+n.href+n.textContent,t=e.length,i=0;t--;)i+=e.charCodeAt(t);return i.toString(36)}function IO(n){vc.length=0;for(var e=n.getElementsByTagName("input"),t=e.length;t--;){var i=e[t];i.checked&&vc.push(i)}}function nc(n){return setTimeout(n,0)}function Jd(n){return clearTimeout(n)}gu&&Le(document,"touchmove",function(n){(he.active||Rs)&&n.cancelable&&n.preventDefault()});he.utils={on:Le,off:Re,css:ue,find:R0,is:function(e,t){return!!jn(e,t,e,!1)},extend:dO,throttle:N0,closest:jn,toggleClass:mn,clone:L0,index:Nn,nextTick:nc,cancelNextTick:Jd,detectDirection:B0,getChild:js};he.get=function(n){return n[wn]};he.mount=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(he.utils=fi(fi({},he.utils),i.utils)),Ma.mount(i)})};he.create=function(n,e){return new he(n,e)};he.version=cO;var ht=[],Fo,Zd,Qd=!1,cd,ud,bc,$o;function DO(){function n(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return n.prototype={dragStarted:function(t){var i=t.originalEvent;this.sortable.nativeDraggable?Le(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Le(document,"pointermove",this._handleFallbackAutoScroll):i.touches?Le(document,"touchmove",this._handleFallbackAutoScroll):Le(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var i=t.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?Re(document,"dragover",this._handleAutoScroll):(Re(document,"pointermove",this._handleFallbackAutoScroll),Re(document,"touchmove",this._handleFallbackAutoScroll),Re(document,"mousemove",this._handleFallbackAutoScroll)),_y(),ic(),fO()},nulling:function(){bc=Zd=Fo=Qd=$o=cd=ud=null,ht.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,i){var r=this,s=(t.touches?t.touches[0]:t).clientX,o=(t.touches?t.touches[0]:t).clientY,l=document.elementFromPoint(s,o);if(bc=t,i||this.options.forceAutoScrollFallback||Aa||Wi||jo){hd(t,this.options,l,i);var c=mr(l,!0);Qd&&(!$o||s!==cd||o!==ud)&&($o&&_y(),$o=setInterval(function(){var h=mr(document.elementFromPoint(s,o),!0);h!==c&&(c=h,ic()),hd(t,r.options,h,i)},10),cd=s,ud=o)}else{if(!this.options.bubbleScroll||mr(l,!0)===ci()){ic();return}hd(t,this.options,mr(l,!1),!1)}}},Vi(n,{pluginName:"scroll",initializeByDefault:!0})}function ic(){ht.forEach(function(n){clearInterval(n.pid)}),ht=[]}function _y(){clearInterval($o)}var hd=N0(function(n,e,t,i){if(e.scroll){var r=(n.touches?n.touches[0]:n).clientX,s=(n.touches?n.touches[0]:n).clientY,o=e.scrollSensitivity,l=e.scrollSpeed,c=ci(),h=!1,d;Zd!==t&&(Zd=t,ic(),Fo=e.scroll,d=e.scrollFn,Fo===!0&&(Fo=mr(t,!0)));var p=0,m=Fo;do{var g=m,v=mt(g),w=v.top,S=v.bottom,E=v.left,k=v.right,I=v.width,R=v.height,N=void 0,V=void 0,U=g.scrollWidth,W=g.scrollHeight,G=ue(g),Y=g.scrollLeft,le=g.scrollTop;g===c?(N=I<U&&(G.overflowX==="auto"||G.overflowX==="scroll"||G.overflowX==="visible"),V=R<W&&(G.overflowY==="auto"||G.overflowY==="scroll"||G.overflowY==="visible")):(N=I<U&&(G.overflowX==="auto"||G.overflowX==="scroll"),V=R<W&&(G.overflowY==="auto"||G.overflowY==="scroll"));var ke=N&&(Math.abs(k-r)<=o&&Y+I<U)-(Math.abs(E-r)<=o&&!!Y),we=V&&(Math.abs(S-s)<=o&&le+R<W)-(Math.abs(w-s)<=o&&!!le);if(!ht[p])for(var pe=0;pe<=p;pe++)ht[pe]||(ht[pe]={});(ht[p].vx!=ke||ht[p].vy!=we||ht[p].el!==g)&&(ht[p].el=g,ht[p].vx=ke,ht[p].vy=we,clearInterval(ht[p].pid),(ke!=0||we!=0)&&(h=!0,ht[p].pid=setInterval((function(){i&&this.layer===0&&he.active._onTouchMove(bc);var _e=ht[this.layer].vy?ht[this.layer].vy*l:0,de=ht[this.layer].vx?ht[this.layer].vx*l:0;typeof d=="function"&&d.call(he.dragged.parentNode[wn],de,_e,n,bc,ht[this.layer].el)!=="continue"||P0(ht[this.layer].el,de,_e)}).bind({layer:p}),24))),p++}while(e.bubbleScroll&&m!==c&&(m=mr(m,!1)));Qd=h}},30),W0=function(e){var t=e.originalEvent,i=e.putSortable,r=e.dragEl,s=e.activeSortable,o=e.dispatchSortableEvent,l=e.hideGhostForTarget,c=e.unhideGhostForTarget;if(t){var h=i||s;l();var d=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,p=document.elementFromPoint(d.clientX,d.clientY);c(),h&&!h.el.contains(p)&&(o("spill"),this.onSpill({dragEl:r,putSortable:i}))}};function Uf(){}Uf.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,i=e.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var r=js(this.sortable.el,this.startIndex,this.options);r?this.sortable.el.insertBefore(t,r):this.sortable.el.appendChild(t),this.sortable.animateAll(),i&&i.animateAll()},drop:W0};Vi(Uf,{pluginName:"revertOnSpill"});function qf(){}qf.prototype={onSpill:function(e){var t=e.dragEl,i=e.putSortable,r=i||this.sortable;r.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),r.animateAll()},drop:W0};Vi(qf,{pluginName:"removeOnSpill"});he.mount(new DO);he.mount(qf,Uf);var _O=he;function RO(n){n.directive("sort",(e,{value:t,modifiers:i,expression:r},{effect:s,evaluate:o,evaluateLater:l,cleanup:c})=>{if(t==="config"||t==="handle"||t==="group")return;if(t==="key"||t==="item"){if([void 0,null,""].includes(r))return;e._x_sort_key=o(r);return}let h={hideGhost:!i.includes("ghost"),useHandles:!!e.querySelector("[x-sort\\:handle]"),group:$O(e,i)},d=NO(r,l),p=PO(e,i,o),m=LO(e,p,h,(g,v)=>{d(g,v)});c(()=>m.destroy())})}function NO(n,e){if([void 0,null,""].includes(n))return()=>{};let t=e(n);return(i,r)=>{Alpine.dontAutoEvaluateFunctions(()=>{t(s=>{typeof s=="function"&&s(i,r)},{scope:{$key:i,$item:i,$position:r}})})}}function PO(n,e,t){return n.hasAttribute("x-sort:config")?t(n.getAttribute("x-sort:config")):{}}function LO(n,e,t,i){let r,s={animation:150,handle:t.useHandles?"[x-sort\\:handle]":null,group:t.group,filter(o){return n.querySelector("[x-sort\\:item]")?!o.target.closest("[x-sort\\:item]"):!1},onSort(o){if(o.from!==o.to&&o.to!==o.target)return;let l=o.item._x_sort_key,c=o.newIndex;(l!==void 0||l!==null)&&i(l,c)},onStart(){document.body.classList.add("sorting"),r=document.querySelector(".sortable-ghost"),t.hideGhost&&r&&(r.style.opacity="0")},onEnd(){document.body.classList.remove("sorting"),t.hideGhost&&r&&(r.style.opacity="1"),r=void 0,FO(n)}};return new _O(n,{...s,...e})}function FO(n){let e=n.firstChild;for(;e.nextSibling;){if(e.textContent.trim()==="[if ENDBLOCK]><![endif]"){n.append(e);break}e=e.nextSibling}}function $O(n,e){return n.hasAttribute("x-sort:group")?n.getAttribute("x-sort:group"):e.indexOf("group")!==-1?e[e.indexOf("group")+1]:null}var BO=RO;/*! Bundled license information: sortablejs/modular/sortable.esm.js: (**! * Sortable 1.15.2 * @author RubaXa <trash@rubaxa.org> * @author owenm <owen23355@gmail.com> * @license MIT *) */function zO(n){n.directive("intersect",n.skipDuringClone((e,{value:t,expression:i,modifiers:r},{evaluateLater:s,cleanup:o})=>{let l=s(i),c={rootMargin:WO(r),threshold:HO(r)},h=new IntersectionObserver(d=>{d.forEach(p=>{p.isIntersecting!==(t==="leave")&&(l(),r.includes("once")&&h.disconnect())})},c);h.observe(e),o(()=>{h.disconnect()})}))}function HO(n){if(n.includes("full"))return .99;if(n.includes("half"))return .5;if(!n.includes("threshold"))return 0;let e=n[n.indexOf("threshold")+1];return e==="100"?1:e==="0"?0:+`.${e}`}function VO(n){let e=n.match(/^(-?[0-9]+)(px|%)?$/);return e?e[1]+(e[2]||"px"):void 0}function WO(n){const e="margin",t="0px 0px 0px 0px",i=n.indexOf(e);if(i===-1)return t;let r=[];for(let s=1;s<5;s++)r.push(VO(n[i+s]||""));return r=r.filter(s=>s!==void 0),r.length?r.join(" ").trim():t}var UO=zO;/**! * Sortable 1.15.6 * @author RubaXa <trash@rubaxa.org> * @author owenm <owen23355@gmail.com> * @license MIT */function Ry(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function pi(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ry(Object(t),!0).forEach(function(i){qO(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Ry(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function rc(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?rc=function(e){return typeof e}:rc=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rc(n)}function qO(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Zn(){return Zn=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},Zn.apply(this,arguments)}function KO(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,s;for(s=0;s<i.length;s++)r=i[s],!(e.indexOf(r)>=0)&&(t[r]=n[r]);return t}function GO(n,e){if(n==null)return{};var t=KO(n,e),i,r;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(r=0;r<s.length;r++)i=s[r],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}function jO(n){return XO(n)||YO(n)||JO(n)||ZO()}function XO(n){if(Array.isArray(n))return ef(n)}function YO(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function JO(n,e){if(n){if(typeof n=="string")return ef(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ef(n,e)}}function ef(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=n[t];return i}function ZO(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var QO="1.15.6";function Bi(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var Ui=Bi(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Oa=Bi(/Edge/i),Ny=Bi(/firefox/i),Qo=Bi(/safari/i)&&!Bi(/chrome/i)&&!Bi(/android/i),Kf=Bi(/iP(ad|od|hone)/i),U0=Bi(/chrome/i)&&Bi(/android/i),q0={capture:!1,passive:!1};function Te(n,e,t){n.addEventListener(e,t,!Ui&&q0)}function xe(n,e,t){n.removeEventListener(e,t,!Ui&&q0)}function wc(n,e){if(e){if(e[0]===">"&&(e=e.substring(1)),n)try{if(n.matches)return n.matches(e);if(n.msMatchesSelector)return n.msMatchesSelector(e);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(e)}catch{return!1}return!1}}function K0(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function sn(n,e,t,i){if(n){t=t||document;do{if(e!=null&&(e[0]===">"?n.parentNode===t&&wc(n,e):wc(n,e))||i&&n===t)return n;if(n===t)break}while(n=K0(n))}return null}var Py=/\s+/g;function ft(n,e,t){if(n&&e)if(n.classList)n.classList[t?"add":"remove"](e);else{var i=(" "+n.className+" ").replace(Py," ").replace(" "+e+" "," ");n.className=(i+(t?" "+e:"")).replace(Py," ")}}function Q(n,e,t){var i=n&&n.style;if(i){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(t=n.currentStyle),e===void 0?t:t[e];!(e in i)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),i[e]=t+(typeof t=="string"?"":"px")}}function Yr(n,e){var t="";if(typeof n=="string")t=n;else do{var i=Q(n,"transform");i&&i!=="none"&&(t=i+" "+t)}while(!e&&(n=n.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(t)}function G0(n,e,t){if(n){var i=n.getElementsByTagName(e),r=0,s=i.length;if(t)for(;r<s;r++)t(i[r],r);return i}return[]}function ui(){var n=document.scrollingElement;return n||document.documentElement}function Ke(n,e,t,i,r){if(!(!n.getBoundingClientRect&&n!==window)){var s,o,l,c,h,d,p;if(n!==window&&n.parentNode&&n!==ui()?(s=n.getBoundingClientRect(),o=s.top,l=s.left,c=s.bottom,h=s.right,d=s.height,p=s.width):(o=0,l=0,c=window.innerHeight,h=window.innerWidth,d=window.innerHeight,p=window.innerWidth),(e||t)&&n!==window&&(r=r||n.parentNode,!Ui))do if(r&&r.getBoundingClientRect&&(Q(r,"transform")!=="none"||t&&Q(r,"position")!=="static")){var m=r.getBoundingClientRect();o-=m.top+parseInt(Q(r,"border-top-width")),l-=m.left+parseInt(Q(r,"border-left-width")),c=o+s.height,h=l+s.width;break}while(r=r.parentNode);if(i&&n!==window){var g=Yr(r||n),v=g&&g.a,w=g&&g.d;g&&(o/=w,l/=v,p/=v,d/=w,c=o+d,h=l+p)}return{top:o,left:l,bottom:c,right:h,width:p,height:d}}}function Ly(n,e,t){for(var i=gr(n,!0),r=Ke(n)[e];i;){var s=Ke(i)[t],o=void 0;if(o=r>=s,!o)return i;if(i===ui())break;i=gr(i,!1)}return!1}function Xs(n,e,t,i){for(var r=0,s=0,o=n.children;s<o.length;){if(o[s].style.display!=="none"&&o[s]!==ae.ghost&&(i||o[s]!==ae.dragged)&&sn(o[s],t.draggable,n,!1)){if(r===e)return o[s];r++}s++}return null}function Gf(n,e){for(var t=n.lastElementChild;t&&(t===ae.ghost||Q(t,"display")==="none"||e&&!wc(t,e));)t=t.previousElementSibling;return t||null}function pt(n,e){var t=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==ae.clone&&(!e||wc(n,e))&&t++;return t}function Fy(n){var e=0,t=0,i=ui();if(n)do{var r=Yr(n),s=r.a,o=r.d;e+=n.scrollLeft*s,t+=n.scrollTop*o}while(n!==i&&(n=n.parentNode));return[e,t]}function eI(n,e){for(var t in n)if(n.hasOwnProperty(t)){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===n[t][i])return Number(t)}return-1}function gr(n,e){if(!n||!n.getBoundingClientRect)return ui();var t=n,i=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var r=Q(t);if(t.clientWidth<t.scrollWidth&&(r.overflowX=="auto"||r.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(r.overflowY=="auto"||r.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return ui();if(i||e)return t;i=!0}}while(t=t.parentNode);return ui()}function tI(n,e){if(n&&e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function dd(n,e){return Math.round(n.top)===Math.round(e.top)&&Math.round(n.left)===Math.round(e.left)&&Math.round(n.height)===Math.round(e.height)&&Math.round(n.width)===Math.round(e.width)}var ea;function j0(n,e){return function(){if(!ea){var t=arguments,i=this;t.length===1?n.call(i,t[0]):n.apply(i,t),ea=setTimeout(function(){ea=void 0},e)}}}function nI(){clearTimeout(ea),ea=void 0}function X0(n,e,t){n.scrollLeft+=e,n.scrollTop+=t}function jf(n){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(n).cloneNode(!0):t?t(n).clone(!0)[0]:n.cloneNode(!0)}function $y(n,e){Q(n,"position","absolute"),Q(n,"top",e.top),Q(n,"left",e.left),Q(n,"width",e.width),Q(n,"height",e.height)}function fd(n){Q(n,"position",""),Q(n,"top",""),Q(n,"left",""),Q(n,"width",""),Q(n,"height","")}function Y0(n,e,t){var i={};return Array.from(n.children).forEach(function(r){var s,o,l,c;if(!(!sn(r,e.draggable,n,!1)||r.animated||r===t)){var h=Ke(r);i.left=Math.min((s=i.left)!==null&&s!==void 0?s:1/0,h.left),i.top=Math.min((o=i.top)!==null&&o!==void 0?o:1/0,h.top),i.right=Math.max((l=i.right)!==null&&l!==void 0?l:-1/0,h.right),i.bottom=Math.max((c=i.bottom)!==null&&c!==void 0?c:-1/0,h.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var Dt="Sortable"+new Date().getTime();function iI(){var n=[],e;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(r){if(!(Q(r,"display")==="none"||r===ae.ghost)){n.push({target:r,rect:Ke(r)});var s=pi({},n[n.length-1].rect);if(r.thisAnimationDuration){var o=Yr(r,!0);o&&(s.top-=o.f,s.left-=o.e)}r.fromRect=s}})}},addAnimationState:function(i){n.push(i)},removeAnimationState:function(i){n.splice(eI(n,{target:i}),1)},animateAll:function(i){var r=this;if(!this.options.animation){clearTimeout(e),typeof i=="function"&&i();return}var s=!1,o=0;n.forEach(function(l){var c=0,h=l.target,d=h.fromRect,p=Ke(h),m=h.prevFromRect,g=h.prevToRect,v=l.rect,w=Yr(h,!0);w&&(p.top-=w.f,p.left-=w.e),h.toRect=p,h.thisAnimationDuration&&dd(m,p)&&!dd(d,p)&&(v.top-p.top)/(v.left-p.left)===(d.top-p.top)/(d.left-p.left)&&(c=sI(v,m,g,r.options)),dd(p,d)||(h.prevFromRect=d,h.prevToRect=p,c||(c=r.options.animation),r.animate(h,v,p,c)),c&&(s=!0,o=Math.max(o,c),clearTimeout(h.animationResetTimer),h.animationResetTimer=setTimeout(function(){h.animationTime=0,h.prevFromRect=null,h.fromRect=null,h.prevToRect=null,h.thisAnimationDuration=null},c),h.thisAnimationDuration=c)}),clearTimeout(e),s?e=setTimeout(function(){typeof i=="function"&&i()},o):typeof i=="function"&&i(),n=[]},animate:function(i,r,s,o){if(o){Q(i,"transition",""),Q(i,"transform","");var l=Yr(this.el),c=l&&l.a,h=l&&l.d,d=(r.left-s.left)/(c||1),p=(r.top-s.top)/(h||1);i.animatingX=!!d,i.animatingY=!!p,Q(i,"transform","translate3d("+d+"px,"+p+"px,0)"),this.forRepaintDummy=rI(i),Q(i,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),Q(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){Q(i,"transition",""),Q(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},o)}}}}function rI(n){return n.offsetWidth}function sI(n,e,t,i){return Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*i.animation}var Ms=[],pd={initializeByDefault:!0},Ia={mount:function(e){for(var t in pd)pd.hasOwnProperty(t)&&!(t in e)&&(e[t]=pd[t]);Ms.forEach(function(i){if(i.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),Ms.push(e)},pluginEvent:function(e,t,i){var r=this;this.eventCanceled=!1,i.cancel=function(){r.eventCanceled=!0};var s=e+"Global";Ms.forEach(function(o){t[o.pluginName]&&(t[o.pluginName][s]&&t[o.pluginName][s](pi({sortable:t},i)),t.options[o.pluginName]&&t[o.pluginName][e]&&t[o.pluginName][e](pi({sortable:t},i)))})},initializePlugins:function(e,t,i,r){Ms.forEach(function(l){var c=l.pluginName;if(!(!e.options[c]&&!l.initializeByDefault)){var h=new l(e,t,e.options);h.sortable=e,h.options=e.options,e[c]=h,Zn(i,h.defaults)}});for(var s in e.options)if(e.options.hasOwnProperty(s)){var o=this.modifyOption(e,s,e.options[s]);typeof o<"u"&&(e.options[s]=o)}},getEventProperties:function(e,t){var i={};return Ms.forEach(function(r){typeof r.eventProperties=="function"&&Zn(i,r.eventProperties.call(t[r.pluginName],e))}),i},modifyOption:function(e,t,i){var r;return Ms.forEach(function(s){e[s.pluginName]&&s.optionListeners&&typeof s.optionListeners[t]=="function"&&(r=s.optionListeners[t].call(e[s.pluginName],i))}),r}};function Bo(n){var e=n.sortable,t=n.rootEl,i=n.name,r=n.targetEl,s=n.cloneEl,o=n.toEl,l=n.fromEl,c=n.oldIndex,h=n.newIndex,d=n.oldDraggableIndex,p=n.newDraggableIndex,m=n.originalEvent,g=n.putSortable,v=n.extraEventProperties;if(e=e||t&&t[Dt],!!e){var w,S=e.options,E="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!Ui&&!Oa?w=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(w=document.createEvent("Event"),w.initEvent(i,!0,!0)),w.to=o||t,w.from=l||t,w.item=r||t,w.clone=s,w.oldIndex=c,w.newIndex=h,w.oldDraggableIndex=d,w.newDraggableIndex=p,w.originalEvent=m,w.pullMode=g?g.lastPutMode:void 0;var k=pi(pi({},v),Ia.getEventProperties(i,e));for(var I in k)w[I]=k[I];t&&t.dispatchEvent(w),S[E]&&S[E].call(e,w)}}var oI=["evt"],nn=function(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=i.evt,s=GO(i,oI);Ia.pluginEvent.bind(ae)(e,t,pi({dragEl:K,parentEl:st,ghostEl:ve,rootEl:Xe,nextEl:Ur,lastDownEl:sc,cloneEl:Qe,cloneHidden:dr,dragStarted:zo,putSortable:At,activeSortable:ae.active,originalEvent:r,oldIndex:zs,oldDraggableIndex:ta,newIndex:vn,newDraggableIndex:ar,hideGhostForTarget:eb,unhideGhostForTarget:tb,cloneNowHidden:function(){dr=!0},cloneNowShown:function(){dr=!1},dispatchSortableEvent:function(l){Ut({sortable:t,name:l,originalEvent:r})}},s))};function Ut(n){Bo(pi({putSortable:At,cloneEl:Qe,targetEl:K,rootEl:Xe,oldIndex:zs,oldDraggableIndex:ta,newIndex:vn,newDraggableIndex:ar},n))}var K,st,ve,Xe,Ur,sc,Qe,dr,zs,vn,ta,ar,_l,At,Ns=!1,Sc=!1,xc=[],zr,Kn,md,gd,By,zy,zo,Os,na,ia=!1,Rl=!1,oc,Lt,yd=[],tf=!1,Cc=[],yu=typeof document<"u",Nl=Kf,Hy=Oa||Ui?"cssFloat":"float",aI=yu&&!U0&&!Kf&&"draggable"in document.createElement("div"),J0=(function(){if(yu){if(Ui)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}})(),Z0=function(e,t){var i=Q(e),r=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),s=Xs(e,0,t),o=Xs(e,1,t),l=s&&Q(s),c=o&&Q(o),h=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+Ke(s).width,d=c&&parseInt(c.marginLeft)+parseInt(c.marginRight)+Ke(o).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&l.float&&l.float!=="none"){var p=l.float==="left"?"left":"right";return o&&(c.clear==="both"||c.clear===p)?"vertical":"horizontal"}return s&&(l.display==="block"||l.display==="flex"||l.display==="table"||l.display==="grid"||h>=r&&i[Hy]==="none"||o&&i[Hy]==="none"&&h+d>r)?"vertical":"horizontal"},lI=function(e,t,i){var r=i?e.left:e.top,s=i?e.right:e.bottom,o=i?e.width:e.height,l=i?t.left:t.top,c=i?t.right:t.bottom,h=i?t.width:t.height;return r===l||s===c||r+o/2===l+h/2},cI=function(e,t){var i;return xc.some(function(r){var s=r[Dt].options.emptyInsertThreshold;if(!(!s||Gf(r))){var o=Ke(r),l=e>=o.left-s&&e<=o.right+s,c=t>=o.top-s&&t<=o.bottom+s;if(l&&c)return i=r}}),i},Q0=function(e){function t(s,o){return function(l,c,h,d){var p=l.options.group.name&&c.options.group.name&&l.options.group.name===c.options.group.name;if(s==null&&(o||p))return!0;if(s==null||s===!1)return!1;if(o&&s==="clone")return s;if(typeof s=="function")return t(s(l,c,h,d),o)(l,c,h,d);var m=(o?l:c).options.group.name;return s===!0||typeof s=="string"&&s===m||s.join&&s.indexOf(m)>-1}}var i={},r=e.group;(!r||rc(r)!="object")&&(r={name:r}),i.name=r.name,i.checkPull=t(r.pull,!0),i.checkPut=t(r.put),i.revertClone=r.revertClone,e.group=i},eb=function(){!J0&&ve&&Q(ve,"display","none")},tb=function(){!J0&&ve&&Q(ve,"display","")};yu&&!U0&&document.addEventListener("click",function(n){if(Sc)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),Sc=!1,!1},!0);var Hr=function(e){if(K){e=e.touches?e.touches[0]:e;var t=cI(e.clientX,e.clientY);if(t){var i={};for(var r in e)e.hasOwnProperty(r)&&(i[r]=e[r]);i.target=i.rootEl=t,i.preventDefault=void 0,i.stopPropagation=void 0,t[Dt]._onDragOver(i)}}},uI=function(e){K&&K.parentNode[Dt]._isOutsideThisEl(e.target)};function ae(n,e){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=e=Zn({},e),n[Dt]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(n.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Z0(n,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(o,l){o.setData("Text",l.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:ae.supportPointer!==!1&&"PointerEvent"in window&&(!Qo||Kf),emptyInsertThreshold:5};Ia.initializePlugins(this,n,t);for(var i in t)!(i in e)&&(e[i]=t[i]);Q0(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]=="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=e.forceFallback?!1:aI,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Te(n,"pointerdown",this._onTapStart):(Te(n,"mousedown",this._onTapStart),Te(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(Te(n,"dragover",this),Te(n,"dragenter",this)),xc.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Zn(this,iI())}ae.prototype={constructor:ae,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(Os=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,K):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,i=this.el,r=this.options,s=r.preventOnFilter,o=e.type,l=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,c=(l||e).target,h=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||c,d=r.filter;if(vI(i),!K&&!(/mousedown|pointerdown/.test(o)&&e.button!==0||r.disabled)&&!h.isContentEditable&&!(!this.nativeDraggable&&Qo&&c&&c.tagName.toUpperCase()==="SELECT")&&(c=sn(c,r.draggable,i,!1),!(c&&c.animated)&&sc!==c)){if(zs=pt(c),ta=pt(c,r.draggable),typeof d=="function"){if(d.call(this,e,c,this)){Ut({sortable:t,rootEl:h,name:"filter",targetEl:c,toEl:i,fromEl:i}),nn("filter",t,{evt:e}),s&&e.preventDefault();return}}else if(d&&(d=d.split(",").some(function(p){if(p=sn(h,p.trim(),i,!1),p)return Ut({sortable:t,rootEl:p,name:"filter",targetEl:c,fromEl:i,toEl:i}),nn("filter",t,{evt:e}),!0}),d)){s&&e.preventDefault();return}r.handle&&!sn(h,r.handle,i,!1)||this._prepareDragStart(e,l,c)}}},_prepareDragStart:function(e,t,i){var r=this,s=r.el,o=r.options,l=s.ownerDocument,c;if(i&&!K&&i.parentNode===s){var h=Ke(i);if(Xe=s,K=i,st=K.parentNode,Ur=K.nextSibling,sc=i,_l=o.group,ae.dragged=K,zr={target:K,clientX:(t||e).clientX,clientY:(t||e).clientY},By=zr.clientX-h.left,zy=zr.clientY-h.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,K.style["will-change"]="all",c=function(){if(nn("delayEnded",r,{evt:e}),ae.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!Ny&&r.nativeDraggable&&(K.draggable=!0),r._triggerDragStart(e,t),Ut({sortable:r,name:"choose",originalEvent:e}),ft(K,o.chosenClass,!0)},o.ignore.split(",").forEach(function(d){G0(K,d.trim(),vd)}),Te(l,"dragover",Hr),Te(l,"mousemove",Hr),Te(l,"touchmove",Hr),o.supportPointer?(Te(l,"pointerup",r._onDrop),!this.nativeDraggable&&Te(l,"pointercancel",r._onDrop)):(Te(l,"mouseup",r._onDrop),Te(l,"touchend",r._onDrop),Te(l,"touchcancel",r._onDrop)),Ny&&this.nativeDraggable&&(this.options.touchStartThreshold=4,K.draggable=!0),nn("delayStart",this,{evt:e}),o.delay&&(!o.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Oa||Ui))){if(ae.eventCanceled){this._onDrop();return}o.supportPointer?(Te(l,"pointerup",r._disableDelayedDrag),Te(l,"pointercancel",r._disableDelayedDrag)):(Te(l,"mouseup",r._disableDelayedDrag),Te(l,"touchend",r._disableDelayedDrag),Te(l,"touchcancel",r._disableDelayedDrag)),Te(l,"mousemove",r._delayedDragTouchMoveHandler),Te(l,"touchmove",r._delayedDragTouchMoveHandler),o.supportPointer&&Te(l,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(c,o.delay)}else c()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){K&&vd(K),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;xe(e,"mouseup",this._disableDelayedDrag),xe(e,"touchend",this._disableDelayedDrag),xe(e,"touchcancel",this._disableDelayedDrag),xe(e,"pointerup",this._disableDelayedDrag),xe(e,"pointercancel",this._disableDelayedDrag),xe(e,"mousemove",this._delayedDragTouchMoveHandler),xe(e,"touchmove",this._delayedDragTouchMoveHandler),xe(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?Te(document,"pointermove",this._onTouchMove):t?Te(document,"touchmove",this._onTouchMove):Te(document,"mousemove",this._onTouchMove):(Te(K,"dragend",this),Te(Xe,"dragstart",this._onDragStart));try{document.selection?ac(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(Ns=!1,Xe&&K){nn("dragStarted",this,{evt:t}),this.nativeDraggable&&Te(document,"dragover",uI);var i=this.options;!e&&ft(K,i.dragClass,!1),ft(K,i.ghostClass,!0),ae.active=this,e&&this._appendGhost(),Ut({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(Kn){this._lastX=Kn.clientX,this._lastY=Kn.clientY,eb();for(var e=document.elementFromPoint(Kn.clientX,Kn.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Kn.clientX,Kn.clientY),e!==t);)t=e;if(K.parentNode[Dt]._isOutsideThisEl(e),t)do{if(t[Dt]){var i=void 0;if(i=t[Dt]._onDragOver({clientX:Kn.clientX,clientY:Kn.clientY,target:e,rootEl:t}),i&&!this.options.dragoverBubble)break}e=t}while(t=K0(t));tb()}},_onTouchMove:function(e){if(zr){var t=this.options,i=t.fallbackTolerance,r=t.fallbackOffset,s=e.touches?e.touches[0]:e,o=ve&&Yr(ve,!0),l=ve&&o&&o.a,c=ve&&o&&o.d,h=Nl&&Lt&&Fy(Lt),d=(s.clientX-zr.clientX+r.x)/(l||1)+(h?h[0]-yd[0]:0)/(l||1),p=(s.clientY-zr.clientY+r.y)/(c||1)+(h?h[1]-yd[1]:0)/(c||1);if(!ae.active&&!Ns){if(i&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<i)return;this._onDragStart(e,!0)}if(ve){o?(o.e+=d-(md||0),o.f+=p-(gd||0)):o={a:1,b:0,c:0,d:1,e:d,f:p};var m="matrix(".concat(o.a,",").concat(o.b,",").concat(o.c,",").concat(o.d,",").concat(o.e,",").concat(o.f,")");Q(ve,"webkitTransform",m),Q(ve,"mozTransform",m),Q(ve,"msTransform",m),Q(ve,"transform",m),md=d,gd=p,Kn=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!ve){var e=this.options.fallbackOnBody?document.body:Xe,t=Ke(K,!0,Nl,!0,e),i=this.options;if(Nl){for(Lt=e;Q(Lt,"position")==="static"&&Q(Lt,"transform")==="none"&&Lt!==document;)Lt=Lt.parentNode;Lt!==document.body&&Lt!==document.documentElement?(Lt===document&&(Lt=ui()),t.top+=Lt.scrollTop,t.left+=Lt.scrollLeft):Lt=ui(),yd=Fy(Lt)}ve=K.cloneNode(!0),ft(ve,i.ghostClass,!1),ft(ve,i.fallbackClass,!0),ft(ve,i.dragClass,!0),Q(ve,"transition",""),Q(ve,"transform",""),Q(ve,"box-sizing","border-box"),Q(ve,"margin",0),Q(ve,"top",t.top),Q(ve,"left",t.left),Q(ve,"width",t.width),Q(ve,"height",t.height),Q(ve,"opacity","0.8"),Q(ve,"position",Nl?"absolute":"fixed"),Q(ve,"zIndex","100000"),Q(ve,"pointerEvents","none"),ae.ghost=ve,e.appendChild(ve),Q(ve,"transform-origin",By/parseInt(ve.style.width)*100+"% "+zy/parseInt(ve.style.height)*100+"%")}},_onDragStart:function(e,t){var i=this,r=e.dataTransfer,s=i.options;if(nn("dragStart",this,{evt:e}),ae.eventCanceled){this._onDrop();return}nn("setupClone",this),ae.eventCanceled||(Qe=jf(K),Qe.removeAttribute("id"),Qe.draggable=!1,Qe.style["will-change"]="",this._hideClone(),ft(Qe,this.options.chosenClass,!1),ae.clone=Qe),i.cloneId=ac(function(){nn("clone",i),!ae.eventCanceled&&(i.options.removeCloneOnHide||Xe.insertBefore(Qe,K),i._hideClone(),Ut({sortable:i,name:"clone"}))}),!t&&ft(K,s.dragClass,!0),t?(Sc=!0,i._loopId=setInterval(i._emulateDragOver,50)):(xe(document,"mouseup",i._onDrop),xe(document,"touchend",i._onDrop),xe(document,"touchcancel",i._onDrop),r&&(r.effectAllowed="move",s.setData&&s.setData.call(i,r,K)),Te(document,"drop",i),Q(K,"transform","translateZ(0)")),Ns=!0,i._dragStartId=ac(i._dragStarted.bind(i,t,e)),Te(document,"selectstart",i),zo=!0,window.getSelection().removeAllRanges(),Qo&&Q(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,i=e.target,r,s,o,l=this.options,c=l.group,h=ae.active,d=_l===c,p=l.sort,m=At||h,g,v=this,w=!1;if(tf)return;function S(Oe,Yt){nn(Oe,v,pi({evt:e,isOwner:d,axis:g?"vertical":"horizontal",revert:o,dragRect:r,targetRect:s,canSort:p,fromSortable:m,target:i,completed:k,onMove:function(_t,ao){return Pl(Xe,t,K,r,_t,Ke(_t),e,ao)},changed:I},Yt))}function E(){S("dragOverAnimationCapture"),v.captureAnimationState(),v!==m&&m.captureAnimationState()}function k(Oe){return S("dragOverCompleted",{insertion:Oe}),Oe&&(d?h._hideClone():h._showClone(v),v!==m&&(ft(K,At?At.options.ghostClass:h.options.ghostClass,!1),ft(K,l.ghostClass,!0)),At!==v&&v!==ae.active?At=v:v===ae.active&&At&&(At=null),m===v&&(v._ignoreWhileAnimating=i),v.animateAll(function(){S("dragOverAnimationComplete"),v._ignoreWhileAnimating=null}),v!==m&&(m.animateAll(),m._ignoreWhileAnimating=null)),(i===K&&!K.animated||i===t&&!i.animated)&&(Os=null),!l.dragoverBubble&&!e.rootEl&&i!==document&&(K.parentNode[Dt]._isOutsideThisEl(e.target),!Oe&&Hr(e)),!l.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),w=!0}function I(){vn=pt(K),ar=pt(K,l.draggable),Ut({sortable:v,name:"change",toEl:t,newIndex:vn,newDraggableIndex:ar,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),i=sn(i,l.draggable,t,!0),S("dragOver"),ae.eventCanceled)return w;if(K.contains(e.target)||i.animated&&i.animatingX&&i.animatingY||v._ignoreWhileAnimating===i)return k(!1);if(Sc=!1,h&&!l.disabled&&(d?p||(o=st!==Xe):At===this||(this.lastPutMode=_l.checkPull(this,h,K,e))&&c.checkPut(this,h,K,e))){if(g=this._getDirection(e,i)==="vertical",r=Ke(K),S("dragOverValid"),ae.eventCanceled)return w;if(o)return st=Xe,E(),this._hideClone(),S("revert"),ae.eventCanceled||(Ur?Xe.insertBefore(K,Ur):Xe.appendChild(K)),k(!0);var R=Gf(t,l.draggable);if(!R||pI(e,g,this)&&!R.animated){if(R===K)return k(!1);if(R&&t===e.target&&(i=R),i&&(s=Ke(i)),Pl(Xe,t,K,r,i,s,e,!!i)!==!1)return E(),R&&R.nextSibling?t.insertBefore(K,R.nextSibling):t.appendChild(K),st=t,I(),k(!0)}else if(R&&fI(e,g,this)){var N=Xs(t,0,l,!0);if(N===K)return k(!1);if(i=N,s=Ke(i),Pl(Xe,t,K,r,i,s,e,!1)!==!1)return E(),t.insertBefore(K,N),st=t,I(),k(!0)}else if(i.parentNode===t){s=Ke(i);var V=0,U,W=K.parentNode!==t,G=!lI(K.animated&&K.toRect||r,i.animated&&i.toRect||s,g),Y=g?"top":"left",le=Ly(i,"top","top")||Ly(K,"top","top"),ke=le?le.scrollTop:void 0;Os!==i&&(U=s[Y],ia=!1,Rl=!G&&l.invertSwap||W),V=mI(e,i,s,g,G?1:l.swapThreshold,l.invertedSwapThreshold==null?l.swapThreshold:l.invertedSwapThreshold,Rl,Os===i);var we;if(V!==0){var pe=pt(K);do pe-=V,we=st.children[pe];while(we&&(Q(we,"display")==="none"||we===ve))}if(V===0||we===i)return k(!1);Os=i,na=V;var _e=i.nextElementSibling,de=!1;de=V===1;var ce=Pl(Xe,t,K,r,i,s,e,de);if(ce!==!1)return(ce===1||ce===-1)&&(de=ce===1),tf=!0,setTimeout(dI,30),E(),de&&!_e?t.appendChild(K):i.parentNode.insertBefore(K,de?_e:i),le&&X0(le,0,ke-le.scrollTop),st=K.parentNode,U!==void 0&&!Rl&&(oc=Math.abs(U-Ke(i)[Y])),I(),k(!0)}if(t.contains(K))return k(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){xe(document,"mousemove",this._onTouchMove),xe(document,"touchmove",this._onTouchMove),xe(document,"pointermove",this._onTouchMove),xe(document,"dragover",Hr),xe(document,"mousemove",Hr),xe(document,"touchmove",Hr)},_offUpEvents:function(){var e=this.el.ownerDocument;xe(e,"mouseup",this._onDrop),xe(e,"touchend",this._onDrop),xe(e,"pointerup",this._onDrop),xe(e,"pointercancel",this._onDrop),xe(e,"touchcancel",this._onDrop),xe(document,"selectstart",this)},_onDrop:function(e){var t=this.el,i=this.options;if(vn=pt(K),ar=pt(K,i.draggable),nn("drop",this,{evt:e}),st=K&&K.parentNode,vn=pt(K),ar=pt(K,i.draggable),ae.eventCanceled){this._nulling();return}Ns=!1,Rl=!1,ia=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),nf(this.cloneId),nf(this._dragStartId),this.nativeDraggable&&(xe(document,"drop",this),xe(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Qo&&Q(document.body,"user-select",""),Q(K,"transform",""),e&&(zo&&(e.cancelable&&e.preventDefault(),!i.dropBubble&&e.stopPropagation()),ve&&ve.parentNode&&ve.parentNode.removeChild(ve),(Xe===st||At&&At.lastPutMode!=="clone")&&Qe&&Qe.parentNode&&Qe.parentNode.removeChild(Qe),K&&(this.nativeDraggable&&xe(K,"dragend",this),vd(K),K.style["will-change"]="",zo&&!Ns&&ft(K,At?At.options.ghostClass:this.options.ghostClass,!1),ft(K,this.options.chosenClass,!1),Ut({sortable:this,name:"unchoose",toEl:st,newIndex:null,newDraggableIndex:null,originalEvent:e}),Xe!==st?(vn>=0&&(Ut({rootEl:st,name:"add",toEl:st,fromEl:Xe,originalEvent:e}),Ut({sortable:this,name:"remove",toEl:st,originalEvent:e}),Ut({rootEl:st,name:"sort",toEl:st,fromEl:Xe,originalEvent:e}),Ut({sortable:this,name:"sort",toEl:st,originalEvent:e})),At&&At.save()):vn!==zs&&vn>=0&&(Ut({sortable:this,name:"update",toEl:st,originalEvent:e}),Ut({sortable:this,name:"sort",toEl:st,originalEvent:e})),ae.active&&((vn==null||vn===-1)&&(vn=zs,ar=ta),Ut({sortable:this,name:"end",toEl:st,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){nn("nulling",this),Xe=K=st=ve=Ur=Qe=sc=dr=zr=Kn=zo=vn=ar=zs=ta=Os=na=At=_l=ae.dragged=ae.ghost=ae.clone=ae.active=null,Cc.forEach(function(e){e.checked=!0}),Cc.length=md=gd=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":K&&(this._onDragOver(e),hI(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,i=this.el.children,r=0,s=i.length,o=this.options;r<s;r++)t=i[r],sn(t,o.draggable,this.el,!1)&&e.push(t.getAttribute(o.dataIdAttr)||yI(t));return e},sort:function(e,t){var i={},r=this.el;this.toArray().forEach(function(s,o){var l=r.children[o];sn(l,this.options.draggable,r,!1)&&(i[s]=l)},this),t&&this.captureAnimationState(),e.forEach(function(s){i[s]&&(r.removeChild(i[s]),r.appendChild(i[s]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return sn(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var i=this.options;if(t===void 0)return i[e];var r=Ia.modifyOption(this,e,t);typeof r<"u"?i[e]=r:i[e]=t,e==="group"&&Q0(i)},destroy:function(){nn("destroy",this);var e=this.el;e[Dt]=null,xe(e,"mousedown",this._onTapStart),xe(e,"touchstart",this._onTapStart),xe(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(xe(e,"dragover",this),xe(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),xc.splice(xc.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!dr){if(nn("hideClone",this),ae.eventCanceled)return;Q(Qe,"display","none"),this.options.removeCloneOnHide&&Qe.parentNode&&Qe.parentNode.removeChild(Qe),dr=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(dr){if(nn("showClone",this),ae.eventCanceled)return;K.parentNode==Xe&&!this.options.group.revertClone?Xe.insertBefore(Qe,K):Ur?Xe.insertBefore(Qe,Ur):Xe.appendChild(Qe),this.options.group.revertClone&&this.animate(K,Qe),Q(Qe,"display",""),dr=!1}}};function hI(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function Pl(n,e,t,i,r,s,o,l){var c,h=n[Dt],d=h.options.onMove,p;return window.CustomEvent&&!Ui&&!Oa?c=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(c=document.createEvent("Event"),c.initEvent("move",!0,!0)),c.to=e,c.from=n,c.dragged=t,c.draggedRect=i,c.related=r||e,c.relatedRect=s||Ke(e),c.willInsertAfter=l,c.originalEvent=o,n.dispatchEvent(c),d&&(p=d.call(h,c,o)),p}function vd(n){n.draggable=!1}function dI(){tf=!1}function fI(n,e,t){var i=Ke(Xs(t.el,0,t.options,!0)),r=Y0(t.el,t.options,ve),s=10;return e?n.clientX<r.left-s||n.clientY<i.top&&n.clientX<i.right:n.clientY<r.top-s||n.clientY<i.bottom&&n.clientX<i.left}function pI(n,e,t){var i=Ke(Gf(t.el,t.options.draggable)),r=Y0(t.el,t.options,ve),s=10;return e?n.clientX>r.right+s||n.clientY>i.bottom&&n.clientX>i.left:n.clientY>r.bottom+s||n.clientX>i.right&&n.clientY>i.top}function mI(n,e,t,i,r,s,o,l){var c=i?n.clientY:n.clientX,h=i?t.height:t.width,d=i?t.top:t.left,p=i?t.bottom:t.right,m=!1;if(!o){if(l&&oc<h*r){if(!ia&&(na===1?c>d+h*s/2:c<p-h*s/2)&&(ia=!0),ia)m=!0;else if(na===1?c<d+oc:c>p-oc)return-na}else if(c>d+h*(1-r)/2&&c<p-h*(1-r)/2)return gI(e)}return m=m||o,m&&(c<d+h*s/2||c>p-h*s/2)?c>d+h/2?1:-1:0}function gI(n){return pt(K)<pt(n)?1:-1}function yI(n){for(var e=n.tagName+n.className+n.src+n.href+n.textContent,t=e.length,i=0;t--;)i+=e.charCodeAt(t);return i.toString(36)}function vI(n){Cc.length=0;for(var e=n.getElementsByTagName("input"),t=e.length;t--;){var i=e[t];i.checked&&Cc.push(i)}}function ac(n){return setTimeout(n,0)}function nf(n){return clearTimeout(n)}yu&&Te(document,"touchmove",function(n){(ae.active||Ns)&&n.cancelable&&n.preventDefault()});ae.utils={on:Te,off:xe,css:Q,find:G0,is:function(e,t){return!!sn(e,t,e,!1)},extend:tI,throttle:j0,closest:sn,toggleClass:ft,clone:jf,index:pt,nextTick:ac,cancelNextTick:nf,detectDirection:Z0,getChild:Xs,expando:Dt};ae.get=function(n){return n[Dt]};ae.mount=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(ae.utils=pi(pi({},ae.utils),i.utils)),Ia.mount(i)})};ae.create=function(n,e){return new ae(n,e)};ae.version=QO;var dt=[],Ho,rf,sf=!1,bd,wd,Ec,Vo;function bI(){function n(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return n.prototype={dragStarted:function(t){var i=t.originalEvent;this.sortable.nativeDraggable?Te(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Te(document,"pointermove",this._handleFallbackAutoScroll):i.touches?Te(document,"touchmove",this._handleFallbackAutoScroll):Te(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var i=t.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?xe(document,"dragover",this._handleAutoScroll):(xe(document,"pointermove",this._handleFallbackAutoScroll),xe(document,"touchmove",this._handleFallbackAutoScroll),xe(document,"mousemove",this._handleFallbackAutoScroll)),Vy(),lc(),nI()},nulling:function(){Ec=rf=Ho=sf=Vo=bd=wd=null,dt.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,i){var r=this,s=(t.touches?t.touches[0]:t).clientX,o=(t.touches?t.touches[0]:t).clientY,l=document.elementFromPoint(s,o);if(Ec=t,i||this.options.forceAutoScrollFallback||Oa||Ui||Qo){Sd(t,this.options,l,i);var c=gr(l,!0);sf&&(!Vo||s!==bd||o!==wd)&&(Vo&&Vy(),Vo=setInterval(function(){var h=gr(document.elementFromPoint(s,o),!0);h!==c&&(c=h,lc()),Sd(t,r.options,h,i)},10),bd=s,wd=o)}else{if(!this.options.bubbleScroll||gr(l,!0)===ui()){lc();return}Sd(t,this.options,gr(l,!1),!1)}}},Zn(n,{pluginName:"scroll",initializeByDefault:!0})}function lc(){dt.forEach(function(n){clearInterval(n.pid)}),dt=[]}function Vy(){clearInterval(Vo)}var Sd=j0(function(n,e,t,i){if(e.scroll){var r=(n.touches?n.touches[0]:n).clientX,s=(n.touches?n.touches[0]:n).clientY,o=e.scrollSensitivity,l=e.scrollSpeed,c=ui(),h=!1,d;rf!==t&&(rf=t,lc(),Ho=e.scroll,d=e.scrollFn,Ho===!0&&(Ho=gr(t,!0)));var p=0,m=Ho;do{var g=m,v=Ke(g),w=v.top,S=v.bottom,E=v.left,k=v.right,I=v.width,R=v.height,N=void 0,V=void 0,U=g.scrollWidth,W=g.scrollHeight,G=Q(g),Y=g.scrollLeft,le=g.scrollTop;g===c?(N=I<U&&(G.overflowX==="auto"||G.overflowX==="scroll"||G.overflowX==="visible"),V=R<W&&(G.overflowY==="auto"||G.overflowY==="scroll"||G.overflowY==="visible")):(N=I<U&&(G.overflowX==="auto"||G.overflowX==="scroll"),V=R<W&&(G.overflowY==="auto"||G.overflowY==="scroll"));var ke=N&&(Math.abs(k-r)<=o&&Y+I<U)-(Math.abs(E-r)<=o&&!!Y),we=V&&(Math.abs(S-s)<=o&&le+R<W)-(Math.abs(w-s)<=o&&!!le);if(!dt[p])for(var pe=0;pe<=p;pe++)dt[pe]||(dt[pe]={});(dt[p].vx!=ke||dt[p].vy!=we||dt[p].el!==g)&&(dt[p].el=g,dt[p].vx=ke,dt[p].vy=we,clearInterval(dt[p].pid),(ke!=0||we!=0)&&(h=!0,dt[p].pid=setInterval((function(){i&&this.layer===0&&ae.active._onTouchMove(Ec);var _e=dt[this.layer].vy?dt[this.layer].vy*l:0,de=dt[this.layer].vx?dt[this.layer].vx*l:0;typeof d=="function"&&d.call(ae.dragged.parentNode[Dt],de,_e,n,Ec,dt[this.layer].el)!=="continue"||X0(dt[this.layer].el,de,_e)}).bind({layer:p}),24))),p++}while(e.bubbleScroll&&m!==c&&(m=gr(m,!1)));sf=h}},30),nb=function(e){var t=e.originalEvent,i=e.putSortable,r=e.dragEl,s=e.activeSortable,o=e.dispatchSortableEvent,l=e.hideGhostForTarget,c=e.unhideGhostForTarget;if(t){var h=i||s;l();var d=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,p=document.elementFromPoint(d.clientX,d.clientY);c(),h&&!h.el.contains(p)&&(o("spill"),this.onSpill({dragEl:r,putSortable:i}))}};function Xf(){}Xf.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,i=e.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var r=Xs(this.sortable.el,this.startIndex,this.options);r?this.sortable.el.insertBefore(t,r):this.sortable.el.appendChild(t),this.sortable.animateAll(),i&&i.animateAll()},drop:nb};Zn(Xf,{pluginName:"revertOnSpill"});function Yf(){}Yf.prototype={onSpill:function(e){var t=e.dragEl,i=e.putSortable,r=i||this.sortable;r.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),r.animateAll()},drop:nb};Zn(Yf,{pluginName:"removeOnSpill"});var ge=[],gn=[],Do,Gn,_o=!1,rn=!1,Is=!1,We,Ro,Ll;function wI(){function n(e){for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this));e.options.avoidImplicitDeselect||(e.options.supportPointer?Te(document,"pointerup",this._deselectMultiDrag):(Te(document,"mouseup",this._deselectMultiDrag),Te(document,"touchend",this._deselectMultiDrag))),Te(document,"keydown",this._checkKeyDown),Te(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(r,s){var o="";ge.length&&Gn===e?ge.forEach(function(l,c){o+=(c?", ":"")+l.textContent}):o=s.textContent,r.setData("Text",o)}}}return n.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var i=t.dragEl;We=i},delayEnded:function(){this.isMultiDrag=~ge.indexOf(We)},setupClone:function(t){var i=t.sortable,r=t.cancel;if(this.isMultiDrag){for(var s=0;s<ge.length;s++)gn.push(jf(ge[s])),gn[s].sortableIndex=ge[s].sortableIndex,gn[s].draggable=!1,gn[s].style["will-change"]="",ft(gn[s],this.options.selectedClass,!1),ge[s]===We&&ft(gn[s],this.options.chosenClass,!1);i._hideClone(),r()}},clone:function(t){var i=t.sortable,r=t.rootEl,s=t.dispatchSortableEvent,o=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||ge.length&&Gn===i&&(Wy(!0,r),s("clone"),o()))},showClone:function(t){var i=t.cloneNowShown,r=t.rootEl,s=t.cancel;this.isMultiDrag&&(Wy(!1,r),gn.forEach(function(o){Q(o,"display","")}),i(),Ll=!1,s())},hideClone:function(t){var i=this;t.sortable;var r=t.cloneNowHidden,s=t.cancel;this.isMultiDrag&&(gn.forEach(function(o){Q(o,"display","none"),i.options.removeCloneOnHide&&o.parentNode&&o.parentNode.removeChild(o)}),r(),Ll=!0,s())},dragStartGlobal:function(t){t.sortable,!this.isMultiDrag&&Gn&&Gn.multiDrag._deselectMultiDrag(),ge.forEach(function(i){i.sortableIndex=pt(i)}),ge=ge.sort(function(i,r){return i.sortableIndex-r.sortableIndex}),Is=!0},dragStarted:function(t){var i=this,r=t.sortable;if(this.isMultiDrag){if(this.options.sort&&(r.captureAnimationState(),this.options.animation)){ge.forEach(function(o){o!==We&&Q(o,"position","absolute")});var s=Ke(We,!1,!0,!0);ge.forEach(function(o){o!==We&&$y(o,s)}),rn=!0,_o=!0}r.animateAll(function(){rn=!1,_o=!1,i.options.animation&&ge.forEach(function(o){fd(o)}),i.options.sort&&Fl()})}},dragOver:function(t){var i=t.target,r=t.completed,s=t.cancel;rn&&~ge.indexOf(i)&&(r(!1),s())},revert:function(t){var i=t.fromSortable,r=t.rootEl,s=t.sortable,o=t.dragRect;ge.length>1&&(ge.forEach(function(l){s.addAnimationState({target:l,rect:rn?Ke(l):o}),fd(l),l.fromRect=o,i.removeAnimationState(l)}),rn=!1,SI(!this.options.removeCloneOnHide,r))},dragOverCompleted:function(t){var i=t.sortable,r=t.isOwner,s=t.insertion,o=t.activeSortable,l=t.parentEl,c=t.putSortable,h=this.options;if(s){if(r&&o._hideClone(),_o=!1,h.animation&&ge.length>1&&(rn||!r&&!o.options.sort&&!c)){var d=Ke(We,!1,!0,!0);ge.forEach(function(m){m!==We&&($y(m,d),l.appendChild(m))}),rn=!0}if(!r)if(rn||Fl(),ge.length>1){var p=Ll;o._showClone(i),o.options.animation&&!Ll&&p&&gn.forEach(function(m){o.addAnimationState({target:m,rect:Ro}),m.fromRect=Ro,m.thisAnimationDuration=null})}else o._showClone(i)}},dragOverAnimationCapture:function(t){var i=t.dragRect,r=t.isOwner,s=t.activeSortable;if(ge.forEach(function(l){l.thisAnimationDuration=null}),s.options.animation&&!r&&s.multiDrag.isMultiDrag){Ro=Zn({},i);var o=Yr(We,!0);Ro.top-=o.f,Ro.left-=o.e}},dragOverAnimationComplete:function(){rn&&(rn=!1,Fl())},drop:function(t){var i=t.originalEvent,r=t.rootEl,s=t.parentEl,o=t.sortable,l=t.dispatchSortableEvent,c=t.oldIndex,h=t.putSortable,d=h||this.sortable;if(i){var p=this.options,m=s.children;if(!Is)if(p.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),ft(We,p.selectedClass,!~ge.indexOf(We)),~ge.indexOf(We))ge.splice(ge.indexOf(We),1),Do=null,Bo({sortable:o,rootEl:r,name:"deselect",targetEl:We,originalEvent:i});else{if(ge.push(We),Bo({sortable:o,rootEl:r,name:"select",targetEl:We,originalEvent:i}),i.shiftKey&&Do&&o.el.contains(Do)){var g=pt(Do),v=pt(We);~g&&~v&&g!==v&&(function(){var k,I;v>g?(I=g,k=v):(I=v,k=g+1);for(var R=p.filter;I<k;I++)if(!~ge.indexOf(m[I])&&sn(m[I],p.draggable,s,!1)){var N=R&&(typeof R=="function"?R.call(o,i,m[I],o):R.split(",").some(function(V){return sn(m[I],V.trim(),s,!1)}));N||(ft(m[I],p.selectedClass,!0),ge.push(m[I]),Bo({sortable:o,rootEl:r,name:"select",targetEl:m[I],originalEvent:i}))}})()}else Do=We;Gn=d}if(Is&&this.isMultiDrag){if(rn=!1,(s[Dt].options.sort||s!==r)&&ge.length>1){var w=Ke(We),S=pt(We,":not(."+this.options.selectedClass+")");if(!_o&&p.animation&&(We.thisAnimationDuration=null),d.captureAnimationState(),!_o&&(p.animation&&(We.fromRect=w,ge.forEach(function(k){if(k.thisAnimationDuration=null,k!==We){var I=rn?Ke(k):w;k.fromRect=I,d.addAnimationState({target:k,rect:I})}})),Fl(),ge.forEach(function(k){m[S]?s.insertBefore(k,m[S]):s.appendChild(k),S++}),c===pt(We))){var E=!1;ge.forEach(function(k){if(k.sortableIndex!==pt(k)){E=!0;return}}),E&&(l("update"),l("sort"))}ge.forEach(function(k){fd(k)}),d.animateAll()}Gn=d}(r===s||h&&h.lastPutMode!=="clone")&&gn.forEach(function(k){k.parentNode&&k.parentNode.removeChild(k)})}},nullingGlobal:function(){this.isMultiDrag=Is=!1,gn.length=0},destroyGlobal:function(){this._deselectMultiDrag(),xe(document,"pointerup",this._deselectMultiDrag),xe(document,"mouseup",this._deselectMultiDrag),xe(document,"touchend",this._deselectMultiDrag),xe(document,"keydown",this._checkKeyDown),xe(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!(typeof Is<"u"&&Is)&&Gn===this.sortable&&!(t&&sn(t.target,this.options.draggable,this.sortable.el,!1))&&!(t&&t.button!==0))for(;ge.length;){var i=ge[0];ft(i,this.options.selectedClass,!1),ge.shift(),Bo({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:i,originalEvent:t})}},_checkKeyDown:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},Zn(n,{pluginName:"multiDrag",utils:{select:function(t){var i=t.parentNode[Dt];!i||!i.options.multiDrag||~ge.indexOf(t)||(Gn&&Gn!==i&&(Gn.multiDrag._deselectMultiDrag(),Gn=i),ft(t,i.options.selectedClass,!0),ge.push(t))},deselect:function(t){var i=t.parentNode[Dt],r=ge.indexOf(t);!i||!i.options.multiDrag||!~r||(ft(t,i.options.selectedClass,!1),ge.splice(r,1))}},eventProperties:function(){var t=this,i=[],r=[];return ge.forEach(function(s){i.push({multiDragElement:s,index:s.sortableIndex});var o;rn&&s!==We?o=-1:rn?o=pt(s,":not(."+t.options.selectedClass+")"):o=pt(s),r.push({multiDragElement:s,index:o})}),{items:jO(ge),clones:[].concat(gn),oldIndicies:i,newIndicies:r}},optionListeners:{multiDragKey:function(t){return t=t.toLowerCase(),t==="ctrl"?t="Control":t.length>1&&(t=t.charAt(0).toUpperCase()+t.substr(1)),t}}})}function SI(n,e){ge.forEach(function(t,i){var r=e.children[t.sortableIndex+(n?Number(i):0)];r?e.insertBefore(t,r):e.appendChild(t)})}function Wy(n,e){gn.forEach(function(t,i){var r=e.children[t.sortableIndex+(n?Number(i):0)];r?e.insertBefore(t,r):e.appendChild(t)})}function Fl(){ge.forEach(function(n){n!==We&&n.parentNode&&n.parentNode.removeChild(n)})}ae.mount(new bI);ae.mount(Yf,Xf);function xI(n={show:!1,focusable:!1}){return{show:n.show,focusable:n.focusable,closeModal(){this.show=!1},openModal(){this.show=!0},focusables(){return[...this.$el.querySelectorAll("a, button, input:not([type='hidden']), textarea, select, details, [tabindex]:not([tabindex='-1'])")].filter(t=>!t.hasAttribute("disabled"))},firstFocusable(){return this.focusables()[0]},lastFocusable(){return this.focusables().slice(-1)[0]},nextFocusable(){return this.focusables()[this.nextFocusableIndex()]||this.firstFocusable()},prevFocusable(){return this.focusables()[this.prevFocusableIndex()]||this.lastFocusable()},nextFocusableIndex(){return(this.focusables().indexOf(document.activeElement)+1)%(this.focusables().length+1)},prevFocusableIndex(){return Math.max(0,this.focusables().indexOf(document.activeElement))-1},init(){this.$watch("show",e=>{e?(document.body.classList.add("overflow-y-hidden"),this.focusable!==!1&&setTimeout(()=>this.firstFocusable().focus(),100)):document.body.classList.remove("overflow-y-hidden")})}}}function CI(n={}){return{isShared:n.isShared??!1,limits:n.limits??{},init(){},pushToAiEngines(e){this.aiEngines.push(e)}}}class ib{constructor(){this.playbackNode=null}async init(e){this.audioContext=new AudioContext({sampleRate:e}),await this.audioContext.audioWorklet.addModule("/themes/default/assets/js/audio/playback-worklet.js"),this.playbackNode=new AudioWorkletNode(this.audioContext,"playback-worklet"),this.playbackNode.connect(this.audioContext.destination)}play(e){this.playbackNode&&this.playbackNode.port.postMessage(e)}clear(){this.playbackNode&&this.playbackNode.port.postMessage(null)}}function Ws(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function l(d){try{h(i.next(d))}catch(p){o(p)}}function c(d){try{h(i.throw(d))}catch(p){o(p)}}function h(d){d.done?s(d.value):r(d.value).then(l,c)}h((i=i.apply(n,[])).next())})}function Kr(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=l(0),o.throw=l(1),o.return=l(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(h){return function(d){return c([h,d])}}function c(h){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(t=0)),t;)try{if(i=1,r&&(s=h[0]&2?r.return:h[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,h[1])).done)return s;switch(r=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,r=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(n,t)}catch(d){h=[6,d],r=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Uy(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function xd(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(l){o={error:l}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Us(n){return this instanceof Us?(this.v=n,this):new Us(n)}function EI(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),r,s=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",o),r[Symbol.asyncIterator]=function(){return this},r;function o(g){return function(v){return Promise.resolve(v).then(g,p)}}function l(g,v){i[g]&&(r[g]=function(w){return new Promise(function(S,E){s.push([g,w,S,E])>1||c(g,w)})},v&&(r[g]=v(r[g])))}function c(g,v){try{h(i[g](v))}catch(w){m(s[0][3],w)}}function h(g){g.value instanceof Us?Promise.resolve(g.value.v).then(d,p):m(s[0][2],g)}function d(g){c("next",g)}function p(g){c("throw",g)}function m(g,v){g(v),s.shift(),s.length&&c(s[0][0],s[0][1])}}function TI(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof Uy=="function"?Uy(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=n[s]&&function(o){return new Promise(function(l,c){o=n[s](o),r(l,c,o.done,o.value)})}}function r(s,o,l,c){Promise.resolve(c).then(function(h){s({value:h,done:l})},o)}}var kI=function(n){return typeof n=="object"&&n!==null&&"type"in n},AI=function(n){return kI(n)&&["error","message","conversation.item.input_audio_transcription.delta","session.created","session.updated","input_audio_buffer.committed","input_audio_buffer.cleared","input_audio_buffer.speech_started","input_audio_buffer.speech_stopped","conversation.item.created","conversation.item.truncated","conversation.item.deleted","conversation.item.input_audio_transcription.completed","conversation.item.input_audio_transcription.failed","response.created","response.done","response.output_item.added","response.output_item.done","response.content_part.added","response.content_part.done","response.text.delta","response.text.done","response.audio_transcript.delta","response.audio_transcript.done","response.audio.delta","response.audio.done","response.function_call_arguments.delta","response.function_call_arguments.done","rate_limits.updated"].includes(n.type)},MI=WebSocket,OI=function(n,e){return n.readyState!==WebSocket.OPEN?Promise.reject(new Error("Socket is not open")):(n.send(e),Promise.resolve())},II=function(n){return{success:!0,message:n}},DI=function(n){return{success:!1,error:n}},_I=function(n){return n.success},RI=(function(){function n(e,t){var i=this;this.closedPromise=void 0,this.messageQueue=[],this.receiverQueue=[],this.done=!1,this.validate=t.validate,this.serialize=t.serialize,this.connectedPromise=new Promise(function(r,s){return Ws(i,void 0,void 0,function(){var o,l,c,h,d=this;return Kr(this,function(p){switch(p.label){case 0:return e.policy!==void 0?[3,1]:(h=e,[3,3]);case 1:return[4,e.policy(e)];case 2:h=p.sent(),p.label=3;case 3:return o=h,l=o.uri,c=o.protocols,this.socket=new MI(l.toString(),c),this.socket.onopen=function(){d.socket.onmessage=d.getMessageHandler(),d.closedPromise=new Promise(function(m){d.socket.onclose=d.getClosedHandler(m)}),d.socket.onerror=d.handleError,r()},this.socket.onerror=function(m){d.error=m.error,s(m)},[2]}})})})}return n.prototype.handleError=function(e){for(this.error=e.error;this.receiverQueue.length>0;){var t=xd(this.receiverQueue.shift(),2);t[0];var i=t[1];i(e.error)}},n.prototype.getClosedHandler=function(e){var t=this;return function(i){for(t.done=!0;t.receiverQueue.length>0;){var r=xd(t.receiverQueue.shift(),2),s=r[0],o=r[1];t.error?o(t.error):s({value:void 0,done:!0})}e()}},n.prototype.getMessageHandler=function(){var e=this;return function(t){var i=e.validate(t);if(_I(i)){var r=i.message;if(e.receiverQueue.length>0){var s=xd(e.receiverQueue.shift(),2),o=s[0];s[1],o({value:r,done:!1})}else e.messageQueue.push(r)}else e.error=i.error,e.socket.close(1e3,"Unexpected message received")}},n.prototype[Symbol.asyncIterator]=function(){var e=this;return{next:function(){if(e.error)return Promise.reject(e.error);if(e.done)return Promise.resolve({value:void 0,done:!0});if(e.messageQueue.length>0){var t=e.messageQueue.shift();return Promise.resolve({value:t,done:!1})}else return new Promise(function(i,r){e.receiverQueue.push([i,r])})}}},n.prototype.send=function(e){return Ws(this,void 0,void 0,function(){var t;return Kr(this,function(i){switch(i.label){case 0:return[4,this.connectedPromise];case 1:if(i.sent(),this.error)throw this.error;return t=this.serialize(e),[2,OI(this.socket,t)]}})})},n.prototype.close=function(){return Ws(this,void 0,void 0,function(){return Kr(this,function(e){switch(e.label){case 0:return[4,this.connectedPromise];case 1:return e.sent(),this.done?[2]:(this.socket.close(),[4,this.closedPromise]);case 2:return e.sent(),[2]}})})},n})();function of(n){return typeof n=="object"&&n!==null&&"key"in n&&typeof n.key=="string"}function NI(n){return typeof n=="object"&&n!==null&&"getToken"in n&&typeof n.getToken=="function"}var PI=function(n){return of(n)||NI(n)},LI=function(n){return typeof n=="object"&&n!==null&&"model"in n&&typeof n.model=="string"},FI=function(n){return typeof n=="object"&&n!==null&&"deployment"in n&&typeof n.deployment=="string"},$I=(function(){function n(e,t,i){var r=this,s=(function(){if(of(e)&&LI(t))return r.openAISettings(e,t);if(PI(t)&&FI(i))return r.azureOpenAISettings(e,t,i);throw new Error("Invalid combination of arguments to initialize the Realtime client")})();this.client=this.getWebsocket(s)}return n.prototype.azureOpenAISettings=function(e,t,i){var r=this,s=["https://cognitiveservices.azure.com/.default"];return this.requestId=crypto.randomUUID(),e.searchParams.set("api-version","2024-10-01-preview"),e.searchParams.set("x-ms-client-request-id",this.requestId),e.searchParams.set("deployment",i.deployment),e.pathname="openai/realtime",{uri:e,policy:function(o){return Ws(r,void 0,void 0,function(){var l;return Kr(this,function(c){switch(c.label){case 0:return of(t)?(o.uri.searchParams.set("api-key",t.key),[3,3]):[3,1];case 1:return[4,t.getToken(s)];case 2:l=c.sent(),o.uri.searchParams.set("Authorization","Bearer ".concat(l.token)),c.label=3;case 3:return[2,o]}})})}}},n.prototype.openAISettings=function(e,t){var i=new URL("wss://api.openai.com/v1/realtime");return i.searchParams.set("model",t.model),{uri:i,protocols:["realtime","openai-insecure-api-key.".concat(e.key),"openai-beta.realtime-v1"]}},n.prototype.getWebsocket=function(e){var t={validate:function(i){i.data;try{var r=JSON.parse(i.data);if(AI(r))return II(r)}catch{return DI(new Error("Invalid JSON message"))}},serialize:function(i){return JSON.stringify(i)}};return new RI(e,t)},n.prototype.messages=function(){return EI(this,arguments,function(){var t,i,r,s,o,l,c,h,d;return Kr(this,function(p){switch(p.label){case 0:p.trys.push([0,7,8,13]),t=!0,i=TI(this.client),p.label=1;case 1:return[4,Us(i.next())];case 2:return r=p.sent(),l=r.done,!l?(d=r.value,t=!1,s=d,[4,Us(s)]):[3,6];case 3:return[4,p.sent()];case 4:p.sent(),p.label=5;case 5:return t=!0,[3,1];case 6:return[3,13];case 7:return o=p.sent(),c={error:o},[3,13];case 8:return p.trys.push([8,,11,12]),!t&&!l&&(h=i.return)?[4,Us(h.call(i))]:[3,10];case 9:p.sent(),p.label=10;case 10:return[3,12];case 11:if(c)throw c.error;return[7];case 12:return[7];case 13:return[2]}})})},n.prototype.send=function(e){return Ws(this,void 0,void 0,function(){return Kr(this,function(t){switch(t.label){case 0:return[4,this.client.send(e)];case 1:return t.sent(),[2]}})})},n.prototype.close=function(){return Ws(this,void 0,void 0,function(){return Kr(this,function(e){switch(e.label){case 0:return[4,this.client.close()];case 1:return e.sent(),[2]}})})},n})();Z.store("realtimeChatStatus",{active:!1,conversationStarted:!1,setActive(n){this.active=n,this.onActiveChange()},setConversationStarted(n){this.conversationStarted=n,this.onConversationStartedChange()},onActiveChange(){document.querySelectorAll(".lqd-realtime-chat-button").forEach(n=>n.classList.toggle("active",this.active)),document.querySelector(".lqd-audio-vis-wrap")?.classList?.toggle("active",this.active)},onConversationStartedChange(){const n=document.querySelector(".chats-wrap");n.classList.toggle("conversation-started",this.conversationStarted),n.classList.toggle("conversation-not-started",!this.conversationStarted),document.querySelectorAll(".lqd-realtime-chat-button").forEach(e=>{e.classList.toggle("conversation-started",this.conversationStarted),e.classList.toggle("conversation-not-started",!this.conversationStarted)})}});const BI=(n,e,t)=>({apiKey:"",recordingActive:!1,buffer:new Uint8Array,wsConnection:null,audioRecorder:null,audioPlayer:null,activeVisulaizer:"idle",audioVisWrap:null,audioVisBars:null,audioVisDotWrap:null,audioVisLoader:null,conversationArea:document.querySelector(".conversation-area"),chatsContainer:document.querySelector(".chats-container"),userBubbleTemplate:document.querySelector("#chat_user_bubble"),aiBubbleTemplate:document.querySelector("#chat_ai_bubble"),lastAiBubble:null,lastUserBubble:null,lastUserQuestion:"",lastAiResponse:"",lastResponseSaved:!1,init(){this.audioVisWrap=document.querySelector(".lqd-audio-vis-wrap"),this.audioVisBars=this.audioVisWrap?.querySelectorAll(".lqd-audio-vis-bar"),this.audioVisDotWrap=this.audioVisWrap?.querySelector(".lqd-audio-vis-dot-wrap"),this.audioVisLoader=this.audioVisWrap?.querySelector(".lqd-audio-vis-loader"),this.processAudioRecordingBuffer=this.processAudioRecordingBuffer.bind(this)},async start(){if(this.checkBalanceRealtime(!0).then(i=>{i.shouldStop&&(toastr.error(i.errorMsg),this.stop())}),!Z.store("realtimeChatStatus").isActive){Z.store("realtimeChatStatus").setActive(!0),this.switchVisualizers("waiting"),this.wsConnection=new $I({key:atob(n)+atob(e)+atob(t)},{model:"gpt-4o-realtime-preview-2024-12-17"});try{await this.wsConnection.send(this.createConfigMessage())}catch(i){this.stop(),console.error("Error sending initial config message:",i),this.appendToChatBubble("ai","[Connection error]: Unable to send initial config message. Please check your endpoint and authentication details.");return}await Promise.all([this.startRecorder(),this.startPlayer()]).then(()=>{this.handleRealtimeMessages(),this.startBarsVisualizer(),this.startDotVisualizer(),this.switchVisualizers("idle")}).catch(i=>{this.stop(),console.error("Error starting recorder and player:",i),this.appendToChatBubble("ai","[Error]: Unable to start audio recorder and player. Please check your microphone permissions and refresh the page.")})}},stop(){if(!this.lastResponseSaved&&"saveResponseAsync"in window&&this.lastUserQuestion.trim()!==""&&this.lastAiResponse.trim()!==""){const i=this.lastAiBubble.closest(".lqd-chat-ai-bubble");saveResponseAsync(this.lastUserQuestion.trim(),this.lastAiResponse.trim(),document.querySelector("#chat_id").value,"","","","","gpt-4o-realtime-preview-2024-12-17").then(r=>{i?.setAttribute("data-message-id",r.message.id)})}this.resetPlayers(),this.wsConnection&&this.wsConnection.close(),this.switchVisualizers(""),Z.store("realtimeChatStatus").setActive(!1)},async startPlayer(){try{this.audioPlayer=new ib,await this.audioPlayer.init(24e3)}catch(i){console.error("Error starting audio player:",i)}},async startRecorder(){try{this.audioRecorder=new O0(this.processAudioRecordingBuffer);const i=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});await this.audioRecorder.start(i),this.recordingActive=!0}catch(i){console.error("Error starting audio recorder:",i)}},createConfigMessage(){let i={type:"session.update",session:{turn_detection:{type:"server_vad",silence_duration_ms:500},input_audio_transcription:{model:"whisper-1"}}};const r=this.getSystemMessage(),s=this.getTemperature(),o=this.getVoice();return r&&(i.session.instructions=r),isNaN(s)||(i.session.temperature=s),o&&(i.session.voice=o),i},async handleRealtimeMessages(){for await(const i of this.wsConnection.messages())switch(""+i.type,i.type){case"session.created":this.switchVisualizers("idle");break;case"response.content_part.added":this.checkBalanceRealtime().then(r=>{r.shouldStop&&(toastr.error(r.errorMsg),this.stop())}),this.lastAiResponse="",Z.store("realtimeChatStatus").setConversationStarted(!0),this.createChatBubble("ai");break;case"response.audio_transcript.delta":this.lastAiResponse+=i.delta,this.appendToChatBubble("ai",i.delta);break;case"response.audio.delta":{this.switchVisualizers("playing");const r=atob(i.delta),s=Uint8Array.from(r,l=>l.charCodeAt(0)),o=new Int16Array(s.buffer);this.audioPlayer.play(o);break}case"input_audio_buffer.speech_started":{this.createChatBubble("user"),this.switchVisualizers("recording"),this.audioPlayer.clear(),this.lastResponseSaved=!1,setTimeout(()=>{this.lastUserQuestion=""},0);break}case"conversation.item.input_audio_transcription.completed":this.lastUserQuestion+=i.transcript,this.appendToChatBubble("user",i.transcript);break;case"response.output_item.done":break;case"conversation.item.truncated":this.appendToChatBubble("ai","...");break;case"conversation.item.deleted":break;case"response.done":if("saveResponseAsync"in window){const r=this.lastAiBubble.closest(".lqd-chat-ai-bubble");saveResponseAsync(this.lastUserQuestion.trim(),this.lastAiResponse.trim(),document.querySelector("#chat_id").value,"","","","","gpt-4o-realtime-preview-2024-12-17").then(s=>{r?.setAttribute("data-message-id",s.message.id)}),this.lastResponseSaved=!0}"formatString"in window&&this.lastAiBubble&&(this.lastAiBubble.innerHTML=formatString(this.lastAiResponse));break;default:JSON.stringify(i,null,2);break}this.resetPlayers()},combineArray(i){const r=new Uint8Array(this.buffer.length+i.length);r.set(this.buffer),r.set(i,this.buffer.length),this.buffer=r},processAudioRecordingBuffer(i){const r=new Uint8Array(i);if(this.combineArray(r),this.buffer.length>=4800){const s=new Uint8Array(this.buffer.slice(0,4800));this.buffer=new Uint8Array(this.buffer.slice(4800));const o=String.fromCharCode(...s),l=btoa(o);this.recordingActive&&this.wsConnection.send({type:"input_audio_buffer.append",audio:l})}},async resetPlayers(){this.recordingActive=!1,this.audioRecorder?.stop(),this.audioPlayer?.clear()},getSystemMessage(){return""},getTemperature(){return parseFloat(.8)},getVoice(){return"alloy"},switchVisualizers(i){this.activeVisulaizer=i,this.audioVisWrap?.setAttribute("data-state",this.activeVisulaizer)},createChatBubble(i){const s=(i==="user"?this.userBubbleTemplate:this.aiBubbleTemplate).content.cloneNode(!0),o=s.querySelector(".chat-content"),l=document.querySelector("#create_canvas_button.active"),c=document.querySelector("#canvas_edit_btn_block");if(this.chatsContainer.appendChild(s),i==="user")this.lastUserBubble=o;else if(this.lastAiBubble=o,l&&c){const h=c.content.cloneNode(!0);o.closest(".chat-content-container")?.insertAdjacentElement("afterbegin",h.firstElementChild)}this.scrollConversationAreaToBottom()},appendToChatBubble(i,r){const s=i==="user"?this.lastUserBubble:this.lastAiBubble;s?(s.textContent+=r,this.scrollConversationAreaToBottom()):(this.createChatBubble(i),this.appendToChatBubble(i,r))},scrollConversationAreaToBottom(){this.conversationArea.scrollTo({top:this.conversationArea.scrollHeight+200,left:0})},startBarsVisualizer(){if(!this.audioVisBars?.length)return;const i=this.audioPlayer.audioContext.createAnalyser();i.fftSize=4096;const r=i.frequencyBinCount,s=new Uint8Array(r),o=this.audioVisBars.length;this.audioPlayer.playbackNode.connect(i);const l=[[85,150],[150,250],[250,400],[400,600],[600,1e3]];this.barHeights=this.barHeights||new Array(o).fill(0);const c=()=>{i.getByteFrequencyData(s),this.audioVisBars.forEach((h,d)=>{const[p,m]=l[d],g=Math.floor(p/(this.audioPlayer.audioContext.sampleRate/i.fftSize)),v=Math.ceil(m/(this.audioPlayer.audioContext.sampleRate/i.fftSize));let w=0;for(let E=g;E<=v&&E<s.length;E++)s[E]>w&&(w=s[E]);let S=w/255*80;this.barHeights[d]+=(S-this.barHeights[d])*.4,this.barHeights[d]+=(Math.random()-.5)*2,this.barHeights[d]=Math.max(5,Math.min(100,this.barHeights[d])),h.animate([{height:h.style.height},{height:`${this.barHeights[d]}%`}],{duration:30,fill:"forwards",easing:"linear"})}),requestAnimationFrame(c)};c()},startDotVisualizer(){if(!this.audioRecorder||!this.audioVisDotWrap)return;const i=this.audioRecorder.audioContext.createAnalyser();i.fftSize=256;const r=i.frequencyBinCount,s=new Uint8Array(r);this.audioRecorder.getMediaStreamSource().connect(i);const o=this.audioVisDotWrap.querySelector(".lqd-audio-vis-dot");if(!o)return;const l=()=>{i.getByteFrequencyData(s);let c=0;for(let m=0;m<r;m++)c+=s[m];const d=1+c/r/256*1.5,p=Math.max(.2,1-(d-1)/1.5);o.style.transform=`scale(${d})`,o.style.opacity=p.toFixed(2),requestAnimationFrame(l)};l()},checkBalanceRealtime(i=!1){return new Promise(r=>{$.ajax({url:"/dashboard/user/realtime/chat/checkBalance",type:"POST",data:{onStart:i},dataType:"json",success:s=>{const o=s.status!=="success",l=s.message||"";console.log("Try Count:",s?.tryCount),r({shouldStop:o,errorMsg:l})},error:()=>{r({shouldStop:!0,errorMsg:"An error occurred."})}})})}}),qy=(n={})=>({prevViews:[],task:!1,currentView:"home",sidebarCollapsed:!1,toolbarCollapsed:!1,modalShow:!1,activeModal:null,activeModalId:null,activeModalIdPrefix:null,currentToolsCat:"primary",tools:n.tools||[],primaryToolKeys:n.primaryToolKeys||[],showImageDetails:!1,zoomLevel:1,reachedMinZoom:!1,reachedMaxZoom:!1,newItems:[],showNotif:!1,editingImageDimensions:{width:0,height:0},painting:!1,brushSize:40,canvasCtx:null,lastUploadingImages:[],uploadingImages:[],promptLibraryShow:!1,promptFilter:"all",searchPromptStr:"",supportMultipleImageTools:["reimagine"],_busy:!1,_template:"",_prompt:"",_selectedTemplateDescription:"",_selectedPromptDescription:"",_selectedTool:"",aiModel:"",_prevEditingImage:{},_editingImage:{},get busy(){return this._busy},set busy(e){this._busy=e},get selectedTemplate(){return this._template.trim()},set selectedTemplate(e){this._template=e,this.$refs.promptInput?.focus()},get prompt(){return this._prompt},set prompt(e){this._prompt=e.trim(),this.$refs.promptInput?.focus()},get selectedTemplateDescription(){return this._selectedTemplateDescription},set selectedTemplateDescription(e){this._selectedTemplateDescription!==e&&(this._selectedTemplateDescription=e)},get selectedPromptDescription(){return this._selectedPromptDescription},set selectedPromptDescription(e){this._selectedPromptDescription!==e&&(this._selectedPromptDescription=e)},get selectedTool(){return this._selectedTool},set selectedTool(e){this.aiModel=AIModelsforTool[e],this._selectedTool!==e&&(this._selectedTool=e,this.makeCanvasEditable(this._selectedTool==="sketch_to_image"?{width:1024,height:1024}:{}),!this.selectedToolSupportMultiImagesUpload()&&this.$refs.editorFileInput.files.length&&this.clearImageInputs())},get prevEditingImage(){return this._prevEditingImage},get editingImage(){return this._editingImage},set editingImage(e){this._prevEditingImage=this._editingImage,this._editingImage=e,this.showImageDetails=!1,this.zoomLevel=1,e?.output&&fetch(e.output).then(t=>t.blob()).then(t=>{const i=new File([t],e.title?.split(".")?.at(0)||"image",{type:t.type}),r=new DataTransfer;r.items.add(i),this.$refs.uploadedImageInput.files=r.files}).catch(t=>{toastr.error("Failed to load image"),console.error("Error creating file from URL:",t)})},init(){this.onViewChange=this.onViewChange.bind(this),this.onZoomLevelChange=this.onZoomLevelChange.bind(this),this.onCreativeSuiteStageInitiated=this.onCreativeSuiteStageInitiated.bind(this),this.makeCanvasEditable=this.makeCanvasEditable.bind(this),this.startPainting=this.startPainting.bind(this),this.stopPainting=this.stopPainting.bind(this),this.paint=this.paint.bind(this),document.documentElement.style.scrollbarGutter="stable",this.$watch("currentView",this.onViewChange),this.$watch("zoomLevel",this.onZoomLevelChange),this.creativeSuite&&this.$watch("creativeSuite.stageInitiated",this.onCreativeSuiteStageInitiated);const e=new URLSearchParams(window.location.search);if(e.has("action")){const t=e.get("action");["merge_face","uncrop","reimagine","remove_background","cleanup","upscale","replace_background","sketch_to_image","remove_text","inpainting","style_transfer","image_relight"].includes(t)&&(this.currentView="editor",this.switchToolsCat({toolKey:t}),this.selectedTool=t)}},switchView(e){if(!this.creativeSuite?.editingTextNode){if(e==="<"){this.currentView=this.prevViews.pop()||"home";return}this.prevViews.push(this.currentView),this.currentView=e||"home"}},switchSidebarCollapsed(e){if(e!=null){this.sidebarCollapsed=e;return}this.sidebarCollapsed=!this.sidebarCollapsed,this.$nextTick(()=>{this.zoomLevel>1&&this.fitToScreen()}),this.$refs.imageEditorSidebar.addEventListener("transitionend",t=>{t.target!==this.$refs.imageEditorSidebar&&t.propertyName!=="transform"||this.reachedMaxZoom&&this.fitToScreen()})},onViewChange(e){const t=e==="editor";document.documentElement.style.overflow=t?"hidden":""},setActiveModal(e,t="modal"){this.activeModal=e,this.activeModalId=e.id,this.activeModalIdPrefix=t},prevImageModal(){const e=document.querySelector(`.image-result[data-id='${this.activeModalId}'][data-id-prefix=${this.activeModalIdPrefix}]`),t=e?.previousElementSibling;if(!t)return;const i=JSON.parse(t.getAttribute("data-payload")||{});this.setActiveModal(i,e.getAttribute("data-id-prefix"))},nextImageModal(){const e=document.querySelector(`.image-result[data-id='${this.activeModalId}'][data-id-prefix=${this.activeModalIdPrefix}]`),t=e?.nextElementSibling;if(!t)return;const i=JSON.parse(t.getAttribute("data-payload")||{});this.setActiveModal(i,e.getAttribute("data-id-prefix"))},getSelectedToolCat(){return this.getToolCat(this.selectedTool)},switchToolsCat(e={}){if(e.cat)return this.currentToolsCat=e.cat;if(e.toolKey)return this.currentToolsCat=this.getToolCat(e.toolKey);if(!e.cat&&!e.toolKey)return this.currentToolsCat=this.currentToolsCat==="primary"?"secondary":"primary"},getToolCat(e){return this.primaryToolKeys.findIndex(t=>t===e)>=0?"primary":"secondary"},selectedToolSupportMultiImagesUpload(){return this.supportMultipleImageTools.includes(this.selectedTool)&&this.aiModel==="openai"},handleDragOver(){this.$refs.dropArea.classList.add("drag-over")},handleDragLeave(){this.$refs.dropArea.classList.remove("drag-over")},handleUploadingMultiImages(e){if(!this.selectedToolSupportMultiImagesUpload())return;const t=Array.from(e),i=Array.from(this.lastUploadingImages),r=new DataTransfer;return i.forEach(s=>{r.items.add(s)}),t.forEach(s=>{if(!s.type.startsWith("image/")){toastr.error("Please upload a valid image file."),this.clearImageInputs();return}i.findIndex(o=>o.name===s.name&&o.size===s.size)===-1&&r.items.add(s)}),this.$refs.editorFileInput.files=r.files,this.$refs.uploadedImageInput.files=r.files,this.lastUploadingImages=r.files,this.uploadingImages=Array.from(r.files).map(s=>({src:URL.createObjectURL(s),name:s.name})),r.files},handleFileChange(e){let t=e.dataTransfer?e.dataTransfer.files:e.target?.files;if(this.$refs.dropArea.classList.remove("drag-over"),!!t){if(e.dataTransfer&&(this.$refs.editorFileInput.files=t),t&&!t.length){this.handleUploadingMultiImages(this.lastUploadingImages);return}this.selectedToolSupportMultiImagesUpload()&&(t=this.handleUploadingMultiImages(t)),this.handleFiles(t)}},handleFiles(e){if(!e[0])return;this.selectedToolSupportMultiImagesUpload()||(this.editingImage={output:URL.createObjectURL(e[0]),name:e[0].name});const t=new FormData;t.append("image",e[0]),t.append("reimagine",e[0]),["reimagine"].includes(this.selectedTool)&&(this.$refs.promptInput&&(this.$refs.promptInput.disabled=!0,this.$refs.promptInput.placeholder="Analyzing image... Please wait..."),fetch("/dashboard/user/image-to-prompt",{method:"POST",headers:{"X-CSRF-TOKEN":"{{ csrf_token() }}"},body:t}).then(i=>i.json()).then(i=>{i.status==="success"?this.prompt=i.prompt:toastr.error(i.prompt)}).catch(i=>{console.log("Error:",i)}).finally(()=>{this.$refs.promptInput&&(this.$refs.promptInput.disabled=!1,this.$refs.promptInput.placeholder="Describe your idea or select a pre-defined prompt")}))},resetUploadedImageInput(){this.zoomLevel=1,this.clearImageInputs(),this.selectedTool==="sketch_to_image"&&this.makeCanvasEditable({width:1024,height:1024})},clearImageInputs(){this.lastUploadingImages=[],this.uploadingImages=[],this.editingImage={},this.$refs.editorFileInput.value="",this.$refs.uploadedImageInput.value=""},downloadImage(e,t){const i=document.createElement("a");i.href=e,i.download=t?t.replaceAll(" ","-"):"image",i.click(),i.remove()},getMaxZoom(){const e=this.$refs.editorCanvas,t=e.offsetWidth,i=window.getComputedStyle(e);return 1+(parseFloat(i.marginLeft)+parseFloat(i.marginRight)-20)/t},setZoomLevel(e){const t=this.getMaxZoom();this.zoomLevel=Math.max(.1,Math.min(t,e)),this.reachedMinZoom=this.zoomLevel===.1,this.reachedMaxZoom=this.zoomLevel>=t},zoomIn(){this.setZoomLevel(this.zoomLevel+.1)},zoomOut(){this.setZoomLevel(this.zoomLevel-.1)},fitToScreen(){const e=this.getMaxZoom();this.setZoomLevel(e)},onZoomLevelChange(){const e=this.$refs.editorCanvas;e.style.setProperty("--zoom-level",this.zoomLevel.toFixed(3)),e.style.setProperty("--zoom-offset","0px");const t=window.getComputedStyle(e),i=parseFloat(t.getPropertyValue("--header-h")),s=e.getBoundingClientRect().top+this.$refs.editorCanvasWrap.scrollTop;s<i&&e.style.setProperty("--zoom-offset",`${(s>=0?i-s:i+Math.abs(s)).toFixed(0)}px`)},submitEditorForm(e){this.busy=!0;const t=new FormData(e.target);fetch(e.target.action,{method:"POST",body:t,headers:{Accept:"application/json"}}).then(i=>i.ok?i.json():i.json().then(r=>{throw new Error(r.message||"An unknown error occurred")})).then(i=>{if(i.type==="error"){toastr.error(i.message);return}if(i?.data?.status==="CREATED"||i?.data?.status==="IN_PROGRESS")this.task=!0,this.getStatus(i.data);else{this.editingImage=i.data,this.newItems.push(i.data),this.showNotif=!0,this.uploadingImages=[],this.selectedTool==="sketch_to_image"&&(this.switchToolsCat({toolKey:this.primaryToolKeys[0]}),this.selectedTool=this.primaryToolKeys[0]);const r=setTimeout(()=>{this.showNotif=!1,clearTimeout(r)},3e3)}}).catch(i=>{console.log(i),toastr.error(i?.message||i)}).finally(()=>{this.task||(this.busy=!1)})},async getStatus(e={}){this.busy=!0,fetch("/dashboard/user/advanced-image/editor/"+e.id+"/status",{method:"GET",headers:{Accept:"application/json"}}).then(t=>t.ok?t.json():t.json().then(i=>{throw new Error(i.message||"An unknown error occurred")})).then(t=>{if(t.status==="error")throw new Error(t.message);if(t.data.status==="COMPLETED"){this.task=!1,this.editingImage=t.data,this.newItems.push(t.data),this.showNotif=!0;const i=setTimeout(()=>{this.showNotif=!1,clearTimeout(i)},3e3);this.busy=!1}else setTimeout(()=>{this.getStatus(t.data)},1e3)}).catch(t=>{toastr.error(t?.message||t)})},async makeCanvasEditable(e={}){this.editingImageDimensions={width:e.width||this.$refs.editorImagePreview.naturalWidth,height:e.height||this.$refs.editorImagePreview.naturalHeight},await this.$nextTick();const t=this.$refs.editorMaskCanvas;this.canvasCtx?.reset(),this.canvasCtx=t.getContext("2d"),this.canvasCtx.fillStyle="black",this.canvasCtx.fillRect(0,0,t.width,t.height)},startPainting(e){this.painting=!0,this.painted=!1,this.paint(e)},stopPainting(){if(!this.painted)return;this.painting=!1,this.canvasCtx.beginPath();const e=this.$refs.editorMaskCanvas,t=document.createElement("canvas");t.width=this.editingImageDimensions.width,t.height=this.editingImageDimensions.height,t.getContext("2d").drawImage(e,0,0,t.width,t.height),t.toBlob(r=>{const s=new File([r],"mask.png",{type:"image/png"}),o=new DataTransfer;o.items.add(s),this.$refs[this.selectedTool==="sketch_to_image"?"sketchFileInput":"maskFileInput"].files=o.files,t.remove()},"image/png"),this.painted=!1},paint(e){if(!this.painting)return;const t=this.$refs.editorMaskCanvas,i=t.getBoundingClientRect(),r=(e.clientX-i.left)*(t.width/i.width),s=(e.clientY-i.top)*(t.height/i.height);this.canvasCtx.lineWidth=this.brushSize,this.canvasCtx.opacityTo=7,this.canvasCtx.lineCap="round",this.canvasCtx.strokeStyle="yellow",this.canvasCtx.lineTo(r,s),this.canvasCtx.stroke(),this.canvasCtx.beginPath(),this.canvasCtx.moveTo(r,s),this.painted=!0},setBrushSize(e){e==="-"?e=Math.max(this.brushSize-10,10):e==="+"&&(e=Math.min(this.brushSize+10,100)),this.brushSize=parseInt(e,10)},togglePromptLibraryShow(){this.promptLibraryShow=!this.promptLibraryShow},changePromptFilter(e){e!==this.promptFilter&&(this.promptFilter=e)},setSearchPromptStr(e){this.searchPromptStr=e.trim().toLowerCase()},setPrompt(e){this.prompt=e},focusOnPrompt(){this.$nextTick(()=>this.$refs.promptInput.focus())},onCreativeSuiteStageInitiated(e){e&&_.defer(()=>{this.toolbarCollapsed=!0})}});var $l=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function WF(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Wo={exports:{}};/** * @license * Lodash <https://lodash.com/> * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> * Released under MIT license <https://lodash.com/license> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */var zI=Wo.exports,Ky;function HI(){return Ky||(Ky=1,(function(n,e){(function(){var t,i="4.17.21",r=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",o="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",h=500,d="__lodash_placeholder__",p=1,m=2,g=4,v=1,w=2,S=1,E=2,k=4,I=8,R=16,N=32,V=64,U=128,W=256,G=512,Y=30,le="...",ke=800,we=16,pe=1,_e=2,de=3,ce=1/0,Oe=9007199254740991,Yt=17976931348623157e292,ji=NaN,_t=4294967295,ao=_t-1,dS=_t>>>1,fS=[["ary",U],["bind",S],["bindKey",E],["curry",I],["curryRight",R],["flip",G],["partial",N],["partialRight",V],["rearg",W]],us="[object Arguments]",La="[object Array]",pS="[object AsyncFunction]",lo="[object Boolean]",co="[object Date]",mS="[object DOMException]",Fa="[object Error]",$a="[object Function]",qp="[object GeneratorFunction]",Bn="[object Map]",uo="[object Number]",gS="[object Null]",bi="[object Object]",Kp="[object Promise]",yS="[object Proxy]",ho="[object RegExp]",zn="[object Set]",fo="[object String]",Ba="[object Symbol]",vS="[object Undefined]",po="[object WeakMap]",bS="[object WeakSet]",mo="[object ArrayBuffer]",hs="[object DataView]",Lu="[object Float32Array]",Fu="[object Float64Array]",$u="[object Int8Array]",Bu="[object Int16Array]",zu="[object Int32Array]",Hu="[object Uint8Array]",Vu="[object Uint8ClampedArray]",Wu="[object Uint16Array]",Uu="[object Uint32Array]",wS=/\b__p \+= '';/g,SS=/\b(__p \+=) '' \+/g,xS=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Gp=/&(?:amp|lt|gt|quot|#39);/g,jp=/[&<>"']/g,CS=RegExp(Gp.source),ES=RegExp(jp.source),TS=/<%-([\s\S]+?)%>/g,kS=/<%([\s\S]+?)%>/g,Xp=/<%=([\s\S]+?)%>/g,AS=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,MS=/^\w*$/,OS=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qu=/[\\^$.*+?()[\]{}|]/g,IS=RegExp(qu.source),Ku=/^\s+/,DS=/\s/,_S=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,RS=/\{\n\/\* \[wrapped with (.+)\] \*/,NS=/,? & /,PS=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,LS=/[()=,{}\[\]\/\s]/,FS=/\\(\\)?/g,$S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Yp=/\w*$/,BS=/^[-+]0x[0-9a-f]+$/i,zS=/^0b[01]+$/i,HS=/^\[object .+?Constructor\]$/,VS=/^0o[0-7]+$/i,WS=/^(?:0|[1-9]\d*)$/,US=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,za=/($^)/,qS=/['\n\r\u2028\u2029\\]/g,Ha="\\ud800-\\udfff",KS="\\u0300-\\u036f",GS="\\ufe20-\\ufe2f",jS="\\u20d0-\\u20ff",Jp=KS+GS+jS,Zp="\\u2700-\\u27bf",Qp="a-z\\xdf-\\xf6\\xf8-\\xff",XS="\\xac\\xb1\\xd7\\xf7",YS="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",JS="\\u2000-\\u206f",ZS=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",em="A-Z\\xc0-\\xd6\\xd8-\\xde",tm="\\ufe0e\\ufe0f",nm=XS+YS+JS+ZS,Gu="['’]",QS="["+Ha+"]",im="["+nm+"]",Va="["+Jp+"]",rm="\\d+",ex="["+Zp+"]",sm="["+Qp+"]",om="[^"+Ha+nm+rm+Zp+Qp+em+"]",ju="\\ud83c[\\udffb-\\udfff]",tx="(?:"+Va+"|"+ju+")",am="[^"+Ha+"]",Xu="(?:\\ud83c[\\udde6-\\uddff]){2}",Yu="[\\ud800-\\udbff][\\udc00-\\udfff]",ds="["+em+"]",lm="\\u200d",cm="(?:"+sm+"|"+om+")",nx="(?:"+ds+"|"+om+")",um="(?:"+Gu+"(?:d|ll|m|re|s|t|ve))?",hm="(?:"+Gu+"(?:D|LL|M|RE|S|T|VE))?",dm=tx+"?",fm="["+tm+"]?",ix="(?:"+lm+"(?:"+[am,Xu,Yu].join("|")+")"+fm+dm+")*",rx="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",sx="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",pm=fm+dm+ix,ox="(?:"+[ex,Xu,Yu].join("|")+")"+pm,ax="(?:"+[am+Va+"?",Va,Xu,Yu,QS].join("|")+")",lx=RegExp(Gu,"g"),cx=RegExp(Va,"g"),Ju=RegExp(ju+"(?="+ju+")|"+ax+pm,"g"),ux=RegExp([ds+"?"+sm+"+"+um+"(?="+[im,ds,"$"].join("|")+")",nx+"+"+hm+"(?="+[im,ds+cm,"$"].join("|")+")",ds+"?"+cm+"+"+um,ds+"+"+hm,sx,rx,rm,ox].join("|"),"g"),hx=RegExp("["+lm+Ha+Jp+tm+"]"),dx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fx=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],px=-1,Ue={};Ue[Lu]=Ue[Fu]=Ue[$u]=Ue[Bu]=Ue[zu]=Ue[Hu]=Ue[Vu]=Ue[Wu]=Ue[Uu]=!0,Ue[us]=Ue[La]=Ue[mo]=Ue[lo]=Ue[hs]=Ue[co]=Ue[Fa]=Ue[$a]=Ue[Bn]=Ue[uo]=Ue[bi]=Ue[ho]=Ue[zn]=Ue[fo]=Ue[po]=!1;var Ve={};Ve[us]=Ve[La]=Ve[mo]=Ve[hs]=Ve[lo]=Ve[co]=Ve[Lu]=Ve[Fu]=Ve[$u]=Ve[Bu]=Ve[zu]=Ve[Bn]=Ve[uo]=Ve[bi]=Ve[ho]=Ve[zn]=Ve[fo]=Ve[Ba]=Ve[Hu]=Ve[Vu]=Ve[Wu]=Ve[Uu]=!0,Ve[Fa]=Ve[$a]=Ve[po]=!1;var mx={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},gx={"&":"&","<":"<",">":">",'"':""","'":"'"},yx={"&":"&","<":"<",">":">",""":'"',"'":"'"},vx={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},bx=parseFloat,wx=parseInt,mm=typeof $l=="object"&&$l&&$l.Object===Object&&$l,Sx=typeof self=="object"&&self&&self.Object===Object&&self,Et=mm||Sx||Function("return this")(),Zu=e&&!e.nodeType&&e,Or=Zu&&!0&&n&&!n.nodeType&&n,gm=Or&&Or.exports===Zu,Qu=gm&&mm.process,En=(function(){try{var M=Or&&Or.require&&Or.require("util").types;return M||Qu&&Qu.binding&&Qu.binding("util")}catch{}})(),ym=En&&En.isArrayBuffer,vm=En&&En.isDate,bm=En&&En.isMap,wm=En&&En.isRegExp,Sm=En&&En.isSet,xm=En&&En.isTypedArray;function cn(M,P,D){switch(D.length){case 0:return M.call(P);case 1:return M.call(P,D[0]);case 2:return M.call(P,D[0],D[1]);case 3:return M.call(P,D[0],D[1],D[2])}return M.apply(P,D)}function xx(M,P,D,J){for(var me=-1,Ne=M==null?0:M.length;++me<Ne;){var vt=M[me];P(J,vt,D(vt),M)}return J}function Tn(M,P){for(var D=-1,J=M==null?0:M.length;++D<J&&P(M[D],D,M)!==!1;);return M}function Cx(M,P){for(var D=M==null?0:M.length;D--&&P(M[D],D,M)!==!1;);return M}function Cm(M,P){for(var D=-1,J=M==null?0:M.length;++D<J;)if(!P(M[D],D,M))return!1;return!0}function Xi(M,P){for(var D=-1,J=M==null?0:M.length,me=0,Ne=[];++D<J;){var vt=M[D];P(vt,D,M)&&(Ne[me++]=vt)}return Ne}function Wa(M,P){var D=M==null?0:M.length;return!!D&&fs(M,P,0)>-1}function eh(M,P,D){for(var J=-1,me=M==null?0:M.length;++J<me;)if(D(P,M[J]))return!0;return!1}function Ge(M,P){for(var D=-1,J=M==null?0:M.length,me=Array(J);++D<J;)me[D]=P(M[D],D,M);return me}function Yi(M,P){for(var D=-1,J=P.length,me=M.length;++D<J;)M[me+D]=P[D];return M}function th(M,P,D,J){var me=-1,Ne=M==null?0:M.length;for(J&&Ne&&(D=M[++me]);++me<Ne;)D=P(D,M[me],me,M);return D}function Ex(M,P,D,J){var me=M==null?0:M.length;for(J&&me&&(D=M[--me]);me--;)D=P(D,M[me],me,M);return D}function nh(M,P){for(var D=-1,J=M==null?0:M.length;++D<J;)if(P(M[D],D,M))return!0;return!1}var Tx=ih("length");function kx(M){return M.split("")}function Ax(M){return M.match(PS)||[]}function Em(M,P,D){var J;return D(M,function(me,Ne,vt){if(P(me,Ne,vt))return J=Ne,!1}),J}function Ua(M,P,D,J){for(var me=M.length,Ne=D+(J?1:-1);J?Ne--:++Ne<me;)if(P(M[Ne],Ne,M))return Ne;return-1}function fs(M,P,D){return P===P?Bx(M,P,D):Ua(M,Tm,D)}function Mx(M,P,D,J){for(var me=D-1,Ne=M.length;++me<Ne;)if(J(M[me],P))return me;return-1}function Tm(M){return M!==M}function km(M,P){var D=M==null?0:M.length;return D?sh(M,P)/D:ji}function ih(M){return function(P){return P==null?t:P[M]}}function rh(M){return function(P){return M==null?t:M[P]}}function Am(M,P,D,J,me){return me(M,function(Ne,vt,ze){D=J?(J=!1,Ne):P(D,Ne,vt,ze)}),D}function Ox(M,P){var D=M.length;for(M.sort(P);D--;)M[D]=M[D].value;return M}function sh(M,P){for(var D,J=-1,me=M.length;++J<me;){var Ne=P(M[J]);Ne!==t&&(D=D===t?Ne:D+Ne)}return D}function oh(M,P){for(var D=-1,J=Array(M);++D<M;)J[D]=P(D);return J}function Ix(M,P){return Ge(P,function(D){return[D,M[D]]})}function Mm(M){return M&&M.slice(0,_m(M)+1).replace(Ku,"")}function un(M){return function(P){return M(P)}}function ah(M,P){return Ge(P,function(D){return M[D]})}function go(M,P){return M.has(P)}function Om(M,P){for(var D=-1,J=M.length;++D<J&&fs(P,M[D],0)>-1;);return D}function Im(M,P){for(var D=M.length;D--&&fs(P,M[D],0)>-1;);return D}function Dx(M,P){for(var D=M.length,J=0;D--;)M[D]===P&&++J;return J}var _x=rh(mx),Rx=rh(gx);function Nx(M){return"\\"+vx[M]}function Px(M,P){return M==null?t:M[P]}function ps(M){return hx.test(M)}function Lx(M){return dx.test(M)}function Fx(M){for(var P,D=[];!(P=M.next()).done;)D.push(P.value);return D}function lh(M){var P=-1,D=Array(M.size);return M.forEach(function(J,me){D[++P]=[me,J]}),D}function Dm(M,P){return function(D){return M(P(D))}}function Ji(M,P){for(var D=-1,J=M.length,me=0,Ne=[];++D<J;){var vt=M[D];(vt===P||vt===d)&&(M[D]=d,Ne[me++]=D)}return Ne}function qa(M){var P=-1,D=Array(M.size);return M.forEach(function(J){D[++P]=J}),D}function $x(M){var P=-1,D=Array(M.size);return M.forEach(function(J){D[++P]=[J,J]}),D}function Bx(M,P,D){for(var J=D-1,me=M.length;++J<me;)if(M[J]===P)return J;return-1}function zx(M,P,D){for(var J=D+1;J--;)if(M[J]===P)return J;return J}function ms(M){return ps(M)?Vx(M):Tx(M)}function Hn(M){return ps(M)?Wx(M):kx(M)}function _m(M){for(var P=M.length;P--&&DS.test(M.charAt(P)););return P}var Hx=rh(yx);function Vx(M){for(var P=Ju.lastIndex=0;Ju.test(M);)++P;return P}function Wx(M){return M.match(Ju)||[]}function Ux(M){return M.match(ux)||[]}var qx=(function M(P){P=P==null?Et:gs.defaults(Et.Object(),P,gs.pick(Et,fx));var D=P.Array,J=P.Date,me=P.Error,Ne=P.Function,vt=P.Math,ze=P.Object,ch=P.RegExp,Kx=P.String,kn=P.TypeError,Ka=D.prototype,Gx=Ne.prototype,ys=ze.prototype,Ga=P["__core-js_shared__"],ja=Gx.toString,$e=ys.hasOwnProperty,jx=0,Rm=(function(){var a=/[^.]+$/.exec(Ga&&Ga.keys&&Ga.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""})(),Xa=ys.toString,Xx=ja.call(ze),Yx=Et._,Jx=ch("^"+ja.call($e).replace(qu,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ya=gm?P.Buffer:t,Zi=P.Symbol,Ja=P.Uint8Array,Nm=Ya?Ya.allocUnsafe:t,Za=Dm(ze.getPrototypeOf,ze),Pm=ze.create,Lm=ys.propertyIsEnumerable,Qa=Ka.splice,Fm=Zi?Zi.isConcatSpreadable:t,yo=Zi?Zi.iterator:t,Ir=Zi?Zi.toStringTag:t,el=(function(){try{var a=Pr(ze,"defineProperty");return a({},"",{}),a}catch{}})(),Zx=P.clearTimeout!==Et.clearTimeout&&P.clearTimeout,Qx=J&&J.now!==Et.Date.now&&J.now,eC=P.setTimeout!==Et.setTimeout&&P.setTimeout,tl=vt.ceil,nl=vt.floor,uh=ze.getOwnPropertySymbols,tC=Ya?Ya.isBuffer:t,$m=P.isFinite,nC=Ka.join,iC=Dm(ze.keys,ze),bt=vt.max,Rt=vt.min,rC=J.now,sC=P.parseInt,Bm=vt.random,oC=Ka.reverse,hh=Pr(P,"DataView"),vo=Pr(P,"Map"),dh=Pr(P,"Promise"),vs=Pr(P,"Set"),bo=Pr(P,"WeakMap"),wo=Pr(ze,"create"),il=bo&&new bo,bs={},aC=Lr(hh),lC=Lr(vo),cC=Lr(dh),uC=Lr(vs),hC=Lr(bo),rl=Zi?Zi.prototype:t,So=rl?rl.valueOf:t,zm=rl?rl.toString:t;function x(a){if(nt(a)&&!be(a)&&!(a instanceof Ie)){if(a instanceof An)return a;if($e.call(a,"__wrapped__"))return Hg(a)}return new An(a)}var ws=(function(){function a(){}return function(u){if(!Je(u))return{};if(Pm)return Pm(u);a.prototype=u;var f=new a;return a.prototype=t,f}})();function sl(){}function An(a,u){this.__wrapped__=a,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=t}x.templateSettings={escape:TS,evaluate:kS,interpolate:Xp,variable:"",imports:{_:x}},x.prototype=sl.prototype,x.prototype.constructor=x,An.prototype=ws(sl.prototype),An.prototype.constructor=An;function Ie(a){this.__wrapped__=a,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=_t,this.__views__=[]}function dC(){var a=new Ie(this.__wrapped__);return a.__actions__=Jt(this.__actions__),a.__dir__=this.__dir__,a.__filtered__=this.__filtered__,a.__iteratees__=Jt(this.__iteratees__),a.__takeCount__=this.__takeCount__,a.__views__=Jt(this.__views__),a}function fC(){if(this.__filtered__){var a=new Ie(this);a.__dir__=-1,a.__filtered__=!0}else a=this.clone(),a.__dir__*=-1;return a}function pC(){var a=this.__wrapped__.value(),u=this.__dir__,f=be(a),y=u<0,b=f?a.length:0,C=kE(0,b,this.__views__),T=C.start,A=C.end,O=A-T,L=y?A:T-1,F=this.__iteratees__,B=F.length,X=0,ee=Rt(O,this.__takeCount__);if(!f||!y&&b==O&&ee==O)return ug(a,this.__actions__);var re=[];e:for(;O--&&X<ee;){L+=u;for(var Ce=-1,se=a[L];++Ce<B;){var Me=F[Ce],De=Me.iteratee,fn=Me.type,Vt=De(se);if(fn==_e)se=Vt;else if(!Vt){if(fn==pe)continue e;break e}}re[X++]=se}return re}Ie.prototype=ws(sl.prototype),Ie.prototype.constructor=Ie;function Dr(a){var u=-1,f=a==null?0:a.length;for(this.clear();++u<f;){var y=a[u];this.set(y[0],y[1])}}function mC(){this.__data__=wo?wo(null):{},this.size=0}function gC(a){var u=this.has(a)&&delete this.__data__[a];return this.size-=u?1:0,u}function yC(a){var u=this.__data__;if(wo){var f=u[a];return f===c?t:f}return $e.call(u,a)?u[a]:t}function vC(a){var u=this.__data__;return wo?u[a]!==t:$e.call(u,a)}function bC(a,u){var f=this.__data__;return this.size+=this.has(a)?0:1,f[a]=wo&&u===t?c:u,this}Dr.prototype.clear=mC,Dr.prototype.delete=gC,Dr.prototype.get=yC,Dr.prototype.has=vC,Dr.prototype.set=bC;function wi(a){var u=-1,f=a==null?0:a.length;for(this.clear();++u<f;){var y=a[u];this.set(y[0],y[1])}}function wC(){this.__data__=[],this.size=0}function SC(a){var u=this.__data__,f=ol(u,a);if(f<0)return!1;var y=u.length-1;return f==y?u.pop():Qa.call(u,f,1),--this.size,!0}function xC(a){var u=this.__data__,f=ol(u,a);return f<0?t:u[f][1]}function CC(a){return ol(this.__data__,a)>-1}function EC(a,u){var f=this.__data__,y=ol(f,a);return y<0?(++this.size,f.push([a,u])):f[y][1]=u,this}wi.prototype.clear=wC,wi.prototype.delete=SC,wi.prototype.get=xC,wi.prototype.has=CC,wi.prototype.set=EC;function Si(a){var u=-1,f=a==null?0:a.length;for(this.clear();++u<f;){var y=a[u];this.set(y[0],y[1])}}function TC(){this.size=0,this.__data__={hash:new Dr,map:new(vo||wi),string:new Dr}}function kC(a){var u=vl(this,a).delete(a);return this.size-=u?1:0,u}function AC(a){return vl(this,a).get(a)}function MC(a){return vl(this,a).has(a)}function OC(a,u){var f=vl(this,a),y=f.size;return f.set(a,u),this.size+=f.size==y?0:1,this}Si.prototype.clear=TC,Si.prototype.delete=kC,Si.prototype.get=AC,Si.prototype.has=MC,Si.prototype.set=OC;function _r(a){var u=-1,f=a==null?0:a.length;for(this.__data__=new Si;++u<f;)this.add(a[u])}function IC(a){return this.__data__.set(a,c),this}function DC(a){return this.__data__.has(a)}_r.prototype.add=_r.prototype.push=IC,_r.prototype.has=DC;function Vn(a){var u=this.__data__=new wi(a);this.size=u.size}function _C(){this.__data__=new wi,this.size=0}function RC(a){var u=this.__data__,f=u.delete(a);return this.size=u.size,f}function NC(a){return this.__data__.get(a)}function PC(a){return this.__data__.has(a)}function LC(a,u){var f=this.__data__;if(f instanceof wi){var y=f.__data__;if(!vo||y.length<r-1)return y.push([a,u]),this.size=++f.size,this;f=this.__data__=new Si(y)}return f.set(a,u),this.size=f.size,this}Vn.prototype.clear=_C,Vn.prototype.delete=RC,Vn.prototype.get=NC,Vn.prototype.has=PC,Vn.prototype.set=LC;function Hm(a,u){var f=be(a),y=!f&&Fr(a),b=!f&&!y&&ir(a),C=!f&&!y&&!b&&Es(a),T=f||y||b||C,A=T?oh(a.length,Kx):[],O=A.length;for(var L in a)(u||$e.call(a,L))&&!(T&&(L=="length"||b&&(L=="offset"||L=="parent")||C&&(L=="buffer"||L=="byteLength"||L=="byteOffset")||Ti(L,O)))&&A.push(L);return A}function Vm(a){var u=a.length;return u?a[Ch(0,u-1)]:t}function FC(a,u){return bl(Jt(a),Rr(u,0,a.length))}function $C(a){return bl(Jt(a))}function fh(a,u,f){(f!==t&&!Wn(a[u],f)||f===t&&!(u in a))&&xi(a,u,f)}function xo(a,u,f){var y=a[u];(!($e.call(a,u)&&Wn(y,f))||f===t&&!(u in a))&&xi(a,u,f)}function ol(a,u){for(var f=a.length;f--;)if(Wn(a[f][0],u))return f;return-1}function BC(a,u,f,y){return Qi(a,function(b,C,T){u(y,b,f(b),T)}),y}function Wm(a,u){return a&&ii(u,wt(u),a)}function zC(a,u){return a&&ii(u,Qt(u),a)}function xi(a,u,f){u=="__proto__"&&el?el(a,u,{configurable:!0,enumerable:!0,value:f,writable:!0}):a[u]=f}function ph(a,u){for(var f=-1,y=u.length,b=D(y),C=a==null;++f<y;)b[f]=C?t:jh(a,u[f]);return b}function Rr(a,u,f){return a===a&&(f!==t&&(a=a<=f?a:f),u!==t&&(a=a>=u?a:u)),a}function Mn(a,u,f,y,b,C){var T,A=u&p,O=u&m,L=u&g;if(f&&(T=b?f(a,y,b,C):f(a)),T!==t)return T;if(!Je(a))return a;var F=be(a);if(F){if(T=ME(a),!A)return Jt(a,T)}else{var B=Nt(a),X=B==$a||B==qp;if(ir(a))return fg(a,A);if(B==bi||B==us||X&&!b){if(T=O||X?{}:_g(a),!A)return O?yE(a,zC(T,a)):gE(a,Wm(T,a))}else{if(!Ve[B])return b?a:{};T=OE(a,B,A)}}C||(C=new Vn);var ee=C.get(a);if(ee)return ee;C.set(a,T),ay(a)?a.forEach(function(se){T.add(Mn(se,u,f,se,a,C))}):sy(a)&&a.forEach(function(se,Me){T.set(Me,Mn(se,u,f,Me,a,C))});var re=L?O?Nh:Rh:O?Qt:wt,Ce=F?t:re(a);return Tn(Ce||a,function(se,Me){Ce&&(Me=se,se=a[Me]),xo(T,Me,Mn(se,u,f,Me,a,C))}),T}function HC(a){var u=wt(a);return function(f){return Um(f,a,u)}}function Um(a,u,f){var y=f.length;if(a==null)return!y;for(a=ze(a);y--;){var b=f[y],C=u[b],T=a[b];if(T===t&&!(b in a)||!C(T))return!1}return!0}function qm(a,u,f){if(typeof a!="function")throw new kn(o);return Oo(function(){a.apply(t,f)},u)}function Co(a,u,f,y){var b=-1,C=Wa,T=!0,A=a.length,O=[],L=u.length;if(!A)return O;f&&(u=Ge(u,un(f))),y?(C=eh,T=!1):u.length>=r&&(C=go,T=!1,u=new _r(u));e:for(;++b<A;){var F=a[b],B=f==null?F:f(F);if(F=y||F!==0?F:0,T&&B===B){for(var X=L;X--;)if(u[X]===B)continue e;O.push(F)}else C(u,B,y)||O.push(F)}return O}var Qi=vg(ni),Km=vg(gh,!0);function VC(a,u){var f=!0;return Qi(a,function(y,b,C){return f=!!u(y,b,C),f}),f}function al(a,u,f){for(var y=-1,b=a.length;++y<b;){var C=a[y],T=u(C);if(T!=null&&(A===t?T===T&&!dn(T):f(T,A)))var A=T,O=C}return O}function WC(a,u,f,y){var b=a.length;for(f=Se(f),f<0&&(f=-f>b?0:b+f),y=y===t||y>b?b:Se(y),y<0&&(y+=b),y=f>y?0:cy(y);f<y;)a[f++]=u;return a}function Gm(a,u){var f=[];return Qi(a,function(y,b,C){u(y,b,C)&&f.push(y)}),f}function Tt(a,u,f,y,b){var C=-1,T=a.length;for(f||(f=DE),b||(b=[]);++C<T;){var A=a[C];u>0&&f(A)?u>1?Tt(A,u-1,f,y,b):Yi(b,A):y||(b[b.length]=A)}return b}var mh=bg(),jm=bg(!0);function ni(a,u){return a&&mh(a,u,wt)}function gh(a,u){return a&&jm(a,u,wt)}function ll(a,u){return Xi(u,function(f){return ki(a[f])})}function Nr(a,u){u=tr(u,a);for(var f=0,y=u.length;a!=null&&f<y;)a=a[ri(u[f++])];return f&&f==y?a:t}function Xm(a,u,f){var y=u(a);return be(a)?y:Yi(y,f(a))}function zt(a){return a==null?a===t?vS:gS:Ir&&Ir in ze(a)?TE(a):$E(a)}function yh(a,u){return a>u}function UC(a,u){return a!=null&&$e.call(a,u)}function qC(a,u){return a!=null&&u in ze(a)}function KC(a,u,f){return a>=Rt(u,f)&&a<bt(u,f)}function vh(a,u,f){for(var y=f?eh:Wa,b=a[0].length,C=a.length,T=C,A=D(C),O=1/0,L=[];T--;){var F=a[T];T&&u&&(F=Ge(F,un(u))),O=Rt(F.length,O),A[T]=!f&&(u||b>=120&&F.length>=120)?new _r(T&&F):t}F=a[0];var B=-1,X=A[0];e:for(;++B<b&&L.length<O;){var ee=F[B],re=u?u(ee):ee;if(ee=f||ee!==0?ee:0,!(X?go(X,re):y(L,re,f))){for(T=C;--T;){var Ce=A[T];if(!(Ce?go(Ce,re):y(a[T],re,f)))continue e}X&&X.push(re),L.push(ee)}}return L}function GC(a,u,f,y){return ni(a,function(b,C,T){u(y,f(b),C,T)}),y}function Eo(a,u,f){u=tr(u,a),a=Lg(a,u);var y=a==null?a:a[ri(In(u))];return y==null?t:cn(y,a,f)}function Ym(a){return nt(a)&&zt(a)==us}function jC(a){return nt(a)&&zt(a)==mo}function XC(a){return nt(a)&&zt(a)==co}function To(a,u,f,y,b){return a===u?!0:a==null||u==null||!nt(a)&&!nt(u)?a!==a&&u!==u:YC(a,u,f,y,To,b)}function YC(a,u,f,y,b,C){var T=be(a),A=be(u),O=T?La:Nt(a),L=A?La:Nt(u);O=O==us?bi:O,L=L==us?bi:L;var F=O==bi,B=L==bi,X=O==L;if(X&&ir(a)){if(!ir(u))return!1;T=!0,F=!1}if(X&&!F)return C||(C=new Vn),T||Es(a)?Og(a,u,f,y,b,C):CE(a,u,O,f,y,b,C);if(!(f&v)){var ee=F&&$e.call(a,"__wrapped__"),re=B&&$e.call(u,"__wrapped__");if(ee||re){var Ce=ee?a.value():a,se=re?u.value():u;return C||(C=new Vn),b(Ce,se,f,y,C)}}return X?(C||(C=new Vn),EE(a,u,f,y,b,C)):!1}function JC(a){return nt(a)&&Nt(a)==Bn}function bh(a,u,f,y){var b=f.length,C=b,T=!y;if(a==null)return!C;for(a=ze(a);b--;){var A=f[b];if(T&&A[2]?A[1]!==a[A[0]]:!(A[0]in a))return!1}for(;++b<C;){A=f[b];var O=A[0],L=a[O],F=A[1];if(T&&A[2]){if(L===t&&!(O in a))return!1}else{var B=new Vn;if(y)var X=y(L,F,O,a,u,B);if(!(X===t?To(F,L,v|w,y,B):X))return!1}}return!0}function Jm(a){if(!Je(a)||RE(a))return!1;var u=ki(a)?Jx:HS;return u.test(Lr(a))}function ZC(a){return nt(a)&&zt(a)==ho}function QC(a){return nt(a)&&Nt(a)==zn}function eE(a){return nt(a)&&Tl(a.length)&&!!Ue[zt(a)]}function Zm(a){return typeof a=="function"?a:a==null?en:typeof a=="object"?be(a)?tg(a[0],a[1]):eg(a):wy(a)}function wh(a){if(!Mo(a))return iC(a);var u=[];for(var f in ze(a))$e.call(a,f)&&f!="constructor"&&u.push(f);return u}function tE(a){if(!Je(a))return FE(a);var u=Mo(a),f=[];for(var y in a)y=="constructor"&&(u||!$e.call(a,y))||f.push(y);return f}function Sh(a,u){return a<u}function Qm(a,u){var f=-1,y=Zt(a)?D(a.length):[];return Qi(a,function(b,C,T){y[++f]=u(b,C,T)}),y}function eg(a){var u=Lh(a);return u.length==1&&u[0][2]?Ng(u[0][0],u[0][1]):function(f){return f===a||bh(f,a,u)}}function tg(a,u){return $h(a)&&Rg(u)?Ng(ri(a),u):function(f){var y=jh(f,a);return y===t&&y===u?Xh(f,a):To(u,y,v|w)}}function cl(a,u,f,y,b){a!==u&&mh(u,function(C,T){if(b||(b=new Vn),Je(C))nE(a,u,T,f,cl,y,b);else{var A=y?y(zh(a,T),C,T+"",a,u,b):t;A===t&&(A=C),fh(a,T,A)}},Qt)}function nE(a,u,f,y,b,C,T){var A=zh(a,f),O=zh(u,f),L=T.get(O);if(L){fh(a,f,L);return}var F=C?C(A,O,f+"",a,u,T):t,B=F===t;if(B){var X=be(O),ee=!X&&ir(O),re=!X&&!ee&&Es(O);F=O,X||ee||re?be(A)?F=A:lt(A)?F=Jt(A):ee?(B=!1,F=fg(O,!0)):re?(B=!1,F=pg(O,!0)):F=[]:Io(O)||Fr(O)?(F=A,Fr(A)?F=uy(A):(!Je(A)||ki(A))&&(F=_g(O))):B=!1}B&&(T.set(O,F),b(F,O,y,C,T),T.delete(O)),fh(a,f,F)}function ng(a,u){var f=a.length;if(f)return u+=u<0?f:0,Ti(u,f)?a[u]:t}function ig(a,u,f){u.length?u=Ge(u,function(C){return be(C)?function(T){return Nr(T,C.length===1?C[0]:C)}:C}):u=[en];var y=-1;u=Ge(u,un(ie()));var b=Qm(a,function(C,T,A){var O=Ge(u,function(L){return L(C)});return{criteria:O,index:++y,value:C}});return Ox(b,function(C,T){return mE(C,T,f)})}function iE(a,u){return rg(a,u,function(f,y){return Xh(a,y)})}function rg(a,u,f){for(var y=-1,b=u.length,C={};++y<b;){var T=u[y],A=Nr(a,T);f(A,T)&&ko(C,tr(T,a),A)}return C}function rE(a){return function(u){return Nr(u,a)}}function xh(a,u,f,y){var b=y?Mx:fs,C=-1,T=u.length,A=a;for(a===u&&(u=Jt(u)),f&&(A=Ge(a,un(f)));++C<T;)for(var O=0,L=u[C],F=f?f(L):L;(O=b(A,F,O,y))>-1;)A!==a&&Qa.call(A,O,1),Qa.call(a,O,1);return a}function sg(a,u){for(var f=a?u.length:0,y=f-1;f--;){var b=u[f];if(f==y||b!==C){var C=b;Ti(b)?Qa.call(a,b,1):kh(a,b)}}return a}function Ch(a,u){return a+nl(Bm()*(u-a+1))}function sE(a,u,f,y){for(var b=-1,C=bt(tl((u-a)/(f||1)),0),T=D(C);C--;)T[y?C:++b]=a,a+=f;return T}function Eh(a,u){var f="";if(!a||u<1||u>Oe)return f;do u%2&&(f+=a),u=nl(u/2),u&&(a+=a);while(u);return f}function Ae(a,u){return Hh(Pg(a,u,en),a+"")}function oE(a){return Vm(Ts(a))}function aE(a,u){var f=Ts(a);return bl(f,Rr(u,0,f.length))}function ko(a,u,f,y){if(!Je(a))return a;u=tr(u,a);for(var b=-1,C=u.length,T=C-1,A=a;A!=null&&++b<C;){var O=ri(u[b]),L=f;if(O==="__proto__"||O==="constructor"||O==="prototype")return a;if(b!=T){var F=A[O];L=y?y(F,O,A):t,L===t&&(L=Je(F)?F:Ti(u[b+1])?[]:{})}xo(A,O,L),A=A[O]}return a}var og=il?function(a,u){return il.set(a,u),a}:en,lE=el?function(a,u){return el(a,"toString",{configurable:!0,enumerable:!1,value:Jh(u),writable:!0})}:en;function cE(a){return bl(Ts(a))}function On(a,u,f){var y=-1,b=a.length;u<0&&(u=-u>b?0:b+u),f=f>b?b:f,f<0&&(f+=b),b=u>f?0:f-u>>>0,u>>>=0;for(var C=D(b);++y<b;)C[y]=a[y+u];return C}function uE(a,u){var f;return Qi(a,function(y,b,C){return f=u(y,b,C),!f}),!!f}function ul(a,u,f){var y=0,b=a==null?y:a.length;if(typeof u=="number"&&u===u&&b<=dS){for(;y<b;){var C=y+b>>>1,T=a[C];T!==null&&!dn(T)&&(f?T<=u:T<u)?y=C+1:b=C}return b}return Th(a,u,en,f)}function Th(a,u,f,y){var b=0,C=a==null?0:a.length;if(C===0)return 0;u=f(u);for(var T=u!==u,A=u===null,O=dn(u),L=u===t;b<C;){var F=nl((b+C)/2),B=f(a[F]),X=B!==t,ee=B===null,re=B===B,Ce=dn(B);if(T)var se=y||re;else L?se=re&&(y||X):A?se=re&&X&&(y||!ee):O?se=re&&X&&!ee&&(y||!Ce):ee||Ce?se=!1:se=y?B<=u:B<u;se?b=F+1:C=F}return Rt(C,ao)}function ag(a,u){for(var f=-1,y=a.length,b=0,C=[];++f<y;){var T=a[f],A=u?u(T):T;if(!f||!Wn(A,O)){var O=A;C[b++]=T===0?0:T}}return C}function lg(a){return typeof a=="number"?a:dn(a)?ji:+a}function hn(a){if(typeof a=="string")return a;if(be(a))return Ge(a,hn)+"";if(dn(a))return zm?zm.call(a):"";var u=a+"";return u=="0"&&1/a==-ce?"-0":u}function er(a,u,f){var y=-1,b=Wa,C=a.length,T=!0,A=[],O=A;if(f)T=!1,b=eh;else if(C>=r){var L=u?null:SE(a);if(L)return qa(L);T=!1,b=go,O=new _r}else O=u?[]:A;e:for(;++y<C;){var F=a[y],B=u?u(F):F;if(F=f||F!==0?F:0,T&&B===B){for(var X=O.length;X--;)if(O[X]===B)continue e;u&&O.push(B),A.push(F)}else b(O,B,f)||(O!==A&&O.push(B),A.push(F))}return A}function kh(a,u){return u=tr(u,a),a=Lg(a,u),a==null||delete a[ri(In(u))]}function cg(a,u,f,y){return ko(a,u,f(Nr(a,u)),y)}function hl(a,u,f,y){for(var b=a.length,C=y?b:-1;(y?C--:++C<b)&&u(a[C],C,a););return f?On(a,y?0:C,y?C+1:b):On(a,y?C+1:0,y?b:C)}function ug(a,u){var f=a;return f instanceof Ie&&(f=f.value()),th(u,function(y,b){return b.func.apply(b.thisArg,Yi([y],b.args))},f)}function Ah(a,u,f){var y=a.length;if(y<2)return y?er(a[0]):[];for(var b=-1,C=D(y);++b<y;)for(var T=a[b],A=-1;++A<y;)A!=b&&(C[b]=Co(C[b]||T,a[A],u,f));return er(Tt(C,1),u,f)}function hg(a,u,f){for(var y=-1,b=a.length,C=u.length,T={};++y<b;){var A=y<C?u[y]:t;f(T,a[y],A)}return T}function Mh(a){return lt(a)?a:[]}function Oh(a){return typeof a=="function"?a:en}function tr(a,u){return be(a)?a:$h(a,u)?[a]:zg(Fe(a))}var hE=Ae;function nr(a,u,f){var y=a.length;return f=f===t?y:f,!u&&f>=y?a:On(a,u,f)}var dg=Zx||function(a){return Et.clearTimeout(a)};function fg(a,u){if(u)return a.slice();var f=a.length,y=Nm?Nm(f):new a.constructor(f);return a.copy(y),y}function Ih(a){var u=new a.constructor(a.byteLength);return new Ja(u).set(new Ja(a)),u}function dE(a,u){var f=u?Ih(a.buffer):a.buffer;return new a.constructor(f,a.byteOffset,a.byteLength)}function fE(a){var u=new a.constructor(a.source,Yp.exec(a));return u.lastIndex=a.lastIndex,u}function pE(a){return So?ze(So.call(a)):{}}function pg(a,u){var f=u?Ih(a.buffer):a.buffer;return new a.constructor(f,a.byteOffset,a.length)}function mg(a,u){if(a!==u){var f=a!==t,y=a===null,b=a===a,C=dn(a),T=u!==t,A=u===null,O=u===u,L=dn(u);if(!A&&!L&&!C&&a>u||C&&T&&O&&!A&&!L||y&&T&&O||!f&&O||!b)return 1;if(!y&&!C&&!L&&a<u||L&&f&&b&&!y&&!C||A&&f&&b||!T&&b||!O)return-1}return 0}function mE(a,u,f){for(var y=-1,b=a.criteria,C=u.criteria,T=b.length,A=f.length;++y<T;){var O=mg(b[y],C[y]);if(O){if(y>=A)return O;var L=f[y];return O*(L=="desc"?-1:1)}}return a.index-u.index}function gg(a,u,f,y){for(var b=-1,C=a.length,T=f.length,A=-1,O=u.length,L=bt(C-T,0),F=D(O+L),B=!y;++A<O;)F[A]=u[A];for(;++b<T;)(B||b<C)&&(F[f[b]]=a[b]);for(;L--;)F[A++]=a[b++];return F}function yg(a,u,f,y){for(var b=-1,C=a.length,T=-1,A=f.length,O=-1,L=u.length,F=bt(C-A,0),B=D(F+L),X=!y;++b<F;)B[b]=a[b];for(var ee=b;++O<L;)B[ee+O]=u[O];for(;++T<A;)(X||b<C)&&(B[ee+f[T]]=a[b++]);return B}function Jt(a,u){var f=-1,y=a.length;for(u||(u=D(y));++f<y;)u[f]=a[f];return u}function ii(a,u,f,y){var b=!f;f||(f={});for(var C=-1,T=u.length;++C<T;){var A=u[C],O=y?y(f[A],a[A],A,f,a):t;O===t&&(O=a[A]),b?xi(f,A,O):xo(f,A,O)}return f}function gE(a,u){return ii(a,Fh(a),u)}function yE(a,u){return ii(a,Ig(a),u)}function dl(a,u){return function(f,y){var b=be(f)?xx:BC,C=u?u():{};return b(f,a,ie(y,2),C)}}function Ss(a){return Ae(function(u,f){var y=-1,b=f.length,C=b>1?f[b-1]:t,T=b>2?f[2]:t;for(C=a.length>3&&typeof C=="function"?(b--,C):t,T&&Ht(f[0],f[1],T)&&(C=b<3?t:C,b=1),u=ze(u);++y<b;){var A=f[y];A&&a(u,A,y,C)}return u})}function vg(a,u){return function(f,y){if(f==null)return f;if(!Zt(f))return a(f,y);for(var b=f.length,C=u?b:-1,T=ze(f);(u?C--:++C<b)&&y(T[C],C,T)!==!1;);return f}}function bg(a){return function(u,f,y){for(var b=-1,C=ze(u),T=y(u),A=T.length;A--;){var O=T[a?A:++b];if(f(C[O],O,C)===!1)break}return u}}function vE(a,u,f){var y=u&S,b=Ao(a);function C(){var T=this&&this!==Et&&this instanceof C?b:a;return T.apply(y?f:this,arguments)}return C}function wg(a){return function(u){u=Fe(u);var f=ps(u)?Hn(u):t,y=f?f[0]:u.charAt(0),b=f?nr(f,1).join(""):u.slice(1);return y[a]()+b}}function xs(a){return function(u){return th(vy(yy(u).replace(lx,"")),a,"")}}function Ao(a){return function(){var u=arguments;switch(u.length){case 0:return new a;case 1:return new a(u[0]);case 2:return new a(u[0],u[1]);case 3:return new a(u[0],u[1],u[2]);case 4:return new a(u[0],u[1],u[2],u[3]);case 5:return new a(u[0],u[1],u[2],u[3],u[4]);case 6:return new a(u[0],u[1],u[2],u[3],u[4],u[5]);case 7:return new a(u[0],u[1],u[2],u[3],u[4],u[5],u[6])}var f=ws(a.prototype),y=a.apply(f,u);return Je(y)?y:f}}function bE(a,u,f){var y=Ao(a);function b(){for(var C=arguments.length,T=D(C),A=C,O=Cs(b);A--;)T[A]=arguments[A];var L=C<3&&T[0]!==O&&T[C-1]!==O?[]:Ji(T,O);if(C-=L.length,C<f)return Tg(a,u,fl,b.placeholder,t,T,L,t,t,f-C);var F=this&&this!==Et&&this instanceof b?y:a;return cn(F,this,T)}return b}function Sg(a){return function(u,f,y){var b=ze(u);if(!Zt(u)){var C=ie(f,3);u=wt(u),f=function(A){return C(b[A],A,b)}}var T=a(u,f,y);return T>-1?b[C?u[T]:T]:t}}function xg(a){return Ei(function(u){var f=u.length,y=f,b=An.prototype.thru;for(a&&u.reverse();y--;){var C=u[y];if(typeof C!="function")throw new kn(o);if(b&&!T&&yl(C)=="wrapper")var T=new An([],!0)}for(y=T?y:f;++y<f;){C=u[y];var A=yl(C),O=A=="wrapper"?Ph(C):t;O&&Bh(O[0])&&O[1]==(U|I|N|W)&&!O[4].length&&O[9]==1?T=T[yl(O[0])].apply(T,O[3]):T=C.length==1&&Bh(C)?T[A]():T.thru(C)}return function(){var L=arguments,F=L[0];if(T&&L.length==1&&be(F))return T.plant(F).value();for(var B=0,X=f?u[B].apply(this,L):F;++B<f;)X=u[B].call(this,X);return X}})}function fl(a,u,f,y,b,C,T,A,O,L){var F=u&U,B=u&S,X=u&E,ee=u&(I|R),re=u&G,Ce=X?t:Ao(a);function se(){for(var Me=arguments.length,De=D(Me),fn=Me;fn--;)De[fn]=arguments[fn];if(ee)var Vt=Cs(se),pn=Dx(De,Vt);if(y&&(De=gg(De,y,b,ee)),C&&(De=yg(De,C,T,ee)),Me-=pn,ee&&Me<L){var ct=Ji(De,Vt);return Tg(a,u,fl,se.placeholder,f,De,ct,A,O,L-Me)}var Un=B?f:this,Mi=X?Un[a]:a;return Me=De.length,A?De=BE(De,A):re&&Me>1&&De.reverse(),F&&O<Me&&(De.length=O),this&&this!==Et&&this instanceof se&&(Mi=Ce||Ao(Mi)),Mi.apply(Un,De)}return se}function Cg(a,u){return function(f,y){return GC(f,a,u(y),{})}}function pl(a,u){return function(f,y){var b;if(f===t&&y===t)return u;if(f!==t&&(b=f),y!==t){if(b===t)return y;typeof f=="string"||typeof y=="string"?(f=hn(f),y=hn(y)):(f=lg(f),y=lg(y)),b=a(f,y)}return b}}function Dh(a){return Ei(function(u){return u=Ge(u,un(ie())),Ae(function(f){var y=this;return a(u,function(b){return cn(b,y,f)})})})}function ml(a,u){u=u===t?" ":hn(u);var f=u.length;if(f<2)return f?Eh(u,a):u;var y=Eh(u,tl(a/ms(u)));return ps(u)?nr(Hn(y),0,a).join(""):y.slice(0,a)}function wE(a,u,f,y){var b=u&S,C=Ao(a);function T(){for(var A=-1,O=arguments.length,L=-1,F=y.length,B=D(F+O),X=this&&this!==Et&&this instanceof T?C:a;++L<F;)B[L]=y[L];for(;O--;)B[L++]=arguments[++A];return cn(X,b?f:this,B)}return T}function Eg(a){return function(u,f,y){return y&&typeof y!="number"&&Ht(u,f,y)&&(f=y=t),u=Ai(u),f===t?(f=u,u=0):f=Ai(f),y=y===t?u<f?1:-1:Ai(y),sE(u,f,y,a)}}function gl(a){return function(u,f){return typeof u=="string"&&typeof f=="string"||(u=Dn(u),f=Dn(f)),a(u,f)}}function Tg(a,u,f,y,b,C,T,A,O,L){var F=u&I,B=F?T:t,X=F?t:T,ee=F?C:t,re=F?t:C;u|=F?N:V,u&=~(F?V:N),u&k||(u&=-4);var Ce=[a,u,b,ee,B,re,X,A,O,L],se=f.apply(t,Ce);return Bh(a)&&Fg(se,Ce),se.placeholder=y,$g(se,a,u)}function _h(a){var u=vt[a];return function(f,y){if(f=Dn(f),y=y==null?0:Rt(Se(y),292),y&&$m(f)){var b=(Fe(f)+"e").split("e"),C=u(b[0]+"e"+(+b[1]+y));return b=(Fe(C)+"e").split("e"),+(b[0]+"e"+(+b[1]-y))}return u(f)}}var SE=vs&&1/qa(new vs([,-0]))[1]==ce?function(a){return new vs(a)}:ed;function kg(a){return function(u){var f=Nt(u);return f==Bn?lh(u):f==zn?$x(u):Ix(u,a(u))}}function Ci(a,u,f,y,b,C,T,A){var O=u&E;if(!O&&typeof a!="function")throw new kn(o);var L=y?y.length:0;if(L||(u&=-97,y=b=t),T=T===t?T:bt(Se(T),0),A=A===t?A:Se(A),L-=b?b.length:0,u&V){var F=y,B=b;y=b=t}var X=O?t:Ph(a),ee=[a,u,f,y,b,F,B,C,T,A];if(X&&LE(ee,X),a=ee[0],u=ee[1],f=ee[2],y=ee[3],b=ee[4],A=ee[9]=ee[9]===t?O?0:a.length:bt(ee[9]-L,0),!A&&u&(I|R)&&(u&=-25),!u||u==S)var re=vE(a,u,f);else u==I||u==R?re=bE(a,u,A):(u==N||u==(S|N))&&!b.length?re=wE(a,u,f,y):re=fl.apply(t,ee);var Ce=X?og:Fg;return $g(Ce(re,ee),a,u)}function Ag(a,u,f,y){return a===t||Wn(a,ys[f])&&!$e.call(y,f)?u:a}function Mg(a,u,f,y,b,C){return Je(a)&&Je(u)&&(C.set(u,a),cl(a,u,t,Mg,C),C.delete(u)),a}function xE(a){return Io(a)?t:a}function Og(a,u,f,y,b,C){var T=f&v,A=a.length,O=u.length;if(A!=O&&!(T&&O>A))return!1;var L=C.get(a),F=C.get(u);if(L&&F)return L==u&&F==a;var B=-1,X=!0,ee=f&w?new _r:t;for(C.set(a,u),C.set(u,a);++B<A;){var re=a[B],Ce=u[B];if(y)var se=T?y(Ce,re,B,u,a,C):y(re,Ce,B,a,u,C);if(se!==t){if(se)continue;X=!1;break}if(ee){if(!nh(u,function(Me,De){if(!go(ee,De)&&(re===Me||b(re,Me,f,y,C)))return ee.push(De)})){X=!1;break}}else if(!(re===Ce||b(re,Ce,f,y,C))){X=!1;break}}return C.delete(a),C.delete(u),X}function CE(a,u,f,y,b,C,T){switch(f){case hs:if(a.byteLength!=u.byteLength||a.byteOffset!=u.byteOffset)return!1;a=a.buffer,u=u.buffer;case mo:return!(a.byteLength!=u.byteLength||!C(new Ja(a),new Ja(u)));case lo:case co:case uo:return Wn(+a,+u);case Fa:return a.name==u.name&&a.message==u.message;case ho:case fo:return a==u+"";case Bn:var A=lh;case zn:var O=y&v;if(A||(A=qa),a.size!=u.size&&!O)return!1;var L=T.get(a);if(L)return L==u;y|=w,T.set(a,u);var F=Og(A(a),A(u),y,b,C,T);return T.delete(a),F;case Ba:if(So)return So.call(a)==So.call(u)}return!1}function EE(a,u,f,y,b,C){var T=f&v,A=Rh(a),O=A.length,L=Rh(u),F=L.length;if(O!=F&&!T)return!1;for(var B=O;B--;){var X=A[B];if(!(T?X in u:$e.call(u,X)))return!1}var ee=C.get(a),re=C.get(u);if(ee&&re)return ee==u&&re==a;var Ce=!0;C.set(a,u),C.set(u,a);for(var se=T;++B<O;){X=A[B];var Me=a[X],De=u[X];if(y)var fn=T?y(De,Me,X,u,a,C):y(Me,De,X,a,u,C);if(!(fn===t?Me===De||b(Me,De,f,y,C):fn)){Ce=!1;break}se||(se=X=="constructor")}if(Ce&&!se){var Vt=a.constructor,pn=u.constructor;Vt!=pn&&"constructor"in a&&"constructor"in u&&!(typeof Vt=="function"&&Vt instanceof Vt&&typeof pn=="function"&&pn instanceof pn)&&(Ce=!1)}return C.delete(a),C.delete(u),Ce}function Ei(a){return Hh(Pg(a,t,Ug),a+"")}function Rh(a){return Xm(a,wt,Fh)}function Nh(a){return Xm(a,Qt,Ig)}var Ph=il?function(a){return il.get(a)}:ed;function yl(a){for(var u=a.name+"",f=bs[u],y=$e.call(bs,u)?f.length:0;y--;){var b=f[y],C=b.func;if(C==null||C==a)return b.name}return u}function Cs(a){var u=$e.call(x,"placeholder")?x:a;return u.placeholder}function ie(){var a=x.iteratee||Zh;return a=a===Zh?Zm:a,arguments.length?a(arguments[0],arguments[1]):a}function vl(a,u){var f=a.__data__;return _E(u)?f[typeof u=="string"?"string":"hash"]:f.map}function Lh(a){for(var u=wt(a),f=u.length;f--;){var y=u[f],b=a[y];u[f]=[y,b,Rg(b)]}return u}function Pr(a,u){var f=Px(a,u);return Jm(f)?f:t}function TE(a){var u=$e.call(a,Ir),f=a[Ir];try{a[Ir]=t;var y=!0}catch{}var b=Xa.call(a);return y&&(u?a[Ir]=f:delete a[Ir]),b}var Fh=uh?function(a){return a==null?[]:(a=ze(a),Xi(uh(a),function(u){return Lm.call(a,u)}))}:td,Ig=uh?function(a){for(var u=[];a;)Yi(u,Fh(a)),a=Za(a);return u}:td,Nt=zt;(hh&&Nt(new hh(new ArrayBuffer(1)))!=hs||vo&&Nt(new vo)!=Bn||dh&&Nt(dh.resolve())!=Kp||vs&&Nt(new vs)!=zn||bo&&Nt(new bo)!=po)&&(Nt=function(a){var u=zt(a),f=u==bi?a.constructor:t,y=f?Lr(f):"";if(y)switch(y){case aC:return hs;case lC:return Bn;case cC:return Kp;case uC:return zn;case hC:return po}return u});function kE(a,u,f){for(var y=-1,b=f.length;++y<b;){var C=f[y],T=C.size;switch(C.type){case"drop":a+=T;break;case"dropRight":u-=T;break;case"take":u=Rt(u,a+T);break;case"takeRight":a=bt(a,u-T);break}}return{start:a,end:u}}function AE(a){var u=a.match(RS);return u?u[1].split(NS):[]}function Dg(a,u,f){u=tr(u,a);for(var y=-1,b=u.length,C=!1;++y<b;){var T=ri(u[y]);if(!(C=a!=null&&f(a,T)))break;a=a[T]}return C||++y!=b?C:(b=a==null?0:a.length,!!b&&Tl(b)&&Ti(T,b)&&(be(a)||Fr(a)))}function ME(a){var u=a.length,f=new a.constructor(u);return u&&typeof a[0]=="string"&&$e.call(a,"index")&&(f.index=a.index,f.input=a.input),f}function _g(a){return typeof a.constructor=="function"&&!Mo(a)?ws(Za(a)):{}}function OE(a,u,f){var y=a.constructor;switch(u){case mo:return Ih(a);case lo:case co:return new y(+a);case hs:return dE(a,f);case Lu:case Fu:case $u:case Bu:case zu:case Hu:case Vu:case Wu:case Uu:return pg(a,f);case Bn:return new y;case uo:case fo:return new y(a);case ho:return fE(a);case zn:return new y;case Ba:return pE(a)}}function IE(a,u){var f=u.length;if(!f)return a;var y=f-1;return u[y]=(f>1?"& ":"")+u[y],u=u.join(f>2?", ":" "),a.replace(_S,`{ /* [wrapped with `+u+`] */ `)}function DE(a){return be(a)||Fr(a)||!!(Fm&&a&&a[Fm])}function Ti(a,u){var f=typeof a;return u=u??Oe,!!u&&(f=="number"||f!="symbol"&&WS.test(a))&&a>-1&&a%1==0&&a<u}function Ht(a,u,f){if(!Je(f))return!1;var y=typeof u;return(y=="number"?Zt(f)&&Ti(u,f.length):y=="string"&&u in f)?Wn(f[u],a):!1}function $h(a,u){if(be(a))return!1;var f=typeof a;return f=="number"||f=="symbol"||f=="boolean"||a==null||dn(a)?!0:MS.test(a)||!AS.test(a)||u!=null&&a in ze(u)}function _E(a){var u=typeof a;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?a!=="__proto__":a===null}function Bh(a){var u=yl(a),f=x[u];if(typeof f!="function"||!(u in Ie.prototype))return!1;if(a===f)return!0;var y=Ph(f);return!!y&&a===y[0]}function RE(a){return!!Rm&&Rm in a}var NE=Ga?ki:nd;function Mo(a){var u=a&&a.constructor,f=typeof u=="function"&&u.prototype||ys;return a===f}function Rg(a){return a===a&&!Je(a)}function Ng(a,u){return function(f){return f==null?!1:f[a]===u&&(u!==t||a in ze(f))}}function PE(a){var u=Cl(a,function(y){return f.size===h&&f.clear(),y}),f=u.cache;return u}function LE(a,u){var f=a[1],y=u[1],b=f|y,C=b<(S|E|U),T=y==U&&f==I||y==U&&f==W&&a[7].length<=u[8]||y==(U|W)&&u[7].length<=u[8]&&f==I;if(!(C||T))return a;y&S&&(a[2]=u[2],b|=f&S?0:k);var A=u[3];if(A){var O=a[3];a[3]=O?gg(O,A,u[4]):A,a[4]=O?Ji(a[3],d):u[4]}return A=u[5],A&&(O=a[5],a[5]=O?yg(O,A,u[6]):A,a[6]=O?Ji(a[5],d):u[6]),A=u[7],A&&(a[7]=A),y&U&&(a[8]=a[8]==null?u[8]:Rt(a[8],u[8])),a[9]==null&&(a[9]=u[9]),a[0]=u[0],a[1]=b,a}function FE(a){var u=[];if(a!=null)for(var f in ze(a))u.push(f);return u}function $E(a){return Xa.call(a)}function Pg(a,u,f){return u=bt(u===t?a.length-1:u,0),function(){for(var y=arguments,b=-1,C=bt(y.length-u,0),T=D(C);++b<C;)T[b]=y[u+b];b=-1;for(var A=D(u+1);++b<u;)A[b]=y[b];return A[u]=f(T),cn(a,this,A)}}function Lg(a,u){return u.length<2?a:Nr(a,On(u,0,-1))}function BE(a,u){for(var f=a.length,y=Rt(u.length,f),b=Jt(a);y--;){var C=u[y];a[y]=Ti(C,f)?b[C]:t}return a}function zh(a,u){if(!(u==="constructor"&&typeof a[u]=="function")&&u!="__proto__")return a[u]}var Fg=Bg(og),Oo=eC||function(a,u){return Et.setTimeout(a,u)},Hh=Bg(lE);function $g(a,u,f){var y=u+"";return Hh(a,IE(y,zE(AE(y),f)))}function Bg(a){var u=0,f=0;return function(){var y=rC(),b=we-(y-f);if(f=y,b>0){if(++u>=ke)return arguments[0]}else u=0;return a.apply(t,arguments)}}function bl(a,u){var f=-1,y=a.length,b=y-1;for(u=u===t?y:u;++f<u;){var C=Ch(f,b),T=a[C];a[C]=a[f],a[f]=T}return a.length=u,a}var zg=PE(function(a){var u=[];return a.charCodeAt(0)===46&&u.push(""),a.replace(OS,function(f,y,b,C){u.push(b?C.replace(FS,"$1"):y||f)}),u});function ri(a){if(typeof a=="string"||dn(a))return a;var u=a+"";return u=="0"&&1/a==-ce?"-0":u}function Lr(a){if(a!=null){try{return ja.call(a)}catch{}try{return a+""}catch{}}return""}function zE(a,u){return Tn(fS,function(f){var y="_."+f[0];u&f[1]&&!Wa(a,y)&&a.push(y)}),a.sort()}function Hg(a){if(a instanceof Ie)return a.clone();var u=new An(a.__wrapped__,a.__chain__);return u.__actions__=Jt(a.__actions__),u.__index__=a.__index__,u.__values__=a.__values__,u}function HE(a,u,f){(f?Ht(a,u,f):u===t)?u=1:u=bt(Se(u),0);var y=a==null?0:a.length;if(!y||u<1)return[];for(var b=0,C=0,T=D(tl(y/u));b<y;)T[C++]=On(a,b,b+=u);return T}function VE(a){for(var u=-1,f=a==null?0:a.length,y=0,b=[];++u<f;){var C=a[u];C&&(b[y++]=C)}return b}function WE(){var a=arguments.length;if(!a)return[];for(var u=D(a-1),f=arguments[0],y=a;y--;)u[y-1]=arguments[y];return Yi(be(f)?Jt(f):[f],Tt(u,1))}var UE=Ae(function(a,u){return lt(a)?Co(a,Tt(u,1,lt,!0)):[]}),qE=Ae(function(a,u){var f=In(u);return lt(f)&&(f=t),lt(a)?Co(a,Tt(u,1,lt,!0),ie(f,2)):[]}),KE=Ae(function(a,u){var f=In(u);return lt(f)&&(f=t),lt(a)?Co(a,Tt(u,1,lt,!0),t,f):[]});function GE(a,u,f){var y=a==null?0:a.length;return y?(u=f||u===t?1:Se(u),On(a,u<0?0:u,y)):[]}function jE(a,u,f){var y=a==null?0:a.length;return y?(u=f||u===t?1:Se(u),u=y-u,On(a,0,u<0?0:u)):[]}function XE(a,u){return a&&a.length?hl(a,ie(u,3),!0,!0):[]}function YE(a,u){return a&&a.length?hl(a,ie(u,3),!0):[]}function JE(a,u,f,y){var b=a==null?0:a.length;return b?(f&&typeof f!="number"&&Ht(a,u,f)&&(f=0,y=b),WC(a,u,f,y)):[]}function Vg(a,u,f){var y=a==null?0:a.length;if(!y)return-1;var b=f==null?0:Se(f);return b<0&&(b=bt(y+b,0)),Ua(a,ie(u,3),b)}function Wg(a,u,f){var y=a==null?0:a.length;if(!y)return-1;var b=y-1;return f!==t&&(b=Se(f),b=f<0?bt(y+b,0):Rt(b,y-1)),Ua(a,ie(u,3),b,!0)}function Ug(a){var u=a==null?0:a.length;return u?Tt(a,1):[]}function ZE(a){var u=a==null?0:a.length;return u?Tt(a,ce):[]}function QE(a,u){var f=a==null?0:a.length;return f?(u=u===t?1:Se(u),Tt(a,u)):[]}function eT(a){for(var u=-1,f=a==null?0:a.length,y={};++u<f;){var b=a[u];y[b[0]]=b[1]}return y}function qg(a){return a&&a.length?a[0]:t}function tT(a,u,f){var y=a==null?0:a.length;if(!y)return-1;var b=f==null?0:Se(f);return b<0&&(b=bt(y+b,0)),fs(a,u,b)}function nT(a){var u=a==null?0:a.length;return u?On(a,0,-1):[]}var iT=Ae(function(a){var u=Ge(a,Mh);return u.length&&u[0]===a[0]?vh(u):[]}),rT=Ae(function(a){var u=In(a),f=Ge(a,Mh);return u===In(f)?u=t:f.pop(),f.length&&f[0]===a[0]?vh(f,ie(u,2)):[]}),sT=Ae(function(a){var u=In(a),f=Ge(a,Mh);return u=typeof u=="function"?u:t,u&&f.pop(),f.length&&f[0]===a[0]?vh(f,t,u):[]});function oT(a,u){return a==null?"":nC.call(a,u)}function In(a){var u=a==null?0:a.length;return u?a[u-1]:t}function aT(a,u,f){var y=a==null?0:a.length;if(!y)return-1;var b=y;return f!==t&&(b=Se(f),b=b<0?bt(y+b,0):Rt(b,y-1)),u===u?zx(a,u,b):Ua(a,Tm,b,!0)}function lT(a,u){return a&&a.length?ng(a,Se(u)):t}var cT=Ae(Kg);function Kg(a,u){return a&&a.length&&u&&u.length?xh(a,u):a}function uT(a,u,f){return a&&a.length&&u&&u.length?xh(a,u,ie(f,2)):a}function hT(a,u,f){return a&&a.length&&u&&u.length?xh(a,u,t,f):a}var dT=Ei(function(a,u){var f=a==null?0:a.length,y=ph(a,u);return sg(a,Ge(u,function(b){return Ti(b,f)?+b:b}).sort(mg)),y});function fT(a,u){var f=[];if(!(a&&a.length))return f;var y=-1,b=[],C=a.length;for(u=ie(u,3);++y<C;){var T=a[y];u(T,y,a)&&(f.push(T),b.push(y))}return sg(a,b),f}function Vh(a){return a==null?a:oC.call(a)}function pT(a,u,f){var y=a==null?0:a.length;return y?(f&&typeof f!="number"&&Ht(a,u,f)?(u=0,f=y):(u=u==null?0:Se(u),f=f===t?y:Se(f)),On(a,u,f)):[]}function mT(a,u){return ul(a,u)}function gT(a,u,f){return Th(a,u,ie(f,2))}function yT(a,u){var f=a==null?0:a.length;if(f){var y=ul(a,u);if(y<f&&Wn(a[y],u))return y}return-1}function vT(a,u){return ul(a,u,!0)}function bT(a,u,f){return Th(a,u,ie(f,2),!0)}function wT(a,u){var f=a==null?0:a.length;if(f){var y=ul(a,u,!0)-1;if(Wn(a[y],u))return y}return-1}function ST(a){return a&&a.length?ag(a):[]}function xT(a,u){return a&&a.length?ag(a,ie(u,2)):[]}function CT(a){var u=a==null?0:a.length;return u?On(a,1,u):[]}function ET(a,u,f){return a&&a.length?(u=f||u===t?1:Se(u),On(a,0,u<0?0:u)):[]}function TT(a,u,f){var y=a==null?0:a.length;return y?(u=f||u===t?1:Se(u),u=y-u,On(a,u<0?0:u,y)):[]}function kT(a,u){return a&&a.length?hl(a,ie(u,3),!1,!0):[]}function AT(a,u){return a&&a.length?hl(a,ie(u,3)):[]}var MT=Ae(function(a){return er(Tt(a,1,lt,!0))}),OT=Ae(function(a){var u=In(a);return lt(u)&&(u=t),er(Tt(a,1,lt,!0),ie(u,2))}),IT=Ae(function(a){var u=In(a);return u=typeof u=="function"?u:t,er(Tt(a,1,lt,!0),t,u)});function DT(a){return a&&a.length?er(a):[]}function _T(a,u){return a&&a.length?er(a,ie(u,2)):[]}function RT(a,u){return u=typeof u=="function"?u:t,a&&a.length?er(a,t,u):[]}function Wh(a){if(!(a&&a.length))return[];var u=0;return a=Xi(a,function(f){if(lt(f))return u=bt(f.length,u),!0}),oh(u,function(f){return Ge(a,ih(f))})}function Gg(a,u){if(!(a&&a.length))return[];var f=Wh(a);return u==null?f:Ge(f,function(y){return cn(u,t,y)})}var NT=Ae(function(a,u){return lt(a)?Co(a,u):[]}),PT=Ae(function(a){return Ah(Xi(a,lt))}),LT=Ae(function(a){var u=In(a);return lt(u)&&(u=t),Ah(Xi(a,lt),ie(u,2))}),FT=Ae(function(a){var u=In(a);return u=typeof u=="function"?u:t,Ah(Xi(a,lt),t,u)}),$T=Ae(Wh);function BT(a,u){return hg(a||[],u||[],xo)}function zT(a,u){return hg(a||[],u||[],ko)}var HT=Ae(function(a){var u=a.length,f=u>1?a[u-1]:t;return f=typeof f=="function"?(a.pop(),f):t,Gg(a,f)});function jg(a){var u=x(a);return u.__chain__=!0,u}function VT(a,u){return u(a),a}function wl(a,u){return u(a)}var WT=Ei(function(a){var u=a.length,f=u?a[0]:0,y=this.__wrapped__,b=function(C){return ph(C,a)};return u>1||this.__actions__.length||!(y instanceof Ie)||!Ti(f)?this.thru(b):(y=y.slice(f,+f+(u?1:0)),y.__actions__.push({func:wl,args:[b],thisArg:t}),new An(y,this.__chain__).thru(function(C){return u&&!C.length&&C.push(t),C}))});function UT(){return jg(this)}function qT(){return new An(this.value(),this.__chain__)}function KT(){this.__values__===t&&(this.__values__=ly(this.value()));var a=this.__index__>=this.__values__.length,u=a?t:this.__values__[this.__index__++];return{done:a,value:u}}function GT(){return this}function jT(a){for(var u,f=this;f instanceof sl;){var y=Hg(f);y.__index__=0,y.__values__=t,u?b.__wrapped__=y:u=y;var b=y;f=f.__wrapped__}return b.__wrapped__=a,u}function XT(){var a=this.__wrapped__;if(a instanceof Ie){var u=a;return this.__actions__.length&&(u=new Ie(this)),u=u.reverse(),u.__actions__.push({func:wl,args:[Vh],thisArg:t}),new An(u,this.__chain__)}return this.thru(Vh)}function YT(){return ug(this.__wrapped__,this.__actions__)}var JT=dl(function(a,u,f){$e.call(a,f)?++a[f]:xi(a,f,1)});function ZT(a,u,f){var y=be(a)?Cm:VC;return f&&Ht(a,u,f)&&(u=t),y(a,ie(u,3))}function QT(a,u){var f=be(a)?Xi:Gm;return f(a,ie(u,3))}var ek=Sg(Vg),tk=Sg(Wg);function nk(a,u){return Tt(Sl(a,u),1)}function ik(a,u){return Tt(Sl(a,u),ce)}function rk(a,u,f){return f=f===t?1:Se(f),Tt(Sl(a,u),f)}function Xg(a,u){var f=be(a)?Tn:Qi;return f(a,ie(u,3))}function Yg(a,u){var f=be(a)?Cx:Km;return f(a,ie(u,3))}var sk=dl(function(a,u,f){$e.call(a,f)?a[f].push(u):xi(a,f,[u])});function ok(a,u,f,y){a=Zt(a)?a:Ts(a),f=f&&!y?Se(f):0;var b=a.length;return f<0&&(f=bt(b+f,0)),kl(a)?f<=b&&a.indexOf(u,f)>-1:!!b&&fs(a,u,f)>-1}var ak=Ae(function(a,u,f){var y=-1,b=typeof u=="function",C=Zt(a)?D(a.length):[];return Qi(a,function(T){C[++y]=b?cn(u,T,f):Eo(T,u,f)}),C}),lk=dl(function(a,u,f){xi(a,f,u)});function Sl(a,u){var f=be(a)?Ge:Qm;return f(a,ie(u,3))}function ck(a,u,f,y){return a==null?[]:(be(u)||(u=u==null?[]:[u]),f=y?t:f,be(f)||(f=f==null?[]:[f]),ig(a,u,f))}var uk=dl(function(a,u,f){a[f?0:1].push(u)},function(){return[[],[]]});function hk(a,u,f){var y=be(a)?th:Am,b=arguments.length<3;return y(a,ie(u,4),f,b,Qi)}function dk(a,u,f){var y=be(a)?Ex:Am,b=arguments.length<3;return y(a,ie(u,4),f,b,Km)}function fk(a,u){var f=be(a)?Xi:Gm;return f(a,El(ie(u,3)))}function pk(a){var u=be(a)?Vm:oE;return u(a)}function mk(a,u,f){(f?Ht(a,u,f):u===t)?u=1:u=Se(u);var y=be(a)?FC:aE;return y(a,u)}function gk(a){var u=be(a)?$C:cE;return u(a)}function yk(a){if(a==null)return 0;if(Zt(a))return kl(a)?ms(a):a.length;var u=Nt(a);return u==Bn||u==zn?a.size:wh(a).length}function vk(a,u,f){var y=be(a)?nh:uE;return f&&Ht(a,u,f)&&(u=t),y(a,ie(u,3))}var bk=Ae(function(a,u){if(a==null)return[];var f=u.length;return f>1&&Ht(a,u[0],u[1])?u=[]:f>2&&Ht(u[0],u[1],u[2])&&(u=[u[0]]),ig(a,Tt(u,1),[])}),xl=Qx||function(){return Et.Date.now()};function wk(a,u){if(typeof u!="function")throw new kn(o);return a=Se(a),function(){if(--a<1)return u.apply(this,arguments)}}function Jg(a,u,f){return u=f?t:u,u=a&&u==null?a.length:u,Ci(a,U,t,t,t,t,u)}function Zg(a,u){var f;if(typeof u!="function")throw new kn(o);return a=Se(a),function(){return--a>0&&(f=u.apply(this,arguments)),a<=1&&(u=t),f}}var Uh=Ae(function(a,u,f){var y=S;if(f.length){var b=Ji(f,Cs(Uh));y|=N}return Ci(a,y,u,f,b)}),Qg=Ae(function(a,u,f){var y=S|E;if(f.length){var b=Ji(f,Cs(Qg));y|=N}return Ci(u,y,a,f,b)});function ey(a,u,f){u=f?t:u;var y=Ci(a,I,t,t,t,t,t,u);return y.placeholder=ey.placeholder,y}function ty(a,u,f){u=f?t:u;var y=Ci(a,R,t,t,t,t,t,u);return y.placeholder=ty.placeholder,y}function ny(a,u,f){var y,b,C,T,A,O,L=0,F=!1,B=!1,X=!0;if(typeof a!="function")throw new kn(o);u=Dn(u)||0,Je(f)&&(F=!!f.leading,B="maxWait"in f,C=B?bt(Dn(f.maxWait)||0,u):C,X="trailing"in f?!!f.trailing:X);function ee(ct){var Un=y,Mi=b;return y=b=t,L=ct,T=a.apply(Mi,Un),T}function re(ct){return L=ct,A=Oo(Me,u),F?ee(ct):T}function Ce(ct){var Un=ct-O,Mi=ct-L,Sy=u-Un;return B?Rt(Sy,C-Mi):Sy}function se(ct){var Un=ct-O,Mi=ct-L;return O===t||Un>=u||Un<0||B&&Mi>=C}function Me(){var ct=xl();if(se(ct))return De(ct);A=Oo(Me,Ce(ct))}function De(ct){return A=t,X&&y?ee(ct):(y=b=t,T)}function fn(){A!==t&&dg(A),L=0,y=O=b=A=t}function Vt(){return A===t?T:De(xl())}function pn(){var ct=xl(),Un=se(ct);if(y=arguments,b=this,O=ct,Un){if(A===t)return re(O);if(B)return dg(A),A=Oo(Me,u),ee(O)}return A===t&&(A=Oo(Me,u)),T}return pn.cancel=fn,pn.flush=Vt,pn}var Sk=Ae(function(a,u){return qm(a,1,u)}),xk=Ae(function(a,u,f){return qm(a,Dn(u)||0,f)});function Ck(a){return Ci(a,G)}function Cl(a,u){if(typeof a!="function"||u!=null&&typeof u!="function")throw new kn(o);var f=function(){var y=arguments,b=u?u.apply(this,y):y[0],C=f.cache;if(C.has(b))return C.get(b);var T=a.apply(this,y);return f.cache=C.set(b,T)||C,T};return f.cache=new(Cl.Cache||Si),f}Cl.Cache=Si;function El(a){if(typeof a!="function")throw new kn(o);return function(){var u=arguments;switch(u.length){case 0:return!a.call(this);case 1:return!a.call(this,u[0]);case 2:return!a.call(this,u[0],u[1]);case 3:return!a.call(this,u[0],u[1],u[2])}return!a.apply(this,u)}}function Ek(a){return Zg(2,a)}var Tk=hE(function(a,u){u=u.length==1&&be(u[0])?Ge(u[0],un(ie())):Ge(Tt(u,1),un(ie()));var f=u.length;return Ae(function(y){for(var b=-1,C=Rt(y.length,f);++b<C;)y[b]=u[b].call(this,y[b]);return cn(a,this,y)})}),qh=Ae(function(a,u){var f=Ji(u,Cs(qh));return Ci(a,N,t,u,f)}),iy=Ae(function(a,u){var f=Ji(u,Cs(iy));return Ci(a,V,t,u,f)}),kk=Ei(function(a,u){return Ci(a,W,t,t,t,u)});function Ak(a,u){if(typeof a!="function")throw new kn(o);return u=u===t?u:Se(u),Ae(a,u)}function Mk(a,u){if(typeof a!="function")throw new kn(o);return u=u==null?0:bt(Se(u),0),Ae(function(f){var y=f[u],b=nr(f,0,u);return y&&Yi(b,y),cn(a,this,b)})}function Ok(a,u,f){var y=!0,b=!0;if(typeof a!="function")throw new kn(o);return Je(f)&&(y="leading"in f?!!f.leading:y,b="trailing"in f?!!f.trailing:b),ny(a,u,{leading:y,maxWait:u,trailing:b})}function Ik(a){return Jg(a,1)}function Dk(a,u){return qh(Oh(u),a)}function _k(){if(!arguments.length)return[];var a=arguments[0];return be(a)?a:[a]}function Rk(a){return Mn(a,g)}function Nk(a,u){return u=typeof u=="function"?u:t,Mn(a,g,u)}function Pk(a){return Mn(a,p|g)}function Lk(a,u){return u=typeof u=="function"?u:t,Mn(a,p|g,u)}function Fk(a,u){return u==null||Um(a,u,wt(u))}function Wn(a,u){return a===u||a!==a&&u!==u}var $k=gl(yh),Bk=gl(function(a,u){return a>=u}),Fr=Ym((function(){return arguments})())?Ym:function(a){return nt(a)&&$e.call(a,"callee")&&!Lm.call(a,"callee")},be=D.isArray,zk=ym?un(ym):jC;function Zt(a){return a!=null&&Tl(a.length)&&!ki(a)}function lt(a){return nt(a)&&Zt(a)}function Hk(a){return a===!0||a===!1||nt(a)&&zt(a)==lo}var ir=tC||nd,Vk=vm?un(vm):XC;function Wk(a){return nt(a)&&a.nodeType===1&&!Io(a)}function Uk(a){if(a==null)return!0;if(Zt(a)&&(be(a)||typeof a=="string"||typeof a.splice=="function"||ir(a)||Es(a)||Fr(a)))return!a.length;var u=Nt(a);if(u==Bn||u==zn)return!a.size;if(Mo(a))return!wh(a).length;for(var f in a)if($e.call(a,f))return!1;return!0}function qk(a,u){return To(a,u)}function Kk(a,u,f){f=typeof f=="function"?f:t;var y=f?f(a,u):t;return y===t?To(a,u,t,f):!!y}function Kh(a){if(!nt(a))return!1;var u=zt(a);return u==Fa||u==mS||typeof a.message=="string"&&typeof a.name=="string"&&!Io(a)}function Gk(a){return typeof a=="number"&&$m(a)}function ki(a){if(!Je(a))return!1;var u=zt(a);return u==$a||u==qp||u==pS||u==yS}function ry(a){return typeof a=="number"&&a==Se(a)}function Tl(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=Oe}function Je(a){var u=typeof a;return a!=null&&(u=="object"||u=="function")}function nt(a){return a!=null&&typeof a=="object"}var sy=bm?un(bm):JC;function jk(a,u){return a===u||bh(a,u,Lh(u))}function Xk(a,u,f){return f=typeof f=="function"?f:t,bh(a,u,Lh(u),f)}function Yk(a){return oy(a)&&a!=+a}function Jk(a){if(NE(a))throw new me(s);return Jm(a)}function Zk(a){return a===null}function Qk(a){return a==null}function oy(a){return typeof a=="number"||nt(a)&&zt(a)==uo}function Io(a){if(!nt(a)||zt(a)!=bi)return!1;var u=Za(a);if(u===null)return!0;var f=$e.call(u,"constructor")&&u.constructor;return typeof f=="function"&&f instanceof f&&ja.call(f)==Xx}var Gh=wm?un(wm):ZC;function eA(a){return ry(a)&&a>=-Oe&&a<=Oe}var ay=Sm?un(Sm):QC;function kl(a){return typeof a=="string"||!be(a)&&nt(a)&&zt(a)==fo}function dn(a){return typeof a=="symbol"||nt(a)&&zt(a)==Ba}var Es=xm?un(xm):eE;function tA(a){return a===t}function nA(a){return nt(a)&&Nt(a)==po}function iA(a){return nt(a)&&zt(a)==bS}var rA=gl(Sh),sA=gl(function(a,u){return a<=u});function ly(a){if(!a)return[];if(Zt(a))return kl(a)?Hn(a):Jt(a);if(yo&&a[yo])return Fx(a[yo]());var u=Nt(a),f=u==Bn?lh:u==zn?qa:Ts;return f(a)}function Ai(a){if(!a)return a===0?a:0;if(a=Dn(a),a===ce||a===-ce){var u=a<0?-1:1;return u*Yt}return a===a?a:0}function Se(a){var u=Ai(a),f=u%1;return u===u?f?u-f:u:0}function cy(a){return a?Rr(Se(a),0,_t):0}function Dn(a){if(typeof a=="number")return a;if(dn(a))return ji;if(Je(a)){var u=typeof a.valueOf=="function"?a.valueOf():a;a=Je(u)?u+"":u}if(typeof a!="string")return a===0?a:+a;a=Mm(a);var f=zS.test(a);return f||VS.test(a)?wx(a.slice(2),f?2:8):BS.test(a)?ji:+a}function uy(a){return ii(a,Qt(a))}function oA(a){return a?Rr(Se(a),-Oe,Oe):a===0?a:0}function Fe(a){return a==null?"":hn(a)}var aA=Ss(function(a,u){if(Mo(u)||Zt(u)){ii(u,wt(u),a);return}for(var f in u)$e.call(u,f)&&xo(a,f,u[f])}),hy=Ss(function(a,u){ii(u,Qt(u),a)}),Al=Ss(function(a,u,f,y){ii(u,Qt(u),a,y)}),lA=Ss(function(a,u,f,y){ii(u,wt(u),a,y)}),cA=Ei(ph);function uA(a,u){var f=ws(a);return u==null?f:Wm(f,u)}var hA=Ae(function(a,u){a=ze(a);var f=-1,y=u.length,b=y>2?u[2]:t;for(b&&Ht(u[0],u[1],b)&&(y=1);++f<y;)for(var C=u[f],T=Qt(C),A=-1,O=T.length;++A<O;){var L=T[A],F=a[L];(F===t||Wn(F,ys[L])&&!$e.call(a,L))&&(a[L]=C[L])}return a}),dA=Ae(function(a){return a.push(t,Mg),cn(dy,t,a)});function fA(a,u){return Em(a,ie(u,3),ni)}function pA(a,u){return Em(a,ie(u,3),gh)}function mA(a,u){return a==null?a:mh(a,ie(u,3),Qt)}function gA(a,u){return a==null?a:jm(a,ie(u,3),Qt)}function yA(a,u){return a&&ni(a,ie(u,3))}function vA(a,u){return a&&gh(a,ie(u,3))}function bA(a){return a==null?[]:ll(a,wt(a))}function wA(a){return a==null?[]:ll(a,Qt(a))}function jh(a,u,f){var y=a==null?t:Nr(a,u);return y===t?f:y}function SA(a,u){return a!=null&&Dg(a,u,UC)}function Xh(a,u){return a!=null&&Dg(a,u,qC)}var xA=Cg(function(a,u,f){u!=null&&typeof u.toString!="function"&&(u=Xa.call(u)),a[u]=f},Jh(en)),CA=Cg(function(a,u,f){u!=null&&typeof u.toString!="function"&&(u=Xa.call(u)),$e.call(a,u)?a[u].push(f):a[u]=[f]},ie),EA=Ae(Eo);function wt(a){return Zt(a)?Hm(a):wh(a)}function Qt(a){return Zt(a)?Hm(a,!0):tE(a)}function TA(a,u){var f={};return u=ie(u,3),ni(a,function(y,b,C){xi(f,u(y,b,C),y)}),f}function kA(a,u){var f={};return u=ie(u,3),ni(a,function(y,b,C){xi(f,b,u(y,b,C))}),f}var AA=Ss(function(a,u,f){cl(a,u,f)}),dy=Ss(function(a,u,f,y){cl(a,u,f,y)}),MA=Ei(function(a,u){var f={};if(a==null)return f;var y=!1;u=Ge(u,function(C){return C=tr(C,a),y||(y=C.length>1),C}),ii(a,Nh(a),f),y&&(f=Mn(f,p|m|g,xE));for(var b=u.length;b--;)kh(f,u[b]);return f});function OA(a,u){return fy(a,El(ie(u)))}var IA=Ei(function(a,u){return a==null?{}:iE(a,u)});function fy(a,u){if(a==null)return{};var f=Ge(Nh(a),function(y){return[y]});return u=ie(u),rg(a,f,function(y,b){return u(y,b[0])})}function DA(a,u,f){u=tr(u,a);var y=-1,b=u.length;for(b||(b=1,a=t);++y<b;){var C=a==null?t:a[ri(u[y])];C===t&&(y=b,C=f),a=ki(C)?C.call(a):C}return a}function _A(a,u,f){return a==null?a:ko(a,u,f)}function RA(a,u,f,y){return y=typeof y=="function"?y:t,a==null?a:ko(a,u,f,y)}var py=kg(wt),my=kg(Qt);function NA(a,u,f){var y=be(a),b=y||ir(a)||Es(a);if(u=ie(u,4),f==null){var C=a&&a.constructor;b?f=y?new C:[]:Je(a)?f=ki(C)?ws(Za(a)):{}:f={}}return(b?Tn:ni)(a,function(T,A,O){return u(f,T,A,O)}),f}function PA(a,u){return a==null?!0:kh(a,u)}function LA(a,u,f){return a==null?a:cg(a,u,Oh(f))}function FA(a,u,f,y){return y=typeof y=="function"?y:t,a==null?a:cg(a,u,Oh(f),y)}function Ts(a){return a==null?[]:ah(a,wt(a))}function $A(a){return a==null?[]:ah(a,Qt(a))}function BA(a,u,f){return f===t&&(f=u,u=t),f!==t&&(f=Dn(f),f=f===f?f:0),u!==t&&(u=Dn(u),u=u===u?u:0),Rr(Dn(a),u,f)}function zA(a,u,f){return u=Ai(u),f===t?(f=u,u=0):f=Ai(f),a=Dn(a),KC(a,u,f)}function HA(a,u,f){if(f&&typeof f!="boolean"&&Ht(a,u,f)&&(u=f=t),f===t&&(typeof u=="boolean"?(f=u,u=t):typeof a=="boolean"&&(f=a,a=t)),a===t&&u===t?(a=0,u=1):(a=Ai(a),u===t?(u=a,a=0):u=Ai(u)),a>u){var y=a;a=u,u=y}if(f||a%1||u%1){var b=Bm();return Rt(a+b*(u-a+bx("1e-"+((b+"").length-1))),u)}return Ch(a,u)}var VA=xs(function(a,u,f){return u=u.toLowerCase(),a+(f?gy(u):u)});function gy(a){return Yh(Fe(a).toLowerCase())}function yy(a){return a=Fe(a),a&&a.replace(US,_x).replace(cx,"")}function WA(a,u,f){a=Fe(a),u=hn(u);var y=a.length;f=f===t?y:Rr(Se(f),0,y);var b=f;return f-=u.length,f>=0&&a.slice(f,b)==u}function UA(a){return a=Fe(a),a&&ES.test(a)?a.replace(jp,Rx):a}function qA(a){return a=Fe(a),a&&IS.test(a)?a.replace(qu,"\\$&"):a}var KA=xs(function(a,u,f){return a+(f?"-":"")+u.toLowerCase()}),GA=xs(function(a,u,f){return a+(f?" ":"")+u.toLowerCase()}),jA=wg("toLowerCase");function XA(a,u,f){a=Fe(a),u=Se(u);var y=u?ms(a):0;if(!u||y>=u)return a;var b=(u-y)/2;return ml(nl(b),f)+a+ml(tl(b),f)}function YA(a,u,f){a=Fe(a),u=Se(u);var y=u?ms(a):0;return u&&y<u?a+ml(u-y,f):a}function JA(a,u,f){a=Fe(a),u=Se(u);var y=u?ms(a):0;return u&&y<u?ml(u-y,f)+a:a}function ZA(a,u,f){return f||u==null?u=0:u&&(u=+u),sC(Fe(a).replace(Ku,""),u||0)}function QA(a,u,f){return(f?Ht(a,u,f):u===t)?u=1:u=Se(u),Eh(Fe(a),u)}function eM(){var a=arguments,u=Fe(a[0]);return a.length<3?u:u.replace(a[1],a[2])}var tM=xs(function(a,u,f){return a+(f?"_":"")+u.toLowerCase()});function nM(a,u,f){return f&&typeof f!="number"&&Ht(a,u,f)&&(u=f=t),f=f===t?_t:f>>>0,f?(a=Fe(a),a&&(typeof u=="string"||u!=null&&!Gh(u))&&(u=hn(u),!u&&ps(a))?nr(Hn(a),0,f):a.split(u,f)):[]}var iM=xs(function(a,u,f){return a+(f?" ":"")+Yh(u)});function rM(a,u,f){return a=Fe(a),f=f==null?0:Rr(Se(f),0,a.length),u=hn(u),a.slice(f,f+u.length)==u}function sM(a,u,f){var y=x.templateSettings;f&&Ht(a,u,f)&&(u=t),a=Fe(a),u=Al({},u,y,Ag);var b=Al({},u.imports,y.imports,Ag),C=wt(b),T=ah(b,C),A,O,L=0,F=u.interpolate||za,B="__p += '",X=ch((u.escape||za).source+"|"+F.source+"|"+(F===Xp?$S:za).source+"|"+(u.evaluate||za).source+"|$","g"),ee="//# sourceURL="+($e.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++px+"]")+` `;a.replace(X,function(se,Me,De,fn,Vt,pn){return De||(De=fn),B+=a.slice(L,pn).replace(qS,Nx),Me&&(A=!0,B+=`' + __e(`+Me+`) + '`),Vt&&(O=!0,B+=`'; `+Vt+`; __p += '`),De&&(B+=`' + ((__t = (`+De+`)) == null ? '' : __t) + '`),L=pn+se.length,se}),B+=`'; `;var re=$e.call(u,"variable")&&u.variable;if(!re)B=`with (obj) { `+B+` } `;else if(LS.test(re))throw new me(l);B=(O?B.replace(wS,""):B).replace(SS,"$1").replace(xS,"$1;"),B="function("+(re||"obj")+`) { `+(re?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(A?", __e = _.escape":"")+(O?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+B+`return __p }`;var Ce=by(function(){return Ne(C,ee+"return "+B).apply(t,T)});if(Ce.source=B,Kh(Ce))throw Ce;return Ce}function oM(a){return Fe(a).toLowerCase()}function aM(a){return Fe(a).toUpperCase()}function lM(a,u,f){if(a=Fe(a),a&&(f||u===t))return Mm(a);if(!a||!(u=hn(u)))return a;var y=Hn(a),b=Hn(u),C=Om(y,b),T=Im(y,b)+1;return nr(y,C,T).join("")}function cM(a,u,f){if(a=Fe(a),a&&(f||u===t))return a.slice(0,_m(a)+1);if(!a||!(u=hn(u)))return a;var y=Hn(a),b=Im(y,Hn(u))+1;return nr(y,0,b).join("")}function uM(a,u,f){if(a=Fe(a),a&&(f||u===t))return a.replace(Ku,"");if(!a||!(u=hn(u)))return a;var y=Hn(a),b=Om(y,Hn(u));return nr(y,b).join("")}function hM(a,u){var f=Y,y=le;if(Je(u)){var b="separator"in u?u.separator:b;f="length"in u?Se(u.length):f,y="omission"in u?hn(u.omission):y}a=Fe(a);var C=a.length;if(ps(a)){var T=Hn(a);C=T.length}if(f>=C)return a;var A=f-ms(y);if(A<1)return y;var O=T?nr(T,0,A).join(""):a.slice(0,A);if(b===t)return O+y;if(T&&(A+=O.length-A),Gh(b)){if(a.slice(A).search(b)){var L,F=O;for(b.global||(b=ch(b.source,Fe(Yp.exec(b))+"g")),b.lastIndex=0;L=b.exec(F);)var B=L.index;O=O.slice(0,B===t?A:B)}}else if(a.indexOf(hn(b),A)!=A){var X=O.lastIndexOf(b);X>-1&&(O=O.slice(0,X))}return O+y}function dM(a){return a=Fe(a),a&&CS.test(a)?a.replace(Gp,Hx):a}var fM=xs(function(a,u,f){return a+(f?" ":"")+u.toUpperCase()}),Yh=wg("toUpperCase");function vy(a,u,f){return a=Fe(a),u=f?t:u,u===t?Lx(a)?Ux(a):Ax(a):a.match(u)||[]}var by=Ae(function(a,u){try{return cn(a,t,u)}catch(f){return Kh(f)?f:new me(f)}}),pM=Ei(function(a,u){return Tn(u,function(f){f=ri(f),xi(a,f,Uh(a[f],a))}),a});function mM(a){var u=a==null?0:a.length,f=ie();return a=u?Ge(a,function(y){if(typeof y[1]!="function")throw new kn(o);return[f(y[0]),y[1]]}):[],Ae(function(y){for(var b=-1;++b<u;){var C=a[b];if(cn(C[0],this,y))return cn(C[1],this,y)}})}function gM(a){return HC(Mn(a,p))}function Jh(a){return function(){return a}}function yM(a,u){return a==null||a!==a?u:a}var vM=xg(),bM=xg(!0);function en(a){return a}function Zh(a){return Zm(typeof a=="function"?a:Mn(a,p))}function wM(a){return eg(Mn(a,p))}function SM(a,u){return tg(a,Mn(u,p))}var xM=Ae(function(a,u){return function(f){return Eo(f,a,u)}}),CM=Ae(function(a,u){return function(f){return Eo(a,f,u)}});function Qh(a,u,f){var y=wt(u),b=ll(u,y);f==null&&!(Je(u)&&(b.length||!y.length))&&(f=u,u=a,a=this,b=ll(u,wt(u)));var C=!(Je(f)&&"chain"in f)||!!f.chain,T=ki(a);return Tn(b,function(A){var O=u[A];a[A]=O,T&&(a.prototype[A]=function(){var L=this.__chain__;if(C||L){var F=a(this.__wrapped__),B=F.__actions__=Jt(this.__actions__);return B.push({func:O,args:arguments,thisArg:a}),F.__chain__=L,F}return O.apply(a,Yi([this.value()],arguments))})}),a}function EM(){return Et._===this&&(Et._=Yx),this}function ed(){}function TM(a){return a=Se(a),Ae(function(u){return ng(u,a)})}var kM=Dh(Ge),AM=Dh(Cm),MM=Dh(nh);function wy(a){return $h(a)?ih(ri(a)):rE(a)}function OM(a){return function(u){return a==null?t:Nr(a,u)}}var IM=Eg(),DM=Eg(!0);function td(){return[]}function nd(){return!1}function _M(){return{}}function RM(){return""}function NM(){return!0}function PM(a,u){if(a=Se(a),a<1||a>Oe)return[];var f=_t,y=Rt(a,_t);u=ie(u),a-=_t;for(var b=oh(y,u);++f<a;)u(f);return b}function LM(a){return be(a)?Ge(a,ri):dn(a)?[a]:Jt(zg(Fe(a)))}function FM(a){var u=++jx;return Fe(a)+u}var $M=pl(function(a,u){return a+u},0),BM=_h("ceil"),zM=pl(function(a,u){return a/u},1),HM=_h("floor");function VM(a){return a&&a.length?al(a,en,yh):t}function WM(a,u){return a&&a.length?al(a,ie(u,2),yh):t}function UM(a){return km(a,en)}function qM(a,u){return km(a,ie(u,2))}function KM(a){return a&&a.length?al(a,en,Sh):t}function GM(a,u){return a&&a.length?al(a,ie(u,2),Sh):t}var jM=pl(function(a,u){return a*u},1),XM=_h("round"),YM=pl(function(a,u){return a-u},0);function JM(a){return a&&a.length?sh(a,en):0}function ZM(a,u){return a&&a.length?sh(a,ie(u,2)):0}return x.after=wk,x.ary=Jg,x.assign=aA,x.assignIn=hy,x.assignInWith=Al,x.assignWith=lA,x.at=cA,x.before=Zg,x.bind=Uh,x.bindAll=pM,x.bindKey=Qg,x.castArray=_k,x.chain=jg,x.chunk=HE,x.compact=VE,x.concat=WE,x.cond=mM,x.conforms=gM,x.constant=Jh,x.countBy=JT,x.create=uA,x.curry=ey,x.curryRight=ty,x.debounce=ny,x.defaults=hA,x.defaultsDeep=dA,x.defer=Sk,x.delay=xk,x.difference=UE,x.differenceBy=qE,x.differenceWith=KE,x.drop=GE,x.dropRight=jE,x.dropRightWhile=XE,x.dropWhile=YE,x.fill=JE,x.filter=QT,x.flatMap=nk,x.flatMapDeep=ik,x.flatMapDepth=rk,x.flatten=Ug,x.flattenDeep=ZE,x.flattenDepth=QE,x.flip=Ck,x.flow=vM,x.flowRight=bM,x.fromPairs=eT,x.functions=bA,x.functionsIn=wA,x.groupBy=sk,x.initial=nT,x.intersection=iT,x.intersectionBy=rT,x.intersectionWith=sT,x.invert=xA,x.invertBy=CA,x.invokeMap=ak,x.iteratee=Zh,x.keyBy=lk,x.keys=wt,x.keysIn=Qt,x.map=Sl,x.mapKeys=TA,x.mapValues=kA,x.matches=wM,x.matchesProperty=SM,x.memoize=Cl,x.merge=AA,x.mergeWith=dy,x.method=xM,x.methodOf=CM,x.mixin=Qh,x.negate=El,x.nthArg=TM,x.omit=MA,x.omitBy=OA,x.once=Ek,x.orderBy=ck,x.over=kM,x.overArgs=Tk,x.overEvery=AM,x.overSome=MM,x.partial=qh,x.partialRight=iy,x.partition=uk,x.pick=IA,x.pickBy=fy,x.property=wy,x.propertyOf=OM,x.pull=cT,x.pullAll=Kg,x.pullAllBy=uT,x.pullAllWith=hT,x.pullAt=dT,x.range=IM,x.rangeRight=DM,x.rearg=kk,x.reject=fk,x.remove=fT,x.rest=Ak,x.reverse=Vh,x.sampleSize=mk,x.set=_A,x.setWith=RA,x.shuffle=gk,x.slice=pT,x.sortBy=bk,x.sortedUniq=ST,x.sortedUniqBy=xT,x.split=nM,x.spread=Mk,x.tail=CT,x.take=ET,x.takeRight=TT,x.takeRightWhile=kT,x.takeWhile=AT,x.tap=VT,x.throttle=Ok,x.thru=wl,x.toArray=ly,x.toPairs=py,x.toPairsIn=my,x.toPath=LM,x.toPlainObject=uy,x.transform=NA,x.unary=Ik,x.union=MT,x.unionBy=OT,x.unionWith=IT,x.uniq=DT,x.uniqBy=_T,x.uniqWith=RT,x.unset=PA,x.unzip=Wh,x.unzipWith=Gg,x.update=LA,x.updateWith=FA,x.values=Ts,x.valuesIn=$A,x.without=NT,x.words=vy,x.wrap=Dk,x.xor=PT,x.xorBy=LT,x.xorWith=FT,x.zip=$T,x.zipObject=BT,x.zipObjectDeep=zT,x.zipWith=HT,x.entries=py,x.entriesIn=my,x.extend=hy,x.extendWith=Al,Qh(x,x),x.add=$M,x.attempt=by,x.camelCase=VA,x.capitalize=gy,x.ceil=BM,x.clamp=BA,x.clone=Rk,x.cloneDeep=Pk,x.cloneDeepWith=Lk,x.cloneWith=Nk,x.conformsTo=Fk,x.deburr=yy,x.defaultTo=yM,x.divide=zM,x.endsWith=WA,x.eq=Wn,x.escape=UA,x.escapeRegExp=qA,x.every=ZT,x.find=ek,x.findIndex=Vg,x.findKey=fA,x.findLast=tk,x.findLastIndex=Wg,x.findLastKey=pA,x.floor=HM,x.forEach=Xg,x.forEachRight=Yg,x.forIn=mA,x.forInRight=gA,x.forOwn=yA,x.forOwnRight=vA,x.get=jh,x.gt=$k,x.gte=Bk,x.has=SA,x.hasIn=Xh,x.head=qg,x.identity=en,x.includes=ok,x.indexOf=tT,x.inRange=zA,x.invoke=EA,x.isArguments=Fr,x.isArray=be,x.isArrayBuffer=zk,x.isArrayLike=Zt,x.isArrayLikeObject=lt,x.isBoolean=Hk,x.isBuffer=ir,x.isDate=Vk,x.isElement=Wk,x.isEmpty=Uk,x.isEqual=qk,x.isEqualWith=Kk,x.isError=Kh,x.isFinite=Gk,x.isFunction=ki,x.isInteger=ry,x.isLength=Tl,x.isMap=sy,x.isMatch=jk,x.isMatchWith=Xk,x.isNaN=Yk,x.isNative=Jk,x.isNil=Qk,x.isNull=Zk,x.isNumber=oy,x.isObject=Je,x.isObjectLike=nt,x.isPlainObject=Io,x.isRegExp=Gh,x.isSafeInteger=eA,x.isSet=ay,x.isString=kl,x.isSymbol=dn,x.isTypedArray=Es,x.isUndefined=tA,x.isWeakMap=nA,x.isWeakSet=iA,x.join=oT,x.kebabCase=KA,x.last=In,x.lastIndexOf=aT,x.lowerCase=GA,x.lowerFirst=jA,x.lt=rA,x.lte=sA,x.max=VM,x.maxBy=WM,x.mean=UM,x.meanBy=qM,x.min=KM,x.minBy=GM,x.stubArray=td,x.stubFalse=nd,x.stubObject=_M,x.stubString=RM,x.stubTrue=NM,x.multiply=jM,x.nth=lT,x.noConflict=EM,x.noop=ed,x.now=xl,x.pad=XA,x.padEnd=YA,x.padStart=JA,x.parseInt=ZA,x.random=HA,x.reduce=hk,x.reduceRight=dk,x.repeat=QA,x.replace=eM,x.result=DA,x.round=XM,x.runInContext=M,x.sample=pk,x.size=yk,x.snakeCase=tM,x.some=vk,x.sortedIndex=mT,x.sortedIndexBy=gT,x.sortedIndexOf=yT,x.sortedLastIndex=vT,x.sortedLastIndexBy=bT,x.sortedLastIndexOf=wT,x.startCase=iM,x.startsWith=rM,x.subtract=YM,x.sum=JM,x.sumBy=ZM,x.template=sM,x.times=PM,x.toFinite=Ai,x.toInteger=Se,x.toLength=cy,x.toLower=oM,x.toNumber=Dn,x.toSafeInteger=oA,x.toString=Fe,x.toUpper=aM,x.trim=lM,x.trimEnd=cM,x.trimStart=uM,x.truncate=hM,x.unescape=dM,x.uniqueId=FM,x.upperCase=fM,x.upperFirst=Yh,x.each=Xg,x.eachRight=Yg,x.first=qg,Qh(x,(function(){var a={};return ni(x,function(u,f){$e.call(x.prototype,f)||(a[f]=u)}),a})(),{chain:!1}),x.VERSION=i,Tn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(a){x[a].placeholder=x}),Tn(["drop","take"],function(a,u){Ie.prototype[a]=function(f){f=f===t?1:bt(Se(f),0);var y=this.__filtered__&&!u?new Ie(this):this.clone();return y.__filtered__?y.__takeCount__=Rt(f,y.__takeCount__):y.__views__.push({size:Rt(f,_t),type:a+(y.__dir__<0?"Right":"")}),y},Ie.prototype[a+"Right"]=function(f){return this.reverse()[a](f).reverse()}}),Tn(["filter","map","takeWhile"],function(a,u){var f=u+1,y=f==pe||f==de;Ie.prototype[a]=function(b){var C=this.clone();return C.__iteratees__.push({iteratee:ie(b,3),type:f}),C.__filtered__=C.__filtered__||y,C}}),Tn(["head","last"],function(a,u){var f="take"+(u?"Right":"");Ie.prototype[a]=function(){return this[f](1).value()[0]}}),Tn(["initial","tail"],function(a,u){var f="drop"+(u?"":"Right");Ie.prototype[a]=function(){return this.__filtered__?new Ie(this):this[f](1)}}),Ie.prototype.compact=function(){return this.filter(en)},Ie.prototype.find=function(a){return this.filter(a).head()},Ie.prototype.findLast=function(a){return this.reverse().find(a)},Ie.prototype.invokeMap=Ae(function(a,u){return typeof a=="function"?new Ie(this):this.map(function(f){return Eo(f,a,u)})}),Ie.prototype.reject=function(a){return this.filter(El(ie(a)))},Ie.prototype.slice=function(a,u){a=Se(a);var f=this;return f.__filtered__&&(a>0||u<0)?new Ie(f):(a<0?f=f.takeRight(-a):a&&(f=f.drop(a)),u!==t&&(u=Se(u),f=u<0?f.dropRight(-u):f.take(u-a)),f)},Ie.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},Ie.prototype.toArray=function(){return this.take(_t)},ni(Ie.prototype,function(a,u){var f=/^(?:filter|find|map|reject)|While$/.test(u),y=/^(?:head|last)$/.test(u),b=x[y?"take"+(u=="last"?"Right":""):u],C=y||/^find/.test(u);b&&(x.prototype[u]=function(){var T=this.__wrapped__,A=y?[1]:arguments,O=T instanceof Ie,L=A[0],F=O||be(T),B=function(Me){var De=b.apply(x,Yi([Me],A));return y&&X?De[0]:De};F&&f&&typeof L=="function"&&L.length!=1&&(O=F=!1);var X=this.__chain__,ee=!!this.__actions__.length,re=C&&!X,Ce=O&&!ee;if(!C&&F){T=Ce?T:new Ie(this);var se=a.apply(T,A);return se.__actions__.push({func:wl,args:[B],thisArg:t}),new An(se,X)}return re&&Ce?a.apply(this,A):(se=this.thru(B),re?y?se.value()[0]:se.value():se)})}),Tn(["pop","push","shift","sort","splice","unshift"],function(a){var u=Ka[a],f=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",y=/^(?:pop|shift)$/.test(a);x.prototype[a]=function(){var b=arguments;if(y&&!this.__chain__){var C=this.value();return u.apply(be(C)?C:[],b)}return this[f](function(T){return u.apply(be(T)?T:[],b)})}}),ni(Ie.prototype,function(a,u){var f=x[u];if(f){var y=f.name+"";$e.call(bs,y)||(bs[y]=[]),bs[y].push({name:u,func:f})}}),bs[fl(t,E).name]=[{name:"wrapper",func:t}],Ie.prototype.clone=dC,Ie.prototype.reverse=fC,Ie.prototype.value=pC,x.prototype.at=WT,x.prototype.chain=UT,x.prototype.commit=qT,x.prototype.next=KT,x.prototype.plant=jT,x.prototype.reverse=XT,x.prototype.toJSON=x.prototype.valueOf=x.prototype.value=YT,x.prototype.first=x.prototype.head,yo&&(x.prototype[yo]=GT),x}),gs=qx();Or?((Or.exports=gs)._=gs,Zu._=gs):Et._=gs}).call(zI)})(Wo,Wo.exports)),Wo.exports}var bn=HI();const VI=({assetsUrl:n=""})=>({stage:null,layer:null,selectionTransformer:null,stageInitiated:!1,activePanel:null,showWelcomeScreen:!0,layersSearchString:"",layersSortable:null,selectedGroupChildNodes:[],selectionColors:{fill:"hsla(205,90%,48%,0.15)",stroke:"hsl(205,90%,48%)"},fetchedAssets:[],prevViews:[],currentView:"home",currentDocId:null,currentDocName:null,updatingName:null,aiTasksQueue:[],activeTool:null,activeFillTab:"color",editingTextNode:null,editingTextarea:null,container:null,konvajsContent:null,containerDimensions:{x:0,y:0,width:0,height:0},konvajsContentDimensions:{x:0,y:0,width:0,height:0},selectedFont:"",fontsSearchString:"",newItems:[],lqdFontPreview:[],googleFontsList:[],showingGoogleFonts:[],fontsPaginationCurrent:20,fontsPaginationLimit:20,loadingFontPreviewQueue:[],adaptiveResize:!0,prevStageWidth:null,prevStageHeight:null,busy:!1,maxZoom:200,minZoom:20,zoomOffsetX:0,zoomOffsetY:0,zoomLevel:100,isSpacePressed:!1,isPanning:!1,reachedMinZoom:!1,reachedMaxZoom:!1,activeTooltipDropdown:null,guidelineOffset:5,placeholderImage:`${n}/img/misc/placeholder-1.jpg`,templatesList:[],loadingTemplates:!0,loadingTemplatesFailed:!1,promptLibraryShow:!1,promptFilter:"all",searchPromptStr:"",prompt:"",history:[],historyPointer:-1,maxHistoryLength:30,historyListeners:["fill","fillLinearGradientStartPoint","fillLinearGradientStartPointX","fillLinearGradientStartPointY","fillLinearGradientEndPoint","fillLinearGradientEndPointX","fillLinearGradientEndPointY","fillLinearGradientColorStops","fillRadialGradientStartPoint","fillRadialGradientStartPointX","fillRadialGradientStartPointY","fillRadialGradientEndPoint","fillRadialGradientEndPointX","fillRadialGradientEndPointY","fillRadialGradientStartRadius","fillRadialGradientEndRadius","fillRadialGradientColorStops","stroke","strokeWidth","lineJoin","lineCap","shadowColor","shadowBlur","shadowOffset","shadowOffsetX","shadowOffsetY","shadowOpacity","shadowEnabled","dash","x","y","width","height","opacity","scale","scaleX","scaleY","rotation","offset","offsetX","offsetY","fontFamily","fontSize","fontStyle","fontVariant","textDecoration","text","align","verticalAlign","padding","lineHeight","wrap","ellipsis","image","crop","blurRadius","skew","skewX","skewY","sides","numPoints","innerRadius","outerRadius","angle"],get creativeSuite(){return this.$data},get nodes(){return this.layer?.getChildren(e=>{const t=e.name(),i=e.getType();return(i==="Shape"||i==="Group")&&!["lqd-cs-guide-line","lqd-cs-highlighter","lqd-cs-selection-transformer","lqd-cs-selection-rectangle"].includes(t)})??[]},get selectedNodes(){return this.selectionTransformer?.nodes()??[]},set selectedNodes(e={nodes:[],ids:[],event:{}}){let t=e.nodes||[],i=e.ids||[],r=e.event||{},s=r.metaKey||r.ctrlKey,o=r.shiftKey;if(i.length&&!t.length&&(t=this.nodes.filter(l=>i.includes(l.id()))),t==="all"&&(t=this.nodes),o){let l=[...this.selectedNodes];t.forEach(c=>{const h=l.findIndex(d=>d.id()===c.id());h!==-1?l.splice(h,1):l.push(c)}),t=l.filter(c=>!c.findAncestors("Group").some(p=>p.getChildren(m=>m.id()===c.id())))}s||t.forEach(l=>{const c=l.findAncestors("Group"),h=c.length;c.forEach((d,p)=>{h>1&&p===0||!t.find(m=>m.id()===d.id())&&!this.selectedGroupChildNodes.find(m=>m.id()===l.id())&&(t.push(d),t=t.filter(m=>m.id()!==l.id()))})}),this.selectedGroupChildNodes.forEach(l=>{const h=l.findAncestors("Group").some(m=>t.some(g=>g.id()===m.id())),p=t.filter(m=>m.getClassName()==="Group").find(m=>m.findOne(`#${l.id()}`));(!t.find(m=>m.id()===l.id())||h||p)&&(l.draggable(!1),this.selectedGroupChildNodes=this.selectedGroupChildNodes.filter(m=>m.id()!==l.id()))}),t=t.filter(l=>!l.getAttr("locked")),this.selectionTransformer.nodes(t),this.selectionTransformer.zIndex(this.nodes.length+1),this.$dispatch("nodes-selected",{nodes:this.selectedNodes,nodesCount:this.selectedNodes.length,selectedNodesRect:this.selectedNodesRect})},get selectedNodesRect(){return this.selectedNodes.length?this.selectionTransformer.getClientRect():{x:0,y:0}},get selectedNodesProps(){const e=this.selectedNodes;if(!e.length)return{};const t=e[0],i=e.find(g=>g.getClassName()==="Rect"),r=e.find(g=>g.getClassName()==="Image"),s=e.find(g=>g.getClassName()==="RegularPolygon"),o=e.find(g=>g.getClassName()==="Star"),l=e.find(g=>g.getClassName()==="Ring"),c=e.find(g=>g.getClassName()==="Arc"),h=e.find(g=>g.getClassName()==="Wedge"),d=e.find(g=>g.getClassName()==="Text"),p=e.find(g=>g.getClassName()==="TextPath"),m={x:t.x(),y:t.y(),rotation:t.rotation(),width:t.width(),height:t.height(),opacity:t.opacity(),fill:t.fill(),fillPatternX:t.fillPatternX()??0,fillPatternY:t.fillPatternY()??0,fillPatternScaleX:t.fillPatternScaleX()??0,fillPatternScaleY:t.fillPatternScaleY()??0,fillPatternRepeat:t.fillPatternRepeat(),cornerRadius:(i?.cornerRadius()||r?.cornerRadius())??0,sides:s?.sides()??0,numPoints:o?.numPoints()??0,innerRadius:(o?.innerRadius()||l?.innerRadius()||c?.innerRadius())??0,outerRadius:(o?.outerRadius()||l?.outerRadius()||c?.outerRadius())??0,angle:(c?.angle()||h?.angle())??0,fontFamily:(d?.fontFamily()||p?.fontFamily())??"",fontSize:(d?.fontSize()||p?.fontSize())??0,fontStyle:(d?.fontStyle()||p?.fontStyle())??"normal 400",textDecoration:(d?.textDecoration()||p?.textDecoration())??"",lineHeight:d?.lineHeight(),letterSpacing:(d?.letterSpacing()||p?.letterSpacing())??0,align:(d?.align()||p?.align())??"",stroke:t.stroke()??"",strokeWidth:t.strokeWidth()??0,dash:t.dash()??0,blurRadius:t.blurRadius()??null,skewX:t.skewX()??null,skewY:t.skewY()??null,globalCompositeOperation:t.globalCompositeOperation()??null};return Object.fromEntries(Object.entries(m).map(([g,v])=>{const S=e.every(E=>this.isPropertyNotApplicableToNodeType(g,E.getClassName())?!0:E[g]()===v)?this.formatPropertyValue(g,v):magicai_localize.mixed;return[g,S]}))},set selectedNodesProps(e={x:null,y:null,rotation:null,width:null,height:null,scaleX:null,scaleY:null,opacity:null,fill:null,fillPatternX:null,fillPatternY:null,fillPatternScaleX:null,fillPatternScaleY:null,fillPatternRepeat:null,cornerRadius:null,sides:null,numPoints:null,innerRadius:null,outerRadius:null,angle:null,fontFamily:null,fontSize:null,fontStyle:null,textDecoration:null,lineHeight:null,letterSpacing:null,align:null,stroke:null,strokeWidth:null,dash:null,blurRadius:null,skewX:null,skewY:null,globalCompositeOperation:null,useRelativeValue:!1}){const t=this.selectedNodes.length>1||e.useRelativeValue,i=["x","y","rotation","width","height","scaleX","scaleY","opacity","fill","fillPatternX","fillPatternY","fillPatternScaleX","fillPatternScaleY","fillPatternRepeat","cornerRadius","sides","numPoints","innerRadius","outerRadius","angle","fontFamily","fontSize","fontStyle","textDecoration","lineHeight","letterSpacing","align","stroke","strokeWidth","dash","blurRadius","skewX","skewY","globalCompositeOperation"];this.selectedNodes.forEach(r=>{const s=r.getClassName();i.forEach(o=>{if(e[o]==null||this.isPropertyNotApplicableToNodeType(o,s))return;const l=r[o==="fontWeight"?"fontStyle":o](),c=!isNaN(parseInt(l)),h=c&&e[o]==="flip"?l*-1:e[o],d=c?parseFloat(h):h;let p=c&&t?l+d:d;if(o==="fontStyle"){const m=(l??"").split(" ");let g=m[0]??"normal",v=m[1]??"400";isNaN(parseInt(e[o]))?g=e[o]:v=e[o],p=`${g} ${v}`}if(o==="rotation"&&["Rect","Text","TextPath","Image"].includes(s)){let m=(p%360+360)%360;m>180&&(m-=360),p=m;const{x:g,y:v,rotation:w}=this.rotateNodeAroundCenter(r,p);r.rotation(w),r.x(g),r.y(v);return}switch(o){case"width":case"height":case"cornerRadius":case"innerRadius":case"outerRadius":p=Math.max(0,p);break;case"sides":case"numPoints":p=Math.max(3,p);break;case"angle":p=Math.max(0,Math.min(360,p));break;case"opacity":p=Math.max(0,Math.min(1,p));break}r[o](p)})})},init(){this.googleFontsList=window.lqdGoogleFontsList,this.beforeUnloadHandler=this.beforeUnloadHandler.bind(this),this.positionTooltip=this.positionTooltip.bind(this),this.handleEditinTextareaOutsideClick=this.handleEditinTextareaOutsideClick.bind(this),this.removeEditingTextarea=this.removeEditingTextarea.bind(this),this.setEditingTextareaTextAndRemove=this.setEditingTextareaTextAndRemove.bind(this),this.addToHistory=bn.debounce(this.addToHistory.bind(this),250,{leading:!1,trailing:!0}),this.loadGoogleFontPreview=bn.throttle(this.loadGoogleFontPreview.bind(this),300,{leading:!1}),this.resizeStage=bn.throttle(this.resizeStage.bind(this),50),this.onWindowResize=bn.throttle(this.onWindowResize.bind(this),250),this.showingGoogleFonts=this.googleFontsList.slice(0,this.fontsPaginationLimit),this.$watch("selectedFont",e=>{this.$dispatch("font-selected",{font:e})}),this.$watch("nodes.length",e=>{this.beforeUnloadListened||(e>0?this.addBeforeUnloadListener():this.removeBeforeUnloadListener())}),this.$watch("[zoomLevel, zoomOffsetX, zoomOffsetY]",()=>{this.positionTooltip(),this.positionEditingTextarea(),this.updateSelectionTransformerStroke()}),this.$watch("currentView",e=>{document.body.classList.toggle("overflow-hidden",["editor","gallery"].includes(e))}),this.initiateStage()},initiateStage(e={width:720,height:720}){const t=this.isMobile(),i=e.width??720,r=e.height??720;if(this.$refs.editorCanvasContainer===null){console.error("Creative Suite canvas was not found");return}if(this.stageInitiated||this.stage){console.warn("Creative Suite canvas was already initiated");return}this.stage=new Konva.Stage({container:this.$refs.editorCanvasContainer,width:i,height:r,name:"lqd-cs-stage",draggable:!1}),this.selectionTransformer=new Konva.Transformer({keepRatio:!1,borderStroke:this.selectionColors.stroke,anchorSize:t?10:6,rotationSnaps:[0,45,90,135,180,225,270,315,360],rotationSnapTolerance:5,rotateAnchorOffset:t?50:30,ignoreStroke:!0,flipEnabled:!1,id:"lqd-cs-selection-transformer",name:"lqd-cs-selection-transformer"}),this.selectionRectangle=new Konva.Rect({fill:this.selectionColors.fill,stroke:this.selectionColors.stroke,strokeWidth:1,visible:!1,id:"lqd-cs-selection-rectangle",name:"lqd-cs-selection-rectangle"}),this.layer=new Konva.Layer({name:"lqd-cs-layer-main"}),this.layer.add(this.selectionTransformer),this.layer.add(this.selectionRectangle),this.stage.add(this.layer),this.container=this.stage.container(),this.konvajsContent=this.container.querySelector(".konvajs-content"),this.container.tabIndex=1,this.container.focus(),this.setContainerDimensions(),this.selectionTransformerEvents(),this.handleSelectionRectangle(),this.initLayers(),this.stageEvents(),this.containerEvents(),this.handlePanAndZoom(),this.initNodesSnap(),this.positionTooltip(),this.handleWindowResize(),this.stageInitiated=!0},setContainerDimensions(){this.containerDimensions={x:this.container.offsetLeft,y:this.container.offsetTop,width:this.container.clientWidth,height:this.container.offsetHeight},this.konvajsContentDimensions={x:this.konvajsContent.offsetLeft,y:this.konvajsContent.offsetTop,width:this.konvajsContent.clientWidth,height:this.konvajsContent.offsetHeight}},handleSelectionRectangle(){let e,t,i,r,s=this.layer.getChildren().length;function o(l){if(!(!this.selectionRectangle.visible()||this.isPanning||this.isSpacePressed)){bn.defer(()=>{this.selectionRectangle.visible(!1)});var c=this.selectionRectangle.getClientRect(),h=this.nodes.filter(d=>Konva.Util.haveIntersection(c,d.getClientRect()));this.selectedNodes={nodes:h,event:l}}}this.stage.on("mousedown",l=>{if(this.isPanning||this.isSpacePressed||l.touches?.length>=2)return;const c=l.target;c._id===this.stage._id?(s=this.layer.getChildren().length,e=this.stage.getPointerPosition().x,t=this.stage.getPointerPosition().y,i=this.stage.getPointerPosition().x,r=this.stage.getPointerPosition().y,this.selectionRectangle.setAttrs({x:e,y:t,width:0,height:0,visible:!0,zIndex:s-1})):this.nodes.find(h=>h.id()===c.id())&&!this.selectedNodes.find(h=>h.id()===c.id())&&(this.selectedNodes={nodes:[c],event:l.evt})}),this.stage.on("mousemove",l=>{!this.selectionRectangle.visible()||this.isPanning||this.isSpacePressed||l.touches?.length>=2||(i=this.stage.getPointerPosition().x,r=this.stage.getPointerPosition().y,this.selectionRectangle.setAttrs({x:Math.min(e,i),y:Math.min(t,r),width:Math.abs(i-e),height:Math.abs(r-t),zIndex:s-1}))}),window.addEventListener("mouseup",o.bind(this)),this.stage.on("dblclick dbltap",l=>{let c=l.target;if(c._id===this.stage._id)return;const h=c.findAncestors("Group");h.length&&(h.length>1&&(c=h[0]),c.draggable(!0),this.selectedGroupChildNodes.push(c),this.selectedNodes={nodes:[c],event:l.evt})}),this.stage.on("click tap",l=>{const c=l.target;if(!(l.evt.shiftKey||this.selectionRectangle.visible()&&this.selectionRectangle.width()>0&&this.selectionRectangle.height()>0)){if(c._id===this.stage._id){this.selectedNodes.length&&(this.selectedNodes={});return}this.selectedNodes={nodes:[c],event:l.evt}}}),this.container.addEventListener("keydown",l=>{const c=l.key;if(!c||this.editingTextNode)return;const h=l.ctrlKey||l.metaKey,d=l.shiftKey;let p=1;switch(h&&(p=.1),d&&(p=10),c){case"Backspace":l.preventDefault(),this.destroySelectedNodes();break;case"ArrowUp":l.preventDefault(),this.selectedNodesProps={y:-p,useRelativeValue:!0},this.positionTooltip();break;case"ArrowDown":l.preventDefault(),this.selectedNodesProps={y:p,useRelativeValue:!0},this.positionTooltip();break;case"ArrowLeft":l.preventDefault(),this.selectedNodesProps={x:-p,useRelativeValue:!0},this.positionTooltip();break;case"ArrowRight":l.preventDefault(),this.selectedNodesProps={x:p,useRelativeValue:!0},this.positionTooltip();break;case"a":l.preventDefault(),h&&(this.selectedNodes={nodes:"all"});break}}),this.konvajsContent.addEventListener("dragover",l=>{l.preventDefault()}),this.konvajsContent.addEventListener("drop",l=>{l.preventDefault(),this.stage.setPointersPositions(l);const c=JSON.parse(l.dataTransfer.getData("data")??"{}");if(!c.type)return;let{x:h,y:d}=this.stage.getPointerPosition();const p=this.addNodeToStage({type:c.type,attrs:{...c.attrs},beforeAdd:m=>{const g=m.getClassName(),v=g==="Rect"||g==="Path",w=m.getClientRect();m.setAttrs({x:h-(v?w.width/2:0),y:d-(v?w.height/2:0)})}});this.selectedNodes={nodes:[p]}})},stageEvents(){this.stage.on("click tap",()=>{this.setActiveTooltipDropdown(null)}),this.stage.on("dragmove",e=>{const t=e.target;if(t.name()==="lqd-cs-stage"){t.x(0),t.y(0);return}}),this.stage.on("widthChange heightChange",this.addToHistory)},containerEvents(){const e=t=>{t.target===this.container&&this.selectedNodes.length&&(this.selectedNodes={})};this.container.addEventListener("click",e.bind(this)),this.container.addEventListener("tap",e.bind(this)),this.container.addEventListener("keydown",t=>{(t.ctrlKey||t.metaKey)&&t.key==="z"&&!t.shiftKey&&(t.preventDefault(),this.undo()),((t.ctrlKey||t.metaKey)&&t.shiftKey&&t.key==="z"||(t.ctrlKey||t.metaKey)&&t.key==="y")&&(t.preventDefault(),this.redo())})},selectionTransformerEvents(){function e(i,r,s){const o=i.getClassName();if(["Rect","Image","Text"].includes(o))i.width(i.width()*r),i.height(i.height()*s),i.scaleX(1),i.scaleY(1);else if(o==="Circle"||o==="RegularPolygon"){const l=i.radius(),c=(r+s)/2;i.radius(l*c),i.scaleX(1),i.scaleY(1)}else o==="Ellipse"&&(i.radiusX(i.radiusX()*r),i.radiusY(i.radiusY()*s),i.scaleX(1),i.scaleY(1))}function t(i,r,s){i.getChildren().forEach(o=>{const l=o.getClassName(),{x:c,y:h}=o.position();if(o.position({x:c*r,y:h*s}),l==="Group"){const d=o.scaleX()*r,p=o.scaleY()*s;o.scaleX(1),o.scaleY(1),t(o,d,p)}else e(o,r*o.scaleX(),s*o.scaleY())})}this.selectionTransformer.on("transform",()=>{this.selectedNodes.forEach(r=>{const s=r.getClassName(),o=r.scaleX(),l=r.scaleY();if(s==="Group"){r.scaleX(1),r.scaleY(1),t(r,o,l);return}e(r,o,l)})})},createNode(e={type:null,attrs:{}}){if(!this.stageInitiated)return;if(!Konva[e.type]){console.error(`Konva does not support the type "${e.type}"`);return}const t=this.generateNameByType(e.type),i=this.stage.width(),r=this.stage.height(),s={x:i/2,y:r/2,fill:Konva.Util.getRandomColor(),stroke:"",strokeWidth:0,draggable:!0,strokeScaleEnabled:!1,text:e.attrs?.text||magicai_localize.double_click_to_edit,fontSize:30,fontStyle:"normal 400",id:`${t.toLowerCase().replace(/\s+/g,"-")}-${Date.now()}`,name:t,perfectDrawEnabled:!1,offset:{x:0,y:0},...e.attrs},o=new Konva[e.type](s);return s.x==="left"&&o.x(0),s.x==="center"&&o.x((i-o.width())/2),s.x==="right"&&o.x(i-o.width()),s.y==="top"&&o.y(0),s.y==="middle"&&o.y((r-o.height())/2),s.y==="bottom"&&o.y(r-o.height()),e.type==="Group"&&this.addGroupHighlighter(o),["Text","TextPath"].includes(e.type)&&this.handleTextEdit(o),e.type==="Image"&&(s.fillSource?this.fetchedAssets.includes(s.fillSource)||s.fillSource===this.placeholderImage?this.setNodeFillPattern({node:o,url:s.fillSource}):this.handleUploadImage(o,s.fillSource):this.setNodeFillPattern({node:o,url:this.placeholderImage})),o.on("heightChange widthChange innerRadiusChange outerRadiusChange radiusChange radiusXChange radiusYChange",()=>{this.handleFillCover(o)}),o.on(this.historyListeners.map(l=>l+="Change").join(" "),this.addToHistory),o},addNodeToStage(e={type:"Ellipse",attrs:{},beforeAdd:null,node:null,addHistory:!0}){if(!this.stageInitiated)return;const t=e.node||this.createNode(e),i=e.addHistory??!0;return e.beforeAdd&&typeof e.beforeAdd=="function"&&e.beforeAdd.call(this,t),this.showWelcomeScreen=!1,this.layer.add(t),this.selectedNodes={nodes:[t]},i&&this.addToHistory(),t},addGroupHighlighter(e){const t=new Konva.Transformer({id:`highlighter-${e.id()}`,name:"lqd-cs-highlighter",enabledAnchors:[],rotateEnabled:!1,borderStroke:this.selectionColors.stroke,draggable:!1});e.setAttr("highlighter",t.id()),this.layer.add(t)},handleHighlighterVisibility(e){let t="",i="",r=e;e.on("mouseover",s=>{const o=s.evt.ctrlKey||s.evt.metaKey,c=e.findAncestors("Group").at(-1);if(!o&&c&&(r=c),r.getType()==="Group"&&o)return;const h=this.layer.findOne(`#highlighter-${r.id()}`),d=this.selectedNodes.find(p=>p.id()===r.id());t=e.stroke(),i=e.strokeWidth(),d||(h&&h.nodes([r]),r.stroke(this.selectionColors.stroke),r.strokeWidth(i??2))}),e.on("mouseout",()=>{const s=r.getAttr("highlighter");s&&this.layer.findOne(`#${s}`).nodes([]),r.stroke(t),r.strokeWidth(i),r=e})},applyFilters(e,t){t.blurRadius?(e.clearCache(),e.cache(),e.filters([Konva.Filters.Blur])):!t.blurRadius&&!e.blurRadius()&&e.isCached()&&e.clearCache()},handleTextEdit(e){e.off("dblclick.editText dbltap.editText"),e.on("dblclick.editText dbltap.editText",()=>{if(e.getAttr("aiTaskInProgress"))return toastr.warn("An AI task is in progress. please wait until it's done.");e.hide(),this.selectionTransformer.hide(),this.editingTextarea=document.createElement("textarea"),this.container.insertAdjacentElement("afterend",this.editingTextarea),this.editingTextarea.classList.add("absolute","border-none","p-0","m-0","overflow-hidden","bg-transparent","outline-none","resize-none","whitespace-pre","origin-top-left","placeholder:text-transparent"),this.editingTextNode=e;const t=e.fontStyle().split(" "),i=this.editingTextNode.text();let r=t[0],s=t[1];isNaN(parseInt(r))||(r=null,s=r),this.editingTextarea.style.fontFamily=e.fontFamily(),this.editingTextarea.style.textAlign=e.align(),this.editingTextarea.style.color=e.fill().toString(),this.editingTextarea.style.transformOrigin="top left",this.editingTextarea.style.textDecoration=e.textDecoration(),this.editingTextarea.value=e.text(),this.editingTextarea.placeholder=this.editingTextarea.value,r&&(this.editingTextarea.style.fontStyle=r),s&&(this.editingTextarea.style.fontWeight=s),this.editingTextarea.focus(),this.editingTextarea.select(),this.positionEditingTextarea(),this.editingTextarea.addEventListener("keydown",o=>{if(this.editingTextarea){if(o.key==="Enter"&&!o.shiftKey){this.setEditingTextareaTextAndRemove();return}if(o.key==="Escape"){this.setEditingTextareaTextAndRemove(i);return}this.editingTextarea.placeholder=this.editingTextarea.value,this.editingTextarea.style.height="auto",this.editingTextarea.style.height=this.editingTextarea.scrollHeight+e.fontSize()+"px"}}),this.$nextTick(()=>{this.editingTextarea.addEventListener("focusout",this.setEditingTextareaTextAndRemove),window.addEventListener("click",this.handleEditinTextareaOutsideClick),window.addEventListener("tap",this.handleEditinTextareaOutsideClick)})}),e.on("fontFamilyChange fontSizeChange fontStyleChange textDecorationChange lineHeightChange letterSpacingChange",({newVal:t,type:i})=>{if(t==null||i==null||!this.editingTextarea)return;const r=i.replace("Change","");let s=t;(r==="letterSpacing"||r==="fontSize")&&(s+="px"),this.editingTextarea.style[r]=s})},handleEditinTextareaOutsideClick(e){this.editingTextNode&&e.target!==this.editingTextarea&&this.setEditingTextareaTextAndRemove(this.editingTextarea.value)},removeEditingTextarea(){!this.editingTextNode||!this.editingTextarea||(this.editingTextarea.removeEventListener("focusout",this.setEditingTextareaTextAndRemove),this.editingTextarea?.remove(),window.removeEventListener("click",this.handleEditinTextareaOutsideClick),window.removeEventListener("tap",this.handleEditinTextareaOutsideClick),this.editingTextNode.show(),this.selectionTransformer.show(),this.selectionTransformer.forceUpdate(),this.editingTextNode=null,this.editingTextarea=null)},setEditingTextareaTextAndRemove(e){!this.editingTextarea||!this.editingTextNode||(typeof e!="string"&&(e=this.editingTextarea?.value??""),this.editingTextNode.text(e),this.removeEditingTextarea())},positionEditingTextarea(){if(!this.editingTextNode)return;const e=this.editingTextNode.getClientRect(),t=this.zoomLevel/100,i={x:e.x*t,y:e.y*t},r=this.konvajsContent.getBoundingClientRect(),s=this.editingTextNode.rotation(),l=this.editingTextNode.getClassName()==="TextPath",c=this.isMobile()?16:10;l&&(i.x+=e.width/2*t,i.y+=e.height/2*t),this.editingTextarea.style.width="auto",this.editingTextarea.style.height="auto",this.editingTextarea.style.top=Math.max(0,r.top+i.y)+"px",this.editingTextarea.style.left=Math.max(0,r.left+i.x)+"px",this.editingTextarea.style.fontSize=Math.max(c,this.editingTextNode.fontSize()*t)+"px",this.editingTextarea.style.letterSpacing=this.editingTextNode.letterSpacing()*t+"px",this.editingTextarea.style.lineHeight=l?"1.2":this.editingTextNode.lineHeight().toString(),this.$nextTick(()=>{this.editingTextarea.style.width=(l?this.stage.width():this.editingTextNode.width())*t+"px",this.editingTextarea.style.height=this.editingTextarea.scrollHeight+this.editingTextNode.fontSize()*this.editingTextNode.lineHeight()+"px"}),s&&!l&&(this.editingTextarea.style.transform=`rotate(${s}deg)`)},updateSelectionTransformerStroke(){const t=100/this.zoomLevel,i=1*Math.min(3,Math.max(.5,t)),s=6*Math.min(3,Math.max(.5,t));this.selectionTransformer.borderStrokeWidth(i),this.selectionTransformer.anchorSize(s)},getNodesFromOptions(e={ids:[],nodes:[],id:null,node:null}){let t=[];return e.nodes?.length?e.nodes==="all"?t=this.nodes:t=e.nodes:e.ids?.length?t=this.nodes.filter(i=>e.ids.includes(i.id())):e.id?t=[this.nodes.find(i=>i.id()===e.id)]:e.node&&(this.nodes.find(i=>i.id()===e.node?.id())?t=[e.node]:console.warn("Could not find the node: ",e.node?.id()??"Unknown node ID")),t},deselectNodes(e){const t=this.getNodesFromOptions(e).map(i=>i.id());this.selectedNodes={nodes:this.selectedNodes.filter(i=>!t.includes(i.id()))}},removeNodes(e){const t=this.getNodesFromOptions(e);this.deselectNodes({nodes:t}),t.forEach(i=>i.remove())},destroyNodes(e){const t=this.getNodesFromOptions(e);this.deselectNodes({nodes:t}),t.forEach(i=>i.destroy()),this.nodes.length||(this.showWelcomeScreen=!0)},destroySelectedNodes(){this.destroyNodes({nodes:this.selectedNodes})},cloneSelectedNodes(){const e=this.selectedNodes.map(t=>{const i=this.generateNameByType(t.getClassName());return t.clone({x:t.x()+20,y:t.y()+20,name:i,id:`${i.toLowerCase().replace(/\s+/g,"-")}-${Date.now()}`})});e.filter(t=>["Text","TextPath"].includes(t.getClassName())).forEach(t=>this.handleTextEdit(t)),this.layer.add(...e),this.selectedNodes={nodes:e}},groupSelectedNodes(){const e=this.selectedNodes;if(!e.length)return;this.generateNameByType("Group");const t=this.addNodeToStage({type:"Group",attrs:{x:0,y:0,width:null,height:null,fill:null,draggable:!0}});e.forEach(i=>{t.add(i),i.draggable(!1)}),this.layer.add(t),this.addGroupHighlighter(t),this.selectedNodes={nodes:[t]}},ungroupSelectedNodes(){const e=this.selectedNodes;if(!e.length)return;e.filter(i=>i.getType()==="Group").forEach(i=>{const r=i.getChildren(),o=i.findAncestors("Group")?.at(0),l=i.id(),c=i.getAttr("highlighter"),h=[];r.forEach(d=>{d.findAncestors("Group").length<=1&&h.push(d)}),h.forEach(d=>{const p=d.getAbsolutePosition(o??this.stage),m=d.rotation(),g=i.rotation(),v=(m+g)%360;d.moveTo(o??this.layer),d.position(p),d.rotation(v),d.draggable(!o)}),this.destroyNodes({ids:[l,c]}),this.selectedNodes={nodes:h}})},getNodesByType(e){return e?this.nodes.filter(t=>t.getClassName()===e):[]},generateNameByType(e){if(!e)return"Node 0";const t=this.getNodesByType(e),i=t.length;return`${t[0]?.getClassName()||e} ${i+1}`},moveNode(e){this.selectedNodes.forEach(t=>t[e]())},initLayers(){const t=(navigator.userAgentData?navigator.userAgentData.platform.includes("macOS"):navigator.platform.includes("Mac"))?"Meta":"Control";this.layersSortable=ae.create(this.$refs.layers,{multiDrag:!0,selectedClass:"selected",multiDragKey:t,animation:150,draggable:".lqd-cs-layer",filter:".lqd-cs-layers-list-template",onSelect:i=>{const r=i.originalEvent.target,s=i.items.map(o=>o.dataset.id);this.selectedNodes={ids:s},this.elementIsFocusable(r)||this.$nextTick(()=>{this.container.focus()})},onEnd:()=>{const i=[...this.nodes],r=this.selectedNodes,s=this.layersSortable.toArray();i.sort((o,l)=>{const c=s.indexOf(o.id());return s.indexOf(l.id())-c}),bn.defer(()=>this.removeNodes({nodes:"all"})),bn.defer(()=>{this.layer.add(...i),this.selectedNodes={nodes:r}})}})},alignSelectedNodes(e){const t=this.selectedNodes;if(t.length===1){const r=t[0],s=r.getClientRect(),o=this.stage.width(),l=this.stage.height(),c=r.x(),h=r.y();switch(e){case"left":r.x(c-s.x);break;case"center":r.x(c-s.x+(o-s.width)/2);break;case"right":r.x(c-s.x+o-s.width);break;case"top":r.y(h-s.y);break;case"middle":r.y(h-s.y+(l-s.height)/2);break;case"bottom":r.y(h-s.y+l-s.height);break}return}const i=t.reduce((r,s)=>{const o=s.getClientRect();return{left:Math.min(r.left,o.x),right:Math.max(r.right,o.x+o.width),top:Math.min(r.top,o.y),bottom:Math.max(r.bottom,o.y+o.height),centerX:(r.left+r.right)/2,centerY:(r.top+r.bottom)/2}},{left:1/0,right:-1/0,top:1/0,bottom:-1/0,centerX:0,centerY:0});i.centerX=(i.left+i.right)/2,i.centerY=(i.top+i.bottom)/2,t.forEach(r=>{const s=r.getClientRect(),o=r.x(),l=r.y();switch(e){case"left":r.x(o-(s.x-i.left));break;case"center":r.x(o+(i.centerX-(s.x+s.width/2)));break;case"right":r.x(o+(i.right-(s.x+s.width)));break;case"top":r.y(l-(s.y-i.top));break;case"middle":r.y(l+(i.centerY-(s.y+s.height/2)));break;case"bottom":r.y(l+(i.bottom-(s.y+s.height)));break}})},rotatePoint({x:e,y:t},i){const r=Math.cos(i),s=Math.sin(i);return{x:e*r-t*s,y:t*r+e*s}},rotateNodeAroundCenter(e,t){const i={x:-e.width()/2,y:-e.height()/2},r=this.rotatePoint(i,Konva.getAngle(e.rotation())),s=this.rotatePoint(i,Konva.getAngle(t)),o=s.x-r.x,l=s.y-r.y,c=e.x()+o,h=e.y()+l;return{rotation:t,x:c,y:h}},isPropertyNotApplicableToNodeType(e,t){return e==="cornerRadius"&&!["Rect","Image"].includes(t)||e==="sides"&&t!=="RegularPolygon"||e==="numPoints"&&t!=="Star"||e==="innerRadius"&&!["Star","Ring","Arc"].includes(t)||e==="outerRadius"&&!["Star","Ring","Arc"].includes(t)||e==="angle"&&!["Arc","Wedge"].includes(t)||["fontSize","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","letterSpacing","align"].includes(e)&&!["Text","TextPath"].includes(t)||e==="lineHeight"&&t!=="Text"},formatPropertyValue(e,t){return typeof t=="number"?e==="opacity"?t.toFixed(2):Number.isInteger(t)?t:t.toFixed(1):e==="fontStyle"&&t==="normal"?400:t},handleFillCover(e){e.getAttr("fillCover")&&this.applyFillCover(e)},async handleUploadImage(e,t){if(t)return fetch(t).then(r=>r.blob()).then(async r=>{const s=new File([r],"image",{type:r.type}),o=await this.uploadImage({file:s,node:e});await this.setNodeFillPattern({node:e,url:o.url})}).catch(r=>{toastr.error("Failed to load image"),console.error("Error creating file from URL:",r)});const i=document.createElement("input");i.type="file",i.accept="image/*",i.style.display="none",document.body.appendChild(i),i.addEventListener("cancel",async r=>{!r.target.files[0]&&!e.fillPatternImage()&&this.destroyNodes({nodes:[e]})}),i.addEventListener("change",async r=>{const s=await this.uploadImage({event:r,node:e});await this.setNodeFillPattern({node:e,url:s.url}),this.activeFillTab="image",this.$nextTick(()=>{document.body.removeChild(i)})}),i.click()},async uploadImage({node:e,event:t,file:i}){if(t&&!i&&(i=t.target.files[0]),!i||!e)return;if(!i.type.startsWith("image/")){toastr.error("Please upload a valid image file");return}const r=new FormData;return r.append("image",i),(await(await fetch("/dashboard/user/creative-suite/image/upload",{method:"POST",body:r,headers:{Accept:"application/json"}})).json()).data},async setNodeFillPattern({node:e,url:t,setSize:i=!0}){const r=new Image;return new Promise((s,o)=>{r.onload=()=>{e.fillPatternImage(r),e.fillPriority("pattern"),e.setAttr("fillImageWidth",r.naturalWidth),e.setAttr("fillImageHeight",r.naturalHeight),e.setAttr("fillSource",r.src),e.setAttr("fillCover",!0),this.applyFillCover(e),s(r),this.fetchedAssets.includes(t)||this.fetchedAssets.push(t)},r.onerror=function(l){o(l)},r.src=t})},removeFillPattern(){const e=this.selectedNodes[0];e.fillPatternImage(null),e.fillPriority("color"),this.$refs.selectedNodeFillPatternInput&&(this.$refs.selectedNodeFillPatternInput.value=""),e.setAttr("fillImageWidth",null),e.setAttr("fillImageHeight",null),e.setAttr("fillSource",null),e.setAttr("fillCover",null),e.setAttr("fillAlign",null)},getFillCoverProps(e){const t=e.getAttr("fillAlign")??"center-middle",i=e.getClassName(),r=e.getClientRect(),s=e.getAttr("fillImageWidth")??r.width,o=e.getAttr("fillImageHeight")??r.height;let l,c,h=!1;i==="Circle"?l=c=e.radius()*2:i==="Ellipse"?(l=e.radiusX()*2,c=e.radiusY()*2):["Rect","Image","Text"].includes(i)?(l=e.width(),c=e.height()):(l=r.width,c=r.height,h=!0);const d=s/o,p=l/c;let m,g;p>=d?(m=l/s,g=l/d/o):(m=c*d/s,g=c/o);const v=s*m,w=o*g;let S=0,E=0;return h||!["Rect","Image","Text"].includes(i)?(t.includes("left")?S=-l/2:t.includes("center")?S=-v/2:t.includes("right")&&(S=-v+l/2),t.includes("top")?E=-c/2:t.includes("middle")?E=-w/2:t.includes("bottom")&&(E=-w+c/2)):(t.includes("left")?S=0:t.includes("center")?S=(l-v)/2:t.includes("right")&&(S=l-v),t.includes("top")?E=0:t.includes("middle")?E=(c-w)/2:t.includes("bottom")&&(E=c-w)),i==="Path"&&h&&(S+=r.x,E+=r.y),{offsetX:S,offsetY:E,scaleX:m,scaleY:g}},applyFillCover(e){if(e=e??this.selectedNodes[0],!e)return;e.setAttr("fillPatternRepeat","no-repeat");const t=this.getFillCoverProps(e);e.setAttrs({fillPatternX:t.offsetX,fillPatternY:t.offsetY,fillPatternScaleX:t.scaleX,fillPatternScaleY:t.scaleY})},onFontsSearchInput(){const e=this.$event.target.value.trim();if(!e){this.fontsPaginationCurrent=this.fontsPaginationLimit,this.showingGoogleFonts=this.googleFontsList.slice(0,this.fontsPaginationLimit);return}this.showingGoogleFonts=this.googleFontsList.filter(t=>t.toLowerCase().includes(e.toLowerCase()))},loadMoreFonts(){this.fontsPaginationCurrent+=this.fontsPaginationLimit,this.showingGoogleFonts=this.googleFontsList.slice(0,this.fontsPaginationCurrent)},addToGoogleFontLoadQueue(e,t=!1){if(!(t&&this.lqdFontPreview.includes(e))){if(!t)return this.loadGoogleFontFull(e);this.loadingFontPreviewQueue.push(e),this.loadGoogleFontPreview(e),this.lqdFontPreview.push(e)}},loadGoogleFontPreview(){if(!this.loadingFontPreviewQueue.length)return;const e=this.loadingFontPreviewQueue.map(r=>`family=${r}`).join("&").replaceAll(" ","+"),t=encodeURIComponent(this.loadingFontPreviewQueue.join("")),i=`https://fonts.googleapis.com/css2?${e}&display=swap&text=${t}`;this.createFontLink(i),this.loadingFontPreviewQueue=[]},async loadGoogleFontFull(e){const t=`https://fonts.googleapis.com/css2?family=${e.replaceAll(/ /g,"+")}:wght@400;500;600;700;800;900&display=swap`;this.createFontLink(t),document.fonts.ready.finally(()=>{this.selectedNodes.find(i=>["Text","TextPath"].includes(i.getClassName()))&&this.selectionTransformer.forceUpdate()})},createFontLink(e){const t=document.createElement("link");t.href=e,t.rel="stylesheet",t.type="text/css",document.head.appendChild(t)},handleStageResize({width:e,height:t,preserveAspectRatio:i=!1}){if(e==null&&t==null)return;const r=parseInt(this.stage.width(),10),s=parseInt(this.stage.height(),10);let o=e??r,l=t??s;if(i&&r&&s){const c=r/s;if(e&&!t)l=o/c;else if(!e&&t)o=l*c;else if(e&&t){const h=o/l;h>c?o=l*c:h<c&&(l=o/c)}}this.prevStageWidth=r,this.prevStageHeight=s,this.resizeStage(o,l)},resizeStage(e,t){this.stage.width(e),this.stage.height(t),this.container.style.width=e+"px",this.container.style.height=t+"px";const i=e/(this.prevStageWidth??1),r=t/(this.prevStageHeight??1);if(this.adaptiveResize&&this.prevStageWidth>0&&this.prevStageHeight>0){const o=e>this.prevStageWidth||t>this.prevStageHeight?Math.max(i,r):Math.min(i,r);this.nodes.forEach(l=>{l.x(l.x()*i),l.y(l.y()*r);const c=l.getClassName();if(l.width&&l.height){const h=l.width(),d=l.height();l.width(h*o),l.height(d*o)}if(c==="Circle"&&l.radius(l.radius()*o),c==="Ellipse"){const h=l.radiusX(),d=l.radiusY();l.radiusX(h*o),l.radiusY(d*o)}c==="RegularPolygon"&&l.radius(l.radius()*o),c==="Star"&&(l.innerRadius(l.innerRadius()*o),l.outerRadius(l.outerRadius()*o)),(c==="Text"||c==="TextPath")&&l.fontSize(l.fontSize()*o),l.fillPatternImage&&l.fillPatternScaleX&&l.fillPatternScaleY&&(l.fillPatternScaleX(l.fillPatternScaleX()*o),l.fillPatternScaleY(l.fillPatternScaleY()*o))}),bn.defer(()=>{this.selectionTransformer.forceUpdate(),this.fitToScreen(),this.setContainerDimensions()})}},switchView(e){if(!(this.editingTextNode||this.tool)){if(e==="<"){this.currentView=this.prevViews.pop()||"home";return}this.prevViews.push(this.currentView),this.currentView=e||"home"}},getZoomPadding(){const e=getComputedStyle(this.$el),t=15,i=parseInt(e.getPropertyValue("--sidebar-w")??0,10)+t,r=parseInt(e.getPropertyValue("--header-h")??0,10)+t;return{x:i,y:r}},getFitToScreenZoom(){const e=this.getZoomPadding(),t=(this.container.clientWidth-e.x)/(this.konvajsContent.clientWidth*(this.zoomLevel/100)),i=(this.container.clientHeight-e.y)/(this.konvajsContent.clientHeight*(this.zoomLevel/100)),r=Math.min(t,i)*100;return Math.max(this.minZoom,Math.min(this.maxZoom,r))},setZoomLevel(e){this.zoomLevel=Math.max(this.minZoom,Math.min(this.maxZoom,e)),this.reachedMinZoom=this.zoomLevel===this.minZoom,this.reachedMaxZoom=this.zoomLevel>=this.maxZoom},zoomIn(){this.setZoomLevel(this.zoomLevel+10)},zoomOut(){this.setZoomLevel(this.zoomLevel-10)},fitToScreen(){const e=this.getFitToScreenZoom();this.setZoomLevel(e);const t=this.getZoomPadding();this.zoomOffsetX=t.x/2,this.zoomOffsetY=t.y/2},positionTooltip(){if(!this.selectedNodes.length)return;const e=this.konvajsContent.getBoundingClientRect(),t=this.selectedNodesRect,i=this.zoomLevel/100,r=e.left+t.x*i+t.width*i/2,s=e.top+t.y*i-40,l=this.$refs.tooltip.getBoundingClientRect().height,c=Math.max(e.left,Math.min(r,e.right)),h=Math.max(e.top-l/2,Math.min(s,e.bottom-l/2));this._tooltipAnimationFrame||(this._tooltipAnimationFrame=requestAnimationFrame(()=>{this.$refs.tooltip.style.left=`${c}px`,this.$refs.tooltip.style.top=`${h}px`,this._tooltipAnimationFrame=null}))},handlePanAndZoom(){let e={x:0,y:0},t=0,i={x:0,y:0},r={x:0,y:0},s={x:0,y:0};const o=S=>{if(this.showWelcomeScreen)return;S.preventDefault();const E=this.konvajsContent.getBoundingClientRect(),k=S.clientX-E.left,I=S.clientY-E.top;if(S.metaKey||S.ctrlKey){const N=(S.deltaY<0?1:-1)*2,V=Math.max(this.minZoom,Math.min(this.maxZoom,this.zoomLevel+N)),U=V/this.zoomLevel;this.setZoomLevel(V);const W={x:E.width/2,y:E.height/2},G={x:(k-W.x)/this.zoomLevel,y:(I-W.y)/this.zoomLevel};this.zoomOffsetX-=G.x*(U-1),this.zoomOffsetY-=G.y*(U-1)}else{const R=this.zoomLevel/15;this.zoomOffsetX-=S.deltaX/R,this.zoomOffsetY-=S.deltaY/R}},l=S=>{this.docActiveElementIsWritable()||S.code==="Space"&&!S.repeat&&!this.isSpacePressed&&!this.showWelcomeScreen&&(this.isSpacePressed=!0,document.body.classList.add("is-panning"),this.container.classList.add("is-panning"),document.activeElement&&document.activeElement!==document.body&&document.activeElement.blur(),this.container.focus(),S.preventDefault())},c=S=>{this.docActiveElementIsWritable()||S.code==="Space"&&(this.isSpacePressed=!1,this.isPanning=!1,document.body.classList.remove("is-panning","is-panning-active"),this.container.classList.remove("is-panning","is-panning-active"))},h=S=>{this.docActiveElementIsWritable()||this.isSpacePressed&&S.button===0&&!this.showWelcomeScreen&&(this.isPanning=!0,e={x:S.clientX,y:S.clientY},document.body.classList.add("is-panning-active"),this.container.classList.add("is-panning-active"),document.activeElement&&document.activeElement!==document.body&&document.activeElement.blur(),this.container.focus(),S.stopPropagation(),S.preventDefault())},d=S=>{if(!this.docActiveElementIsWritable()&&this.isPanning){const E=S.clientX-e.x,k=S.clientY-e.y;e={x:S.clientX,y:S.clientY},this.zoomOffsetX+=E/(this.zoomLevel/15),this.zoomOffsetY+=k/(this.zoomLevel/15),S.preventDefault(),S.stopPropagation()}},p=()=>{this.docActiveElementIsWritable()||this.isPanning&&(this.isPanning=!1,document.body.classList.remove("is-panning-active"),this.container.classList.remove("is-panning-active"))},m=()=>{this.docActiveElementIsWritable()||this.isPanning&&(this.isPanning=!1,document.body.classList.remove("is-panning-active"),this.container.classList.remove("is-panning-active"))},g=S=>{const E=S.touches;if(this.showWelcomeScreen||E.length<2)return;const k=E[0],I=E[1];k&&I&&this.stage.stopDrag(!1),t=Math.hypot(I.clientX-k.clientX,I.clientY-k.clientY);const R=this.konvajsContent.getBoundingClientRect();i={x:(k.clientX+I.clientX)/2-R.left,y:(k.clientY+I.clientY)/2-R.top},r={x:(k.clientX+I.clientX)/2,y:(k.clientY+I.clientY)/2},s={x:this.zoomOffsetX,y:this.zoomOffsetY}},v=S=>{const E=S.touches;if(!(this.showWelcomeScreen||E.length<2)&&(S.preventDefault(),E.length===2)){const k=E[0],I=E[1];if(k&&I){const R={x:(k.clientX+I.clientX)/2,y:(k.clientY+I.clientY)/2},N=R.x-r.x,V=R.y-r.y;this.zoomOffsetX=s.x+N/(this.zoomLevel/15),this.zoomOffsetY=s.y+V/(this.zoomLevel/15);const U=Math.hypot(I.clientX-k.clientX,I.clientY-k.clientY),W=U/t;if(t>0&&W!==1){const G=this.konvajsContent.getBoundingClientRect(),Y={x:(k.clientX+I.clientX)/2-G.left,y:(k.clientY+I.clientY)/2-G.top},le=Math.max(this.minZoom,Math.min(this.maxZoom,this.zoomLevel*W)),ke=this.zoomLevel,pe=le/ke;this.setZoomLevel(le);const _e=G.width/2,de=G.height/2,ce=(i.x-_e)/ke,Oe=(i.y-de)/ke;this.zoomOffsetX-=ce*(pe-1),this.zoomOffsetY-=Oe*(pe-1),t=U,i=Y}}}},w=S=>{this.showWelcomeScreen||(t=0,i={x:0,y:0},this.stage.draggable(!0))};this.container.addEventListener("wheel",o,{passive:!1}),this.container.addEventListener("mousedown",h),this.container.addEventListener("touchstart",g),this.container.addEventListener("touchmove",v),this.container.addEventListener("touchend",w),this.container.addEventListener("touchcancel",w),document.addEventListener("keydown",l),document.addEventListener("keyup",c),document.addEventListener("mousemove",d),document.addEventListener("mouseup",p),document.addEventListener("mouseleave",m),window.addEventListener("resize",this.positionTooltip),this.selectionTransformer.on("transform",this.positionTooltip),document.addEventListener("nodes-selected",this.positionTooltip)},initNodesSnap(){let e=this.nodes,t=[];const i=()=>{var l=[0,this.stage.width()/2,this.stage.width()],c=[0,this.stage.height()/2,this.stage.height()];return e.forEach(h=>{if(!this.selectionTransformer.nodes().find(p=>p.id()===h.id())){var d=h.getClientRect();l.push([d.x,d.x+d.width,d.x+d.width/2]),c.push([d.y,d.y+d.height,d.y+d.height/2])}}),{vertical:l.flat(),horizontal:c.flat()}},r=()=>{const l=this.selectionTransformer.getClientRect(),c=this.selectionTransformer.absolutePosition();return l.height=l.height-this.selectionTransformer.rotateAnchorOffset(),l.y=l.y+this.selectionTransformer.rotateAnchorOffset(),{vertical:[{guide:Math.round(l.x),offset:Math.round(c.x-l.x),snap:"start"},{guide:Math.round(l.x+l.width/2),offset:Math.round(c.x-l.x-l.width/2),snap:"center"},{guide:Math.round(l.x+l.width),offset:Math.round(c.x-l.x-l.width),snap:"end"}],horizontal:[{guide:Math.round(l.y),offset:Math.round(c.y-l.y),snap:"start"},{guide:Math.round(l.y+l.height/2),offset:Math.round(c.y-l.y-l.height/2),snap:"center"},{guide:Math.round(l.y+l.height),offset:Math.round(c.y-l.y-l.height),snap:"end"}]}},s=(l,c)=>{var h=[],d=[];l.vertical.forEach(v=>{c.vertical.forEach(w=>{var S=Math.abs(v-w.guide);S<this.guidelineOffset&&h.push({lineGuide:v,diff:S,snap:w.snap,offset:w.offset})})}),l.horizontal.forEach(v=>{c.horizontal.forEach(w=>{var S=Math.abs(v-w.guide);S<this.guidelineOffset&&d.push({lineGuide:v,diff:S,snap:w.snap,offset:w.offset})})});var p=[],m=h.sort((v,w)=>v.diff-w.diff)[0],g=d.sort((v,w)=>v.diff-w.diff)[0];return m&&p.push({lineGuide:m.lineGuide,offset:m.offset,orientation:"V",snap:m.snap}),g&&p.push({lineGuide:g.lineGuide,offset:g.offset,orientation:"H",snap:g.snap}),p},o=l=>{l.forEach(c=>{const h=c.orientation==="H";var d=new Konva.Line({points:h?[-6e3,0,6e3,0]:[0,-6e3,0,6e3],stroke:this.selectionColors.stroke,strokeWidth:1,name:"lqd-cs-guide-line",dash:[4,6]});this.layer.add(d),d.absolutePosition({x:h?0:c.lineGuide,y:h?c.lineGuide:0})})};this.selectionTransformer.on("dragstart",()=>{e=this.nodes,t=[];const l=this.selectionTransformer.absolutePosition();this.selectedNodes.forEach(c=>{const h=c.absolutePosition();t.push({id:c.id(),xDiff:h.x-l.x,yDiff:h.y-l.y})})}),this.selectionTransformer.on("dragmove",l=>{this.layer.find(".lqd-cs-guide-line").forEach(m=>m.destroy());var c=i(),h=r(),d=s(c,h);if(!d.length){this.positionTooltip();return}o(d);const p={...this.selectionTransformer.absolutePosition()};d.forEach(m=>{switch(m.orientation){case"V":{p.x=m.lineGuide+m.offset;break}case"H":{p.y=m.lineGuide+m.offset;break}}}),this.selectionTransformer.absolutePosition(p),this.selectedNodes.forEach(m=>{const g=t.find(v=>v.id===m.id());g&&m.absolutePosition({x:p.x+g.xDiff,y:p.y+g.yDiff})}),this.positionTooltip()}),this.layer.on("dragend",()=>{this.layer.find(".lqd-cs-guide-line").forEach(l=>l.destroy())})},addToHistory(){this.history.length>this.maxHistoryLength-1&&this.history.shift(),this.historyPointer!==this.history.length-1&&(this.history=this.history.slice(0,this.historyPointer+1)),this.history.push({stage:{width:this.stage.width(),height:this.stage.height()},zoom:{zoomOffsetX:this.zoomOffsetX,zoomOffsetY:this.zoomOffsetY,zoomLevel:this.zoomLevel},nodes:this.nodes.map(e=>e.toJSON()),selectedNodeIds:this.selectedNodes.map(e=>e.id())}),this.historyPointer=Math.min(this.history.length-1,this.historyPointer+1)},undo(){this.historyPointer!==-1&&(this.historyPointer=Math.max(-1,this.historyPointer-1),this.applyHistory())},redo(){this.historyPointer!==this.history.length-1&&(this.historyPointer=Math.min(this.history.length-1,this.historyPointer+1),this.applyHistory())},applyHistory(){if(this.historyPointer===-1)return this.destroyNodes({nodes:"all"});const e=this.history[this.historyPointer];if(!e)return;const t=this.stage.width(),i=this.stage.height();let r=!1;e.stage?.width&&e.stage.width!==t&&(this.stage.width(e.stage.width),r=!0),e.stage?.height&&e.stage.height!==i&&(this.stage.height(e.stage.height),r=!0),r&&e.zoom&&this.$nextTick(()=>{this.fitToScreen()}),this.destroyNodes({nodes:"all"}),e.nodes?.forEach(s=>{try{const o=Konva.Node.create(s),l=o.getClassName(),c=o.getAttrs();this.addNodeToStage({type:l,attrs:c,addHistory:!1}),o.destroy(),e.selectedNodeIds&&(this.selectedNodes={ids:e.selectedNodeIds})}catch(o){console.error("Error creating node:",o)}})},downloadImage(){if(this.stage){this.busy=!0;try{const e=this.selectionTransformer.visible();this.selectionTransformer.visible(!1);const t=document.createElement("div");t.style.position="absolute",t.style.zIndex="-1",t.style.opacity="0",t.style.width=`${this.stage.width()}px`,t.style.height=`${this.stage.height()}px`,document.body.appendChild(t);const i=new Konva.Stage({container:t,width:this.stage.width(),height:this.stage.height(),background:"white"}),r=this.layer.clone();r.find("#lqd-cs-selection-transformer, #lqd-cs-selection-rectangle").forEach(s=>{s.remove()}),i.add(r),i.toDataURL({mimeType:"image/png",quality:1,pixelRatio:2,callback:s=>{const o=document.createElement("a");o.download=`canvas-export-${new Date().getTime()}.png`,o.href=s,document.body.appendChild(o),o.click(),document.body.removeChild(o),document.body.removeChild(t),i.destroy(),this.selectionTransformer.visible(e),this.busy=!1}})}catch(e){console.error("Error exporting image:",e),this.busy=!1,this.selectionTransformer.visible(!0)}}},resetCanvas(){this.nodes.length&&confirm(magicai_localize.all_your_current_edits_will_be_lost__are_you_sure_)&&(this.resetHistory(),this.destroyNodes({nodes:"all"}),this.fitToScreen(),this.currentDocId=null,this.currentDocName=null)},resetHistory(){this.history=[],this.historyPointer=-1},beforeUnloadHandler(e){if(this.nodes.length>0){const t=magicai_localize.you_have_unsaved_changes__are_you_sure_you_want_to_leave_;return e.preventDefault(),e.returnValue=t,t}},addBeforeUnloadListener(){this.beforeUnloadListened=!0,window.addEventListener("beforeunload",this.beforeUnloadHandler)},removeBeforeUnloadListener(){this.beforeUnloadListened=!1,window.removeEventListener("beforeunload",this.beforeUnloadHandler)},handleExport(){if(!(!this.stage||!this.nodes.length))try{const e=this.getExportData(),t="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(e)),i=document.createElement("a");i.setAttribute("href",t),i.setAttribute("download",`canvas-export-${new Date().getTime()}.json`),document.body.appendChild(i),i.click(),i.remove(),toastr.success("Canvas exported successfully")}catch(e){console.error("Error exporting canvas:",e),toastr.error("Failed to export canvas")}},getExportData(){const e=this.nodes.map(t=>t.toJSON());return{name:this.currentDocName||"Untitled Document",stage:{width:this.stage.width(),height:this.stage.height()},nodes:e}},handleImport(){const e=document.createElement("input");e.type="file",e.accept=".json",e.style.display="none",e.addEventListener("change",t=>{const i=t.target.files[0];if(!i)return;const r=new FileReader;r.onload=s=>{try{const o=JSON.parse(s.target.result);this.importData({data:o}),this.currentView!=="editor"&&this.switchView("editor"),toastr.success("Canvas imported successfully")}catch(o){console.error("Error importing canvas:",o),toastr.error("Failed to import canvas")}},r.readAsText(i),e.remove()}),document.body.appendChild(e),e.click()},importData({data:e,docId:t=null,switchToEditor:i=!0}){if(!e.nodes||!Array.isArray(e.nodes))throw new Error("Invalid file format");(!this.nodes.length||this.nodes.length&&confirm(magicai_localize.all_your_current_edits_will_be_lost__are_you_sure_))&&(this.destroyNodes({nodes:"all"}),e.name&&(this.currentDocName=e.name),e.stage&&this.handleStageResize({width:e.stage.width,height:e.stage.height}),e.nodes.forEach(r=>{try{const s=Konva.Node.create(r),o=s.getClassName(),l=s.getAttrs();this.addNodeToStage({type:o,attrs:l,addHistory:!1,beforeAdd:c=>{l.fontFamily&&this.loadGoogleFontFull(l.fontFamily),o==="Group"&&s.getChildren().forEach(d=>{d.draggable(!1),c.add(d.clone())})}}),s.destroy()}catch(s){console.error("Error creating node:",s)}}),this.resetHistory(),this.currentDocId=t,i&&this.currentView!=="editor"&&this.switchView("editor"))},async loadTemplatesList(e){if(e==null)return;this.loadingTemplates=!0,this.loadingTemplatesFailed=!1;const i=await(await fetch(e)).json();if(this.loadingTemplates=!1,!(i instanceof Array)||!i.length){this.loadingTemplatesFailed=!0,toastr.error(magicai_localize.could_not_fetch_templates_list_please_try_again||"Could not fetch templates list. Please try again.");return}this.templatesList=i},loadTemplate(e){if(e==null)return;const t=this.templatesList.find(i=>i.id==e);if(!t)return toastr.error(magicai_localize.could_not_fetch_template_data_please_try_again||"Could not fetch template data. Please try again.");this.importData({data:t.data})},async saveDocument(){const e=this.getExportData(),t=new FormData,i=document.createElement("div");i.style.position="absolute",i.style.zIndex="-1",i.style.opacity="0",i.style.width=`${this.stage.width()}px`,i.style.height=`${this.stage.height()}px`,document.body.appendChild(i);const r=new Konva.Stage({container:i,width:this.stage.width(),height:this.stage.height(),background:"white"}),s=this.layer.clone();s.find("#lqd-cs-selection-transformer, #lqd-cs-selection-rectangle").forEach(l=>{l.remove()}),r.add(s);const o=await r.toBlob({mimeType:"image/png",quality:.7,pixelRatio:Math.min(2,Math.max(1,720/Math.min(720,r.width())))});document.body.removeChild(i),r.destroy(),t.append("payload",JSON.stringify(e)),t.append("preview",new File([o],"preview.png",{type:"image/png"})),this.currentDocId!=null&&t.append("id",this.currentDocId),this.currentDocName&&t.append("name",this.currentDocName);try{const l=await fetch("/dashboard/user/creative-suite/document",{method:"POST",body:t,headers:{Accept:"application/json"}});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);const c=await l.json();if(c.status==="error"){toastr.error(c.message||magicai_localize.error_saving_document);return}if(c.data.id){const h=document.querySelectorAll(`.lqd-cs-doc-item[data-id="${c.data.id}"]`);this.currentDocId=c.data.id,h.length?h.forEach(d=>d.querySelector("img").src=c.data.preview_url):this.newItems.push(c.data)}this.removeBeforeUnloadListener(),toastr.success(magicai_localize.saved_succesfully)}catch(l){toastr.error("Upload failed:",l)}},async duplicateDocument(e){if(!e)return;const t=new FormData;t.append("id",e);try{const i=await fetch("/dashboard/user/creative-suite/document/duplicate",{method:"POST",body:t,headers:{Accept:"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const r=await i.json();if(r.status==="error"){toastr.error(r.message||magicai_localize.error_saving_document);return}r.data&&(document.querySelector(`.lqd-cs-doc-item[data-id="${r.data.id}"]`)||this.newItems.push(r.data),toastr.success(magicai_localize.duplicated_the_document_successfully))}catch(i){toastr.error("Upload failed:",i)}},async deleteDocument(e){if(!e)return;const t=new FormData;t.append("id",e);try{const i=await fetch("/dashboard/user/creative-suite/document/delete",{method:"POST",body:t,headers:{Accept:"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const r=await i.json();if(r.status==="error"){toastr.error(r.message||magicai_localize.error_saving_document);return}r.status==="success"&&(document.querySelectorAll(`.lqd-cs-doc-item[data-id="${e}"]`)?.forEach(s=>s.remove()),toastr.success(magicai_localize.document_deleted_successfully))}catch(i){toastr.error("Upload failed:",i)}},async loadDocument(e){if(e)try{const t=await fetch(`/dashboard/user/creative-suite/document/${e}`);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const i=await t.json();if(!i.data.payload)return;this.importData({data:JSON.parse(i.data.payload),docId:i.data.id}),this.currentDocName=i.data.name,this.$nextTick(()=>{this.positionTooltip()})}catch(t){console.error("Upload failed:",t)}},async updateDocumentName(e){const t=new FormData(e.target);if(t.get("id")){this.updatingName=!0;try{const i=await fetch("/dashboard/user/creative-suite/document/name",{method:"POST",body:t,headers:{Accept:"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const r=await i.json();if(r.status==="error"){toastr.error(responseData.message||magicai_localize.error_saving_document);return}document.querySelectorAll(`.lqd-cs-doc-item[data-id="${r.id}"]`).forEach(o=>{const l=o.querySelector("h5");l&&(l.innerText=r.name)}),toastr.success(magicai_localize.name_updated_successfully)}catch(i){toastr.error("Updating name failed:",i)}finally{this.updatingName=!1}}},handleWindowResize(){window.addEventListener("resize",this.onWindowResize)},onWindowResize(){this.setContainerDimensions()},setActiveTooltipDropdown(e){if(!e||this.activeTooltipDropdown===e)return this.activeTooltipDropdown=null;this.activeTooltipDropdown=e},elementIsFocusable(e,t=[]){if(!e||!(e instanceof HTMLElement))return;const i=["INPUT","BUTTON","TEXTAREA","SELECT","A"];return bn.difference(i,t).includes(e.tagName)},docActiveElementIsWritable(){return document.activeElement&&["TEXTAREA","INPUT"].includes(document.activeElement.tagName)},async aiTextAction({prompt:e=""}){if(!e.trim())return;const t=this.selectedNodes.filter(i=>i.getClassName()==="Text");t.length&&t.forEach(async i=>{const r=`request-${i.id()}`,s=new FormData;s.append("lock_key",r),s.append("prompt",e),s.append("content",i.text()),this.aiTasksQueue.push(r),i.setAttr("aiTaskInProgress",!0);const o=await fetch("/dashboard/user/openai/update-writing",{method:"POST",body:s,headers:{Accept:"application/json"}});this.aiTasksQueue=this.aiTasksQueue.filter(c=>c===r),i.setAttr("aiTaskInProgress",!1);const l=await o.json();if(l.type==="error"){toastr.error(l.message);return}l.result&&i.text(l.result)})},async aiImageAction(e){const t=this.selectedNodes.filter(i=>i.getClassName()==="Image"||i.fillPatternImage());t.length&&t.forEach(async i=>{const r=`request-${i.id()}`,s=new FormData(e.target),o=Math.min(720,i.width()),l=Math.min(720,i.getAttr("fillImageWidth")??720),c=await i.toBlob({pixelRatio:Math.min(2,Math.max(1,l/o))}),h=new File([c],"image",{type:c.type});s.append("lock_key",r),s.append("uploaded_image",h),this.aiTasksQueue.push(r),i.setAttr("aiTaskInProgress",!0);const d=await fetch(e.target.action,{method:"POST",body:s,headers:{Accept:"application/json"}});if(this.aiTasksQueue=this.aiTasksQueue.filter(m=>m===r),i.setAttr("aiTaskInProgress",!1),!d.ok)return d.json().then(m=>{toastr.error(m.message||"An unknown error occurred")});const p=await d.json();if(p.type==="error"){toastr.error(p.message);return}p?.data?.status==="CREATED"||p?.data?.status==="IN_PROGRESS"?this.getAIImageStatus(p.data,i,r):this.onAIImageProcessDone(p.data,i,r)})},async getAIImageStatus(e={},t,i){const r=await fetch("/dashboard/user/advanced-image/editor/"+e.id+"/status",{method:"GET",headers:{Accept:"application/json"}});if(!r.ok)return r.json().then(o=>{toastr.error(o.message||"An unknown error occurred")});const s=await r.json();if(s.status==="error")return toastr.error(s.message);s.data.status==="COMPLETED"?this.onAIImageProcessDone(s.data,t,i):setTimeout(()=>{this.getAIImageStatus(s.data,t,i)},1e3)},onAIImageProcessDone(e,t,i){console.log(e)},isMobile(){return window.innerWidth<768},togglePromptLibraryShow(){this.promptLibraryShow=!this.promptLibraryShow},changePromptFilter(e){e!==this.promptFilter&&(this.promptFilter=e)},setSearchPromptStr(e){this.searchPromptStr=e.trim().toLowerCase()},setPrompt(e){this.prompt=e},focusOnPrompt(){this.$nextTick(()=>{this.$refs.promptInput?.focus(),this.dropdownOpen=!0})}});var WI=Object.defineProperty,rb=(n,e)=>{for(var t in e)WI(n,t,{get:e[t],enumerable:!0})},UI={};rb(UI,{lerp:()=>ob,makeCurveEasings:()=>lb,pointOnCurve:()=>ab,scaleSpreadArray:()=>qI,shuffleArray:()=>sb});function sb(n,e=Math.random){const t=[...n];let i=t.length,r;for(;i!=0;)r=Math.floor(e()*i),i--,[t[i],t[r]]=[t[r],t[i]];return t}var ob=(n,e,t)=>e+n*(t-e),qI=(n,e,t=0,i=ob)=>{if(!n||n.length<2)throw new Error("valuesToFill array must have at least two values.");if(e<1&&t>0)throw new Error("Target size must be at least 1");if(e<n.length&&t===0)throw new Error("Target size must be greater than or equal to the valuesToFill array length.");if(t<=0){const l=e-n.length,c=n.map(h=>[h]);for(let h=0;h<l;h++){const d=h%(n.length-1);if(d>=0&&d<c.length){const p=c[d];p&&p.push(null)}}for(let h=0;h<c.length-1;h++){const d=c[h],p=c[h+1];if(!d||!p)continue;const m=d[0],g=p[0];if(!(m===void 0||g===void 0))for(let v=1;v<d.length;v++){const w=v/d.length;d[v]=i(w,m,g)}}return c.flat()}const r=[],s=t,o=1-t;for(let l=0;l<e;l++){const c=e===1?.5:l/(e-1),h=s+c*(o-s);let d=0;const p=n.map((k,I)=>I/(n.length-1));for(let k=1;k<p.length;k++){const I=p[k];if(I!==void 0&&h<=I){d=k-1;break}k===p.length-1&&(d=k-1)}d=Math.min(Math.max(0,d),n.length-2);const m=p[d]||0,g=p[d+1]||1;let v=0;g>m&&(v=(h-m)/(g-m));const w=n[d],S=n[d+1];if(w===void 0||S===void 0)throw new Error(`Invalid segment values at index ${d}`);const E=i(v,w,S);r.push(E)}return r},ab=(n,e)=>t=>{const i=Math.PI/2,r=i/1,s=t;let o=0,l=0;if(n==="lamé"){const c=s*i,h=2/(2+20*e),d=Math.cos(c),p=Math.sin(c);o=Math.sign(d)*Math.abs(d)**h,l=Math.sign(p)*Math.abs(p)**h}else if(n==="arc")l=Math.cos(-Math.PI/2+t*r+e),o=Math.sin(Math.PI/2+t*r-e);else if(n==="pow")o=Math.pow(1-s,1-e),l=Math.pow(s,1-e);else if(n==="powY")o=Math.pow(1-s,e),l=Math.pow(s,1-e);else if(n==="powX")o=Math.pow(s,e),l=Math.pow(s,1-e);else if(typeof n=="function"){const[c,h]=n(t,e);o=c,l=h}else throw new Error(`pointOnCurve() curveAccent parameter is expected to be "lamé" | "arc" | "pow" | "powY" | "powX" or a function but \`${n}\` given.`);return{x:o,y:l}},lb=(n,e)=>{const t=ab(n,e);return{sEasing:i=>t(i).x,lEasing:i=>t(i).y}},af={};rb(af,{colorHarmonies:()=>GI,colorToCSS:()=>YI,harveyHue:()=>KI,hsv2hsl:()=>cb,normalizeHue:()=>Pe,uniqueRandomHues:()=>jI});function Pe(n){return(n%360+360)%360}function KI(n){if(n=Pe(n)/360,n===1||n===0)return n;n=1+n%1;const e=1/6,t=n%e/e*Math.PI/2,[i,r]=[e*Math.cos(t),e*Math.sin(t)],s=Math.floor(n*6);return[r,1/3-i,1/3+r,2/3-i,2/3+r,1-i][s%6]*360}var GI={complementary:n=>[Pe(n),Pe(n+180)],splitComplementary:n=>[Pe(n),Pe(n+150),Pe(n-150)],triadic:n=>[Pe(n),Pe(n+120),Pe(n+240)],tetradic:n=>[Pe(n),Pe(n+90),Pe(n+180),Pe(n+270)],monochromatic:n=>[Pe(n),Pe(n)],doubleComplementary:n=>[Pe(n),Pe(n+180),Pe(n+30),Pe(n+210)],compound:n=>[Pe(n),Pe(n+180),Pe(n+60),Pe(n+240)],analogous:n=>[Pe(n),Pe(n+30),Pe(n+60),Pe(n+90),Pe(n+120),Pe(n+150)]};function jI({startHue:n=0,total:e=9,minHueDiffAngle:t=60,rndFn:i=Math.random}={}){t=Math.min(t,360/e);const r=n||i()*360,s=Array.from({length:Math.round(360/t)},(l,c)=>(r+c*t)%360);let o=sb(s,i);return o.length>e&&(o=o.slice(0,e)),o}var cb=([n,e,t])=>{const i=t-t*e/2,r=Math.min(i,1-i),s=r===0?0:(t-i)/r;return[n,s,i]},XI={oklch:n=>[n[2]*100+"%",n[1]*100+"%",n[0]],lch:n=>[n[2]*100+"%",n[1]*100+"%",n[0]],hsl:n=>[n[0],n[1]*100+"%",n[2]*100+"%"],hsv:n=>{const[e,t,i]=cb(n);return[e,t*100+"%",i*100+"%"]}},YI=(n,e="oklch")=>`${e==="hsv"?"hsl":e}(${XI[e](n).join(" ")})`;function lf({total:n=9,hStart:e=Math.random()*360,hStartCenter:t=.5,hEasing:i=p=>p,hCycles:r=1,sRange:s=[.4,.35],sEasing:o=p=>Math.pow(p,2),lRange:l=[Math.random()*.1,.9],lEasing:c=p=>Math.pow(p,1.5),transformFn:h=([p,m,g])=>[p,m,g],hueList:d}={}){const p=l[1]-l[0],m=s[1]-s[0],g=d&&d.length>0?d.length:n;return Array.from({length:g},(v,w)=>{const S=w/(g-1),E=1/g,k=d?d[w]:Pe(e+(1-i(S,E)-t)*(360*r)),I=s[0]+m*o(S,E),R=l[0]+p*c(S,E);return h([k,I,R],w)})}var JI=({total:n=9,hStart:e=Math.random()*360,hStartCenter:t=.5,hCycles:i=1,sRange:r=[.4,.35],lRange:s=[Math.random()*.1,.9],hueList:o,curveMethod:l="lamé",curveAccent:c=.5,transformFn:h=([d,p,m])=>[d,p,m]}={})=>{const{sEasing:d,lEasing:p}=lb(l,c);return lf({total:n,hStart:e,hStartCenter:t,hCycles:i,sRange:r,lRange:s,sEasing:d,lEasing:p,transformFn:h,hueList:o})};function ZI(){return{options:{},styleTag:document.querySelector("#lqd-customizer-style"),darkMode:document.body.classList.contains("theme-dark"),rootStyles:null,styleString:"",lqdFontPreview:[],googleFontsList:[],showingGoogleFonts:[],fontsPaginationCurrent:20,fontsPaginationLimit:20,loadingFontPreviewQueue:[],localStorageKey:"lqdCustomizerStyle",cssSelectors:{light:":root",dark:".theme-dark"},init(){const n=document.body.getAttribute("data-theme");this.localStorageKey=n+":"+this.localStorageKey,this.onImportStyles=_.throttle(this.onImportStyles.bind(this),300,{leading:!1}),this.loadGoogleFontPreview=_.throttle(this.loadGoogleFontPreview.bind(this),300,{leading:!1}),this.options=window.lqdCustomizerOptions,this.googleFontsList=window.lqdGoogleFontsList,this.currentEdits=this.readFromLocalStorage();const e=document.body.classList.contains("theme-dark");this.rootStyles=getComputedStyle(e?document.body:document.documentElement),Object.entries(this.options).forEach(([t])=>{this.options[t].type==="color"&&(this.options[t].values={},this.options[t].values.light={},this.options[t].values.dark={})}),this.$watch("$store.darkMode.on",t=>{this.darkMode=t,this.rootStyles=getComputedStyle(t?document.body:document.documentElement)}),this.$watch("options",this.updateOutputs.bind(this)),this.showingGoogleFonts=this.googleFontsList.slice(0,this.fontsPaginationLimit),this.currentEdits&&this.onImportStyles(this.currentEdits)},setStyleStrings(){let n="",e="";if(Object.entries(this.options).forEach(([t,i])=>{const r=i.type==="font",s=i.cssVar;let o=i.value,l=null;i.values?.light&&(o=i.values.light.twHsl),i.values?.dark&&(l=i.values.dark.twHsl),o&&(n+=` ${s}: ${r?`'${o}'`:o}; `),l&&(e+=` ${s}: ${l}; `)}),!n.length&&!e.length)return this.styleString="";this.styleString=`${this.cssSelectors.light} { ${n}}`,e.length&&(this.styleString+=` ${this.cssSelectors.dark} { ${e}}`)},updateOutputs(){this.setStyleStrings(),this.fillStyleTag(),this.writeToLocalStorage()},fillStyleTag(){if(!this.styleTag)return console.error("Style tag not found");this.styleTag.innerText=this.styleString.replace(/[\n\t]/g,"")},onColorInput({key:n,color:e,manipulations:t=[],assosiatedKeys:i=[]}){if(this.options[n]?.type!=="color")return;const r=this.parseColor({color:e,format:["twHsl","hex"],manipulations:t}),s=this.darkMode?"dark":"light";this.options[n].values[s]={twHsl:r.twHsl,hex:r.hex},i.length&&i.forEach(({key:o,color:l,manipulations:c})=>{this.onColorInput({key:o,color:l||e,manipulations:c})})},parseColor({color:n,format:e="hsl",manipulations:t=[]}){const i=typeof n=="string";let r=i?n.trim():n;i&&(/^--[\w-]+$/.test(n)&&(r=this.rootStyles.getPropertyValue(n).trim()),/\S+\s+\S+/.test(r)&&!r.startsWith("hsl")&&(r=`hsl(${r})`));let s=tinycolor(r);if(t.length&&t.forEach(({type:o,value:l,condition:c})=>{if(!(c==="lightMode"&&this.darkMode||c==="darkMode"&&!this.darkMode)){if(o==="autoBlackWhite")return s=s.getLuminance()>=.4?tinycolor("#000"):tinycolor("#fff");s=s[o](l)}}),Array.isArray(e)){const o={};return e.forEach(l=>{o[l]=this.getColorString(s,l)}),o}return this.getColorString(s,e)},getColorString(n,e="hsl"){if(e==="colorObj")return n;if(e==="twHsl"){const t=n.toHsl();return`${Math.ceil(t.h)} ${Math.ceil(t.s*100)}% ${Math.ceil(t.l*100)}%${t.a&&t.a!==1?` / ${Math.ceil(t.a*100)}%`:""}`}return n.toString(e)},randomColors(){const n=tinycolor.random();let e=[.25,1],t=[1,.05];this.darkMode&&(e[1]=.7,t=t.reverse());const i=lf({total:7,hStart:n.toHsl().h,hStartCenter:0,hCycles:.75,hEasing:(de,ce)=>de+(-ce+Math.random()*ce*2)*.5,sRange:e,lRange:t,sEasing:(de,ce)=>de+(-ce+Math.random()*ce*2)*.5,lEasing:(de,ce)=>de+(-ce+Math.random()*ce*2)*.5}),r=JI({hueList:af.colorHarmonies.splitComplementary(n.toHsl().h),sRange:e.reverse(),lRange:t.reverse(),curveMethod:"arc",curveAccent:.01}),s=lf({hueList:af.uniqueRandomHues({startHue:0,total:4,minDistance:90}),sRange:[.5,.9],lRange:[.5,.9]}),o=Math.floor(i.length/2),l=i[o],c=i[o-1],h=i[o+1],d=i[0],p=i[i.length-1],m=i[1],g=Math.floor(r.length/2),v=r[r.length-1],w=r[0],S=r[g],E=s[0],k=s[1],I=s[2],R=tinycolor({h:l[0],s:l[1],l:l[2]}),N=tinycolor({h:c[0],s:Math.min(1,c[1]),l:Math.min(1,c[2])}),V=tinycolor({h:h[0],s:Math.min(1,h[1]),l:Math.min(1,h[2])}),U=tinycolor({h:p[0],s:Math.min(1,p[1]),l:Math.min(1,p[2])}),W=tinycolor({h:d[0],s:Math.min(1,d[1]),l:Math.min(1,d[2])}).desaturate(this.darkMode?30:0),G=tinycolor({h:m[0],s:Math.min(1,m[1]),l:Math.min(1,m[2])}).desaturate(20).setAlpha(.55),Y=tinycolor({h:v[0],s:Math.min(1,v[1]),l:Math.min(1,v[2])}).desaturate(this.darkMode?30:0),le=tinycolor({h:w[0],s:Math.min(1,w[1]),l:Math.min(1,w[2])}),ke=tinycolor({h:S[0],s:Math.min(1,S[1]),l:Math.min(1,S[2])})[this.darkMode?"lighten":"darken"](30),we=tinycolor({h:E[0],s:Math.min(1,E[1]),l:Math.min(1,E[2])}),pe=tinycolor({h:k[0],s:Math.min(1,k[1]),l:Math.min(1,k[2])}),_e=tinycolor({h:I[0],s:Math.min(1,I[1]),l:Math.min(1,I[2])});this.onColorInput({key:"colorMainPrimary",color:R,assosiatedKeys:[{key:"colorMainPrimaryForeground",manipulations:[{type:"autoBlackWhite"}]}]}),this.onColorInput({key:"colorMainSecondary",color:N,assosiatedKeys:[{key:"colorMainSecondaryForeground",manipulations:[{type:"autoBlackWhite"}]}]}),this.onColorInput({key:"colorMainAccent",color:V,assosiatedKeys:[{key:"colorMainAccentForeground",manipulations:[{type:"autoBlackWhite"}]}]}),this.onColorInput({key:"colorMainForeground",color:U,assosiatedKeys:[{key:"colorMainHeadingForeground",manipulations:[{type:"darken",value:22,condition:"lightMode"},{type:"lighten",value:30,condition:"darkMode"},{type:"desaturate",value:7,condition:"lightMode"},{type:"desaturate",value:30,condition:"darkMode"}]}]}),this.onColorInput({key:"colorMainBackground",color:W}),this.onColorInput({key:"colorMainBorder",color:G}),this.onColorInput({key:"colorNavbarBackground",color:Y}),this.onColorInput({key:"colorNavbarForeground",color:le}),this.onColorInput({key:"colorNavbarActiveBackground",color:ke,assosiatedKeys:[{key:"colorNavbarActiveForeground"},{key:"colorNavbarHoverForeground"},{key:"colorNavbarHoverBackground"}]}),this.onColorInput({key:"colorMainGradientFrom",color:we}),this.onColorInput({key:"colorMainGradientVia",color:pe}),this.onColorInput({key:"colorMainGradientTo",color:_e})},addToGoogleFontLoadQueue(n,e=!1){if(!(e&&this.lqdFontPreview.includes(n))){if(!e)return this.loadGoogleFontFull(n);this.loadingFontPreviewQueue.push(n),this.loadGoogleFontPreview(n),this.lqdFontPreview.push(n)}},loadGoogleFontPreview(){if(!this.loadingFontPreviewQueue.length)return;const n=this.loadingFontPreviewQueue.map(i=>`family=${i}`).join("&").replaceAll(" ","+"),e=encodeURIComponent(this.loadingFontPreviewQueue.join("")),t=`https://fonts.googleapis.com/css2?${n}&display=swap&text=${e}`;this.createLink(t),this.loadingFontPreviewQueue=[]},loadGoogleFontFull(n){const e=`https://fonts.googleapis.com/css2?family=${n.replaceAll(/ /g,"+")}&display=swap`;this.createLink(e)},createLink(n){const e=document.createElement("link");e.href=n,e.rel="stylesheet",e.type="text/css",document.head.appendChild(e)},onImportStyles(n){if(!n)return;let e=n.trim();const t={},i=/([\w\s\.\:\-\#]+)\s*\{([^}]*)\}/g;let r;for(;(r=i.exec(e))!==null;){const s=r[1].trim(),o=r[2].trim().split(";").filter(Boolean);t[s]=t[s]||[];for(const l of o){const c=l.indexOf(":");if(c>0){const h=l.slice(0,c).trim(),d=l.slice(c+1).trim();h&&d&&t[s].push({property:h,value:d})}}}Object.entries(this.options).forEach(([s,o])=>{const l=o.cssVar;Object.entries(this.cssSelectors).forEach(([c,h])=>{const d=t[h]?.find(m=>m.property===l);if(!d)return;const p=this.sanitizeCssValue(d.value);if(o.type==="color"){const m=this.parseColor({color:p,format:["twHsl","hex"]});this.options[s].values[c].twHsl=m.twHsl,this.options[s].values[c].hex=m.hex}else if(o.type==="font"){const m=p.replace(/['"]/g,"");this.options[s].value=m,this.addToGoogleFontLoadQueue(m)}else this.options[s].value=p})})},sanitizeCssValue(n){if(!n)return"";n=n.replace(/javascript:/gi,"").replace(/expression\(/gi,"").replace(/eval\(/gi,"").replace(/url\(/gi,"").replace(/data:/gi,""),n=n.replace(/[^\w\s,.#:;%\/\-+()[\]@!~="'*]/g,"");const e=(n.match(/'/g)||[]).length,t=(n.match(/"/g)||[]).length;return e%2!==0&&(n=n.replace(/'/g,"")),t%2!==0&&(n=n.replace(/"/g,"")),n},resetStyles(){Object.entries(this.options).forEach(([n,e])=>{e.type==="color"?(this.options[n].values.light={},this.options[n].values.dark={}):e.type==="font"?this.options[n].value="":this.options[n].value=""})},readFromLocalStorage(){let n=localStorage.getItem(this.localStorageKey);return n||(n=this.styleTag.textContent),n},writeToLocalStorage(){const n=this.styleString.replace(/[\n\t]/g,"");if(!n){this.emptyLocalStorage();return}localStorage.setItem(this.localStorageKey,n)},emptyLocalStorage(){localStorage.removeItem(this.localStorageKey)},saveAndClose(){this.setBackEnd(this.styleString??"")},discardChanges(){!(this.currentEdits?.replace(/[\n\t]/g,"")?.trim()??"").length&&this.resetStyles(),this.emptyLocalStorage(),this.setBackEnd("",!0)},async setBackEnd(n="",e=!1){const t={};Object.entries(this.options).forEach(([s,o])=>{o.type==="font"&&(t[s]=o.value)});const i=await fetch("/dashboard/admin/live-customizer",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({style:n,fonts:t,clear:e})});let r=await i.json();if(!i.ok){toastr.error("Error uploading the customizer styles");return}if(r.status==="success"){toastr.success(r.message),setTimeout(()=>{this.emptyLocalStorage(),window.location.reload()},1e3);return}toastr.error(r.message??"Error uploading the customizer styles")}}}function QI(n){return{dropdownOpen:!1,selectedFont:"",searchString:"",init(){this.$watch("selectedFont",e=>{this.options[n].value=e})},onSearchInput(){const e=this.$event.target.value.trim();if(!e){this.fontsPaginationCurrent=this.fontsPaginationLimit,this.showingGoogleFonts=this.googleFontsList.slice(0,this.fontsPaginationLimit);return}this.showingGoogleFonts=this.googleFontsList.filter(t=>t.toLowerCase().includes(e.toLowerCase()))},loadMoreFonts(){this.fontsPaginationCurrent+=this.fontsPaginationLimit,this.showingGoogleFonts=this.googleFontsList.slice(0,this.fontsPaginationCurrent)}}}Z.store("realtimeChatStatus",{active:!1,conversationStarted:!1,setActive(n){this.active=n,this.onActiveChange()},setConversationStarted(n){this.conversationStarted=n,this.onConversationStartedChange()},onActiveChange(){document.querySelectorAll(".lqd-realtime-chat-button").forEach(n=>n.classList.toggle("active",this.active)),document.querySelector(".lqd-audio-vis-wrap")?.classList?.toggle("active",this.active)},onConversationStartedChange(){const n=document.querySelector(".chats-wrap");n.classList.toggle("conversation-started",this.conversationStarted),n.classList.toggle("conversation-not-started",!this.conversationStarted),document.querySelectorAll(".lqd-realtime-chat-button").forEach(e=>{e.classList.toggle("conversation-started",this.conversationStarted),e.classList.toggle("conversation-not-started",!this.conversationStarted)})}});const eD=n=>({agentId:n,recordingActive:!1,buffer:new Uint8Array,conversation:null,audioRecorder:null,audioPlayer:null,activeVisulaizer:"idle",audioVisWrap:null,audioVisBars:null,audioVisDotWrap:null,audioVisLoader:null,conversationArea:document.querySelector(".conversation-area"),chatsContainer:document.querySelector(".chats-container"),userBubbleTemplate:document.querySelector("#chat_user_bubble"),aiBubbleTemplate:document.querySelector("#chat_ai_bubble"),lastAiBubble:null,lastUserBubble:null,lastUserQuestion:"",lastAiResponse:"",lastResponseSaved:!1,init(){this.audioVisWrap=document.querySelector(".lqd-audio-vis-wrap"),this.audioVisBars=this.audioVisWrap?.querySelectorAll(".lqd-audio-vis-bar"),this.audioVisDotWrap=this.audioVisWrap?.querySelector(".lqd-audio-vis-dot-wrap"),this.audioVisLoader=this.audioVisWrap?.querySelector(".lqd-audio-vis-loader"),this.processAudioRecordingBuffer=this.processAudioRecordingBuffer.bind(this)},async start(){if(Z.store("realtimeChatStatus").isActive)return;Z.store("realtimeChatStatus").setActive(!0),this.switchVisualizers("waiting");const e=await this.checkBalance(!0);if(e.shouldStop){toastr.error(e.errorMsg),this.stop();return}this.conversation=await iO.startSession({agentId:this.agentId,onConnect:async()=>{await Promise.all([this.startRecorder(),this.startPlayer()]).then(()=>{this.startBarsVisualizer(),this.startDotVisualizer(),this.switchVisualizers("idle"),Z.store("realtimeChatStatus").setConversationStarted(!0)}).catch(t=>{this.stop(),console.error("Error starting recorder and player:",t),this.appendToChatBubble("ai","[Error]: Unable to start audio recorder and player. Please check your microphone permissions and refresh the page.")})},onDisconnect:()=>{this.disconnectHandle(this.conversation?.connection),this.stop()},onModeChange:t=>{this.checkBalance().then(i=>{if(i.shouldStop){this.stop(),toastr.error(i.errorMsg);return}})},onMessage:t=>{t.source=="ai"?(this.createChatBubble("ai"),this.appendToChatBubble("ai",t.message),this.lastAiResponse=t.message,"saveResponseAsync"in window&&(saveResponseAsync(this.lastUserQuestion.trim(),this.lastAiResponse.trim(),document.querySelector("#chat_id").value,"","","","","elevenlabs-voice-chatbot"),this.lastResponseSaved=!0),"formatString"in window&&this.lastAiBubble&&(this.lastAiBubble.innerHTML=formatString(this.lastAiResponse)),this.lastAiResponse=this.lastUserQuestion=""):(this.createChatBubble("user"),this.appendToChatBubble("user",t.message),this.lastUserQuestion+=" "+t.message,this.lastResponseSaved=!1)},onError:t=>{console.error("Error:",t),this.stop()}})},async stop(){!this.lastResponseSaved&&"saveResponseAsync"in window&&this.lastUserQuestion.trim()!==""&&this.lastAiResponse.trim()!==""&&saveResponseAsync(this.lastUserQuestion.trim(),this.lastAiResponse.trim(),document.querySelector("#chat_id").value,"","","","","elevenlabs-voice-chatbot"),this.resetPlayers(),this.conversation&&(await this.conversation.endSession(),this.conversation=null),this.switchVisualizers(""),Z.store("realtimeChatStatus").setActive(!1)},async startPlayer(){try{this.audioPlayer=new ib,await this.audioPlayer.init(24e3)}catch(e){console.error("Error starting audio player:",e)}},async startRecorder(){try{this.audioRecorder=new O0(this.processAudioRecordingBuffer);const e=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});await this.audioRecorder.start(e),this.recordingActive=!0}catch(e){console.error("Error starting audio recorder:",e)}},combineArray(e){const t=new Uint8Array(this.buffer.length+e.length);t.set(this.buffer),t.set(e,this.buffer.length),this.buffer=t},processAudioRecordingBuffer(e){const t=new Uint8Array(e);if(this.combineArray(t),this.buffer.length>=4800){const i=new Uint8Array(this.buffer.slice(0,4800));this.buffer=new Uint8Array(this.buffer.slice(4800));const r=String.fromCharCode(...i);btoa(r)}},async resetPlayers(){this.recordingActive=!1,this.audioRecorder?.stop(),this.audioPlayer?.clear()},getSystemMessage(){return""},getTemperature(){return parseFloat(.8)},getVoice(){return"alloy"},switchVisualizers(e){this.activeVisulaizer=e,this.audioVisWrap?.setAttribute("data-state",this.activeVisulaizer)},createChatBubble(e){const i=(e==="user"?this.userBubbleTemplate:this.aiBubbleTemplate).content.cloneNode(!0),r=i.querySelector(".chat-content");this.chatsContainer.appendChild(i),e==="user"?this.lastUserBubble=r:this.lastAiBubble=r,this.scrollConversationAreaToBottom()},appendToChatBubble(e,t){const i=e==="user"?this.lastUserBubble:this.lastAiBubble;i?(i.textContent+=t,this.scrollConversationAreaToBottom()):(this.createChatBubble(e),this.appendToChatBubble(e,t))},scrollConversationAreaToBottom(){this.conversationArea.scrollTo({top:this.conversationArea.scrollHeight+200,left:0})},startBarsVisualizer(){if(!this.audioVisBars?.length)return;const e=this.audioPlayer.audioContext.createAnalyser();e.fftSize=4096;const t=e.frequencyBinCount,i=new Uint8Array(t),r=this.audioVisBars.length;this.audioPlayer.playbackNode.connect(e);const s=[[85,150],[150,250],[250,400],[400,600],[600,1e3]];this.barHeights=this.barHeights||new Array(r).fill(0);const o=()=>{e.getByteFrequencyData(i),this.audioVisBars.forEach((l,c)=>{const[h,d]=s[c],p=Math.floor(h/(this.audioPlayer.audioContext.sampleRate/e.fftSize)),m=Math.ceil(d/(this.audioPlayer.audioContext.sampleRate/e.fftSize));let g=0;for(let w=p;w<=m&&w<i.length;w++)i[w]>g&&(g=i[w]);let v=g/255*80;this.barHeights[c]+=(v-this.barHeights[c])*.4,this.barHeights[c]+=(Math.random()-.5)*2,this.barHeights[c]=Math.max(5,Math.min(100,this.barHeights[c])),l.animate([{height:l.style.height},{height:`${this.barHeights[c]}%`}],{duration:30,fill:"forwards",easing:"linear"})}),requestAnimationFrame(o)};o()},startDotVisualizer(){if(!this.audioRecorder||!this.audioVisDotWrap)return;const e=this.audioRecorder.audioContext.createAnalyser();e.fftSize=256;const t=e.frequencyBinCount,i=new Uint8Array(t);this.audioRecorder.getMediaStreamSource().connect(e);const r=this.audioVisDotWrap.querySelector(".lqd-audio-vis-dot");if(!r)return;const s=()=>{e.getByteFrequencyData(i);let o=0;for(let d=0;d<t;d++)o+=i[d];const c=1+o/t/256*1.5,h=Math.max(.2,1-(c-1)/1.5);r.style.transform=`scale(${c})`,r.style.opacity=h.toFixed(2),requestAnimationFrame(s)};s()},checkBalance(e=!1){return new Promise(t=>{$.ajax({url:"/dashboard/admin/voice-chatbot/check-balance",type:"POST",data:{onStart:e},dataType:"json",success:i=>{const r=i.status!=="success",s=i.message||"";t({shouldStop:r,errorMsg:s})},error:()=>{t({shouldStop:!0,errorMsg:"An error occurred."})}})})},disconnectHandle(e){e?.disconnectionDetails?.reason=="error"&&(toastr.error("Something went wrong. Please contact support for assistance"),console.error(e?.disconnectionDetails?.message))}});function Mt(n){this.content=n}Mt.prototype={constructor:Mt,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var i=t&&t!=n?this.remove(t):this,r=i.find(n),s=i.content.slice();return r==-1?s.push(t||n,e):(s[r+1]=e,t&&(s[r]=t)),new Mt(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Mt(t)},addToStart:function(n,e){return new Mt([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Mt(t)},addBefore:function(n,e,t){var i=this.remove(e),r=i.content.slice(),s=i.find(n);return r.splice(s==-1?r.length:s,0,e,t),new Mt(r)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Mt.from(n),n.size?new Mt(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Mt.from(n),n.size?new Mt(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Mt.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Mt.from=function(n){if(n instanceof Mt)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Mt(e)};function ub(n,e,t){for(let i=0;;i++){if(i==n.childCount||i==e.childCount)return n.childCount==e.childCount?null:t;let r=n.child(i),s=e.child(i);if(r==s){t+=r.nodeSize;continue}if(!r.sameMarkup(s))return t;if(r.isText&&r.text!=s.text){for(let o=0;r.text[o]==s.text[o];o++)t++;return t}if(r.content.size||s.content.size){let o=ub(r.content,s.content,t+1);if(o!=null)return o}t+=r.nodeSize}}function hb(n,e,t,i){for(let r=n.childCount,s=e.childCount;;){if(r==0||s==0)return r==s?null:{a:t,b:i};let o=n.child(--r),l=e.child(--s),c=o.nodeSize;if(o==l){t-=c,i-=c;continue}if(!o.sameMarkup(l))return{a:t,b:i};if(o.isText&&o.text!=l.text){let h=0,d=Math.min(o.text.length,l.text.length);for(;h<d&&o.text[o.text.length-h-1]==l.text[l.text.length-h-1];)h++,t--,i--;return{a:t,b:i}}if(o.content.size||l.content.size){let h=hb(o.content,l.content,t-1,i-1);if(h)return h}t-=c,i-=c}}class z{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let i=0;i<e.length;i++)this.size+=e[i].nodeSize}nodesBetween(e,t,i,r=0,s){for(let o=0,l=0;l<t;o++){let c=this.content[o],h=l+c.nodeSize;if(h>e&&i(c,r+l,s||null,o)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,t-d),i,r+d)}l=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,i,r){let s="",o=!0;return this.nodesBetween(e,t,(l,c)=>{let h=l.isText?l.text.slice(Math.max(e,c)-c,t-c):l.isLeaf?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&h||l.isTextblock)&&i&&(o?o=!1:s+=i),s+=h},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,i=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(i)&&(r[r.length-1]=t.withText(t.text+i.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new z(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let i=[],r=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],c=o+l.nodeSize;c>e&&((o<e||c>t)&&(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))),i.push(l),r+=l.nodeSize),o=c}return new z(i,r)}cutByIndex(e,t){return e==t?z.empty:e==0&&t==this.content.length?this:new z(this.content.slice(e,t))}replaceChild(e,t){let i=this.content[e];if(i==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-i.nodeSize;return r[e]=t,new z(r,s)}addToStart(e){return new z([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new z(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,i=0;t<this.content.length;t++){let r=this.content[t];e(r,i,t),i+=r.nodeSize}}findDiffStart(e,t=0){return ub(this,e,t)}findDiffEnd(e,t=this.size,i=e.size){return hb(this,e,t,i)}findIndex(e){if(e==0)return Bl(0,e);if(e==this.size)return Bl(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,i=0;;t++){let r=this.child(t),s=i+r.nodeSize;if(s>=e)return s==e?Bl(t+1,s):Bl(t,i);i=s}}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 z.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new z(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return z.empty;let t,i=0;for(let r=0;r<e.length;r++){let s=e[r];i+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new z(t||e,i)}static from(e){if(!e)return z.empty;if(e instanceof z)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new z([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}z.empty=new z([],0);const Cd={index:0,offset:0};function Bl(n,e){return Cd.index=n,Cd.offset=e,Cd}function Tc(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!Tc(n[i],e[i]))return!1}else{for(let i in n)if(!(i in e)||!Tc(n[i],e[i]))return!1;for(let i in e)if(!(i in n))return!1}return!0}let He=class cf{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,i=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!i&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),i=!0),t&&t.push(s)}}return t||(t=e.slice()),i||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Tc(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let i=e.marks[t.type];if(!i)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=i.create(t.attrs);return i.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(t[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return cf.none;if(e instanceof cf)return[e];let t=e.slice();return t.sort((i,r)=>i.type.rank-r.type.rank),t}};He.none=[];class kc extends Error{}class j{constructor(e,t,i){this.content=e,this.openStart=t,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let i=fb(this.content,e+this.openStart,t);return i&&new j(i,this.openStart,this.openEnd)}removeBetween(e,t){return new j(db(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 j.empty;let i=t.openStart||0,r=t.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new j(z.fromJSON(e,t.content),i,r)}static maxOpen(e,t=!0){let i=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)i++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new j(e,i,r)}}j.empty=new j(z.empty,0,0);function db(n,e,t){let{index:i,offset:r}=n.findIndex(e),s=n.maybeChild(i),{index:o,offset:l}=n.findIndex(t);if(r==e||s.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(i!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(i,s.copy(db(s.content,e-r-1,t-r-1)))}function fb(n,e,t,i){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r);if(s==e||o.isText)return i&&!i.canReplace(r,r,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=fb(o.content,e-s-1,t,o);return l&&n.replaceChild(r,o.copy(l))}function tD(n,e,t){if(t.openStart>n.depth)throw new kc("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new kc("Inconsistent open depths");return pb(n,e,t,0)}function pb(n,e,t,i){let r=n.index(i),s=n.node(i);if(r==e.index(i)&&i<n.depth-t.openStart){let o=pb(n,e,t,i+1);return s.copy(s.content.replaceChild(r,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==i&&e.depth==i){let o=n.parent,l=o.content;return Zr(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=nD(t,n);return Zr(s,gb(n,o,l,e,i))}else return Zr(s,Ac(n,e,i))}function mb(n,e){if(!e.type.compatibleContent(n.type))throw new kc("Cannot join "+e.type.name+" onto "+n.type.name)}function uf(n,e,t){let i=n.node(t);return mb(i,e.node(t)),i}function Jr(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function ra(n,e,t,i){let r=(e||n).node(t),s=0,o=e?e.index(t):r.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Jr(n.nodeAfter,i),s++));for(let l=s;l<o;l++)Jr(r.child(l),i);e&&e.depth==t&&e.textOffset&&Jr(e.nodeBefore,i)}function Zr(n,e){return n.type.checkContent(e),n.copy(e)}function gb(n,e,t,i,r){let s=n.depth>r&&uf(n,e,r+1),o=i.depth>r&&uf(t,i,r+1),l=[];return ra(null,n,r,l),s&&o&&e.index(r)==t.index(r)?(mb(s,o),Jr(Zr(s,gb(n,e,t,i,r+1)),l)):(s&&Jr(Zr(s,Ac(n,e,r+1)),l),ra(e,t,r,l),o&&Jr(Zr(o,Ac(t,i,r+1)),l)),ra(i,null,r,l),new z(l)}function Ac(n,e,t){let i=[];if(ra(null,n,t,i),n.depth>t){let r=uf(n,e,t+1);Jr(Zr(r,Ac(n,e,t+1)),i)}return ra(e,null,t,i),new z(i)}function nD(n,e){let t=e.depth-n.openStart,r=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)r=e.node(s).copy(z.from(r));return{start:r.resolveNoCache(n.openStart+t),end:r.resolveNoCache(r.content.size-n.openEnd-t)}}class ma{constructor(e,t,i){this.pos=e,this.path=t,this.parentOffset=i,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 i=this.pos-this.path[this.path.length-1],r=e.child(t);return i?e.child(t).cut(i):r}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 i=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)r+=i.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return He.none;if(this.textOffset)return e.child(t).marks;let i=e.maybeChild(t-1),r=e.maybeChild(t);if(!i){let l=i;i=r,r=l}let s=i.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!r||!s[o].isInSet(r.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let i=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!r||!i[s].isInSet(r.marks))&&(i=i[s--].removeFromSet(i));return i}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!t||t(this.node(i))))return new Mc(this,e,i);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<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let i=[],r=0,s=t;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(s),h=s-c;if(i.push(o,l,r+c),!h||(o=o.child(l),o.isText))break;s=h-1,r+=c+1}return new ma(t,i,s)}static resolveCached(e,t){let i=Gy.get(e);if(i)for(let s=0;s<i.elts.length;s++){let o=i.elts[s];if(o.pos==t)return o}else Gy.set(e,i=new iD);let r=i.elts[i.i]=ma.resolve(e,t);return i.i=(i.i+1)%rD,r}}class iD{constructor(){this.elts=[],this.i=0}}const rD=12,Gy=new WeakMap;class Mc{constructor(e,t,i){this.$from=e,this.$to=t,this.depth=i}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const sD=Object.create(null);let wr=class hf{constructor(e,t,i,r=He.none){this.type=e,this.attrs=t,this.marks=r,this.content=i||z.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,i,r=0){this.content.nodesBetween(e,t,i,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,i,r){return this.content.textBetween(e,t,i,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,i){return this.type==e&&Tc(this.attrs,t||e.defaultAttrs||sD)&&He.sameSet(this.marks,i||He.none)}copy(e=null){return e==this.content?this:new hf(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new hf(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,i=!1){if(e==t)return j.empty;let r=this.resolve(e),s=this.resolve(t),o=i?0:r.sharedDepth(t),l=r.start(o),h=r.node(o).content.cut(r.pos-l,s.pos-l);return new j(h,r.depth-o,s.depth-o)}replace(e,t,i){return tD(this.resolve(e),this.resolve(t),i)}nodeAt(e){for(let t=this;;){let{index:i,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(i),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:i}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(t),index:t,offset:i};let r=this.content.child(t-1);return{node:r,index:t-1,offset:i-r.nodeSize}}resolve(e){return ma.resolveCached(this,e)}resolveNoCache(e){return ma.resolve(this,e)}rangeHasMark(e,t,i){let r=!1;return t>e&&this.nodesBetween(e,t,s=>(i.isInSet(s.marks)&&(r=!0),!r)),r}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()+")"),yb(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,i=z.empty,r=0,s=i.childCount){let o=this.contentMatchAt(e).matchFragment(i,r,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let c=r;c<s;c++)if(!this.type.allowsMarks(i.child(c).marks))return!1;return!0}canReplaceWith(e,t,i,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(i),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=He.none;for(let t=0;t<this.marks.length;t++){let i=this.marks[t];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!He.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.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 i;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=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,i)}let r=z.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,r,i);return s.type.checkAttrs(s.attrs),s}};wr.prototype.text=void 0;class Oc extends wr{constructor(e,t,i,r){if(super(e,t,null,r),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):yb(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 Oc(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Oc(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 yb(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class ns{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let i=new oD(e,t);if(i.next==null)return ns.empty;let r=vb(i);i.next&&i.err("Unexpected trailing text");let s=fD(dD(r));return pD(s,i),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,i=e.childCount){let r=this;for(let s=t;r&&s<i;s++)r=r.matchType(e.child(s).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let i=0;i<e.next.length;i++)if(this.next[t].type==e.next[i].type)return!0;return!1}fillBefore(e,t=!1,i=0){let r=[this];function s(o,l){let c=o.matchFragment(e,i);if(c&&(!t||c.validEnd))return z.from(l.map(h=>h.createAndFill()));for(let h=0;h<o.next.length;h++){let{type:d,next:p}=o.next[h];if(!(d.isText||d.hasRequiredAttrs())&&r.indexOf(p)==-1){r.push(p);let m=s(p,l.concat(d));if(m)return m}}return null}return s(this,[])}findWrapping(e){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==e)return this.wrapCache[i+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let r=i.shift(),s=r.match;if(s.matchType(e)){let o=[];for(let l=r;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:c}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!r.type||c.validEnd)&&(i.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=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(i){e.push(i);for(let r=0;r<i.next.length;r++)e.indexOf(i.next[r].next)==-1&&t(i.next[r].next)}return t(this),e.map((i,r)=>{let s=r+(i.validEnd?"*":" ")+" ";for(let o=0;o<i.next.length;o++)s+=(o?", ":"")+i.next[o].type.name+"->"+e.indexOf(i.next[o].next);return s}).join(` `)}}ns.empty=new ns(!0);class oD{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 vb(n){let e=[];do e.push(aD(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function aD(n){let e=[];do e.push(lD(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function lD(n){let e=hD(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=cD(n,e);else break;return e}function jy(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function cD(n,e){let t=jy(n),i=t;return n.eat(",")&&(n.next!="}"?i=jy(n):i=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:i,expr:e}}function uD(n,e){let t=n.nodeTypes,i=t[e];if(i)return[i];let r=[];for(let s in t){let o=t[s];o.isInGroup(e)&&r.push(o)}return r.length==0&&n.err("No node type or group '"+e+"' found"),r}function hD(n){if(n.eat("(")){let e=vb(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=uD(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 dD(n){let e=[[]];return r(s(n,0),t()),e;function t(){return e.push([])-1}function i(o,l,c){let h={term:c,to:l};return e[o].push(h),h}function r(o,l){o.forEach(c=>c.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((c,h)=>c.concat(s(h,l)),[]);if(o.type=="seq")for(let c=0;;c++){let h=s(o.exprs[c],l);if(c==o.exprs.length-1)return h;r(h,l=t())}else if(o.type=="star"){let c=t();return i(l,c),r(s(o.expr,c),c),[i(c)]}else if(o.type=="plus"){let c=t();return r(s(o.expr,l),c),r(s(o.expr,c),c),[i(c)]}else{if(o.type=="opt")return[i(l)].concat(s(o.expr,l));if(o.type=="range"){let c=l;for(let h=0;h<o.min;h++){let d=t();r(s(o.expr,c),d),c=d}if(o.max==-1)r(s(o.expr,c),c);else for(let h=o.min;h<o.max;h++){let d=t();i(c,d),r(s(o.expr,c),d),c=d}return[i(c)]}else{if(o.type=="name")return[i(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function bb(n,e){return e-n}function Xy(n,e){let t=[];return i(e),t.sort(bb);function i(r){let s=n[r];if(s.length==1&&!s[0].term)return i(s[0].to);t.push(r);for(let o=0;o<s.length;o++){let{term:l,to:c}=s[o];!l&&t.indexOf(c)==-1&&i(c)}}}function fD(n){let e=Object.create(null);return t(Xy(n,0));function t(i){let r=[];i.forEach(o=>{n[o].forEach(({term:l,to:c})=>{if(!l)return;let h;for(let d=0;d<r.length;d++)r[d][0]==l&&(h=r[d][1]);Xy(n,c).forEach(d=>{h||r.push([l,h=[]]),h.indexOf(d)==-1&&h.push(d)})})});let s=e[i.join(",")]=new ns(i.indexOf(n.length-1)>-1);for(let o=0;o<r.length;o++){let l=r[o][1].sort(bb);s.next.push({type:r[o][0],next:e[l.join(",")]||t(l)})}return s}}function pD(n,e){for(let t=0,i=[n];t<i.length;t++){let r=i[t],s=!r.validEnd,o=[];for(let l=0;l<r.next.length;l++){let{type:c,next:h}=r.next[l];o.push(c.name),s&&!(c.isText||c.hasRequiredAttrs())&&(s=!1),i.indexOf(h)==-1&&i.push(h)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function wb(n){let e=Object.create(null);for(let t in n){let i=n[t];if(!i.hasDefault)return null;e[t]=i.default}return e}function Sb(n,e){let t=Object.create(null);for(let i in n){let r=e&&e[i];if(r===void 0){let s=n[i];if(s.hasDefault)r=s.default;else throw new RangeError("No value supplied for attribute "+i)}t[i]=r}return t}function xb(n,e,t,i){for(let r in e)if(!(r in n))throw new RangeError(`Unsupported attribute ${r} for ${t} of type ${r}`);for(let r in n){let s=n[r];s.validate&&s.validate(e[r])}}function Cb(n,e){let t=Object.create(null);if(e)for(let i in e)t[i]=new gD(n,i,e[i]);return t}let Yy=class Eb{constructor(e,t,i){this.name=e,this.schema=t,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Cb(e,i.attrs),this.defaultAttrs=wb(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ns.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-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:Sb(this.attrs,e)}create(e=null,t,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new wr(this,this.computeAttrs(e),z.from(t),He.setFrom(i))}createChecked(e=null,t,i){return t=z.from(t),this.checkContent(t),new wr(this,this.computeAttrs(e),t,He.setFrom(i))}createAndFill(e=null,t,i){if(e=this.computeAttrs(e),t=z.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(z.empty,!0);return s?new wr(this,e,t.append(s),He.setFrom(i)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){xb(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?t&&t.push(e[i]):t||(t=e.slice(0,i));return t?t.length?t:He.none:e}static compile(e,t){let i=Object.create(null);e.forEach((s,o)=>i[s]=new Eb(s,t,o));let r=t.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let s in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function mD(n,e,t){let i=t.split("|");return r=>{let s=r===null?"null":typeof r;if(i.indexOf(s)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${n}, got ${s}`)}}class gD{constructor(e,t,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?mD(e,t,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class vu{constructor(e,t,i,r){this.name=e,this.rank=t,this.schema=i,this.spec=r,this.attrs=Cb(e,r.attrs),this.excluded=null;let s=wb(this.attrs);this.instance=s?new He(this,s):null}create(e=null){return!e&&this.instance?this.instance:new He(this,Sb(this.attrs,e))}static compile(e,t){let i=Object.create(null),r=0;return e.forEach((s,o)=>i[s]=new vu(s,r++,t,o)),i}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){xb(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Tb{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=Mt.from(e.nodes),t.marks=Mt.from(e.marks||{}),this.nodes=Yy.compile(this.spec.nodes,this),this.marks=vu.compile(this.spec.marks,this);let i=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=i[o]||(i[o]=ns.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Jy(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Jy(this,o.split(" "))}this.nodeFromJSON=r=>wr.fromJSON(this,r),this.markFromJSON=r=>He.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,i,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Yy){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,i,r)}text(e,t){let i=this.nodes.text;return new Oc(i,i.defaultAttrs,e,He.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 Jy(n,e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],s=n.marks[r],o=s;if(s)t.push(s);else for(let l in n.marks){let c=n.marks[l];(r=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(r)>-1)&&t.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return t}function yD(n){return n.tag!=null}function vD(n){return n.style!=null}let sa=class df{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let i=this.matchedStyles=[];t.forEach(r=>{if(yD(r))this.tags.push(r);else if(vD(r)){let s=/[^=]*/.exec(r.style)[0];i.indexOf(s)<0&&i.push(s),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let i=new Qy(this,t,!1);return i.addAll(e,He.none,t.from,t.to),i.finish()}parseSlice(e,t={}){let i=new Qy(this,t,!0);return i.addAll(e,He.none,t.from,t.to),j.maxOpen(i.finish())}matchTag(e,t,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let s=this.tags[r];if(SD(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,i,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!i.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let c=o.getAttrs(t);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let t=[];function i(r){let s=r.priority==null?50:r.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,r)}for(let r in e.marks){let s=e.marks[r].spec.parseDOM;s&&s.forEach(o=>{i(o=ev(o)),o.mark||o.ignore||o.clearMark||(o.mark=r)})}for(let r in e.nodes){let s=e.nodes[r].spec.parseDOM;s&&s.forEach(o=>{i(o=ev(o)),o.node||o.ignore||o.mark||(o.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new df(e,df.schemaRules(e)))}};const kb={address:!0,article:!0,aside:!0,blockquote:!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},bD={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ab={ol:!0,ul:!0},ga=1,ff=2,oa=4;function Zy(n,e,t){return e!=null?(e?ga:0)|(e==="full"?ff:0):n&&n.whitespace=="pre"?ga|ff:t&~oa}class zl{constructor(e,t,i,r,s,o){this.type=e,this.attrs=t,this.marks=i,this.solid=r,this.options=o,this.content=[],this.activeMarks=He.none,this.match=s||(o&oa?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(z.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let i=this.type.contentMatch,r;return(r=i.findWrapping(e.type))?(this.match=i,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ga)){let i=this.content[this.content.length-1],r;if(i&&i.isText&&(r=/[ \t\r\n\u000c]+$/.exec(i.text))){let s=i;i.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-r[0].length))}}let t=z.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(z.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&&!kb.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Qy{constructor(e,t,i){this.parser=e,this.options=t,this.isOpen=i,this.open=0,this.localPreserveWS=!1;let r=t.topNode,s,o=Zy(null,t.preserveWhitespace,0)|(i?oa:0);r?s=new zl(r.type,r.attrs,He.none,!0,t.topMatch||r.type.contentMatch,o):i?s=new zl(null,null,He.none,!0,null,o):s=new zl(e.schema.topNodeType,null,He.none,!0,null,o),this.nodes=[s],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 i=e.nodeValue,r=this.top,s=r.options&ff?"full":this.localPreserveWS||(r.options&ga)>0;if(s==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(s)s!=="full"?i=i.replace(/\r?\n|\r/g," "):i=i.replace(/\r\n?/g,` `);else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let o=r.content[r.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(i=i.slice(1))}i&&this.insertNode(this.parser.schema.text(i),t,!/\S/.test(i)),this.findInText(e)}else this.findInside(e)}addElement(e,t,i){let r=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Ab.hasOwnProperty(o)&&this.parser.normalizeLists&&wD(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,i));e:if(c?c.ignore:bD.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let h,d=this.needsBlock;if(kb.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),h=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let p=c&&c.skip?t:this.readStyles(e,t);p&&this.addAll(e,p),h&&this.sync(s),this.needsBlock=d}else{let h=this.readStyles(e,t);h&&this.addElementByRule(e,c,h,c.consuming===!1?l:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let i=e.style;if(i&&i.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let s=this.parser.matchedStyles[r],o=i.getPropertyValue(s);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(s,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?t=t.filter(h=>!c.clearMark(h)):t=t.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return t}addElementByRule(e,t,i,r){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),i,e.nodeName=="BR")||this.leafFallback(e,i);else{let c=this.enter(o,t.attrs||null,i,t.preserveWhitespace);c&&(s=!0,i=c)}else{let c=this.parser.schema.marks[t.mark];i=i.concat(c.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,i,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,i,!1));else{let c=e;typeof t.contentElement=="string"?c=e.querySelector(t.contentElement):typeof t.contentElement=="function"?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c,i),this.findAround(e,c,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,i,r){let s=i||0;for(let o=i?e.childNodes[i]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,i){let r,s;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],h=c.findWrapping(e);if(h&&(!r||r.length>h.length+l)&&(r=h,s=c,!h.length))break;if(c.solid){if(i)break;l+=2}}if(!r)return null;this.sync(s);for(let o=0;o<r.length;o++)t=this.enterInner(r[o],null,t,!1);return t}insertNode(e,t,i){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let r=this.findPlace(e,t,i);if(r){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=He.none;for(let l of r.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):tv(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,i,r){let s=this.findPlace(e.create(t),i,!1);return s&&(s=this.enterInner(e,t,i,!0,r)),s}enterInner(e,t,i,r=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Zy(e,s,o.options);o.options&oa&&o.content.length==0&&(l|=oa);let c=He.none;return i=i.filter(h=>(o.type?o.type.allowsMarkType(h.type):tv(h.type,e))?(c=h.addToSet(c),!1):!0),this.nodes.push(new zl(e,t,c,r,null,l)),this.open++,i}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|=ga)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let i=this.nodes[t].content;for(let r=i.length-1;r>=0;r--)e+=i[r].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==t&&(this.find[i].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,i){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(i?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),i=this.options.context,r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),s=-(i?i.depth+1:0)+(r?0:1),o=(l,c)=>{for(;l>=0;l--){let h=t[l];if(h==""){if(l==t.length-1||l==0)continue;for(;c>=s;c--)if(o(l-1,c))return!0;return!1}else{let d=c>0||c==0&&r?this.nodes[c].type:i&&c>=s?i.node(c-s).type:null;if(!d||d.name!=h&&!d.isInGroup(h))return!1;c--}}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 i=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let i=this.parser.schema.nodes[t];if(i.isTextblock&&i.defaultAttrs)return i}}}function wD(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&Ab.hasOwnProperty(i)&&t?(t.appendChild(e),e=t):i=="li"?t=e:i&&(t=null)}}function SD(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ev(n){let e={};for(let t in n)e[t]=n[t];return e}function tv(n,e){let t=e.schema.nodes;for(let i in t){let r=t[i];if(!r.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let c=0;c<l.edgeCount;c++){let{type:h,next:d}=l.edge(c);if(h==e||s.indexOf(d)<0&&o(d))return!0}};if(o(r.contentMatch))return!0}}class ls{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},i){i||(i=Ed(t).createDocumentFragment());let r=i,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,c=0;for(;l<s.length&&c<o.marks.length;){let h=o.marks[c];if(!this.marks[h.type.name]){c++;continue}if(!h.eq(s[l][0])||h.type.spec.spanning===!1)break;l++,c++}for(;l<s.length;)r=s.pop()[1];for(;c<o.marks.length;){let h=o.marks[c++],d=this.serializeMark(h,o.isInline,t);d&&(s.push([h,r]),r.appendChild(d.dom),r=d.contentDOM||d.dom)}}r.appendChild(this.serializeNodeInner(o,t))}),i}serializeNodeInner(e,t){let{dom:i,contentDOM:r}=cc(Ed(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return i}serializeNode(e,t={}){let i=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(i),i=s.dom)}return i}serializeMark(e,t,i={}){let r=this.marks[e.type.name];return r&&cc(Ed(i),r(e,t),null,e.attrs)}static renderSpec(e,t,i=null,r){return cc(e,t,i,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ls(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=nv(e.nodes);return t.text||(t.text=i=>i.text),t}static marksFromSchema(e){return nv(e.marks)}}function nv(n){let e={};for(let t in n){let i=n[t].spec.toDOM;i&&(e[t]=i)}return e}function Ed(n){return n.document||window.document}const iv=new WeakMap;function xD(n){let e=iv.get(n);return e===void 0&&iv.set(n,e=CD(n)),e}function CD(n){let e=null;function t(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")e||(e=[]),e.push(i);else for(let r=0;r<i.length;r++)t(i[r]);else for(let r in i)t(i[r])}return t(n),e}function cc(n,e,t,i){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],s;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(s=xD(i))&&s.indexOf(e)>-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=r.indexOf(" ");o>0&&(t=r.slice(0,o),r=r.slice(o+1));let l,c=t?n.createElementNS(t,r):n.createElement(r),h=e[1],d=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){d=2;for(let p in h)if(h[p]!=null){let m=p.indexOf(" ");m>0?c.setAttributeNS(p.slice(0,m),p.slice(m+1),h[p]):p=="style"&&c.style?c.style.cssText=h[p]:c.setAttribute(p,h[p])}}for(let p=d;p<e.length;p++){let m=e[p];if(m===0){if(p<e.length-1||p>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:g,contentDOM:v}=cc(n,m,t,i);if(c.appendChild(g),v){if(l)throw new RangeError("Multiple content holes");l=v}}}return{dom:c,contentDOM:l}}const Mb=65535,Ob=Math.pow(2,16);function ED(n,e){return n+e*Ob}function rv(n){return n&Mb}function TD(n){return(n-(n&Mb))/Ob}const Ib=1,Db=2,uc=4,_b=8;class pf{constructor(e,t,i){this.pos=e,this.delInfo=t,this.recover=i}get deleted(){return(this.delInfo&_b)>0}get deletedBefore(){return(this.delInfo&(Ib|uc))>0}get deletedAfter(){return(this.delInfo&(Db|uc))>0}get deletedAcross(){return(this.delInfo&uc)>0}}class Sn{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Sn.empty)return Sn.empty}recover(e){let t=0,i=rv(e);if(!this.inverted)for(let r=0;r<i;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[i*3]+t+TD(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,i){let r=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let h=this.ranges[l+s],d=this.ranges[l+o],p=c+h;if(e<=p){let m=h?e==c?-1:e==p?1:t:t,g=c+r+(m<0?0:d);if(i)return g;let v=e==(t<0?c:p)?null:ED(l/3,e-c),w=e==c?Db:e==p?Ib:uc;return(t<0?e!=c:e!=p)&&(w|=_b),new pf(g,w,v)}r+=d-h}return i?e+r:new pf(e+r,0,null)}touches(e,t){let i=0,r=rv(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let h=this.ranges[l+s],d=c+h;if(e<=d&&l==r*3)return!0;i+=this.ranges[l+o]-h}return!1}forEach(e){let t=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let o=this.ranges[r],l=o-(this.inverted?s:0),c=o+(this.inverted?0:s),h=this.ranges[r+t],d=this.ranges[r+i];e(l,l+h,c,c+d),s+=d-h}}invert(){return new Sn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Sn.empty:new Sn(e<0?[0,-e,0]:[0,0,e])}}Sn.empty=new Sn([]);class ya{constructor(e,t,i=0,r=e?e.length:0){this.mirror=t,this.from=i,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new ya(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,i=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?i+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,i=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?i-r-1:void 0)}}invert(){let e=new ya;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let i=this.from;i<this.to;i++)e=this._maps[i].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,i){let r=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let c=this.getMirror(s);if(c!=null&&c>s&&c<this.to){s=c,e=this._maps[c].recover(l.recover);continue}}r|=l.delInfo,e=l.pos}return i?e:new pf(e,r,null)}}const Td=Object.create(null);class Bt{getMap(){return Sn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=Td[t.stepType];if(!i)throw new RangeError(`No step type ${t.stepType} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in Td)throw new RangeError("Duplicate use of step JSON ID "+e);return Td[e]=t,t.prototype.jsonID=e,t}}class gt{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new gt(e,null)}static fail(e){return new gt(null,e)}static fromReplace(e,t,i,r){try{return gt.ok(e.replace(t,i,r))}catch(s){if(s instanceof kc)return gt.fail(s.message);throw s}}}function Jf(n,e,t){let i=[];for(let r=0;r<n.childCount;r++){let s=n.child(r);s.content.size&&(s=s.copy(Jf(s.content,e,s))),s.isInline&&(s=e(s,t,r)),i.push(s)}return z.fromArray(i)}class yr extends Bt{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=e.resolve(this.from),r=i.node(i.sharedDepth(this.to)),s=new j(Jf(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),r),t.openStart,t.openEnd);return gt.fromReplace(e,this.from,this.to,s)}invert(){return new Yn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new yr(t.pos,i.pos,this.mark)}merge(e){return e instanceof yr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yr(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 yr(t.from,t.to,e.markFromJSON(t.mark))}}Bt.jsonID("addMark",yr);class Yn extends Bt{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=new j(Jf(t.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return gt.fromReplace(e,this.from,this.to,i)}invert(){return new yr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new Yn(t.pos,i.pos,this.mark)}merge(e){return e instanceof Yn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Yn(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 Yn(t.from,t.to,e.markFromJSON(t.mark))}}Bt.jsonID("removeMark",Yn);class vr extends Bt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return gt.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return gt.fromReplace(e,this.pos,this.pos+1,new j(z.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let i=this.mark.addToSet(t.marks);if(i.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(i))return new vr(this.pos,t.marks[r]);return new vr(this.pos,this.mark)}}return new is(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new vr(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new vr(t.pos,e.markFromJSON(t.mark))}}Bt.jsonID("addNodeMark",vr);class is extends Bt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return gt.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return gt.fromReplace(e,this.pos,this.pos+1,new j(z.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new vr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new is(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new is(t.pos,e.markFromJSON(t.mark))}}Bt.jsonID("removeNodeMark",is);class St extends Bt{constructor(e,t,i,r=!1){super(),this.from=e,this.to=t,this.slice=i,this.structure=r}apply(e){return this.structure&&mf(e,this.from,this.to)?gt.fail("Structure replace would overwrite content"):gt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Sn([this.from,this.to-this.from,this.slice.size])}invert(e){return new St(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deletedAcross&&i.deletedAcross?null:new St(t.pos,Math.max(t.pos,i.pos),this.slice,this.structure)}merge(e){if(!(e instanceof St)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?j.empty:new j(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new St(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?j.empty:new j(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new St(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};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")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new St(t.from,t.to,j.fromJSON(e,t.slice),!!t.structure)}}Bt.jsonID("replace",St);class xt extends Bt{constructor(e,t,i,r,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=i,this.gapTo=r,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(mf(e,this.from,this.gapFrom)||mf(e,this.gapTo,this.to)))return gt.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return gt.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,t.content);return i?gt.fromReplace(e,this.from,this.to,i):gt.fail("Content does not fit in gap")}getMap(){return new Sn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new xt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return t.deletedAcross&&i.deletedAcross||r<t.pos||s>i.pos?null:new xt(t.pos,i.pos,r,s,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 xt(t.from,t.to,t.gapFrom,t.gapTo,j.fromJSON(e,t.slice),t.insert,!!t.structure)}}Bt.jsonID("replaceAround",xt);function mf(n,e,t){let i=n.resolve(e),r=t-e,s=i.depth;for(;r>0&&s>0&&i.indexAfter(s)==i.node(s).childCount;)s--,r--;if(r>0){let o=i.node(s).maybeChild(i.indexAfter(s));for(;r>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,r--}}return!1}function kD(n,e,t,i){let r=[],s=[],o,l;n.doc.nodesBetween(e,t,(c,h,d)=>{if(!c.isInline)return;let p=c.marks;if(!i.isInSet(p)&&d.type.allowsMarkType(i.type)){let m=Math.max(h,e),g=Math.min(h+c.nodeSize,t),v=i.addToSet(p);for(let w=0;w<p.length;w++)p[w].isInSet(v)||(o&&o.to==m&&o.mark.eq(p[w])?o.to=g:r.push(o=new Yn(m,g,p[w])));l&&l.to==m?l.to=g:s.push(l=new yr(m,g,i))}}),r.forEach(c=>n.step(c)),s.forEach(c=>n.step(c))}function AD(n,e,t,i){let r=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let c=null;if(i instanceof vu){let h=o.marks,d;for(;d=i.isInSet(h);)(c||(c=[])).push(d),h=d.removeFromSet(h)}else i?i.isInSet(o.marks)&&(c=[i]):c=o.marks;if(c&&c.length){let h=Math.min(l+o.nodeSize,t);for(let d=0;d<c.length;d++){let p=c[d],m;for(let g=0;g<r.length;g++){let v=r[g];v.step==s-1&&p.eq(r[g].style)&&(m=v)}m?(m.to=h,m.step=s):r.push({style:p,from:Math.max(l,e),to:h,step:s})}}}),r.forEach(o=>n.step(new Yn(o.from,o.to,o.style)))}function Zf(n,e,t,i=t.contentMatch,r=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<s.childCount;c++){let h=s.child(c),d=l+h.nodeSize,p=i.matchType(h.type);if(!p)o.push(new St(l,d,j.empty));else{i=p;for(let m=0;m<h.marks.length;m++)t.allowsMarkType(h.marks[m].type)||n.step(new Yn(l,d,h.marks[m]));if(r&&h.isText&&t.whitespace!="pre"){let m,g=/\r?\n|\r/g,v;for(;m=g.exec(h.text);)v||(v=new j(z.from(t.schema.text(" ",t.allowedMarks(h.marks))),0,0)),o.push(new St(l+m.index,l+m.index+m[0].length,v))}}l=d}if(!i.validEnd){let c=i.fillBefore(z.empty,!0);n.replace(l,l,new j(c,0,0))}for(let c=o.length-1;c>=0;c--)n.step(o[c])}function MD(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function so(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let i=n.depth;;--i){let r=n.$from.node(i),s=n.$from.index(i),o=n.$to.indexAfter(i);if(i<n.depth&&r.canReplace(s,o,t))return i;if(i==0||r.type.spec.isolating||!MD(r,s,o))break}return null}function OD(n,e,t){let{$from:i,$to:r,depth:s}=e,o=i.before(s+1),l=r.after(s+1),c=o,h=l,d=z.empty,p=0;for(let v=s,w=!1;v>t;v--)w||i.index(v)>0?(w=!0,d=z.from(i.node(v).copy(d)),p++):c--;let m=z.empty,g=0;for(let v=s,w=!1;v>t;v--)w||r.after(v+1)<r.end(v)?(w=!0,m=z.from(r.node(v).copy(m)),g++):h++;n.step(new xt(c,h,o,l,new j(d.append(m),p,g),d.size-p,!0))}function Qf(n,e,t=null,i=n){let r=ID(n,e),s=r&&DD(i,e);return s?r.map(sv).concat({type:e,attrs:t}).concat(s.map(sv)):null}function sv(n){return{type:n,attrs:null}}function ID(n,e){let{parent:t,startIndex:i,endIndex:r}=n,s=t.contentMatchAt(i).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(i,r,o)?s:null}function DD(n,e){let{parent:t,startIndex:i,endIndex:r}=n,s=t.child(i),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let c=(o.length?o[o.length-1]:e).contentMatch;for(let h=i;c&&h<r;h++)c=c.matchType(t.child(h).type);return!c||!c.validEnd?null:o}function _D(n,e,t){let i=z.empty;for(let o=t.length-1;o>=0;o--){if(i.size){let l=t[o].type.contentMatch.matchFragment(i);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=z.from(t[o].type.create(t[o].attrs,i))}let r=e.start,s=e.end;n.step(new xt(r,s,r,s,new j(i,0,0),t.length,!0))}function RD(n,e,t,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let c=typeof r=="function"?r(o):r;if(o.isTextblock&&!o.hasMarkup(i,c)&&ND(n.doc,n.mapping.slice(s).map(l),i)){let h=null;if(i.schema.linebreakReplacement){let g=i.whitespace=="pre",v=!!i.contentMatch.matchType(i.schema.linebreakReplacement);g&&!v?h=!1:!g&&v&&(h=!0)}h===!1&&Nb(n,o,l,s),Zf(n,n.mapping.slice(s).map(l,1),i,void 0,h===null);let d=n.mapping.slice(s),p=d.map(l,1),m=d.map(l+o.nodeSize,1);return n.step(new xt(p,m,p+1,m-1,new j(z.from(i.create(c,null,o.marks)),0,0),1,!0)),h===!0&&Rb(n,o,l,s),!1}})}function Rb(n,e,t,i){e.forEach((r,s)=>{if(r.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(r.text);){let c=n.mapping.slice(i).map(t+1+s+o.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Nb(n,e,t,i){e.forEach((r,s)=>{if(r.type==r.type.schema.linebreakReplacement){let o=n.mapping.slice(i).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(` `))}})}function ND(n,e,t){let i=n.resolve(e),r=i.index();return i.parent.canReplaceWith(r,r+1,t)}function PD(n,e,t,i,r){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(i,null,r||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new xt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new j(z.from(o),0,0),1,!0))}function zi(n,e,t=1,i){let r=n.resolve(e),s=r.depth-t,o=i&&i[i.length-1]||r.parent;if(s<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!o.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let h=r.depth-1,d=t-2;h>s;h--,d--){let p=r.node(h),m=r.index(h);if(p.type.spec.isolating)return!1;let g=p.content.cutByIndex(m,p.childCount),v=i&&i[d+1];v&&(g=g.replaceChild(0,v.type.create(v.attrs)));let w=i&&i[d]||p;if(!p.canReplace(m+1,p.childCount)||!w.type.validContent(g))return!1}let l=r.indexAfter(s),c=i&&i[0];return r.node(s).canReplaceWith(l,l,c?c.type:r.node(s+1).type)}function LD(n,e,t=1,i){let r=n.doc.resolve(e),s=z.empty,o=z.empty;for(let l=r.depth,c=r.depth-t,h=t-1;l>c;l--,h--){s=z.from(r.node(l).copy(s));let d=i&&i[h];o=z.from(d?d.type.create(d.attrs,o):r.node(l).copy(o))}n.step(new St(e,e,new j(s.append(o),t,t),!0))}function Ar(n,e){let t=n.resolve(e),i=t.index();return Pb(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(i,i+1)}function FD(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:i}=n.type.schema;for(let r=0;r<e.childCount;r++){let s=e.child(r),o=s.type==i?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Pb(n,e){return!!(n&&e&&!n.isLeaf&&FD(n,e))}function bu(n,e,t=-1){let i=n.resolve(e);for(let r=i.depth;;r--){let s,o,l=i.index(r);if(r==i.depth?(s=i.nodeBefore,o=i.nodeAfter):t>0?(s=i.node(r+1),l++,o=i.node(r).maybeChild(l)):(s=i.node(r).maybeChild(l-1),o=i.node(r+1)),s&&!s.isTextblock&&Pb(s,o)&&i.node(r).canReplace(l,l+1))return e;if(r==0)break;e=t<0?i.before(r):i.after(r)}}function $D(n,e,t){let i=null,{linebreakReplacement:r}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(r&&o.inlineContent){let d=o.whitespace=="pre",p=!!o.contentMatch.matchType(r);d&&!p?i=!1:!d&&p&&(i=!0)}let l=n.steps.length;if(i===!1){let d=n.doc.resolve(e+t);Nb(n,d.node(),d.before(),l)}o.inlineContent&&Zf(n,e+t-1,o,s.node().contentMatchAt(s.index()),i==null);let c=n.mapping.slice(l),h=c.map(e-t);if(n.step(new St(h,c.map(e+t,-1),j.empty,!0)),i===!0){let d=n.doc.resolve(h);Rb(n,d.node(),d.before(),n.steps.length)}return n}function BD(n,e,t){let i=n.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),t))return e;if(i.parentOffset==0)for(let r=i.depth-1;r>=0;r--){let s=i.index(r);if(i.node(r).canReplaceWith(s,s,t))return i.before(r+1);if(s>0)return null}if(i.parentOffset==i.parent.content.size)for(let r=i.depth-1;r>=0;r--){let s=i.indexAfter(r);if(i.node(r).canReplaceWith(s,s,t))return i.after(r+1);if(s<i.node(r).childCount)return null}return null}function Lb(n,e,t){let i=n.resolve(e);if(!t.content.size)return e;let r=t.content;for(let s=0;s<t.openStart;s++)r=r.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=i.depth;o>=0;o--){let l=o==i.depth?0:i.pos<=(i.start(o+1)+i.end(o+1))/2?-1:1,c=i.index(o)+(l>0?1:0),h=i.node(o),d=!1;if(s==1)d=h.canReplace(c,c,r);else{let p=h.contentMatchAt(c).findWrapping(r.firstChild.type);d=p&&h.canReplaceWith(c,c,p[0])}if(d)return l==0?i.pos:l<0?i.before(o+1):i.after(o+1)}return null}function wu(n,e,t=e,i=j.empty){if(e==t&&!i.size)return null;let r=n.resolve(e),s=n.resolve(t);return Fb(r,s,i)?new St(e,t,i):new zD(r,s,i).fit()}function Fb(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class zD{constructor(e,t,i){this.$from=e,this.$to=t,this.unplaced=i,this.frontier=[],this.placed=z.empty;for(let r=0;r<=e.depth;r++){let s=e.node(r);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=z.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,i=this.$from,r=this.close(e<0?this.$to:i.doc.resolve(e));if(!r)return null;let s=this.placed,o=i.depth,l=r.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let c=new j(s,o,l);return e>-1?new xt(i.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||i.pos!=this.$to.pos?new St(i.pos,r.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<e;i++){let s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=i){e=i;break}t=s.content}for(let t=1;t<=2;t++)for(let i=t==1?e:this.unplaced.openStart;i>=0;i--){let r,s=null;i?(s=kd(this.unplaced.content,i-1).firstChild,r=s.content):r=this.unplaced.content;let o=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:h}=this.frontier[l],d,p=null;if(t==1&&(o?h.matchType(o.type)||(p=h.fillBefore(z.from(o),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:i,frontierDepth:l,parent:s,inject:p};if(t==2&&o&&(d=h.findWrapping(o.type)))return{sliceDepth:i,frontierDepth:l,parent:s,wrap:d};if(s&&h.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:i}=this.unplaced,r=kd(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new j(e,t+1,Math.max(i,r.size+t>=e.size-i?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:i}=this.unplaced,r=kd(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new j(Uo(e,t-1,1),t-1,s?t-1:i)}else this.unplaced=new j(Uo(e,t,1),t,i)}placeNodes({sliceDepth:e,frontierDepth:t,parent:i,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let w=0;w<s.length;w++)this.openFrontierNode(s[w]);let o=this.unplaced,l=i?i.content:o.content,c=o.openStart-e,h=0,d=[],{match:p,type:m}=this.frontier[t];if(r){for(let w=0;w<r.childCount;w++)d.push(r.child(w));p=p.matchFragment(r)}let g=l.size+e-(o.content.size-o.openEnd);for(;h<l.childCount;){let w=l.child(h),S=p.matchType(w.type);if(!S)break;h++,(h>1||c==0||w.content.size)&&(p=S,d.push($b(w.mark(m.allowedMarks(w.marks)),h==1?c:0,h==l.childCount?g:-1)))}let v=h==l.childCount;v||(g=-1),this.placed=qo(this.placed,t,z.from(d)),this.frontier[t].match=p,v&&g<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,S=l;w<g;w++){let E=S.lastChild;this.frontier.push({type:E.type,match:E.contentMatchAt(E.childCount)}),S=E.content}this.unplaced=v?e==0?j.empty:new j(Uo(o.content,e-1,1),e-1,g<0?o.openEnd:e-1):new j(Uo(o.content,e,h),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ad(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:i}=this.$to,r=this.$to.after(i);for(;i>1&&r==this.$to.end(--i);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:i,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Ad(e,t,r,i,s);if(o){for(let l=t-1;l>=0;l--){let{match:c,type:h}=this.frontier[l],d=Ad(e,l,h,c,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:s?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=qo(this.placed,t.depth,t.fit)),e=t.move;for(let i=t.depth+1;i<=e.depth;i++){let r=e.node(i),s=r.type.contentMatch.fillBefore(r.content,!0,e.index(i));this.openFrontierNode(r.type,r.attrs,s)}return e}openFrontierNode(e,t=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=qo(this.placed,this.depth,z.from(e.create(t,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(z.empty,!0);t.childCount&&(this.placed=qo(this.placed,this.frontier.length,t))}}function Uo(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Uo(n.firstChild.content,e-1,t)))}function qo(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(qo(n.lastChild.content,e-1,t)))}function kd(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function $b(n,e,t){if(e<=0)return n;let i=n.content;return e>1&&(i=i.replaceChild(0,$b(i.firstChild,e-1,i.childCount==1?t-1:0))),e>0&&(i=n.type.contentMatch.fillBefore(i).append(i),t<=0&&(i=i.append(n.type.contentMatch.matchFragment(i).fillBefore(z.empty,!0)))),n.copy(i)}function Ad(n,e,t,i,r){let s=n.node(e),o=r?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,o);return l&&!HD(t,s.content,o)?l:null}function HD(n,e,t){for(let i=t;i<e.childCount;i++)if(!n.allowsMarks(e.child(i).marks))return!0;return!1}function VD(n){return n.spec.defining||n.spec.definingForContent}function WD(n,e,t,i){if(!i.size)return n.deleteRange(e,t);let r=n.doc.resolve(e),s=n.doc.resolve(t);if(Fb(r,s,i))return n.step(new St(e,t,i));let o=zb(r,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(r.depth+1);o.unshift(l);for(let m=r.depth,g=r.pos-1;m>0;m--,g--){let v=r.node(m).type.spec;if(v.defining||v.definingAsContext||v.isolating)break;o.indexOf(m)>-1?l=m:r.before(m)==g&&o.splice(1,0,-m)}let c=o.indexOf(l),h=[],d=i.openStart;for(let m=i.content,g=0;;g++){let v=m.firstChild;if(h.push(v),g==i.openStart)break;m=v.content}for(let m=d-1;m>=0;m--){let g=h[m],v=VD(g.type);if(v&&!g.sameMarkup(r.node(Math.abs(l)-1)))d=m;else if(v||!g.type.isTextblock)break}for(let m=i.openStart;m>=0;m--){let g=(m+d+1)%(i.openStart+1),v=h[g];if(v)for(let w=0;w<o.length;w++){let S=o[(w+c)%o.length],E=!0;S<0&&(E=!1,S=-S);let k=r.node(S-1),I=r.index(S-1);if(k.canReplaceWith(I,I,v.type,v.marks))return n.replace(r.before(S),E?s.after(S):t,new j(Bb(i.content,0,i.openStart,g),g,i.openEnd))}}let p=n.steps.length;for(let m=o.length-1;m>=0&&(n.replace(e,t,i),!(n.steps.length>p));m--){let g=o[m];g<0||(e=r.before(g),t=s.after(g))}}function Bb(n,e,t,i,r){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Bb(s.content,e+1,t,i,s)))}if(e>i){let s=r.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(z.empty,!0))}return n}function UD(n,e,t,i){if(!i.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let r=BD(n.doc,e,i.type);r!=null&&(e=t=r)}n.replaceRange(e,t,new j(z.from(i),0,0))}function qD(n,e,t){let i=n.doc.resolve(e),r=n.doc.resolve(t),s=zb(i,r);for(let o=0;o<s.length;o++){let l=s[o],c=o==s.length-1;if(c&&l==0||i.node(l).type.contentMatch.validEnd)return n.delete(i.start(l),r.end(l));if(l>0&&(c||i.node(l-1).canReplace(i.index(l-1),r.indexAfter(l-1))))return n.delete(i.before(l),r.after(l))}for(let o=1;o<=i.depth&&o<=r.depth;o++)if(e-i.start(o)==i.depth-o&&t>i.end(o)&&r.end(o)-t!=r.depth-o&&i.start(o-1)==r.start(o-1)&&i.node(o-1).canReplace(i.index(o-1),r.index(o-1)))return n.delete(i.before(o),t);n.delete(e,t)}function zb(n,e){let t=[],i=Math.min(n.depth,e.depth);for(let r=i;r>=0;r--){let s=n.start(r);if(s<n.pos-(n.depth-r)||e.end(r)>e.pos+(e.depth-r)||n.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(s==e.start(r)||r==n.depth&&r==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==s-1)&&t.push(r)}return t}class qs extends Bt{constructor(e,t,i){super(),this.pos=e,this.attr=t,this.value=i}apply(e){let t=e.nodeAt(this.pos);if(!t)return gt.fail("No node at attribute step's position");let i=Object.create(null);for(let s in t.attrs)i[s]=t.attrs[s];i[this.attr]=this.value;let r=t.type.create(i,null,t.marks);return gt.fromReplace(e,this.pos,this.pos+1,new j(z.from(r),0,t.isLeaf?0:1))}getMap(){return Sn.empty}invert(e){return new qs(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 qs(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 qs(t.pos,t.attr,t.value)}}Bt.jsonID("attr",qs);class va extends Bt{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let i=e.type.create(t,e.content,e.marks);return gt.ok(i)}getMap(){return Sn.empty}invert(e){return new va(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 va(t.attr,t.value)}}Bt.jsonID("docAttr",va);let Ys=class extends Error{};Ys=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Ys.prototype=Object.create(Error.prototype);Ys.prototype.constructor=Ys;Ys.prototype.name="TransformError";class Hb{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ya}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ys(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}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,i=j.empty){let r=wu(this.doc,e,t,i);return r&&this.step(r),this}replaceWith(e,t,i){return this.replace(e,t,new j(z.from(i),0,0))}delete(e,t){return this.replace(e,t,j.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,i){return WD(this,e,t,i),this}replaceRangeWith(e,t,i){return UD(this,e,t,i),this}deleteRange(e,t){return qD(this,e,t),this}lift(e,t){return OD(this,e,t),this}join(e,t=1){return $D(this,e,t),this}wrap(e,t){return _D(this,e,t),this}setBlockType(e,t=e,i,r=null){return RD(this,e,t,i,r),this}setNodeMarkup(e,t,i=null,r){return PD(this,e,t,i,r),this}setNodeAttribute(e,t,i){return this.step(new qs(e,t,i)),this}setDocAttribute(e,t){return this.step(new va(e,t)),this}addNodeMark(e,t){return this.step(new vr(e,t)),this}removeNodeMark(e,t){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(t instanceof He)t.isInSet(i.marks)&&this.step(new is(e,t));else{let r=i.marks,s,o=[];for(;s=t.isInSet(r);)o.push(new is(e,s)),r=s.removeFromSet(r);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,i){return LD(this,e,t,i),this}addMark(e,t,i){return kD(this,e,t,i),this}removeMark(e,t,i){return AD(this,e,t,i),this}clearIncompatible(e,t,i){return Zf(this,e,t,i),this}}const Md=Object.create(null);class oe{constructor(e,t,i){this.$anchor=e,this.$head=t,this.ranges=i||[new Vb(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<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=j.empty){let i=t.content.lastChild,r=null;for(let l=0;l<t.openEnd;l++)r=i,i=i.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:h}=o[l],d=e.mapping.slice(s);e.replaceRange(d.map(c.pos),d.map(h.pos),l?j.empty:t),l==0&&lv(e,s,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let i=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:o,$to:l}=r[s],c=e.mapping.slice(i),h=c.map(o.pos),d=c.map(l.pos);s?e.deleteRange(h,d):(e.replaceRangeWith(h,d,t),lv(e,i,t.isInline?-1:1))}}static findFrom(e,t,i=!1){let r=e.parent.inlineContent?new fe(e):Ps(e.node(0),e.parent,e.pos,e.index(),t,i);if(r)return r;for(let s=e.depth-1;s>=0;s--){let o=t<0?Ps(e.node(0),e.node(s),e.before(s+1),e.index(s),t,i):Ps(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,i);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new xn(e.node(0))}static atStart(e){return Ps(e,e,0,0,1)||new xn(e)}static atEnd(e){return Ps(e,e,e.content.size,e.childCount,-1)||new xn(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=Md[t.type];if(!i)throw new RangeError(`No selection type ${t.type} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in Md)throw new RangeError("Duplicate use of selection JSON ID "+e);return Md[e]=t,t.prototype.jsonID=e,t}getBookmark(){return fe.between(this.$anchor,this.$head).getBookmark()}}oe.prototype.visible=!0;class Vb{constructor(e,t){this.$from=e,this.$to=t}}let ov=!1;function av(n){!ov&&!n.parent.inlineContent&&(ov=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class fe extends oe{constructor(e,t=e){av(e),av(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let i=e.resolve(t.map(this.head));if(!i.parent.inlineContent)return oe.near(i);let r=e.resolve(t.map(this.anchor));return new fe(r.parent.inlineContent?r:i,i)}replace(e,t=j.empty){if(super.replace(e,t),t==j.empty){let i=this.$from.marksAcross(this.$to);i&&e.ensureMarks(i)}}eq(e){return e instanceof fe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Su(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 fe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){let r=e.resolve(t);return new this(r,i==t?r:e.resolve(i))}static between(e,t,i){let r=e.pos-t.pos;if((!i||r)&&(i=r>=0?1:-1),!t.parent.inlineContent){let s=oe.findFrom(t,i,!0)||oe.findFrom(t,-i,!0);if(s)t=s.$head;else return oe.near(t,i)}return e.parent.inlineContent||(r==0?e=t:(e=(oe.findFrom(e,-i,!0)||oe.findFrom(e,i,!0)).$anchor,e.pos<t.pos!=r<0&&(e=t))),new fe(e,t)}}oe.jsonID("text",fe);class Su{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Su(e.map(this.anchor),e.map(this.head))}resolve(e){return fe.between(e.resolve(this.anchor),e.resolve(this.head))}}class ne extends oe{constructor(e){let t=e.nodeAfter,i=e.node(0).resolve(e.pos+t.nodeSize);super(e,i),this.node=t}map(e,t){let{deleted:i,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);return i?oe.near(s):new ne(s)}content(){return new j(z.from(this.node),0,0)}eq(e){return e instanceof ne&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ep(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ne(e.resolve(t.anchor))}static create(e,t){return new ne(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ne.prototype.visible=!1;oe.jsonID("node",ne);class ep{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:i}=e.mapResult(this.anchor);return t?new Su(i,i):new ep(i)}resolve(e){let t=e.resolve(this.anchor),i=t.nodeAfter;return i&&ne.isSelectable(i)?new ne(t):oe.near(t)}}class xn extends oe{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=j.empty){if(t==j.empty){e.delete(0,e.doc.content.size);let i=oe.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new xn(e)}map(e){return new xn(e)}eq(e){return e instanceof xn}getBookmark(){return KD}}oe.jsonID("all",xn);const KD={map(){return this},resolve(n){return new xn(n)}};function Ps(n,e,t,i,r,s=!1){if(e.inlineContent)return fe.create(n,t);for(let o=i-(r>0?0:1);r>0?o<e.childCount:o>=0;o+=r){let l=e.child(o);if(l.isAtom){if(!s&&ne.isSelectable(l))return ne.create(n,t-(r<0?l.nodeSize:0))}else{let c=Ps(n,l,t+r,r<0?l.childCount:0,r,s);if(c)return c}t+=l.nodeSize*r}return null}function lv(n,e,t){let i=n.steps.length-1;if(i<e)return;let r=n.steps[i];if(!(r instanceof St||r instanceof xt))return;let s=n.mapping.maps[i],o;s.forEach((l,c,h,d)=>{o==null&&(o=d)}),n.setSelection(oe.near(n.doc.resolve(o),t))}const cv=1,Hl=2,uv=4;class GD extends Hb{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.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|cv)&~Hl,this.storedMarks=null,this}get selectionSet(){return(this.updated&cv)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Hl,this}ensureMarks(e){return He.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&Hl)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Hl,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let i=this.selection;return t&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||He.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,i){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(i==null&&(i=t),i=i??t,!e)return this.deleteRange(t,i);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=i==t?o.marks():o.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(t,i,r.text(e,s)),this.selection.empty||this.setSelection(oe.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|=uv,this}get scrolledIntoView(){return(this.updated&uv)>0}}function hv(n,e){return!e||!n?n:n.bind(e)}class Ko{constructor(e,t,i){this.name=e,this.init=hv(t.init,i),this.apply=hv(t.apply,i)}}const jD=[new Ko("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ko("selection",{init(n,e){return n.selection||oe.atStart(e.doc)},apply(n){return n.selection}}),new Ko("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,i){return i.selection.$cursor?n.storedMarks:null}}),new Ko("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Od{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=jD.slice(),t&&t.forEach(i=>{if(this.pluginsByKey[i.key])throw new RangeError("Adding different instances of a keyed plugin ("+i.key+")");this.plugins.push(i),this.pluginsByKey[i.key]=i,i.spec.state&&this.fields.push(new Ko(i.key,i.spec.state,i))})}}class Hs{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 i=0;i<this.config.plugins.length;i++)if(i!=t){let r=this.config.plugins[i];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],i=this.applyInner(e),r=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=r?r[o].n:0,h=r?r[o].state:this,d=c<t.length&&l.spec.appendTransaction.call(l,c?t.slice(c):t,h,i);if(d&&i.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!r){r=[];for(let p=0;p<this.config.plugins.length;p++)r.push(p<o?{state:i,n:t.length}:{state:this,n:0})}t.push(d),i=i.applyInner(d),s=!0}r&&(r[o]={state:i,n:t.length})}}if(!s)return{state:i,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Hs(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let s=i[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new GD(this)}static create(e){let t=new Od(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new Hs(t);for(let r=0;r<t.fields.length;r++)i[t.fields[r].name]=t.fields[r].init(e,i);return i}reconfigure(e){let t=new Od(this.schema,e.plugins),i=t.fields,r=new Hs(t);for(let s=0;s<i.length;s++){let o=i[s].name;r[o]=this.hasOwnProperty(o)?this[o]:i[s].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(i=>i.toJSON())),e&&typeof e=="object")for(let i in e){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[i],s=r.spec.state;s&&s.toJSON&&(t[i]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,i){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new Od(e.schema,e.plugins),s=new Hs(r);return r.fields.forEach(o=>{if(o.name=="doc")s.doc=wr.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=oe.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let l in i){let c=i[l],h=c.spec.state;if(c.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=h.fromJSON.call(c,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function Wb(n,e,t){for(let i in n){let r=n[i];r instanceof Function?r=r.bind(e):i=="handleDOMEvents"&&(r=Wb(r,e,{})),t[i]=r}return t}class Ye{constructor(e){this.spec=e,this.props={},e.props&&Wb(e.props,this,this.props),this.key=e.key?e.key.key:Ub("plugin")}getState(e){return e[this.key]}}const Id=Object.create(null);function Ub(n){return n in Id?n+"$"+ ++Id[n]:(Id[n]=0,n+"$")}class tt{constructor(e="key"){this.key=Ub(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ot=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Js=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let gf=null;const Ni=function(n,e,t){let i=gf||(gf=document.createRange());return i.setEnd(n,t??n.nodeValue.length),i.setStart(n,e||0),i},XD=function(){gf=null},rs=function(n,e,t,i){return t&&(dv(n,e,t,i,-1)||dv(n,e,t,i,1))},YD=/^(img|br|input|textarea|hr)$/i;function dv(n,e,t,i,r){for(var s;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Ln(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Da(n)||YD.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ot(n)+(r<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(r<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=r;else return!1;else n=o,e=r<0?Ln(n):0}else return!1}}function Ln(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function JD(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Ln(n)}else if(n.parentNode&&!Da(n))e=Ot(n),n=n.parentNode;else return null}}function ZD(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Da(n))e=Ot(n)+1,n=n.parentNode;else return null}}function QD(n,e,t){for(let i=e==0,r=e==Ln(n);i||r;){if(n==t)return!0;let s=Ot(n);if(n=n.parentNode,!n)return!1;i=i&&s==0,r=r&&s==Ln(n)}}function Da(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const xu=function(n){return n.focusNode&&rs(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function qr(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function e_(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function t_(n,e,t){if(n.caretPositionFromPoint)try{let i=n.caretPositionFromPoint(e,t);if(i)return{node:i.offsetNode,offset:Math.min(Ln(i.offsetNode),i.offset)}}catch{}if(n.caretRangeFromPoint){let i=n.caretRangeFromPoint(e,t);if(i)return{node:i.startContainer,offset:Math.min(Ln(i.startContainer),i.startOffset)}}}const mi=typeof navigator<"u"?navigator:null,fv=typeof document<"u"?document:null,Mr=mi&&mi.userAgent||"",yf=/Edge\/(\d+)/.exec(Mr),qb=/MSIE \d/.exec(Mr),vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Mr),an=!!(qb||vf||yf),Sr=qb?document.documentMode:vf?+vf[1]:yf?+yf[1]:0,Qn=!an&&/gecko\/(\d+)/i.test(Mr);Qn&&+(/Firefox\/(\d+)/.exec(Mr)||[0,0])[1];const bf=!an&&/Chrome\/(\d+)/.exec(Mr),$t=!!bf,Kb=bf?+bf[1]:0,Gt=!an&&!!mi&&/Apple Computer/.test(mi.vendor),Zs=Gt&&(/Mobile\/\w+/.test(Mr)||!!mi&&mi.maxTouchPoints>2),Pn=Zs||(mi?/Mac/.test(mi.platform):!1),n_=mi?/Win/.test(mi.platform):!1,Li=/Android \d/.test(Mr),_a=!!fv&&"webkitFontSmoothing"in fv.documentElement.style,i_=_a?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function r_(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 Oi(n,e){return typeof n=="number"?n:n[e]}function s_(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,i=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*i}}function pv(n,e,t){let i=n.someProp("scrollThreshold")||0,r=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Js(o);continue}let l=o,c=l==s.body,h=c?r_(s):s_(l),d=0,p=0;if(e.top<h.top+Oi(i,"top")?p=-(h.top-e.top+Oi(r,"top")):e.bottom>h.bottom-Oi(i,"bottom")&&(p=e.bottom-e.top>h.bottom-h.top?e.top+Oi(r,"top")-h.top:e.bottom-h.bottom+Oi(r,"bottom")),e.left<h.left+Oi(i,"left")?d=-(h.left-e.left+Oi(r,"left")):e.right>h.right-Oi(i,"right")&&(d=e.right-h.right+Oi(r,"right")),d||p)if(c)s.defaultView.scrollBy(d,p);else{let g=l.scrollLeft,v=l.scrollTop;p&&(l.scrollTop+=p),d&&(l.scrollLeft+=d);let w=l.scrollLeft-g,S=l.scrollTop-v;e={left:e.left-w,top:e.top-S,right:e.right-w,bottom:e.bottom-S}}let m=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(m))break;o=m=="absolute"?o.offsetParent:Js(o)}}function o_(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),i,r;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=t-20){i=l,r=c.top;break}}return{refDOM:i,refTop:r,stack:Gb(n.dom)}}function Gb(n){let e=[],t=n.ownerDocument;for(let i=n;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),n!=t);i=Js(i));return e}function a_({refDOM:n,refTop:e,stack:t}){let i=n?n.getBoundingClientRect().top:0;jb(t,i==0?0:i-e)}function jb(n,e){for(let t=0;t<n.length;t++){let{dom:i,top:r,left:s}=n[t];i.scrollTop!=r+e&&(i.scrollTop=r+e),i.scrollLeft!=s&&(i.scrollLeft=s)}}let Ds=null;function l_(n){if(n.setActive)return n.setActive();if(Ds)return n.focus(Ds);let e=Gb(n);n.focus(Ds==null?{get preventScroll(){return Ds={preventScroll:!0},!0}}:void 0),Ds||(Ds=!1,jb(e,0))}function Xb(n,e){let t,i=2e8,r,s=0,o=e.top,l=e.top,c,h;for(let d=n.firstChild,p=0;d;d=d.nextSibling,p++){let m;if(d.nodeType==1)m=d.getClientRects();else if(d.nodeType==3)m=Ni(d).getClientRects();else continue;for(let g=0;g<m.length;g++){let v=m[g];if(v.top<=o&&v.bottom>=l){o=Math.max(v.bottom,o),l=Math.min(v.top,l);let w=v.left>e.left?v.left-e.left:v.right<e.left?e.left-v.right:0;if(w<i){t=d,i=w,r=w&&t.nodeType==3?{left:v.right<e.left?v.right:v.left,top:e.top}:e,d.nodeType==1&&w&&(s=p+(e.left>=(v.left+v.right)/2?1:0));continue}}else v.top>e.top&&!c&&v.left<=e.left&&v.right>=e.left&&(c=d,h={left:Math.max(v.left,Math.min(v.right,e.left)),top:v.top});!t&&(e.left>=v.right&&e.top>=v.top||e.left>=v.left&&e.top>=v.bottom)&&(s=p+1)}}return!t&&c&&(t=c,r=h,i=0),t&&t.nodeType==3?c_(t,r):!t||i&&t.nodeType==1?{node:n,offset:s}:Xb(t,r)}function c_(n,e){let t=n.nodeValue.length,i=document.createRange();for(let r=0;r<t;r++){i.setEnd(n,r+1),i.setStart(n,r);let s=sr(i,1);if(s.top!=s.bottom&&tp(e,s))return{node:n,offset:r+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function tp(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function u_(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function h_(n,e,t){let{node:i,offset:r}=Xb(e,t),s=-1;if(i.nodeType==1&&!i.firstChild){let o=i.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(i,r,s)}function d_(n,e,t,i){let r=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>i.left||c.top>i.top?r=l.posBefore:(!o&&c.right<i.left||c.bottom<i.top)&&(r=l.posAfter),o=!0),!l.contentDOM&&r<0&&!l.node.isText))return(l.node.isBlock?i.top<(c.top+c.bottom)/2:i.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return r>-1?r:n.docView.posFromDOM(e,t,-1)}function Yb(n,e,t){let i=n.childNodes.length;if(i&&t.top<t.bottom)for(let r=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-t.top)/(t.bottom-t.top))-2)),s=r;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let h=l[c];if(tp(e,h))return Yb(o,e,h)}}if((s=(s+1)%i)==r)break}return n}function f_(n,e){let t=n.dom.ownerDocument,i,r=0,s=t_(t,e.left,e.top);s&&({node:i,offset:r}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let h=n.dom.getBoundingClientRect();if(!tp(e,h)||(o=Yb(n.dom,e,h),!o))return null}if(Gt)for(let h=o;i&&h;h=Js(h))h.draggable&&(i=void 0);if(o=u_(o,e),i){if(Qn&&i.nodeType==1&&(r=Math.min(r,i.childNodes.length),r<i.childNodes.length)){let d=i.childNodes[r],p;d.nodeName=="IMG"&&(p=d.getBoundingClientRect()).right<=e.left&&p.bottom>e.top&&r++}let h;_a&&r&&i.nodeType==1&&(h=i.childNodes[r-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&r--,i==n.dom&&r==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(r==0||i.nodeType!=1||i.childNodes[r-1].nodeName!="BR")&&(l=d_(n,i,r,e))}l==null&&(l=h_(n,o,e));let c=n.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function mv(n){return n.top<n.bottom||n.left<n.right}function sr(n,e){let t=n.getClientRects();if(t.length){let i=t[e<0?0:t.length-1];if(mv(i))return i}return Array.prototype.find.call(t,mv)||n.getBoundingClientRect()}const p_=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Jb(n,e,t){let{node:i,offset:r,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=_a||Qn;if(i.nodeType==3)if(o&&(p_.test(i.nodeValue)||(t<0?!r:r==i.nodeValue.length))){let c=sr(Ni(i,r,r),t);if(Qn&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let h=sr(Ni(i,r-1,r-1),-1);if(h.top==c.top){let d=sr(Ni(i,r,r+1),-1);if(d.top!=c.top)return No(d,d.left<h.left)}}return c}else{let c=r,h=r,d=t<0?1:-1;return t<0&&!r?(h++,d=-1):t>=0&&r==i.nodeValue.length?(c--,d=1):t<0?c--:h++,No(sr(Ni(i,c,h),d),d<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&r&&(t<0||r==Ln(i))){let c=i.childNodes[r-1];if(c.nodeType==1)return Dd(c.getBoundingClientRect(),!1)}if(s==null&&r<Ln(i)){let c=i.childNodes[r];if(c.nodeType==1)return Dd(c.getBoundingClientRect(),!0)}return Dd(i.getBoundingClientRect(),t>=0)}if(s==null&&r&&(t<0||r==Ln(i))){let c=i.childNodes[r-1],h=c.nodeType==3?Ni(c,Ln(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(h)return No(sr(h,1),!1)}if(s==null&&r<Ln(i)){let c=i.childNodes[r];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let h=c?c.nodeType==3?Ni(c,0,o?0:1):c.nodeType==1?c:null:null;if(h)return No(sr(h,-1),!0)}return No(sr(i.nodeType==3?Ni(i):i,-t),t>=0)}function No(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 Dd(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 Zb(n,e,t){let i=n.state,r=n.root.activeElement;i!=e&&n.updateState(e),r!=n.dom&&n.focus();try{return t()}finally{i!=e&&n.updateState(i),r!=n.dom&&r&&r.focus()}}function m_(n,e,t){let i=e.selection,r=t=="up"?i.$from:i.$to;return Zb(n,e,()=>{let{node:s}=n.docView.domFromPos(r.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Jb(n,r.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=Ni(l,0,l.nodeValue.length).getClientRects();else continue;for(let h=0;h<c.length;h++){let d=c[h];if(d.bottom>d.top+1&&(t=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const g_=/[\u0590-\u08ac]/;function y_(n,e,t){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,s=!r,o=r==i.parent.content.size,l=n.domSelection();return l?!g_.test(i.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Zb(n,e,()=>{let{focusNode:c,focusOffset:h,anchorNode:d,anchorOffset:p}=n.domSelectionRange(),m=l.caretBidiLevel;l.modify("move",t,"character");let g=i.depth?n.docView.domAfterPos(i.before()):n.dom,{focusNode:v,focusOffset:w}=n.domSelectionRange(),S=v&&!g.contains(v.nodeType==1?v:v.parentNode)||c==v&&h==w;try{l.collapse(d,p),c&&(c!=d||h!=p)&&l.extend&&l.extend(c,h)}catch{}return m!=null&&(l.caretBidiLevel=m),S}):i.pos==i.start()||i.pos==i.end()}let gv=null,yv=null,vv=!1;function v_(n,e,t){return gv==e&&yv==t?vv:(gv=e,yv=t,vv=t=="up"||t=="down"?m_(n,e,t):y_(n,e,t))}const Fn=0,bv=1,Gr=2,gi=3;class Ra{constructor(e,t,i,r){this.parent=e,this.children=t,this.dom=i,this.contentDOM=r,this.dirty=Fn,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,i){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,i=this.posAtStart;;t++){let r=this.children[t];if(r==e)return i;i+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,i){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(i<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>Ot(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!1;break}if(s.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!0;break}if(s.nextSibling)break}}return r??i>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let i=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),o;if(s&&(!t||s.node))if(i&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))i=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let i=t;i;i=i.parent)if(i==this)return t}posFromDOM(e,t,i){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,i)}return-1}descAt(e){for(let t=0,i=0;t<this.children.length;t++){let r=this.children[t],s=i+r.size;if(i==e&&s!=i){for(;!r.border&&r.children.length;)for(let o=0;o<r.children.length;o++){let l=r.children[o];if(l.size){r=l;break}}return r}if(e<s)return r.descAt(e-i-r.border);i=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,r=0;for(let s=0;i<this.children.length;i++){let o=this.children[i],l=s+o.size;if(l>e||o instanceof ew){r=e-s;break}s=l}if(r)return this.children[i].domFromPos(r-this.children[i].border,t);for(let s;i&&!(s=this.children[i-1]).size&&s instanceof Qb&&s.side>=0;i--);if(t<=0){let s,o=!0;for(;s=i?this.children[i-1]:null,!(!s||s.dom.parentNode==this.contentDOM);i--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Ot(s.dom)+1:0}}else{let s,o=!0;for(;s=i<this.children.length?this.children[i]:null,!(!s||s.dom.parentNode==this.contentDOM);i++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Ot(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,i=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let o=i,l=0;;l++){let c=this.children[l],h=o+c.size;if(r==-1&&e<=h){let d=o+c.border;if(e>=d&&t<=h-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,t,d);e=o;for(let p=l;p>0;p--){let m=this.children[p-1];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(1)){r=Ot(m.dom)+1;break}e-=m.size}r==-1&&(r=0)}if(r>-1&&(h>t||l==this.children.length-1)){t=h;for(let d=l+1;d<this.children.length;d++){let p=this.children[d];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(-1)){s=Ot(p.dom);break}t+=p.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=h}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:i}=this.domFromPos(e,0);if(t.nodeType!=1||i==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[i]}setSelection(e,t,i,r=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let g=0,v=0;g<this.children.length;g++){let w=this.children[g],S=v+w.size;if(s>v&&o<S)return w.setSelection(e-v-w.border,t-v-w.border,i,r);v=S}let l=this.domFromPos(e,e?-1:1),c=t==e?l:this.domFromPos(t,t?-1:1),h=i.root.getSelection(),d=i.domSelectionRange(),p=!1;if((Qn||Gt)&&e==t){let{node:g,offset:v}=l;if(g.nodeType==3){if(p=!!(v&&g.nodeValue[v-1]==` `),p&&v==g.nodeValue.length)for(let w=g,S;w;w=w.parentNode){if(S=w.nextSibling){S.nodeName=="BR"&&(l=c={node:S.parentNode,offset:Ot(S)+1});break}let E=w.pmViewDesc;if(E&&E.node&&E.node.isBlock)break}}else{let w=g.childNodes[v-1];p=w&&(w.nodeName=="BR"||w.contentEditable=="false")}}if(Qn&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let g=d.focusNode.childNodes[d.focusOffset];g&&g.contentEditable=="false"&&(r=!0)}if(!(r||p&&Gt)&&rs(l.node,l.offset,d.anchorNode,d.anchorOffset)&&rs(c.node,c.offset,d.focusNode,d.focusOffset))return;let m=!1;if((h.extend||e==t)&&!p){h.collapse(l.node,l.offset);try{e!=t&&h.extend(c.node,c.offset),m=!0}catch{}}if(!m){if(e>t){let v=l;l=c,c=v}let g=document.createRange();g.setEnd(c.node,c.offset),g.setStart(l.node,l.offset),h.removeAllRanges(),h.addRange(g)}}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 i=0,r=0;r<this.children.length;r++){let s=this.children[r],o=i+s.size;if(i==o?e<=o&&t>=i:e<o&&t>i){let l=i+s.border,c=o-s.border;if(e>=l&&t<=c){this.dirty=e==i||t==o?Gr:bv,e==l&&t==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=gi:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Gr:gi}i=o}this.dirty=Gr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=e==1?Gr:bv;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Qb extends Ra{constructor(e,t,i,r){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(i,()=>{if(!s)return r;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Fn&&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 b_ extends Ra{constructor(e,t,i,r){super(e,[],t,null),this.textDOM=i,this.text=r}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 ss extends Ra{constructor(e,t,i,r,s){super(e,[],i,r),this.mark=t,this.spec=s}static create(e,t,i,r){let s=r.nodeViews[t.type.name],o=s&&s(t,r,i);return(!o||!o.dom)&&(o=ls.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new ss(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&gi||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=gi&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Fn){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=Fn}}slice(e,t,i){let r=ss.create(this.parent,this.mark,!0,i),s=this.children,o=this.size;t<o&&(s=Sf(s,t,o,i)),e>0&&(s=Sf(s,0,e,i));for(let l=0;l<s.length;l++)s[l].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class xr extends Ra{constructor(e,t,i,r,s,o,l,c,h){super(e,[],s,o),this.node=t,this.outerDeco=i,this.innerDeco=r,this.nodeDOM=l}static create(e,t,i,r,s,o){let l=s.nodeViews[t.type.name],c,h=l&&l(t,s,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},i,r),d=h&&h.dom,p=h&&h.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:p}=ls.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let m=d;return d=iw(d,i,t),h?c=new w_(e,t,i,r,d,p||null,m,h,s,o+1):t.isText?new Cu(e,t,i,r,d,m,s):new xr(e,t,i,r,d,p||null,m,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let i=this.children[t];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>z.empty)}return e}matchesNode(e,t,i){return this.dirty==Fn&&e.eq(this.node)&&Ic(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,c=new x_(this,o&&o.node,e);T_(this.node,this.innerDeco,(h,d,p)=>{h.spec.marks?c.syncToMarks(h.spec.marks,i,e):h.type.side>=0&&!p&&c.syncToMarks(d==this.node.childCount?He.none:this.node.child(d).marks,i,e),c.placeWidget(h,e,r)},(h,d,p,m)=>{c.syncToMarks(h.marks,i,e);let g;c.findNodeMatch(h,d,p,m)||l&&e.state.selection.from>r&&e.state.selection.to<r+h.nodeSize&&(g=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(h,d,p,g,e)||c.updateNextNode(h,d,p,e,m,r)||c.addNode(h,d,p,e,r),r+=h.nodeSize}),c.syncToMarks([],i,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Gr)&&(o&&this.protectLocalComposition(e,o),tw(this.contentDOM,this.children,e),Zs&&k_(this.dom))}localCompositionInfo(e,t){let{from:i,to:r}=e.state.selection;if(!(e.state.selection instanceof fe)||i<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=A_(this.node.content,o,i-t,r-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:r}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new b_(this,s,t,r);e.input.compositionNodes.push(o),this.children=Sf(this.children,i,i+r.length,e,o)}update(e,t,i,r){return this.dirty==gi||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,i,r),!0)}updateInner(e,t,i,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Fn}updateOuterDeco(e){if(Ic(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=nw(this.dom,this.nodeDOM,wf(this.outerDeco,this.node,t),wf(e,this.node,t)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function wv(n,e,t,i,r){iw(i,e,n);let s=new xr(void 0,n,e,t,i,i,i,r,0);return s.contentDOM&&s.updateChildren(r,0),s}class Cu extends xr{constructor(e,t,i,r,s,o,l){super(e,t,i,r,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,i,r){return this.dirty==gi||this.dirty!=Fn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Fn||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Fn,!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,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,i){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new Cu(this.parent,r,this.outerDeco,this.innerDeco,s,s,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=gi)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ew extends Ra{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Fn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class w_ extends xr{constructor(e,t,i,r,s,o,l,c,h,d){super(e,t,i,r,s,o,l,h,d),this.spec=c}update(e,t,i,r){if(this.dirty==gi)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,i);return s&&this.updateInner(e,t,i,r),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,i,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,r){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,r)}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 tw(n,e,t){let i=n.firstChild,r=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=i;)i=Sv(i),r=!0;i=i.nextSibling}else r=!0,n.insertBefore(l,i);if(o instanceof ss){let c=i?i.previousSibling:n.lastChild;tw(o.contentDOM,o.children,t),i=c?c.nextSibling:n.firstChild}}for(;i;)i=Sv(i),r=!0;r&&t.trackWrites==n&&(t.trackWrites=null)}const aa=function(n){n&&(this.nodeName=n)};aa.prototype=Object.create(null);const jr=[new aa];function wf(n,e,t){if(n.length==0)return jr;let i=t?jr[0]:new aa,r=[i];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&r.push(i=new aa(o.nodeName));for(let l in o){let c=o[l];c!=null&&(t&&r.length==1&&r.push(i=new aa(e.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+c:l=="style"?i.style=(i.style?i.style+";":"")+c:l!="nodeName"&&(i[l]=c))}}}return r}function nw(n,e,t,i){if(t==jr&&i==jr)return e;let r=e;for(let s=0;s<i.length;s++){let o=i[s],l=t[s];if(s){let c;l&&l.nodeName==o.nodeName&&r!=n&&(c=r.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(r),l=jr[0]),r=c}S_(r,l||jr[0],o)}return r}function S_(n,e,t){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in t)&&n.removeAttribute(i);for(let i in t)i!="class"&&i!="style"&&i!="nodeName"&&t[i]!=e[i]&&n.setAttribute(i,t[i]);if(e.class!=t.class){let i=e.class?e.class.split(" ").filter(Boolean):[],r=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.remove(i[s]);for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.add(r[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=i.exec(e.style);)n.style.removeProperty(r[1])}t.style&&(n.style.cssText+=t.style)}}function iw(n,e,t){return nw(n,n,jr,wf(e,t,n.nodeType!=1))}function Ic(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Sv(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class x_{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=C_(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i){let r=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;r<o&&(r==s-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&e[r].type.spec.spanning!==!1;)r++;for(;r<s;)this.destroyRest(),this.top.dirty=Fn,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let h=this.top.children[c];if(h.matchesMark(e[s])&&!this.isLocked(h.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=ss.create(this.top,e[s],t,i);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,i,r){let s=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,i))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let h=this.top.children[l];if(h.matchesNode(e,t,i)&&!this.preMatch.matched.has(h)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,i,r,s){let o=this.top.children[r];return o.dirty==gi&&o.dom==o.contentDOM&&(o.dirty=Gr),o.update(e,t,i,s)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let i=e.pmViewDesc;if(i){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==i)return r}return-1}e=t}}updateNextNode(e,t,i,r,s,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof xr){let h=this.preMatch.matched.get(c);if(h!=null&&h!=s)return!1;let d=c.dom,p,m=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=gi&&Ic(t,c.outerDeco));if(!m&&c.update(e,t,i,r))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!m&&(p=this.recreateWrapper(c,e,t,i,r,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=p,p.contentDOM&&(p.dirty=Gr,p.updateChildren(r,o+1),p.dirty=Fn),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,r,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ic(i,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=xr.create(this.top,t,i,r,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,t,i,r,s){let o=xr.create(this.top,e,t,i,r,s);o.contentDOM&&o.updateChildren(r,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let s=new Qb(this.top,e,t,i);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ss;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Cu)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Gt||$t)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let r=new ew(this.top,[],i,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function C_(n,e){let t=e,i=t.children.length,r=n.childCount,s=new Map,o=[];e:for(;r>0;){let l;for(;;)if(i){let h=t.children[i-1];if(h instanceof ss)t=h,i=h.children.length;else{l=h,i--;break}}else{if(t==e)break e;i=t.parent.children.indexOf(t),t=t.parent}let c=l.node;if(c){if(c!=n.child(r-1))break;--r,s.set(l,r),o.push(l)}}return{index:r,matched:s,matches:o.reverse()}}function E_(n,e){return n.type.side-e.type.side}function T_(n,e,t,i){let r=e.locals(n),s=0;if(r.length==0){for(let h=0;h<n.childCount;h++){let d=n.child(h);i(d,r,e.forChild(s,d),h),s+=d.nodeSize}return}let o=0,l=[],c=null;for(let h=0;;){let d,p;for(;o<r.length&&r[o].to==s;){let S=r[o++];S.widget&&(d?(p||(p=[d])).push(S):d=S)}if(d)if(p){p.sort(E_);for(let S=0;S<p.length;S++)t(p[S],h,!!c)}else t(d,h,!!c);let m,g;if(c)g=-1,m=c,c=null;else if(h<n.childCount)g=h,m=n.child(h++);else break;for(let S=0;S<l.length;S++)l[S].to<=s&&l.splice(S--,1);for(;o<r.length&&r[o].from<=s&&r[o].to>s;)l.push(r[o++]);let v=s+m.nodeSize;if(m.isText){let S=v;o<r.length&&r[o].from<S&&(S=r[o].from);for(let E=0;E<l.length;E++)l[E].to<S&&(S=l[E].to);S<v&&(c=m.cut(S-s),m=m.cut(0,S-s),v=S,g=-1)}else for(;o<r.length&&r[o].to<v;)o++;let w=m.isInline&&!m.isLeaf?l.filter(S=>!S.inline):l.slice();i(m,w,e.forChild(s,m),g),s=v}}function k_(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 A_(n,e,t,i){for(let r=0,s=0;r<n.childCount&&s<=i;){let o=n.child(r++),l=s;if(s+=o.nodeSize,!o.isText)continue;let c=o.text;for(;r<n.childCount;){let h=n.child(r++);if(s+=h.nodeSize,!h.isText)break;c+=h.text}if(s>=t){if(s>=i&&c.slice(i-e.length-l,i-l)==e)return i-e.length;let h=l<i?c.lastIndexOf(e,i-l-1):-1;if(h>=0&&h+e.length+l>=t)return l+h;if(t==i&&c.length>=i+e.length-l&&c.slice(i-l,i-l+e.length)==e)return i}}return-1}function Sf(n,e,t,i,r){let s=[];for(let o=0,l=0;o<n.length;o++){let c=n[o],h=l,d=l+=c.size;h>=t||d<=e?s.push(c):(h<e&&s.push(c.slice(0,e-h,i)),r&&(s.push(r),r=void 0),d>t&&s.push(c.slice(t-h,c.size,i)))}return s}function np(n,e=null){let t=n.domSelectionRange(),i=n.state.doc;if(!t.focusNode)return null;let r=n.docView.nearestDesc(t.focusNode),s=r&&r.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=i.resolve(o),c,h;if(xu(t)){for(c=o;r&&!r.node;)r=r.parent;let p=r.node;if(r&&p.isAtom&&ne.isSelectable(p)&&r.parent&&!(p.isInline&&QD(t.focusNode,t.focusOffset,r.dom))){let m=r.posBefore;h=new ne(o==m?l:i.resolve(m))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=o,m=o;for(let g=0;g<t.rangeCount;g++){let v=t.getRangeAt(g);p=Math.min(p,n.docView.posFromDOM(v.startContainer,v.startOffset,1)),m=Math.max(m,n.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(p<0)return null;[c,o]=m==n.state.selection.anchor?[m,p]:[p,m],l=i.resolve(o)}else c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null}let d=i.resolve(c);if(!h){let p=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;h=ip(n,d,l,p)}return h}function rw(n){return n.editable?n.hasFocus():ow(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Hi(n,e=!1){let t=n.state.selection;if(sw(n,t),!!rw(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&$t){let i=n.domSelectionRange(),r=n.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&rs(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)O_(n);else{let{anchor:i,head:r}=t,s,o;xv&&!(t instanceof fe)&&(t.$from.parent.inlineContent||(s=Cv(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Cv(n,t.to))),n.docView.setSelection(i,r,n,e),xv&&(s&&Ev(s),o&&Ev(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&M_(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const xv=Gt||$t&&Kb<63;function Cv(n,e){let{node:t,offset:i}=n.docView.domFromPos(e,0),r=i<t.childNodes.length?t.childNodes[i]:null,s=i?t.childNodes[i-1]:null;if(Gt&&r&&r.contentEditable=="false")return _d(r);if((!r||r.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(r)return _d(r);if(s)return _d(s)}}function _d(n){return n.contentEditable="true",Gt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ev(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function M_(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),i=t.anchorNode,r=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=i||t.anchorOffset!=r)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!rw(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function O_(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let i=n.cursorWrapper.dom,r=i.nodeName=="IMG";r?t.setStart(i.parentNode,Ot(i)+1):t.setStart(i,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!r&&!n.state.selection.visible&&an&&Sr<=11&&(i.disabled=!0,i.disabled=!1)}function sw(n,e){if(e instanceof ne){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Tv(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Tv(n)}function Tv(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ip(n,e,t,i){return n.someProp("createSelectionBetween",r=>r(n,e,t))||fe.between(e,t,i)}function kv(n){return n.editable&&!n.hasFocus()?!1:ow(n)}function ow(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function I_(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return rs(e.node,e.offset,t.anchorNode,t.anchorOffset)}function xf(n,e){let{$anchor:t,$head:i}=n.selection,r=e>0?t.max(i):t.min(i),s=r.parent.inlineContent?r.depth?n.doc.resolve(e>0?r.after():r.before()):null:r;return s&&oe.findFrom(s,e)}function lr(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Av(n,e,t){let i=n.state.selection;if(i instanceof fe)if(t.indexOf("s")>-1){let{$head:r}=i,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(r.pos+s.nodeSize*(e<0?-1:1));return lr(n,new fe(i.$anchor,o))}else if(i.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let r=xf(n.state,e);return r&&r instanceof ne?lr(n,r):!1}else if(!(Pn&&t.indexOf("m")>-1)){let r=i.$head,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?r.pos-s.nodeSize:r.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?ne.isSelectable(s)?lr(n,new ne(e<0?n.state.doc.resolve(r.pos-s.nodeSize):r)):_a?lr(n,new fe(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(i instanceof ne&&i.node.isInline)return lr(n,new fe(e>0?i.$to:i.$from));{let r=xf(n.state,e);return r?lr(n,r):!1}}}function Dc(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function la(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function _s(n,e){return e<0?D_(n):__(n)}function D_(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let r,s,o=!1;for(Qn&&t.nodeType==1&&i<Dc(t)&&la(t.childNodes[i],-1)&&(o=!0);;)if(i>0){if(t.nodeType!=1)break;{let l=t.childNodes[i-1];if(la(l,-1))r=t,s=--i;else if(l.nodeType==3)t=l,i=t.nodeValue.length;else break}}else{if(aw(t))break;{let l=t.previousSibling;for(;l&&la(l,-1);)r=t.parentNode,s=Ot(l),l=l.previousSibling;if(l)t=l,i=Dc(t);else{if(t=t.parentNode,t==n.dom)break;i=0}}}o?Cf(n,t,i):r&&Cf(n,r,s)}function __(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let r=Dc(t),s,o;for(;;)if(i<r){if(t.nodeType!=1)break;let l=t.childNodes[i];if(la(l,1))s=t,o=++i;else break}else{if(aw(t))break;{let l=t.nextSibling;for(;l&&la(l,1);)s=l.parentNode,o=Ot(l)+1,l=l.nextSibling;if(l)t=l,i=0,r=Dc(t);else{if(t=t.parentNode,t==n.dom)break;i=r=0}}}s&&Cf(n,s,o)}function aw(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function R_(n,e){for(;n&&e==n.childNodes.length&&!Da(n);)e=Ot(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function N_(n,e){for(;n&&!e&&!Da(n);)e=Ot(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Cf(n,e,t){if(e.nodeType!=3){let s,o;(o=R_(e,t))?(e=o,t=0):(s=N_(e,t))&&(e=s,t=s.nodeValue.length)}let i=n.domSelection();if(!i)return;if(xu(i)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),i.removeAllRanges(),i.addRange(s)}else i.extend&&i.extend(e,t);n.domObserver.setCurSelection();let{state:r}=n;setTimeout(()=>{n.state==r&&Hi(n)},50)}function Mv(n,e){let t=n.state.doc.resolve(e);if(!($t||n_)&&t.parent.inlineContent){let r=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(s.left-r.left)>1)return s.left<r.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(s.left-r.left)>1)return s.left>r.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Ov(n,e,t){let i=n.state.selection;if(i instanceof fe&&!i.empty||t.indexOf("s")>-1||Pn&&t.indexOf("m")>-1)return!1;let{$from:r,$to:s}=i;if(!r.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=xf(n.state,e);if(o&&o instanceof ne)return lr(n,o)}if(!r.parent.inlineContent){let o=e<0?r:s,l=i instanceof xn?oe.near(o,e):oe.findFrom(o,e);return l?lr(n,l):!1}return!1}function Iv(n,e){if(!(n.state.selection instanceof fe))return!0;let{$head:t,$anchor:i,empty:r}=n.state.selection;if(!t.sameParent(i))return!0;if(!r)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function Dv(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function P_(n){if(!Gt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;Dv(n,i,"true"),setTimeout(()=>Dv(n,i,"false"),20)}return!1}function L_(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function F_(n,e){let t=e.keyCode,i=L_(e);if(t==8||Pn&&t==72&&i=="c")return Iv(n,-1)||_s(n,-1);if(t==46&&!e.shiftKey||Pn&&t==68&&i=="c")return Iv(n,1)||_s(n,1);if(t==13||t==27)return!0;if(t==37||Pn&&t==66&&i=="c"){let r=t==37?Mv(n,n.state.selection.from)=="ltr"?-1:1:-1;return Av(n,r,i)||_s(n,r)}else if(t==39||Pn&&t==70&&i=="c"){let r=t==39?Mv(n,n.state.selection.from)=="ltr"?1:-1:1;return Av(n,r,i)||_s(n,r)}else{if(t==38||Pn&&t==80&&i=="c")return Ov(n,-1,i)||_s(n,-1);if(t==40||Pn&&t==78&&i=="c")return P_(n)||Ov(n,1,i)||_s(n,1);if(i==(Pn?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function rp(n,e){n.someProp("transformCopied",g=>{e=g(e,n)});let t=[],{content:i,openStart:r,openEnd:s}=e;for(;r>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1;){r--,s--;let g=i.firstChild;t.push(g.type.name,g.attrs!=g.type.defaultAttrs?g.attrs:null),i=g.content}let o=n.someProp("clipboardSerializer")||ls.fromSchema(n.state.schema),l=fw(),c=l.createElement("div");c.appendChild(o.serializeFragment(i,{document:l}));let h=c.firstChild,d,p=0;for(;h&&h.nodeType==1&&(d=dw[h.nodeName.toLowerCase()]);){for(let g=d.length-1;g>=0;g--){let v=l.createElement(d[g]);for(;c.firstChild;)v.appendChild(c.firstChild);c.appendChild(v),p++}h=c.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${r} ${s}${p?` -${p}`:""} ${JSON.stringify(t)}`);let m=n.someProp("clipboardTextSerializer",g=>g(e,n))||e.content.textBetween(0,e.content.size,` `);return{dom:c,text:m,slice:e}}function lw(n,e,t,i,r){let s=r.parent.type.spec.code,o,l;if(!t&&!e)return null;let c=e&&(i||s||!t);if(c){if(n.someProp("transformPastedText",m=>{e=m(e,s||i,n)}),s)return e?new j(z.from(n.state.schema.text(e.replace(/\r\n?/g,` `))),0,0):j.empty;let p=n.someProp("clipboardTextParser",m=>m(e,r,i,n));if(p)l=p;else{let m=r.marks(),{schema:g}=n.state,v=ls.fromSchema(g);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let S=o.appendChild(document.createElement("p"));w&&S.appendChild(v.serializeNode(g.text(w,m)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),o=H_(t),_a&&V_(o);let h=o&&o.querySelector("[data-pm-slice]"),d=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let p=+d[3];p>0;p--){let m=o.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;o=m}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||sa.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:r,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!$_.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=W_(_v(l,+d[1],+d[2]),d[4]);else if(l=j.maxOpen(B_(l.content,r),!0),l.openStart||l.openEnd){let p=0,m=0;for(let g=l.content.firstChild;p<l.openStart&&!g.type.spec.isolating;p++,g=g.firstChild);for(let g=l.content.lastChild;m<l.openEnd&&!g.type.spec.isolating;m++,g=g.lastChild);l=_v(l,p,m)}return n.someProp("transformPasted",p=>{l=p(l,n)}),l}const $_=/^(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 B_(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let c=r.findWrapping(l.type),h;if(!c)return o=null;if(h=o.length&&s.length&&uw(c,s,l,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=hw(o[o.length-1],s.length));let d=cw(l,c);o.push(d),r=r.matchType(d.type),s=c}}),o)return z.from(o)}return n}function cw(n,e,t=0){for(let i=e.length-1;i>=t;i--)n=e[i].create(null,z.from(n));return n}function uw(n,e,t,i,r){if(r<n.length&&r<e.length&&n[r]==e[r]){let s=uw(n,e,t,i.lastChild,r+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(r==n.length-1?t.type:n[r+1]))return i.copy(i.content.append(z.from(cw(t,n,r+1))))}}function hw(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,hw(n.lastChild,e-1)),i=n.contentMatchAt(n.childCount).fillBefore(z.empty,!0);return n.copy(t.append(i))}function Ef(n,e,t,i,r,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),r<i-1&&(l=Ef(l,e,t,i,r+1,s)),r>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=r).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(z.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function _v(n,e,t){return e<n.openStart&&(n=new j(Ef(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new j(Ef(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const dw={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Rv=null;function fw(){return Rv||(Rv=document.implementation.createHTMLDocument("title"))}let Rd=null;function z_(n){let e=window.trustedTypes;return e?(Rd||(Rd=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Rd.createHTML(n)):n}function H_(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=fw().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&dw[i[1].toLowerCase()])&&(n=r.map(s=>"<"+s+">").join("")+n+r.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=z_(n),r)for(let s=0;s<r.length;s++)t=t.querySelector(r[s])||t;return t}function V_(n){let e=n.querySelectorAll($t?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent==" "&&i.parentNode&&i.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),i)}}function W_(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return n}let{content:r,openStart:s,openEnd:o}=n;for(let l=i.length-2;l>=0;l-=2){let c=t.nodes[i[l]];if(!c||c.hasRequiredAttrs())break;r=z.from(c.create(i[l+1],r)),s++,o++}return new j(r,s,o)}const jt={},Xt={},U_={touchstart:!0,touchmove:!0};class q_{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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function K_(n){for(let e in jt){let t=jt[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=i=>{j_(n,i)&&!sp(n,i)&&(n.editable||!(i.type in Xt))&&t(n,i)},U_[e]?{passive:!0}:void 0)}Gt&&n.dom.addEventListener("input",()=>null),Tf(n)}function br(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function G_(n){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 Tf(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=i=>sp(n,i))})}function sp(n,e){return n.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(n,e)||e.defaultPrevented:!1})}function j_(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 X_(n,e){!sp(n,e)&&jt[e.type]&&(n.editable||!(e.type in Xt))&&jt[e.type](n,e)}Xt.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!mw(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Li&&$t&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Zs&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();n.input.lastIOSEnter=i,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==i&&(n.someProp("handleKeyDown",r=>r(n,qr(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",i=>i(n,t))||F_(n,t)?t.preventDefault():br(n,"key")};Xt.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Xt.keypress=(n,e)=>{let t=e;if(mw(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Pn&&t.metaKey)return;if(n.someProp("handleKeyPress",r=>r(n,t))){t.preventDefault();return}let i=n.state.selection;if(!(i instanceof fe)||!i.$from.sameParent(i.$to)){let r=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(r).scrollIntoView();!/[\r\n]/.test(r)&&!n.someProp("handleTextInput",o=>o(n,i.$from.pos,i.$to.pos,r,s))&&n.dispatch(s()),t.preventDefault()}};function Eu(n){return{left:n.clientX,top:n.clientY}}function Y_(n,e){let t=e.x-n.clientX,i=e.y-n.clientY;return t*t+i*i<100}function op(n,e,t,i,r){if(i==-1)return!1;let s=n.state.doc.resolve(i);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),r,!0):l(n,t,s.node(o),s.before(o),r,!1)))return!0;return!1}function Ks(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let i=n.state.tr.setSelection(e);i.setMeta("pointer",!0),n.dispatch(i)}function J_(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&ne.isSelectable(i)?(Ks(n,new ne(t)),!0):!1}function Z_(n,e){if(e==-1)return!1;let t=n.state.selection,i,r;t instanceof ne&&(i=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(ne.isSelectable(l)){i&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?r=s.before(t.$from.depth):r=s.before(o);break}}return r!=null?(Ks(n,ne.create(n.state.doc,r)),!0):!1}function Q_(n,e,t,i,r){return op(n,"handleClickOn",e,t,i)||n.someProp("handleClick",s=>s(n,e,i))||(r?Z_(n,t):J_(n,t))}function eR(n,e,t,i){return op(n,"handleDoubleClickOn",e,t,i)||n.someProp("handleDoubleClick",r=>r(n,e,i))}function tR(n,e,t,i){return op(n,"handleTripleClickOn",e,t,i)||n.someProp("handleTripleClick",r=>r(n,e,i))||nR(n,t,i)}function nR(n,e,t){if(t.button!=0)return!1;let i=n.state.doc;if(e==-1)return i.inlineContent?(Ks(n,fe.create(i,0,i.content.size)),!0):!1;let r=i.resolve(e);for(let s=r.depth+1;s>0;s--){let o=s>r.depth?r.nodeAfter:r.node(s),l=r.before(s);if(o.inlineContent)Ks(n,fe.create(i,l+1,l+1+o.content.size));else if(ne.isSelectable(o))Ks(n,ne.create(i,l));else continue;return!0}}function ap(n){return _c(n)}const pw=Pn?"metaKey":"ctrlKey";jt.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let i=ap(n),r=Date.now(),s="singleClick";r-n.input.lastClick.time<500&&Y_(t,n.input.lastClick)&&!t[pw]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:s,button:t.button};let o=n.posAtCoords(Eu(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new iR(n,o,t,!!i)):(s=="doubleClick"?eR:tR)(n,o.pos,o.inside,t)?t.preventDefault():br(n,"pointer"))};class iR{constructor(e,t,i,r){this.view=e,this.pos=t,this.event=i,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[pw],this.allowDefault=i.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);s=d.parent,o=d.depth?d.before():0}const l=r?null:i.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.dom.nodeType==1?c.dom:null;let{selection:h}=e.state;(i.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||h instanceof ne&&h.from<=o&&h.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Qn&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),br(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>Hi(this.view)),this.view.input.mouseDown=null}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(Eu(e))),this.updateAllowDefault(e),this.allowDefault||!t?br(this.view,"pointer"):Q_(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Gt&&this.mightDrag&&!this.mightDrag.node.isAtom||$t&&!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)?(Ks(this.view,oe.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):br(this.view,"pointer")}move(e){this.updateAllowDefault(e),br(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}jt.touchstart=n=>{n.input.lastTouch=Date.now(),ap(n),br(n,"pointer")};jt.touchmove=n=>{n.input.lastTouch=Date.now(),br(n,"pointer")};jt.contextmenu=n=>ap(n);function mw(n,e){return n.composing?!0:Gt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const rR=Li?5e3:-1;Xt.compositionstart=Xt.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof fe&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),_c(n,!0),n.markCursor=null;else if(_c(n,!e.selection.empty),Qn&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=n.domSelectionRange();for(let r=i.focusNode,s=i.focusOffset;r&&r.nodeType==1&&s!=0;){let o=s<0?r.lastChild:r.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else r=o,s=-1}}n.input.composing=!0}gw(n,rR)};Xt.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,gw(n,20))};function gw(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>_c(n),e))}function yw(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=oR());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function sR(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=JD(e.focusNode,e.focusOffset),i=ZD(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let r=i.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||i==s)return s;if(!r||!r.isText(i.nodeValue))return i;if(n.input.compositionNode==i){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return i}}return t||i}function oR(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function _c(n,e=!1){if(!(Li&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),yw(n),e||n.docView&&n.docView.dirty){let t=np(n),i=n.state.selection;return t&&!t.eq(i)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function aR(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 i=getSelection(),r=document.createRange();r.selectNodeContents(e),n.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const ba=an&&Sr<15||Zs&&i_<604;jt.copy=Xt.cut=(n,e)=>{let t=e,i=n.state.selection,r=t.type=="cut";if(i.empty)return;let s=ba?null:t.clipboardData,o=i.content(),{dom:l,text:c}=rp(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):aR(n,l),r&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function lR(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function cR(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,i=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let r=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),i.parentNode&&i.parentNode.removeChild(i),t?wa(n,i.value,null,r,e):wa(n,i.textContent,i.innerHTML,r,e)},50)}function wa(n,e,t,i,r){let s=lw(n,e,t,i,n.state.selection.$from);if(n.someProp("handlePaste",c=>c(n,r,s||j.empty)))return!0;if(!s)return!1;let o=lR(s),l=o?n.state.tr.replaceSelectionWith(o,i):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function vw(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," "):""}Xt.paste=(n,e)=>{let t=e;if(n.composing&&!Li)return;let i=ba?null:t.clipboardData,r=n.input.shiftKey&&n.input.lastKeyCode!=45;i&&wa(n,vw(i),i.getData("text/html"),r,t)?t.preventDefault():cR(n,t)};class bw{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const uR=Pn?"altKey":"ctrlKey";function ww(n,e){let t=n.someProp("dragCopies",i=>!i(e));return t??!e[uR]}jt.dragstart=(n,e)=>{let t=e,i=n.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let r=n.state.selection,s=r.empty?null:n.posAtCoords(Eu(t)),o;if(!(s&&s.pos>=r.from&&s.pos<=(r instanceof ne?r.to-1:r.to))){if(i&&i.mightDrag)o=ne.create(n.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(o=ne.create(n.state.doc,p.posBefore))}}let l=(o||n.state.selection).content(),{dom:c,text:h,slice:d}=rp(n,l);(!t.dataTransfer.files.length||!$t||Kb>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ba?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",ba||t.dataTransfer.setData("text/plain",h),n.dragging=new bw(d,ww(n,t),o)};jt.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Xt.dragover=Xt.dragenter=(n,e)=>e.preventDefault();Xt.drop=(n,e)=>{let t=e,i=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let r=n.posAtCoords(Eu(t));if(!r)return;let s=n.state.doc.resolve(r.pos),o=i&&i.slice;o?n.someProp("transformPasted",v=>{o=v(o,n)}):o=lw(n,vw(t.dataTransfer),ba?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(i&&ww(n,t));if(n.someProp("handleDrop",v=>v(n,t,o||j.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let c=o?Lb(n.state.doc,s.pos,o):s.pos;c==null&&(c=s.pos);let h=n.state.tr;if(l){let{node:v}=i;v?v.replace(h):h.deleteSelection()}let d=h.mapping.map(c),p=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,m=h.doc;if(p?h.replaceRangeWith(d,d,o.content.firstChild):h.replaceRange(d,d,o),h.doc.eq(m))return;let g=h.doc.resolve(d);if(p&&ne.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))h.setSelection(new ne(g));else{let v=h.mapping.map(c);h.mapping.maps[h.mapping.maps.length-1].forEach((w,S,E,k)=>v=k),h.setSelection(ip(n,g,h.doc.resolve(v)))}n.focus(),n.dispatch(h.setMeta("uiEvent","drop"))};jt.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())&&Hi(n)},20))};jt.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)};jt.beforeinput=(n,e)=>{if($t&&Li&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:i}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=i||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,qr(8,"Backspace")))))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in Xt)jt[n]=Xt[n];function Sa(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 Rc{constructor(e,t){this.toDOM=e,this.spec=t||Qr,this.side=this.spec.side||0}map(e,t,i,r){let{pos:s,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new Kt(s-i,s-i,this)}valid(){return!0}eq(e){return this==e||e instanceof Rc&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Sa(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Cr{constructor(e,t){this.attrs=e,this.spec=t||Qr}map(e,t,i,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-i,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-i;return s>=o?null:new Kt(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Cr&&Sa(this.attrs,e.attrs)&&Sa(this.spec,e.spec)}static is(e){return e.type instanceof Cr}destroy(){}}class lp{constructor(e,t){this.attrs=e,this.spec=t||Qr}map(e,t,i,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=s.pos?null:new Kt(s.pos-i,o.pos-i,this)}valid(e,t){let{index:i,offset:r}=e.content.findIndex(t.from),s;return r==t.from&&!(s=e.child(i)).isText&&r+s.nodeSize==t.to}eq(e){return this==e||e instanceof lp&&Sa(this.attrs,e.attrs)&&Sa(this.spec,e.spec)}destroy(){}}class Kt{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new Kt(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new Kt(e,e,new Rc(t,i))}static inline(e,t,i,r){return new Kt(e,t,new Cr(i,r))}static node(e,t,i,r){return new Kt(e,t,new lp(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Cr}get widget(){return this.type instanceof Rc}}const Ls=[],Qr={};class et{constructor(e,t){this.local=e.length?e:Ls,this.children=t.length?t:Ls}static create(e,t){return t.length?Nc(t,e,0,Qr):Ft}find(e,t,i){let r=[];return this.findInner(e??0,t??1e9,r,0,i),r}findInner(e,t,i,r,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&i.push(l.copy(l.from+r,l.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,i,r+l,s)}}map(e,t,i){return this==Ft||e.maps.length==0?this:this.mapInner(e,t,0,0,i||Qr)}mapInner(e,t,i,r,s){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,i,r);c&&c.type.valid(t,c)?(o||(o=[])).push(c):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?hR(this.children,o||[],e,t,i,r,s):o?new et(o.sort(es),Ls):Ft}add(e,t){return t.length?this==Ft?et.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let r,s=0;e.forEach((l,c)=>{let h=c+i,d;if(d=xw(t,l,h)){for(r||(r=this.children.slice());s<r.length&&r[s]<c;)s+=3;r[s]==c?r[s+2]=r[s+2].addInner(l,d,h+1):r.splice(s,0,c,c+l.nodeSize,Nc(d,l,h+1,Qr)),s+=3}});let o=Sw(s?Cw(t):t,-i);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new et(o.length?this.local.concat(o).sort(es):this.local,r||this.children)}remove(e){return e.length==0||this==Ft?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,r=this.local;for(let s=0;s<i.length;s+=3){let o,l=i[s]+t,c=i[s+1]+t;for(let d=0,p;d<e.length;d++)(p=e[d])&&p.from>l&&p.to<c&&(e[d]=null,(o||(o=[])).push(p));if(!o)continue;i==this.children&&(i=this.children.slice());let h=i[s+2].removeInner(o,l+1);h!=Ft?i[s+2]=h:(i.splice(s,3),s-=3)}if(r.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<r.length;l++)r[l].eq(o,t)&&(r==this.local&&(r=this.local.slice()),r.splice(l--,1))}return i==this.children&&r==this.local?this:r.length||i.length?new et(r,i):Ft}forChild(e,t){if(this==Ft)return this;if(t.isLeaf)return et.empty;let i,r;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>s&&c.type instanceof Cr){let h=Math.max(s,c.from)-s,d=Math.min(o,c.to)-s;h<d&&(r||(r=[])).push(c.copy(h,d))}}if(r){let l=new et(r.sort(es),Ls);return i?new fr([l,i]):l}return i||Ft}eq(e){if(this==e)return!0;if(!(e instanceof et)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return cp(this.localsInner(e))}localsInner(e){if(this==Ft)return Ls;if(e.inlineContent||!this.local.some(Cr.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof Cr||t.push(this.local[i]);return t}forEachSet(e){e(this)}}et.empty=new et([],[]);et.removeOverlap=cp;const Ft=et.empty;class fr{constructor(e){this.members=e}map(e,t){const i=this.members.map(r=>r.map(e,t,Qr));return fr.from(i)}forChild(e,t){if(t.isLeaf)return et.empty;let i=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=Ft&&(s instanceof fr?i=i.concat(s.members):i.push(s))}return fr.from(i)}eq(e){if(!(e instanceof fr)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,i=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(!t)t=s;else{i&&(t=t.slice(),i=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?cp(i?t:t.sort(es)):Ls}static from(e){switch(e.length){case 0:return Ft;case 1:return e[0];default:return new fr(e.every(t=>t instanceof et)?e:e.reduce((t,i)=>t.concat(i instanceof et?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function hR(n,e,t,i,r,s,o){let l=n.slice();for(let h=0,d=s;h<t.maps.length;h++){let p=0;t.maps[h].forEach((m,g,v,w)=>{let S=w-v-(g-m);for(let E=0;E<l.length;E+=3){let k=l[E+1];if(k<0||m>k+d-p)continue;let I=l[E]+d-p;g>=I?l[E+1]=m<=I?-2:-1:m>=d&&S&&(l[E]+=S,l[E+1]+=S)}p+=S}),d=t.maps[h].map(d,-1)}let c=!1;for(let h=0;h<l.length;h+=3)if(l[h+1]<0){if(l[h+1]==-2){c=!0,l[h+1]=-1;continue}let d=t.map(n[h]+s),p=d-r;if(p<0||p>=i.content.size){c=!0;continue}let m=t.map(n[h+1]+s,-1),g=m-r,{index:v,offset:w}=i.content.findIndex(p),S=i.maybeChild(v);if(S&&w==p&&w+S.nodeSize==g){let E=l[h+2].mapInner(t,S,d+1,n[h]+s+1,o);E!=Ft?(l[h]=p,l[h+1]=g,l[h+2]=E):(l[h+1]=-2,c=!0)}else c=!0}if(c){let h=dR(l,n,e,t,r,s,o),d=Nc(h,i,0,o);e=d.local;for(let p=0;p<l.length;p+=3)l[p+1]<0&&(l.splice(p,3),p-=3);for(let p=0,m=0;p<d.children.length;p+=3){let g=d.children[p];for(;m<l.length&&l[m]<g;)m+=3;l.splice(m,0,d.children[p],d.children[p+1],d.children[p+2])}}return new et(e.sort(es),l)}function Sw(n,e){if(!e||!n.length)return n;let t=[];for(let i=0;i<n.length;i++){let r=n[i];t.push(new Kt(r.from+e,r.to+e,r.type))}return t}function dR(n,e,t,i,r,s,o){function l(c,h){for(let d=0;d<c.local.length;d++){let p=c.local[d].map(i,r,h);p?t.push(p):o.onRemove&&o.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+h+1)}for(let c=0;c<n.length;c+=3)n[c+1]==-1&&l(n[c+2],e[c]+s+1);return t}function xw(n,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,r=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<i&&((r||(r=[])).push(o),n[s]=null);return r}function Cw(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Nc(n,e,t,i){let r=[],s=!1;e.forEach((l,c)=>{let h=xw(n,l,c+t);if(h){s=!0;let d=Nc(h,l,t+c+1,i);d!=Ft&&r.push(c,c+l.nodeSize,d)}});let o=Sw(s?Cw(n):n,-t).sort(es);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(i.onRemove&&i.onRemove(o[l].spec),o.splice(l--,1));return o.length||r.length?new et(o,r):Ft}function es(n,e){return n.from-e.from||n.to-e.to}function cp(n){let e=n;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let r=t+1;r<e.length;r++){let s=e[r];if(s.from==i.from){s.to!=i.to&&(e==n&&(e=n.slice()),e[r]=s.copy(s.from,i.to),Nv(e,r+1,s.copy(i.to,s.to)));continue}else{s.from<i.to&&(e==n&&(e=n.slice()),e[t]=i.copy(i.from,s.from),Nv(e,r,i.copy(s.from,i.to)));break}}}return e}function Nv(n,e,t){for(;e<n.length&&es(t,n[e])>0;)e++;n.splice(e,0,t)}function Nd(n){let e=[];return n.someProp("decorations",t=>{let i=t(n.state);i&&i!=Ft&&e.push(i)}),n.cursorWrapper&&e.push(et.create(n.state.doc,[n.cursorWrapper.deco])),fr.from(e)}const fR={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},pR=an&&Sr<=11;class mR{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 gR{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new mR,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let r=0;r<i.length;r++)this.queue.push(i[r]);an&&Sr<=11&&i.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),pR&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.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,fR)),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;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.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(kv(this.view)){if(this.suppressingSelectionUpdates)return Hi(this.view);if(an&&Sr<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&rs(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,i;for(let s=e.focusNode;s;s=Js(s))t.add(s);for(let s=e.anchorNode;s;s=Js(s))if(t.has(s)){i=s;break}let r=i&&this.view.docView.nearestDesc(i);if(r&&r.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))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 i=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&kv(e)&&!this.ignoreSelectionChange(i),s=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<t.length;d++){let p=this.registerMutation(t[d],c);p&&(s=s<0?p.from:Math.min(p.from,s),o=o<0?p.to:Math.max(p.to,o),p.typeOver&&(l=!0))}if(Qn&&c.length){let d=c.filter(p=>p.nodeName=="BR");if(d.length==2){let[p,m]=d;p.parentNode&&p.parentNode.parentNode==m.parentNode?m.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let m of d){let g=m.parentNode;g&&g.nodeName=="LI"&&(!p||bR(e,p)!=g)&&m.remove()}}}let h=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&xu(i)&&(h=np(e))&&h.eq(oe.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Hi(e),this.currentSelection.set(i),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,o),yR(e)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||Hi(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let p=e.addedNodes[d];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let r=e.previousSibling,s=e.nextSibling;if(an&&Sr<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:p,nextSibling:m}=e.addedNodes[d];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(r=p),(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(s=m)}let o=r&&r.parentNode==e.target?Ot(r)+1:0,l=i.localPosFromDOM(e.target,o,-1),c=s&&s.parentNode==e.target?Ot(s):e.target.childNodes.length,h=i.localPosFromDOM(e.target,c,1);return{from:l,to:h}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Pv=new WeakMap,Lv=!1;function yR(n){if(!Pv.has(n)&&(Pv.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Qn,Lv)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Lv=!0}}function Fv(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return rs(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function vR(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Fv(n,r)}let t;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",i,!0),t?Fv(n,t):null}function bR(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let i=n.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function wR(n,e,t){let{node:i,fromOffset:r,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),c=n.domSelectionRange(),h,d=c.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(h=[{node:d,offset:c.anchorOffset}],xu(c)||h.push({node:c.focusNode,offset:c.focusOffset})),$t&&n.input.lastKeyCode===8)for(let S=s;S>r;S--){let E=i.childNodes[S-1],k=E.pmViewDesc;if(E.nodeName=="BR"&&!k){s=S;break}if(!k||k.size)break}let p=n.state.doc,m=n.someProp("domParser")||sa.fromSchema(n.state.schema),g=p.resolve(o),v=null,w=m.parse(i,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:r,to:s,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:SR,context:g});if(h&&h[0].pos!=null){let S=h[0].pos,E=h[1]&&h[1].pos;E==null&&(E=S),v={anchor:S+o,head:E+o}}return{doc:w,sel:v,from:o,to:l}}function SR(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Gt&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Gt&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const xR=/^(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 CR(n,e,t,i,r){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let W=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,G=np(n,W);if(G&&!n.state.selection.eq(G)){if($t&&Li&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",le=>le(n,qr(13,"Enter"))))return;let Y=n.state.tr.setSelection(G);W=="pointer"?Y.setMeta("pointer",!0):W=="key"&&Y.scrollIntoView(),s&&Y.setMeta("composition",s),n.dispatch(Y)}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 c=n.state.selection,h=wR(n,e,t),d=n.state.doc,p=d.slice(h.from,h.to),m,g;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(m=n.state.selection.to,g="end"):(m=n.state.selection.from,g="start"),n.input.lastKeyCode=null;let v=kR(p.content,h.doc.content,h.from,m,g);if(v&&n.input.domChangeCount++,(Zs&&n.input.lastIOSEnter>Date.now()-225||Li)&&r.some(W=>W.nodeType==1&&!xR.test(W.nodeName))&&(!v||v.endA>=v.endB)&&n.someProp("handleKeyDown",W=>W(n,qr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!v)if(i&&c instanceof fe&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))v={start:c.from,endA:c.to,endB:c.to};else{if(h.sel){let W=$v(n,n.state.doc,h.sel);if(W&&!W.eq(n.state.selection)){let G=n.state.tr.setSelection(W);s&&G.setMeta("composition",s),n.dispatch(G)}}return}n.state.selection.from<n.state.selection.to&&v.start==v.endB&&n.state.selection instanceof fe&&(v.start>n.state.selection.from&&v.start<=n.state.selection.from+2&&n.state.selection.from>=h.from?v.start=n.state.selection.from:v.endA<n.state.selection.to&&v.endA>=n.state.selection.to-2&&n.state.selection.to<=h.to&&(v.endB+=n.state.selection.to-v.endA,v.endA=n.state.selection.to)),an&&Sr<=11&&v.endB==v.start+1&&v.endA==v.start&&v.start>h.from&&h.doc.textBetween(v.start-h.from-1,v.start-h.from+1)==" "&&(v.start--,v.endA--,v.endB--);let w=h.doc.resolveNoCache(v.start-h.from),S=h.doc.resolveNoCache(v.endB-h.from),E=d.resolve(v.start),k=w.sameParent(S)&&w.parent.inlineContent&&E.end()>=v.endA,I;if((Zs&&n.input.lastIOSEnter>Date.now()-225&&(!k||r.some(W=>W.nodeName=="DIV"||W.nodeName=="P"))||!k&&w.pos<h.doc.content.size&&(!w.sameParent(S)||!w.parent.inlineContent)&&!/\S/.test(h.doc.textBetween(w.pos,S.pos,"",""))&&(I=oe.findFrom(h.doc.resolve(w.pos+1),1,!0))&&I.head>w.pos)&&n.someProp("handleKeyDown",W=>W(n,qr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>v.start&&TR(d,v.start,v.endA,w,S)&&n.someProp("handleKeyDown",W=>W(n,qr(8,"Backspace")))){Li&&$t&&n.domObserver.suppressSelectionUpdates();return}$t&&v.endB==v.start&&(n.input.lastChromeDelete=Date.now()),Li&&!k&&w.start()!=S.start()&&S.parentOffset==0&&w.depth==S.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==v.endA&&(v.endB-=2,S=h.doc.resolveNoCache(v.endB-h.from),setTimeout(()=>{n.someProp("handleKeyDown",function(W){return W(n,qr(13,"Enter"))})},20));let R=v.start,N=v.endA,V=W=>{let G=W||n.state.tr.replace(R,N,h.doc.slice(v.start-h.from,v.endB-h.from));if(h.sel){let Y=$v(n,G.doc,h.sel);Y&&!($t&&n.composing&&Y.empty&&(v.start!=v.endB||n.input.lastChromeDelete<Date.now()-100)&&(Y.head==R||Y.head==G.mapping.map(N)-1)||an&&Y.empty&&Y.head==R)&&G.setSelection(Y)}return s&&G.setMeta("composition",s),G.scrollIntoView()},U;if(k){if(w.pos==S.pos){an&&Sr<=11&&w.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Hi(n),20));let W=V(n.state.tr.delete(R,N)),G=d.resolve(v.start).marksAcross(d.resolve(v.endA));G&&W.ensureMarks(G),n.dispatch(W)}else if(v.endA==v.endB&&(U=ER(w.parent.content.cut(w.parentOffset,S.parentOffset),E.parent.content.cut(E.parentOffset,v.endA-E.start())))){let W=V(n.state.tr);U.type=="add"?W.addMark(R,N,U.mark):W.removeMark(R,N,U.mark),n.dispatch(W)}else if(w.parent.child(w.index()).isText&&w.index()==S.index()-(S.textOffset?0:1)){let W=w.parent.textBetween(w.parentOffset,S.parentOffset),G=()=>V(n.state.tr.insertText(W,R,N));n.someProp("handleTextInput",Y=>Y(n,R,N,W,G))||n.dispatch(G())}}else n.dispatch(V())}function $v(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ip(n,e.resolve(t.anchor),e.resolve(t.head))}function ER(n,e){let t=n.firstChild.marks,i=e.firstChild.marks,r=t,s=i,o,l,c;for(let d=0;d<i.length;d++)r=i[d].removeFromSet(r);for(let d=0;d<t.length;d++)s=t[d].removeFromSet(s);if(r.length==1&&s.length==0)l=r[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(r.length==0&&s.length==1)l=s[0],o="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let h=[];for(let d=0;d<e.childCount;d++)h.push(c(e.child(d)));if(z.from(h).eq(n))return{mark:l,type:o}}function TR(n,e,t,i,r){if(t-e<=r.pos-i.pos||Pd(i,!0,!1)<r.pos)return!1;let s=n.resolve(e);if(!i.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(Pd(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Pd(o,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(o.parent.content)}function Pd(n,e,t){let i=n.depth,r=e?n.end():n.pos;for(;i>0&&(e||n.indexAfter(i)==n.node(i).childCount);)i--,r++,e=!1;if(t){let s=n.node(i).maybeChild(n.indexAfter(i));for(;s&&!s.isLeaf;)s=s.firstChild,r++}return r}function kR(n,e,t,i,r){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(r=="end"){let c=Math.max(0,s-Math.min(o,l));i-=o+c-s}if(o<s&&n.size<e.size){let c=i<=s&&i>=o?s-i:0;s-=c,s&&s<e.size&&Bv(e.textBetween(s-1,s+1))&&(s+=c?1:-1),l=s+(l-o),o=s}else if(l<s){let c=i<=s&&i>=l?s-i:0;s-=c,s&&s<n.size&&Bv(n.textBetween(s-1,s+1))&&(s+=c?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function Bv(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Ew{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 q_,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Uv),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=Vv(this),Hv(this),this.nodeViews=Wv(this),this.docView=wv(this.state.doc,zv(this),Nd(this),this.dom,this),this.domObserver=new gR(this,(i,r,s,o)=>CR(this,i,r,s,o)),this.domObserver.start(),K_(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&&Tf(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Uv),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let r=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(yw(this),o=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let g=Wv(this);MR(g,this.nodeViews)&&(this.nodeViews=g,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Tf(this),this.editable=Vv(this),Hv(this);let c=Nd(this),h=zv(this),d=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",p=s||!this.docView.matchesNode(e.doc,h,c);(p||!e.selection.eq(r.selection))&&(o=!0);let m=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&o_(this);if(o){this.domObserver.stop();let g=p&&(an||$t)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&AR(r.selection,e.selection);if(p){let v=$t?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=sR(this)),(s||!this.docView.update(e.doc,h,c,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=wv(e.doc,h,c,this.dom,this)),v&&!this.trackWrites&&(g=!0)}g||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&I_(this))?Hi(this,g):(sw(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((i=this.dragging)===null||i===void 0)&&i.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():m&&a_(m)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof ne){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&pv(this,t.getBoundingClientRect(),e)}else pv(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;t<this.directPlugins.length;t++){let i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,r=-1;if(this.state.doc.nodeAt(i.from)==i.node)r=i.from;else{let s=i.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==i.node&&(r=s)}this.dragging=new bw(e.slice,e.move,r<0?void 0:ne.create(this.state.doc,r))}someProp(e,t){let i=this._props&&this._props[e],r;if(i!=null&&(r=t?t(i):i))return r;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(r=t?t(l):l))return r}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(r=t?t(l):l))return r}}hasFocus(){if(an){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&l_(this.dom),Hi(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return f_(this,e)}coordsAtPos(e,t=1){return Jb(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,i=-1){let r=this.docView.posFromDOM(e,t,i);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return v_(this,t||this.state,e)}pasteHTML(e,t){return wa(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return wa(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return rp(this,e)}destroy(){this.docView&&(G_(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Nd(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,XD())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return X_(this,e)}domSelectionRange(){let e=this.domSelection();return e?Gt&&this.root.nodeType===11&&e_(this.dom.ownerDocument)==this.dom&&vR(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Ew.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function zv(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 i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[Kt.node(0,n.state.doc.content.size,e)]}function Hv(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:Kt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Vv(n){return!n.someProp("editable",e=>e(n.state)===!1)}function AR(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 Wv(n){let e=Object.create(null);function t(i){for(let r in i)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=i[r])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function MR(n,e){let t=0,i=0;for(let r in n){if(n[r]!=e[r])return!0;t++}for(let r in e)i++;return t!=i}function Uv(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 Er={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:"'"},Pc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},OR=typeof navigator<"u"&&/Mac/.test(navigator.platform),IR=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var It=0;It<10;It++)Er[48+It]=Er[96+It]=String(It);for(var It=1;It<=24;It++)Er[It+111]="F"+It;for(var It=65;It<=90;It++)Er[It]=String.fromCharCode(It+32),Pc[It]=String.fromCharCode(It);for(var Ld in Er)Pc.hasOwnProperty(Ld)||(Pc[Ld]=Er[Ld]);function DR(n){var e=OR&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||IR&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Pc:Er)[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 _R=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),RR=typeof navigator<"u"&&/Win/.test(navigator.platform);function NR(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let i,r,s,o;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))_R?o=!0:r=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(t="Alt-"+t),r&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function PR(n){let e=Object.create(null);for(let t in n)e[NR(t)]=n[t];return e}function Fd(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function LR(n){return new Ye({props:{handleKeyDown:up(n)}})}function up(n){let e=PR(n);return function(t,i){let r=DR(i),s,o=e[Fd(r,i)];if(o&&o(t.state,t.dispatch,t))return!0;if(r.length==1&&r!=" "){if(i.shiftKey){let l=e[Fd(r,i,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((i.altKey||i.metaKey||i.ctrlKey)&&!(RR&&i.ctrlKey&&i.altKey)&&(s=Er[i.keyCode])&&s!=r){let l=e[Fd(s,i)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const hp=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Tw(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const kw=(n,e,t)=>{let i=Tw(n,t);if(!i)return!1;let r=dp(i);if(!r){let o=i.blockRange(),l=o&&so(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=r.nodeBefore;if(Pw(n,r,e,-1))return!0;if(i.parent.content.size==0&&(Qs(s,"end")||ne.isSelectable(s)))for(let o=i.depth;;o--){let l=wu(n.doc,i.before(o),i.after(o),j.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=n.tr.step(l);c.setSelection(Qs(s,"end")?oe.findFrom(c.doc.resolve(c.mapping.map(r.pos,-1)),-1):ne.create(c.doc,r.pos-s.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||i.node(o-1).childCount>1)break}return s.isAtom&&r.depth==i.depth-1?(e&&e(n.tr.delete(r.pos-s.nodeSize,r.pos).scrollIntoView()),!0):!1},FR=(n,e,t)=>{let i=Tw(n,t);if(!i)return!1;let r=dp(i);return r?Aw(n,r,e):!1},$R=(n,e,t)=>{let i=Ow(n,t);if(!i)return!1;let r=fp(i);return r?Aw(n,r,e):!1};function Aw(n,e,t){let i=e.nodeBefore,r=i,s=e.pos-1;for(;!r.isTextblock;s--){if(r.type.spec.isolating)return!1;let d=r.lastChild;if(!d)return!1;r=d}let o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let h=wu(n.doc,s,c,j.empty);if(!h||h.from!=s||h instanceof St&&h.slice.size>=c-s)return!1;if(t){let d=n.tr.step(h);d.setSelection(fe.create(d.doc,s)),t(d.scrollIntoView())}return!0}function Qs(n,e,t=!1){for(let i=n;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(t&&i.childCount!=1)return!1}return!1}const Mw=(n,e,t)=>{let{$head:i,empty:r}=n.selection,s=i;if(!r)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):i.parentOffset>0)return!1;s=dp(i)}let o=s&&s.nodeBefore;return!o||!ne.isSelectable(o)?!1:(e&&e(n.tr.setSelection(ne.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function dp(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 Ow(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Iw=(n,e,t)=>{let i=Ow(n,t);if(!i)return!1;let r=fp(i);if(!r)return!1;let s=r.nodeAfter;if(Pw(n,r,e,1))return!0;if(i.parent.content.size==0&&(Qs(s,"start")||ne.isSelectable(s))){let o=wu(n.doc,i.before(),i.after(),j.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Qs(s,"start")?oe.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):ne.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&r.depth==i.depth-1?(e&&e(n.tr.delete(r.pos,r.pos+s.nodeSize).scrollIntoView()),!0):!1},Dw=(n,e,t)=>{let{$head:i,empty:r}=n.selection,s=i;if(!r)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):i.parentOffset<i.parent.content.size)return!1;s=fp(i)}let o=s&&s.nodeAfter;return!o||!ne.isSelectable(o)?!1:(e&&e(n.tr.setSelection(ne.create(n.doc,s.pos)).scrollIntoView()),!0)};function fp(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const BR=(n,e)=>{let t=n.selection,i=t instanceof ne,r;if(i){if(t.node.isTextblock||!Ar(n.doc,t.from))return!1;r=t.from}else if(r=bu(n.doc,t.from,-1),r==null)return!1;if(e){let s=n.tr.join(r);i&&s.setSelection(ne.create(s.doc,r-n.doc.resolve(r).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},zR=(n,e)=>{let t=n.selection,i;if(t instanceof ne){if(t.node.isTextblock||!Ar(n.doc,t.to))return!1;i=t.to}else if(i=bu(n.doc,t.to,1),i==null)return!1;return e&&e(n.tr.join(i).scrollIntoView()),!0},HR=(n,e)=>{let{$from:t,$to:i}=n.selection,r=t.blockRange(i),s=r&&so(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)},_w=(n,e)=>{let{$head:t,$anchor:i}=n.selection;return!t.parent.type.spec.code||!t.sameParent(i)?!1:(e&&e(n.tr.insertText(` `).scrollIntoView()),!0)};function pp(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const VR=(n,e)=>{let{$head:t,$anchor:i}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(i))return!1;let r=t.node(-1),s=t.indexAfter(-1),o=pp(r.contentMatchAt(s));if(!o||!r.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),c=n.tr.replaceWith(l,l,o.createAndFill());c.setSelection(oe.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Rw=(n,e)=>{let t=n.selection,{$from:i,$to:r}=t;if(t instanceof xn||i.parent.inlineContent||r.parent.inlineContent)return!1;let s=pp(r.parent.contentMatchAt(r.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!i.parentOffset&&r.index()<r.parent.childCount?i:r).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(fe.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Nw=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(zi(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let i=t.blockRange(),r=i&&so(i);return r==null?!1:(e&&e(n.tr.lift(i,r).scrollIntoView()),!0)};function WR(n){return(e,t)=>{let{$from:i,$to:r}=e.selection;if(e.selection instanceof ne&&e.selection.node.isBlock)return!i.parentOffset||!zi(e.doc,i.pos)?!1:(t&&t(e.tr.split(i.pos).scrollIntoView()),!0);if(!i.depth)return!1;let s=[],o,l,c=!1,h=!1;for(let g=i.depth;;g--)if(i.node(g).isBlock){c=i.end(g)==i.pos+(i.depth-g),h=i.start(g)==i.pos-(i.depth-g),l=pp(i.node(g-1).contentMatchAt(i.indexAfter(g-1))),s.unshift(c&&l?{type:l}:null),o=g;break}else{if(g==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof fe||e.selection instanceof xn)&&d.deleteSelection();let p=d.mapping.map(i.pos),m=zi(d.doc,p,s.length,s);if(m||(s[0]=l?{type:l}:null,m=zi(d.doc,p,s.length,s)),!m)return!1;if(d.split(p,s.length,s),!c&&h&&i.node(o).type!=l){let g=d.mapping.map(i.before(o)),v=d.doc.resolve(g);l&&i.node(o-1).canReplaceWith(v.index(),v.index()+1,l)&&d.setNodeMarkup(d.mapping.map(i.before(o)),l)}return t&&t(d.scrollIntoView()),!0}}const UR=WR(),qR=(n,e)=>{let{$from:t,to:i}=n.selection,r,s=t.sharedDepth(i);return s==0?!1:(r=t.before(s),e&&e(n.tr.setSelection(ne.create(n.doc,r))),!0)};function KR(n,e,t){let i=e.nodeBefore,r=e.nodeAfter,s=e.index();return!i||!r||!i.type.compatibleContent(r.type)?!1:!i.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(r.isTextblock||Ar(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Pw(n,e,t,i){let r=e.nodeBefore,s=e.nodeAfter,o,l,c=r.type.spec.isolating||s.type.spec.isolating;if(!c&&KR(n,e,t))return!0;let h=!c&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(l=r.contentMatchAt(r.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let g=e.pos+s.nodeSize,v=z.empty;for(let E=o.length-1;E>=0;E--)v=z.from(o[E].create(null,v));v=z.from(r.copy(v));let w=n.tr.step(new xt(e.pos-1,g,e.pos,g,new j(v,1,0),o.length,!0)),S=w.doc.resolve(g+2*o.length);S.nodeAfter&&S.nodeAfter.type==r.type&&Ar(w.doc,S.pos)&&w.join(S.pos),t(w.scrollIntoView())}return!0}let d=s.type.spec.isolating||i>0&&c?null:oe.findFrom(e,1),p=d&&d.$from.blockRange(d.$to),m=p&&so(p);if(m!=null&&m>=e.depth)return t&&t(n.tr.lift(p,m).scrollIntoView()),!0;if(h&&Qs(s,"start",!0)&&Qs(r,"end")){let g=r,v=[];for(;v.push(g),!g.isTextblock;)g=g.lastChild;let w=s,S=1;for(;!w.isTextblock;w=w.firstChild)S++;if(g.canReplace(g.childCount,g.childCount,w.content)){if(t){let E=z.empty;for(let I=v.length-1;I>=0;I--)E=z.from(v[I].copy(E));let k=n.tr.step(new xt(e.pos-v.length,e.pos+s.nodeSize,e.pos+S,e.pos+s.nodeSize-S,new j(E,v.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function Lw(n){return function(e,t){let i=e.selection,r=n<0?i.$from:i.$to,s=r.depth;for(;r.node(s).isInline;){if(!s)return!1;s--}return r.node(s).isTextblock?(t&&t(e.tr.setSelection(fe.create(e.doc,n<0?r.start(s):r.end(s)))),!0):!1}}const GR=Lw(-1),jR=Lw(1);function XR(n,e=null){return function(t,i){let{$from:r,$to:s}=t.selection,o=r.blockRange(s),l=o&&Qf(o,n,e);return l?(i&&i(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function qv(n,e=null){return function(t,i){let r=!1;for(let s=0;s<t.selection.ranges.length&&!r;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(c,h)=>{if(r)return!1;if(!(!c.isTextblock||c.hasMarkup(n,e)))if(c.type==n)r=!0;else{let d=t.doc.resolve(h),p=d.index();r=d.parent.canReplaceWith(p,p+1,n)}})}if(!r)return!1;if(i){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=t.selection.ranges[o];s.setBlockType(l,c,n,e)}i(s.scrollIntoView())}return!0}}function mp(...n){return function(e,t,i){for(let r=0;r<n.length;r++)if(n[r](e,t,i))return!0;return!1}}mp(hp,kw,Mw);mp(hp,Iw,Dw);mp(_w,Rw,Nw,UR);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function YR(n,e=null){return function(t,i){let{$from:r,$to:s}=t.selection,o=r.blockRange(s);if(!o)return!1;let l=i?t.tr:null;return JR(l,o,n,e)?(i&&i(l.scrollIntoView()),!0):!1}}function JR(n,e,t,i=null){let r=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=o.resolve(e.start-2);s=new Mc(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new Mc(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=Qf(s,t,i,e);return l?(n&&ZR(n,e,l,r,t),!0):!1}function ZR(n,e,t,i,r){let s=z.empty;for(let d=t.length-1;d>=0;d--)s=z.from(t[d].type.create(t[d].attrs,s));n.step(new xt(e.start-(i?2:0),e.end,e.start,e.end,new j(s,0,0),t.length,!0));let o=0;for(let d=0;d<t.length;d++)t[d].type==r&&(o=d+1);let l=t.length-o,c=e.start+t.length-(i?2:0),h=e.parent;for(let d=e.startIndex,p=e.endIndex,m=!0;d<p;d++,m=!1)!m&&zi(n.doc,c,l)&&(n.split(c,l),c+=2*l),c+=h.child(d).nodeSize;return n}function QR(n){return function(e,t){let{$from:i,$to:r}=e.selection,s=i.blockRange(r,o=>o.childCount>0&&o.firstChild.type==n);return s?t?i.node(s.depth-1).type==n?eN(e,t,n,s):tN(e,t,s):!0:!1}}function eN(n,e,t,i){let r=n.tr,s=i.end,o=i.$to.end(i.depth);s<o&&(r.step(new xt(s-1,o,s,o,new j(z.from(t.create(null,i.parent.copy())),1,0),1,!0)),i=new Mc(r.doc.resolve(i.$from.pos),r.doc.resolve(o),i.depth));const l=so(i);if(l==null)return!1;r.lift(i,l);let c=r.doc.resolve(r.mapping.map(s,-1)-1);return Ar(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),e(r.scrollIntoView()),!0}function tN(n,e,t){let i=n.tr,r=t.parent;for(let g=t.end,v=t.endIndex-1,w=t.startIndex;v>w;v--)g-=r.child(v).nodeSize,i.delete(g-1,g+1);let s=i.doc.resolve(t.start),o=s.nodeAfter;if(i.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,c=t.endIndex==r.childCount,h=s.node(-1),d=s.index(-1);if(!h.canReplace(d+(l?0:1),d+1,o.content.append(c?z.empty:z.from(r))))return!1;let p=s.pos,m=p+o.nodeSize;return i.step(new xt(p-(l?1:0),m+(c?1:0),p+1,m-1,new j((l?z.empty:z.from(r.copy(z.empty))).append(c?z.empty:z.from(r.copy(z.empty))),l?0:1,c?0:1),l?0:1)),e(i.scrollIntoView()),!0}function nN(n){return function(e,t){let{$from:i,$to:r}=e.selection,s=i.blockRange(r,h=>h.childCount>0&&h.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,c=l.child(o-1);if(c.type!=n)return!1;if(t){let h=c.lastChild&&c.lastChild.type==l.type,d=z.from(h?n.create():null),p=new j(z.from(n.create(null,z.from(l.type.create(null,d)))),h?3:1,0),m=s.start,g=s.end;t(e.tr.step(new xt(m-(h?3:1),g,m,g,p,1,!0)).scrollIntoView())}return!0}}var iN=Object.defineProperty,Fw=(n,e)=>{for(var t in e)iN(n,t,{get:e[t],enumerable:!0})};function Tu(n){const{state:e,transaction:t}=n;let{selection:i}=t,{doc:r}=t,{storedMarks:s}=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 s},get selection(){return i},get doc(){return r},get tr(){return i=t.selection,r=t.doc,s=t.storedMarks,t}}}var ku=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:i}=e,{tr:r}=t,s=this.buildProps(r);return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...h)=>{const d=l(...h)(s);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(r),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:i,state:r}=this,{view:s}=i,o=[],l=!!n,c=n||r.tr,h=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),o.every(p=>p===!0)),d={...Object.fromEntries(Object.entries(t).map(([p,m])=>[p,(...v)=>{const w=this.buildProps(c,e),S=m(...v)(w);return o.push(S),d}])),run:h};return d}createCan(n){const{rawCommands:e,state:t}=this,i=!1,r=n||t.tr,s=this.buildProps(r,i);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...h)=>c(...h)({...s,dispatch:void 0})])),chain:()=>this.createChain(r,i)}}buildProps(n,e=!0){const{rawCommands:t,editor:i,state:r}=this,{view:s}=i,o={tr:n,editor:i,view:s,state:Tu({state:r,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...h)=>c(...h)(o)]))}};return o}},rN=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(i=>i.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(i=>i!==e):delete this.callbacks[n]),this}once(n,e){const t=(...i)=>{this.off(n,t),e.apply(this,i)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}};function $w(n,e){const t=new Hb(n);return e.forEach(i=>{i.steps.forEach(r=>{t.step(r)})}),t}var Bw=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const i=e[t];i.nodeType===3&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)?n.removeChild(i):i.nodeType===1&&Bw(i)}return n};function Vl(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Bw(t)}function xa(n,e,t){if(n instanceof wr||n instanceof z)return n;t={slice:!0,parseOptions:{},...t};const i=typeof n=="object"&&n!==null,r=typeof n=="string";if(i)try{if(Array.isArray(n)&&n.length>0)return z.fromArray(n.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),xa("",e,t)}if(r){if(t.errorOnInvalidContent){let o=!1,l="";const c=new Tb({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:h=>(o=!0,l=typeof h=="string"?h:h.outerHTML,null)}]}})});if(t.slice?sa.fromSchema(c).parseSlice(Vl(n),t.parseOptions):sa.fromSchema(c).parse(Vl(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=sa.fromSchema(e);return t.slice?s.parseSlice(Vl(n),t.parseOptions).content:s.parse(Vl(n),t.parseOptions)}return xa("",e,t)}function kf(n,e,t={},i={}){return xa(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:i.errorOnInvalidContent})}function sN(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function oN(n,e,t){const i=[];return n.nodesBetween(e.from,e.to,(r,s)=>{t(r)&&i.push({node:r,pos:s})}),i}function aN(n,e){for(let t=n.depth;t>0;t-=1){const i=n.node(t);if(e(i))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:i}}}function Au(n){return e=>aN(e.$from,n)}function te(n,e,t){return n.config[e]===void 0&&n.parent?te(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?te(n.parent,e,t):null}):n.config[e]}function gp(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},i=te(e,"addExtensions",t);return i?[e,...gp(i())]:e}).flat(10)}function yp(n,e){const t=ls.fromSchema(e).serializeFragment(n),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(t),r.innerHTML}function zw(n){return typeof n=="function"}function Be(n,e=void 0,...t){return zw(n)?e?n.bind(e)(...t):n(...t):n}function lN(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Ca(n){const e=n.filter(r=>r.type==="extension"),t=n.filter(r=>r.type==="node"),i=n.filter(r=>r.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:i}}function Hw(n){const e=[],{nodeExtensions:t,markExtensions:i}=Ca(n),r=[...t,...i],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:r},c=te(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(p=>{Object.entries(d.attributes).forEach(([m,g])=>{e.push({type:p,name:m,attribute:{...s,...g}})})})})}),r.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=te(o,"addAttributes",l);if(!c)return;const h=c();Object.entries(h).forEach(([d,p])=>{const m={...s,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:o.name,name:d,attribute:m})})}),e}function ut(...n){return n.filter(e=>!!e).reduce((e,t)=>{const i={...e};return Object.entries(t).forEach(([r,s])=>{if(!i[r]){i[r]=s;return}if(r==="class"){const l=s?String(s).split(" "):[],c=i[r]?i[r].split(" "):[],h=l.filter(d=>!c.includes(d));i[r]=[...c,...h].join(" ")}else if(r==="style"){const l=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],c=i[r]?i[r].split(";").map(d=>d.trim()).filter(Boolean):[],h=new Map;c.forEach(d=>{const[p,m]=d.split(":").map(g=>g.trim());h.set(p,m)}),l.forEach(d=>{const[p,m]=d.split(":").map(g=>g.trim());h.set(p,m)}),i[r]=Array.from(h.entries()).map(([d,p])=>`${d}: ${p}`).join("; ")}else i[r]=s}),i},{})}function Lc(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,i)=>ut(t,i),{})}function cN(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Kv(n,e){return"style"in n?n:{...n,getAttrs:t=>{const i=n.getAttrs?n.getAttrs(t):n.attrs;if(i===!1)return!1;const r=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):cN(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...i,...r}}}}function Gv(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&lN(t)?!1:t!=null))}function uN(n,e){var t;const i=Hw(n),{nodeExtensions:r,markExtensions:s}=Ca(n),o=(t=r.find(h=>te(h,"topNode")))==null?void 0:t.name,l=Object.fromEntries(r.map(h=>{const d=i.filter(E=>E.type===h.name),p={name:h.name,options:h.options,storage:h.storage,editor:e},m=n.reduce((E,k)=>{const I=te(k,"extendNodeSchema",p);return{...E,...I?I(h):{}}},{}),g=Gv({...m,content:Be(te(h,"content",p)),marks:Be(te(h,"marks",p)),group:Be(te(h,"group",p)),inline:Be(te(h,"inline",p)),atom:Be(te(h,"atom",p)),selectable:Be(te(h,"selectable",p)),draggable:Be(te(h,"draggable",p)),code:Be(te(h,"code",p)),whitespace:Be(te(h,"whitespace",p)),linebreakReplacement:Be(te(h,"linebreakReplacement",p)),defining:Be(te(h,"defining",p)),isolating:Be(te(h,"isolating",p)),attrs:Object.fromEntries(d.map(E=>{var k,I;return[E.name,{default:(k=E?.attribute)==null?void 0:k.default,validate:(I=E?.attribute)==null?void 0:I.validate}]}))}),v=Be(te(h,"parseHTML",p));v&&(g.parseDOM=v.map(E=>Kv(E,d)));const w=te(h,"renderHTML",p);w&&(g.toDOM=E=>w({node:E,HTMLAttributes:Lc(E,d)}));const S=te(h,"renderText",p);return S&&(g.toText=S),[h.name,g]})),c=Object.fromEntries(s.map(h=>{const d=i.filter(S=>S.type===h.name),p={name:h.name,options:h.options,storage:h.storage,editor:e},m=n.reduce((S,E)=>{const k=te(E,"extendMarkSchema",p);return{...S,...k?k(h):{}}},{}),g=Gv({...m,inclusive:Be(te(h,"inclusive",p)),excludes:Be(te(h,"excludes",p)),group:Be(te(h,"group",p)),spanning:Be(te(h,"spanning",p)),code:Be(te(h,"code",p)),attrs:Object.fromEntries(d.map(S=>{var E,k;return[S.name,{default:(E=S?.attribute)==null?void 0:E.default,validate:(k=S?.attribute)==null?void 0:k.validate}]}))}),v=Be(te(h,"parseHTML",p));v&&(g.parseDOM=v.map(S=>Kv(S,d)));const w=te(h,"renderHTML",p);return w&&(g.toDOM=S=>w({mark:S,HTMLAttributes:Lc(S,d)})),[h.name,g]}));return new Tb({topNode:o,nodes:l,marks:c})}function hN(n){const e=n.filter((t,i)=>n.indexOf(t)!==i);return Array.from(new Set(e))}function vp(n){return n.sort((t,i)=>{const r=te(t,"priority")||100,s=te(i,"priority")||100;return r>s?-1:r<s?1:0})}function Vw(n){const e=vp(gp(n)),t=hN(e.map(i=>i.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),e}function Ww(n,e,t){const{from:i,to:r}=e,{blockSeparator:s=` `,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(i,r,(c,h,d,p)=>{var m;c.isBlock&&h>i&&(l+=s);const g=o?.[c.type.name];if(g)return d&&(l+=g({node:c,pos:h,parent:d,index:p,range:e})),!1;c.isText&&(l+=(m=c?.text)==null?void 0:m.slice(Math.max(i,h)-h,r-h))}),l}function Uw(n,e){const t={from:0,to:n.content.size};return Ww(n,t,e)}function bp(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function qi(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}function qw(n,e){const t=qi(e,n.schema),{from:i,to:r,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(i,r,c=>{o.push(...c.marks)});const l=o.find(c=>c.type.name===t.name);return l?{...l.attrs}:{}}function yt(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}function dN(n,e){const t=yt(e,n.schema),{from:i,to:r}=n.selection,s=[];n.doc.nodesBetween(i,r,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Mu(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Kw(n,e){const t=Mu(typeof e=="string"?e:e.name,n.schema);return t==="node"?dN(n,e):t==="mark"?qw(n,e):{}}function fN(n,e=JSON.stringify){const t={};return n.filter(i=>{const r=e(i);return Object.prototype.hasOwnProperty.call(t,r)?!1:t[r]=!0})}function pN(n){const e=fN(n);return e.length===1?e:e.filter((t,i)=>!e.filter((s,o)=>o!==i).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function Gw(n){const{mapping:e,steps:t}=n,i=[];return e.maps.forEach((r,s)=>{const o=[];if(r.ranges.length)r.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=t[s];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const h=e.slice(s).map(l,-1),d=e.slice(s).map(c),p=e.invert().map(h,-1),m=e.invert().map(d);i.push({oldRange:{from:p,to:m},newRange:{from:h,to:d}})})}),pN(i)}function wp(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Fc(n,e,t={strict:!0}){const i=Object.keys(e);return i.length?i.every(r=>t.strict?e[r]===n[r]:wp(e[r])?e[r].test(n[r]):e[r]===n[r]):!0}function jw(n,e,t={}){return n.find(i=>i.type===e&&Fc(Object.fromEntries(Object.keys(t).map(r=>[r,i.attrs[r]])),t))}function jv(n,e,t={}){return!!jw(n,e,t)}function Sp(n,e,t){var i;if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if((!r.node||!r.node.marks.some(d=>d.type===e))&&(r=n.parent.childBefore(n.parentOffset)),!r.node||!r.node.marks.some(d=>d.type===e)||(t=t||((i=r.node.marks[0])==null?void 0:i.attrs),!jw([...r.node.marks],e,t)))return;let o=r.index,l=n.start()+r.offset,c=o+1,h=l+r.node.nodeSize;for(;o>0&&jv([...n.parent.child(o-1).marks],e,t);)o-=1,l-=n.parent.child(o).nodeSize;for(;c<n.parent.childCount&&jv([...n.parent.child(c).marks],e,t);)h+=n.parent.child(c).nodeSize,c+=1;return{from:l,to:h}}function xp(n,e,t){const i=[];return n===e?t.resolve(n).marks().forEach(r=>{const s=t.resolve(n),o=Sp(s,r.type);o&&i.push({mark:r,...o})}):t.nodesBetween(n,e,(r,s)=>{!r||r?.nodeSize===void 0||i.push(...r.marks.map(o=>({from:s,to:s+r.nodeSize,mark:o})))}),i}var mN=(n,e,t,i=20)=>{const r=n.doc.resolve(t);let s=i,o=null;for(;s>0&&o===null;){const l=r.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function $d(n,e){return e.nodes[n]||e.marks[n]||null}function hc(n,e,t){return Object.fromEntries(Object.entries(t).filter(([i])=>{const r=n.find(s=>s.type===e&&s.name===i);return r?r.attribute.keepOnSplit:!1}))}var gN=(n,e=500)=>{let t="";const i=n.parentOffset;return n.parent.nodesBetween(Math.max(0,i-e),i,(r,s,o,l)=>{var c,h;const d=((h=(c=r.type.spec).toText)==null?void 0:h.call(c,{node:r,pos:s,parent:o,index:l}))||r.textContent||"%leaf%";t+=r.isAtom&&!r.isText?d:d.slice(0,Math.max(0,i-s))}),t};function Af(n,e,t={}){const{empty:i,ranges:r}=n.selection,s=e?qi(e,n.schema):null;if(i)return!!(n.storedMarks||n.selection.$from.marks()).filter(p=>s?s.name===p.type.name:!0).find(p=>Fc(p.attrs,t,{strict:!1}));let o=0;const l=[];if(r.forEach(({$from:p,$to:m})=>{const g=p.pos,v=m.pos;n.doc.nodesBetween(g,v,(w,S)=>{if(!w.isText&&!w.marks.length)return;const E=Math.max(g,S),k=Math.min(v,S+w.nodeSize),I=k-E;o+=I,l.push(...w.marks.map(R=>({mark:R,from:E,to:k})))})}),o===0)return!1;const c=l.filter(p=>s?s.name===p.mark.type.name:!0).filter(p=>Fc(p.mark.attrs,t,{strict:!1})).reduce((p,m)=>p+m.to-m.from,0),h=l.filter(p=>s?p.mark.type!==s&&p.mark.type.excludes(s):!0).reduce((p,m)=>p+m.to-m.from,0);return(c>0?c+h:c)>=o}function Tr(n,e,t={}){const{from:i,to:r,empty:s}=n.selection,o=e?yt(e,n.schema):null,l=[];n.doc.nodesBetween(i,r,(p,m)=>{if(p.isText)return;const g=Math.max(i,m),v=Math.min(r,m+p.nodeSize);l.push({node:p,from:g,to:v})});const c=r-i,h=l.filter(p=>o?o.name===p.node.type.name:!0).filter(p=>Fc(p.node.attrs,t,{strict:!1}));return s?!!h.length:h.reduce((p,m)=>p+m.to-m.from,0)>=c}function yN(n,e,t={}){if(!e)return Tr(n,null,t)||Af(n,null,t);const i=Mu(e,n.schema);return i==="node"?Tr(n,e,t):i==="mark"?Af(n,e,t):!1}var vN=(n,e)=>{const{$from:t,$to:i,$anchor:r}=n.selection;if(e){const s=Au(l=>l.type.name===e)(n.selection);if(!s)return!1;const o=n.doc.resolve(s.pos+1);return r.pos+1===o.end()}return!(i.parentOffset<i.parent.nodeSize-2||t.pos!==i.pos)},bN=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Xv(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Yv(n,e){const{nodeExtensions:t}=Ca(e),i=t.find(o=>o.name===n);if(!i)return!1;const r={name:i.name,options:i.options,storage:i.storage},s=Be(te(i,"group",r));return typeof s!="string"?!1:s.split(" ").includes("list")}function Ou(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var i;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((i=n.text)!=null?i:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let r=!0;return n.content.forEach(s=>{r!==!1&&(Ou(s,{ignoreWhitespace:t,checkChildren:e})||(r=!1))}),r}return!1}function Xw(n){return n instanceof ne}function Cp(n){return n instanceof fe}function Fi(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Yw(n,e,t){const r=n.state.doc.content.size,s=Fi(e,0,r),o=Fi(t,0,r),l=n.coordsAtPos(s),c=n.coordsAtPos(o,-1),h=Math.min(l.top,c.top),d=Math.max(l.bottom,c.bottom),p=Math.min(l.left,c.left),m=Math.max(l.right,c.right),g=m-p,v=d-h,E={top:h,bottom:d,left:p,right:m,width:g,height:v,x:p,y:h};return{...E,toJSON:()=>E}}function Jw(n,e=null){if(!e)return null;const t=oe.atStart(n),i=oe.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return i;const r=t.from,s=i.to;return e==="all"?fe.create(n,Fi(0,r,s),Fi(n.content.size,r,s)):fe.create(n,Fi(e,r,s),Fi(e,r,s))}function wN(n,e,t){const i=n.steps.length-1;if(i<e)return;const r=n.steps[i];if(!(r instanceof St||r instanceof xt))return;const s=n.mapping.maps[i];let o=0;s.forEach((l,c,h,d)=>{o===0&&(o=d)}),n.setSelection(oe.near(n.doc.resolve(o),t))}var Iu=class{constructor(n){this.find=n.find,this.handler=n.handler}},SN=(n,e)=>{if(wp(e))return e.exec(n);const t=e(n);if(!t)return null;const i=[t.text];return i.index=t.index,i.input=n,i.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(t.replaceWith)),i};function Wl(n){var e;const{editor:t,from:i,to:r,text:s,rules:o,plugin:l}=n,{view:c}=t;if(c.composing)return!1;const h=c.state.doc.resolve(i);if(h.parent.type.spec.code||(e=h.nodeBefore||h.nodeAfter)!=null&&e.marks.find(m=>m.type.spec.code))return!1;let d=!1;const p=gN(h)+s;return o.forEach(m=>{if(d)return;const g=SN(p,m.find);if(!g)return;const v=c.state.tr,w=Tu({state:c.state,transaction:v}),S={from:i-(g[0].length-s.length),to:r},{commands:E,chain:k,can:I}=new ku({editor:t,state:w});m.handler({state:w,range:S,match:g,commands:E,chain:k,can:I})===null||!v.steps.length||(v.setMeta(l,{transform:v,from:i,to:r,text:s}),c.dispatch(v),d=!0)}),d}function xN(n){const{editor:e,rules:t}=n,i=new Ye({state:{init(){return null},apply(r,s,o){const l=r.getMeta(i);if(l)return l;const c=r.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=yp(z.from(d),o.schema);const{from:p}=c,m=p+d.length;Wl({editor:e,from:p,to:m,text:d,rules:t,plugin:i})}),r.selectionSet||r.docChanged?null:s}},props:{handleTextInput(r,s,o,l){return Wl({editor:e,from:s,to:o,text:l,rules:t,plugin:i})},handleDOMEvents:{compositionend:r=>(setTimeout(()=>{const{$cursor:s}=r.state.selection;s&&Wl({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:i})}),!1)},handleKeyDown(r,s){if(s.key!=="Enter")return!1;const{$cursor:o}=r.state.selection;return o?Wl({editor:e,from:o.pos,to:o.pos,text:` `,rules:t,plugin:i}):!1}},isInputRules:!0});return i}function CN(n){return Object.prototype.toString.call(n).slice(8,-1)}function Ul(n){return CN(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Zw(n,e){const t={...n};return Ul(n)&&Ul(e)&&Object.keys(e).forEach(i=>{Ul(e[i])&&Ul(n[i])?t[i]=Zw(n[i],e[i]):t[i]=e[i]}),t}var Ep=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...Be(te(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Be(te(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>Zw(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},cs=class Qw extends Ep{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new Qw(t)}static handleExit({editor:e,mark:t}){const{tr:i}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const o=r.marks();if(!!!o.find(h=>h?.type.name===t.name))return!1;const c=o.find(h=>h?.type.name===t.name);return c&&i.removeStoredMark(c),i.insertText(" ",r.pos),e.view.dispatch(i),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function EN(n){return typeof n=="number"}var TN=class{constructor(n){this.find=n.find,this.handler=n.handler}},kN=(n,e,t)=>{if(wp(e))return[...n.matchAll(e)];const i=e(n,t);return i?i.map(r=>{const s=[r.text];return s.index=r.index,s.input=n,s.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(r.replaceWith)),s}):[]};function AN(n){const{editor:e,state:t,from:i,to:r,rule:s,pasteEvent:o,dropEvent:l}=n,{commands:c,chain:h,can:d}=new ku({editor:e,state:t}),p=[];return t.doc.nodesBetween(i,r,(g,v)=>{if(!g.isTextblock||g.type.spec.code)return;const w=Math.max(i,v),S=Math.min(r,v+g.content.size),E=g.textBetween(w-v,S-v,void 0,"");kN(E,s.find,o).forEach(I=>{if(I.index===void 0)return;const R=w+I.index+1,N=R+I[0].length,V={from:t.tr.mapping.map(R),to:t.tr.mapping.map(N)},U=s.handler({state:t,range:V,match:I,commands:c,chain:h,can:d,pasteEvent:o,dropEvent:l});p.push(U)})}),p.every(g=>g!==null)}var ql=null,MN=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function ON(n){const{editor:e,rules:t}=n;let i=null,r=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:p,to:m,rule:g,pasteEvt:v})=>{const w=d.tr,S=Tu({state:d,transaction:w});if(!(!AN({editor:e,state:S,from:Math.max(p-1,0),to:m.b-1,rule:g,pasteEvent:v,dropEvent:l})||!w.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return t.map(d=>new Ye({view(p){const m=v=>{var w;i=(w=p.dom.parentElement)!=null&&w.contains(v.target)?p.dom.parentElement:null,i&&(ql=e)},g=()=>{ql&&(ql=null)};return window.addEventListener("dragstart",m),window.addEventListener("dragend",g),{destroy(){window.removeEventListener("dragstart",m),window.removeEventListener("dragend",g)}}},props:{handleDOMEvents:{drop:(p,m)=>{if(s=i===p.dom.parentElement,l=m,!s){const g=ql;g?.isEditable&&setTimeout(()=>{const v=g.state.selection;v&&g.commands.deleteRange({from:v.from,to:v.to})},10)}return!1},paste:(p,m)=>{var g;const v=(g=m.clipboardData)==null?void 0:g.getData("text/html");return o=m,r=!!v?.includes("data-pm-slice"),!1}}},appendTransaction:(p,m,g)=>{const v=p[0],w=v.getMeta("uiEvent")==="paste"&&!r,S=v.getMeta("uiEvent")==="drop"&&!s,E=v.getMeta("applyPasteRules"),k=!!E;if(!w&&!S&&!k)return;if(k){let{text:N}=E;typeof N=="string"?N=N:N=yp(z.from(N),g.schema);const{from:V}=E,U=V+N.length,W=MN(N);return c({rule:d,state:g,from:V,to:{b:U},pasteEvt:W})}const I=m.doc.content.findDiffStart(g.doc.content),R=m.doc.content.findDiffEnd(g.doc.content);if(!(!EN(I)||!R||I===R.b))return c({rule:d,state:g,from:I,to:R,pasteEvt:o})}}))}var Du=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.extensions=Vw(n),this.schema=uN(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:$d(e.name,this.schema)},i=te(e,"addCommands",t);return i?{...n,...i()}:n},{})}get plugins(){const{editor:n}=this,e=vp([...this.extensions].reverse()),t=[],i=[],r=e.map(s=>{const o={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:n,type:$d(s.name,this.schema)},l=[],c=te(s,"addKeyboardShortcuts",o);let h={};if(s.type==="mark"&&te(s,"exitable",o)&&(h.ArrowRight=()=>cs.handleExit({editor:n,mark:s})),c){const v=Object.fromEntries(Object.entries(c()).map(([w,S])=>[w,()=>S({editor:n})]));h={...h,...v}}const d=LR(h);l.push(d);const p=te(s,"addInputRules",o);Xv(s,n.options.enableInputRules)&&p&&t.push(...p());const m=te(s,"addPasteRules",o);Xv(s,n.options.enablePasteRules)&&m&&i.push(...m());const g=te(s,"addProseMirrorPlugins",o);if(g){const v=g();l.push(...v)}return l}).flat();return[xN({editor:n,rules:t}),...ON({editor:n,rules:i}),...r]}get attributes(){return Hw(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=Ca(this.extensions);return Object.fromEntries(e.filter(t=>!!te(t,"addNodeView")).map(t=>{const i=this.attributes.filter(l=>l.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:yt(t.name,this.schema)},s=te(t,"addNodeView",r);if(!s)return[];const o=(l,c,h,d,p)=>{const m=Lc(l,i);return s()({node:l,view:c,getPos:h,decorations:d,innerDecorations:p,editor:n,extension:t,HTMLAttributes:m})};return[t.name,o]}))}get markViews(){const{editor:n}=this,{markExtensions:e}=Ca(this.extensions);return Object.fromEntries(e.filter(t=>!!te(t,"addMarkView")).map(t=>{const i=this.attributes.filter(l=>l.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:qi(t.name,this.schema)},s=te(t,"addMarkView",r);if(!s)return[];const o=(l,c,h)=>{const d=Lc(l,i);return s()({mark:l,view:c,inline:h,editor:n,extension:t,HTMLAttributes:d,updateAttributes:p=>{WP(l,n,p)}})};return[t.name,o]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const i={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:$d(e.name,this.schema)};e.type==="mark"&&((t=Be(te(e,"keepOnSplit",i)))==null||t)&&this.splittableMarks.push(e.name);const r=te(e,"onBeforeCreate",i),s=te(e,"onCreate",i),o=te(e,"onUpdate",i),l=te(e,"onSelectionUpdate",i),c=te(e,"onTransaction",i),h=te(e,"onFocus",i),d=te(e,"onBlur",i),p=te(e,"onDestroy",i);r&&this.editor.on("beforeCreate",r),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),h&&this.editor.on("focus",h),d&&this.editor.on("blur",d),p&&this.editor.on("destroy",p)})}};Du.resolve=Vw;Du.sort=vp;Du.flatten=gp;var IN={};Fw(IN,{ClipboardTextSerializer:()=>t1,Commands:()=>r1,Delete:()=>s1,Drop:()=>o1,Editable:()=>a1,FocusEvents:()=>c1,Keymap:()=>u1,Paste:()=>h1,Tabindex:()=>d1,focusEventsPluginKey:()=>l1});var at=class e1 extends Ep{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new e1(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},t1=at.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ye({key:new tt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:i,selection:r}=e,{ranges:s}=r,o=Math.min(...s.map(d=>d.$from.pos)),l=Math.max(...s.map(d=>d.$to.pos)),c=bp(t);return Ww(i,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),n1={};Fw(n1,{blur:()=>DN,clearContent:()=>_N,clearNodes:()=>RN,command:()=>NN,createParagraphNear:()=>PN,cut:()=>LN,deleteCurrentNode:()=>FN,deleteNode:()=>$N,deleteRange:()=>BN,deleteSelection:()=>zN,enter:()=>HN,exitCode:()=>VN,extendMarkRange:()=>WN,first:()=>UN,focus:()=>KN,forEach:()=>GN,insertContent:()=>jN,insertContentAt:()=>YN,joinBackward:()=>QN,joinDown:()=>ZN,joinForward:()=>eP,joinItemBackward:()=>tP,joinItemForward:()=>nP,joinTextblockBackward:()=>iP,joinTextblockForward:()=>rP,joinUp:()=>JN,keyboardShortcut:()=>oP,lift:()=>aP,liftEmptyBlock:()=>lP,liftListItem:()=>cP,newlineInCode:()=>uP,resetAttributes:()=>hP,scrollIntoView:()=>dP,selectAll:()=>fP,selectNodeBackward:()=>pP,selectNodeForward:()=>mP,selectParentNode:()=>gP,selectTextblockEnd:()=>yP,selectTextblockStart:()=>vP,setContent:()=>bP,setMark:()=>SP,setMeta:()=>xP,setNode:()=>CP,setNodeSelection:()=>EP,setTextSelection:()=>TP,sinkListItem:()=>kP,splitBlock:()=>AP,splitListItem:()=>MP,toggleList:()=>OP,toggleMark:()=>IP,toggleNode:()=>DP,toggleWrap:()=>_P,undoInputRule:()=>RP,unsetAllMarks:()=>NP,unsetMark:()=>PP,updateAttributes:()=>LP,wrapIn:()=>FP,wrapInList:()=>$P});var DN=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),_N=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),RN=()=>({state:n,tr:e,dispatch:t})=>{const{selection:i}=e,{ranges:r}=i;return t&&r.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:h,mapping:d}=e,p=h.resolve(d.map(c)),m=h.resolve(d.map(c+l.nodeSize)),g=p.blockRange(m);if(!g)return;const v=so(g);if(l.type.isTextblock){const{defaultType:w}=p.parent.contentMatchAt(p.index());e.setNodeMarkup(g.start,w)}(v||v===0)&&e.lift(g,v)})}),!0},NN=n=>e=>n(e),PN=()=>({state:n,dispatch:e})=>Rw(n,e),LN=(n,e)=>({editor:t,tr:i})=>{const{state:r}=t,s=r.doc.slice(n.from,n.to);i.deleteRange(n.from,n.to);const o=i.mapping.map(e);return i.insert(o,s.content),i.setSelection(new fe(i.doc.resolve(Math.max(o-1,0)))),!0},FN=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,i=t.$anchor.node();if(i.content.size>0)return!1;const r=n.selection.$anchor;for(let s=r.depth;s>0;s-=1)if(r.node(s).type===i.type){if(e){const l=r.before(s),c=r.after(s);n.delete(l,c).scrollIntoView()}return!0}return!1},$N=n=>({tr:e,state:t,dispatch:i})=>{const r=yt(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r){if(i){const c=s.before(o),h=s.after(o);e.delete(c,h).scrollIntoView()}return!0}return!1},BN=n=>({tr:e,dispatch:t})=>{const{from:i,to:r}=n;return t&&e.delete(i,r),!0},zN=()=>({state:n,dispatch:e})=>hp(n,e),HN=()=>({commands:n})=>n.keyboardShortcut("Enter"),VN=()=>({state:n,dispatch:e})=>VR(n,e),WN=(n,e={})=>({tr:t,state:i,dispatch:r})=>{const s=qi(n,i.schema),{doc:o,selection:l}=t,{$from:c,from:h,to:d}=l;if(r){const p=Sp(c,s,e);if(p&&p.from<=h&&p.to>=d){const m=fe.create(o,p.from,p.to);t.setSelection(m)}}return!0},UN=n=>e=>{const t=typeof n=="function"?n(e):n;for(let i=0;i<t.length;i+=1)if(t[i](e))return!0;return!1};function qN(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Tp(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var KN=(n=null,e={})=>({editor:t,view:i,tr:r,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(Tp()||qN())&&i.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(i.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(i.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!Cp(t.state.selection))return o(),!0;const l=Jw(r.doc,n)||t.state.selection,c=t.state.selection.eq(l);return s&&(c||r.setSelection(l),c&&r.storedMarks&&r.setStoredMarks(r.storedMarks),o()),!0},GN=(n,e)=>t=>n.every((i,r)=>e(i,{...t,index:r})),jN=(n,e)=>({tr:t,commands:i})=>i.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),XN=n=>!("type"in n),YN=(n,e,t)=>({tr:i,dispatch:r,editor:s})=>{var o;if(r){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const{selection:c}=s.state,h=E=>{s.emit("contentError",{editor:s,error:E,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{xa(e,s.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(E){h(E)}try{l=xa(e,s.schema,{parseOptions:d,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(E){return h(E),!1}let{from:p,to:m}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},g=!0,v=!0;if((XN(l)?l:[l]).forEach(E=>{E.check(),g=g?E.isText&&E.marks.length===0:!1,v=v?E.isBlock:!1}),p===m&&v){const{parent:E}=i.doc.resolve(p);E.isTextblock&&!E.type.spec.code&&!E.childCount&&(p-=1,m+=1)}let S;if(g){if(Array.isArray(e))S=e.map(E=>E.text||"").join("");else if(e instanceof z){let E="";e.forEach(k=>{k.text&&(E+=k.text)}),S=E}else typeof e=="object"&&e&&e.text?S=e.text:S=e;i.insertText(S,p,m)}else{S=l;const E=c.$from.parentOffset===0,k=c.$from.node().isText||c.$from.node().isTextblock,I=c.$from.node().content.size>0;E&&k&&I&&(p=Math.max(0,p-1)),i.replaceWith(p,m,S)}t.updateSelection&&wN(i,i.steps.length-1,-1),t.applyInputRules&&i.setMeta("applyInputRules",{from:p,text:S}),t.applyPasteRules&&i.setMeta("applyPasteRules",{from:p,text:S})}return!0},JN=()=>({state:n,dispatch:e})=>BR(n,e),ZN=()=>({state:n,dispatch:e})=>zR(n,e),QN=()=>({state:n,dispatch:e})=>kw(n,e),eP=()=>({state:n,dispatch:e})=>Iw(n,e),tP=()=>({state:n,dispatch:e,tr:t})=>{try{const i=bu(n.doc,n.selection.$from.pos,-1);return i==null?!1:(t.join(i,2),e&&e(t),!0)}catch{return!1}},nP=()=>({state:n,dispatch:e,tr:t})=>{try{const i=bu(n.doc,n.selection.$from.pos,1);return i==null?!1:(t.join(i,2),e&&e(t),!0)}catch{return!1}},iP=()=>({state:n,dispatch:e})=>FR(n,e),rP=()=>({state:n,dispatch:e})=>$R(n,e);function i1(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function sP(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let i,r,s,o;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))Tp()||i1()?o=!0:r=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return i&&(t=`Alt-${t}`),r&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var oP=n=>({editor:e,view:t,tr:i,dispatch:r})=>{const s=sP(n).split(/-(?!$)/),o=s.find(h=>!["Alt","Ctrl","Meta","Shift"].includes(h)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{t.someProp("handleKeyDown",h=>h(t,l))});return c?.steps.forEach(h=>{const d=h.map(i.mapping);d&&r&&i.maybeStep(d)}),!0},aP=(n,e={})=>({state:t,dispatch:i})=>{const r=yt(n,t.schema);return Tr(t,r,e)?HR(t,i):!1},lP=()=>({state:n,dispatch:e})=>Nw(n,e),cP=n=>({state:e,dispatch:t})=>{const i=yt(n,e.schema);return QR(i)(e,t)},uP=()=>({state:n,dispatch:e})=>_w(n,e);function Jv(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((i,r)=>(t.includes(r)||(i[r]=n[r]),i),{})}var hP=(n,e)=>({tr:t,state:i,dispatch:r})=>{let s=null,o=null;const l=Mu(typeof n=="string"?n:n.name,i.schema);return l?(l==="node"&&(s=yt(n,i.schema)),l==="mark"&&(o=qi(n,i.schema)),r&&t.selection.ranges.forEach(c=>{i.doc.nodesBetween(c.$from.pos,c.$to.pos,(h,d)=>{s&&s===h.type&&t.setNodeMarkup(d,void 0,Jv(h.attrs,e)),o&&h.marks.length&&h.marks.forEach(p=>{o===p.type&&t.addMark(d,d+h.nodeSize,o.create(Jv(p.attrs,e)))})})}),!0):!1},dP=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),fP=()=>({tr:n,dispatch:e})=>{if(e){const t=new xn(n.doc);n.setSelection(t)}return!0},pP=()=>({state:n,dispatch:e})=>Mw(n,e),mP=()=>({state:n,dispatch:e})=>Dw(n,e),gP=()=>({state:n,dispatch:e})=>qR(n,e),yP=()=>({state:n,dispatch:e})=>jR(n,e),vP=()=>({state:n,dispatch:e})=>GR(n,e),bP=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:i={}}={})=>({editor:r,tr:s,dispatch:o,commands:l})=>{const{doc:c}=s;if(i.preserveWhitespace!=="full"){const h=kf(n,r.schema,i,{errorOnInvalidContent:e??r.options.enableContentCheck});return o&&s.replaceWith(0,c.content.size,h).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:c.content.size},n,{parseOptions:i,errorOnInvalidContent:e??r.options.enableContentCheck})};function wP(n,e,t){var i;const{selection:r}=e;let s=null;if(Cp(r)&&(s=r.$cursor),s){const l=(i=n.storedMarks)!=null?i:s.marks();return!!t.isInSet(l)||!l.some(c=>c.type.excludes(t))}const{ranges:o}=r;return o.some(({$from:l,$to:c})=>{let h=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,c.pos,(d,p,m)=>{if(h)return!1;if(d.isInline){const g=!m||m.type.allowsMarkType(t),v=!!t.isInSet(d.marks)||!d.marks.some(w=>w.type.excludes(t));h=g&&v}return!h}),h})}var SP=(n,e={})=>({tr:t,state:i,dispatch:r})=>{const{selection:s}=t,{empty:o,ranges:l}=s,c=qi(n,i.schema);if(r)if(o){const h=qw(i,c);t.addStoredMark(c.create({...h,...e}))}else l.forEach(h=>{const d=h.$from.pos,p=h.$to.pos;i.doc.nodesBetween(d,p,(m,g)=>{const v=Math.max(g,d),w=Math.min(g+m.nodeSize,p);m.marks.find(E=>E.type===c)?m.marks.forEach(E=>{c===E.type&&t.addMark(v,w,c.create({...E.attrs,...e}))}):t.addMark(v,w,c.create(e))})});return wP(i,t,c)},xP=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),CP=(n,e={})=>({state:t,dispatch:i,chain:r})=>{const s=yt(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?r().command(({commands:l})=>qv(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>qv(s,{...o,...e})(l,i)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},EP=n=>({tr:e,dispatch:t})=>{if(t){const{doc:i}=e,r=Fi(n,0,i.content.size),s=ne.create(i,r);e.setSelection(s)}return!0},TP=n=>({tr:e,dispatch:t})=>{if(t){const{doc:i}=e,{from:r,to:s}=typeof n=="number"?{from:n,to:n}:n,o=fe.atStart(i).from,l=fe.atEnd(i).to,c=Fi(r,o,l),h=Fi(s,o,l),d=fe.create(i,c,h);e.setSelection(d)}return!0},kP=n=>({state:e,dispatch:t})=>{const i=yt(n,e.schema);return nN(i)(e,t)};function Zv(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const i=t.filter(r=>e?.includes(r.type.name));n.tr.ensureMarks(i)}}var AP=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:i,editor:r})=>{const{selection:s,doc:o}=e,{$from:l,$to:c}=s,h=r.extensionManager.attributes,d=hc(h,l.node().type.name,l.node().attrs);if(s instanceof ne&&s.node.isBlock)return!l.parentOffset||!zi(o,l.pos)?!1:(i&&(n&&Zv(t,r.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const p=c.parentOffset===c.parent.content.size,m=l.depth===0?void 0:sN(l.node(-1).contentMatchAt(l.indexAfter(-1)));let g=p&&m?[{type:m,attrs:d}]:void 0,v=zi(e.doc,e.mapping.map(l.pos),1,g);if(!g&&!v&&zi(e.doc,e.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(v=!0,g=m?[{type:m,attrs:d}]:void 0),i){if(v&&(s instanceof fe&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,g),m&&!p&&!l.parentOffset&&l.parent.type!==m)){const w=e.mapping.map(l.before()),S=e.doc.resolve(w);l.node(-1).canReplaceWith(S.index(),S.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}n&&Zv(t,r.extensionManager.splittableMarks),e.scrollIntoView()}return v},MP=(n,e={})=>({tr:t,state:i,dispatch:r,editor:s})=>{var o;const l=yt(n,i.schema),{$from:c,$to:h}=i.selection,d=i.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(h))return!1;const p=c.node(-1);if(p.type!==l)return!1;const m=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(r){let E=z.empty;const k=c.index(-1)?1:c.index(-2)?2:3;for(let W=c.depth-k;W>=c.depth-3;W-=1)E=z.from(c.node(W).copy(E));const I=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,R={...hc(m,c.node().type.name,c.node().attrs),...e},N=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(R))||void 0;E=E.append(z.from(l.createAndFill(null,N)||void 0));const V=c.before(c.depth-(k-1));t.replace(V,c.after(-I),new j(E,4-k,0));let U=-1;t.doc.nodesBetween(V,t.doc.content.size,(W,G)=>{if(U>-1)return!1;W.isTextblock&&W.content.size===0&&(U=G+1)}),U>-1&&t.setSelection(fe.near(t.doc.resolve(U))),t.scrollIntoView()}return!0}const g=h.pos===c.end()?p.contentMatchAt(0).defaultType:null,v={...hc(m,p.type.name,p.attrs),...e},w={...hc(m,c.node().type.name,c.node().attrs),...e};t.delete(c.pos,h.pos);const S=g?[{type:l,attrs:v},{type:g,attrs:w}]:[{type:l,attrs:v}];if(!zi(t.doc,c.pos,2))return!1;if(r){const{selection:E,storedMarks:k}=i,{splittableMarks:I}=s.extensionManager,R=k||E.$to.parentOffset&&E.$from.marks();if(t.split(c.pos,2,S).scrollIntoView(),!R||!r)return!0;const N=R.filter(V=>I.includes(V.type.name));t.ensureMarks(N)}return!0},Bd=(n,e)=>{const t=Au(o=>o.type===e)(n.selection);if(!t)return!0;const i=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(i===void 0)return!0;const r=n.doc.nodeAt(i);return t.node.type===r?.type&&Ar(n.doc,t.pos)&&n.join(t.pos),!0},zd=(n,e)=>{const t=Au(o=>o.type===e)(n.selection);if(!t)return!0;const i=n.doc.resolve(t.start).after(t.depth);if(i===void 0)return!0;const r=n.doc.nodeAt(i);return t.node.type===r?.type&&Ar(n.doc,i)&&n.join(i),!0},OP=(n,e,t,i={})=>({editor:r,tr:s,state:o,dispatch:l,chain:c,commands:h,can:d})=>{const{extensions:p,splittableMarks:m}=r.extensionManager,g=yt(n,o.schema),v=yt(e,o.schema),{selection:w,storedMarks:S}=o,{$from:E,$to:k}=w,I=E.blockRange(k),R=S||w.$to.parentOffset&&w.$from.marks();if(!I)return!1;const N=Au(V=>Yv(V.type.name,p))(w);if(I.depth>=1&&N&&I.depth-N.depth<=1){if(N.node.type===g)return h.liftListItem(v);if(Yv(N.node.type.name,p)&&g.validContent(N.node.content)&&l)return c().command(()=>(s.setNodeMarkup(N.pos,g),!0)).command(()=>Bd(s,g)).command(()=>zd(s,g)).run()}return!t||!R||!l?c().command(()=>d().wrapInList(g,i)?!0:h.clearNodes()).wrapInList(g,i).command(()=>Bd(s,g)).command(()=>zd(s,g)).run():c().command(()=>{const V=d().wrapInList(g,i),U=R.filter(W=>m.includes(W.type.name));return s.ensureMarks(U),V?!0:h.clearNodes()}).wrapInList(g,i).command(()=>Bd(s,g)).command(()=>zd(s,g)).run()},IP=(n,e={},t={})=>({state:i,commands:r})=>{const{extendEmptyMarkRange:s=!1}=t,o=qi(n,i.schema);return Af(i,o,e)?r.unsetMark(o,{extendEmptyMarkRange:s}):r.setMark(o,e)},DP=(n,e,t={})=>({state:i,commands:r})=>{const s=yt(n,i.schema),o=yt(e,i.schema),l=Tr(i,s,t);let c;return i.selection.$anchor.sameParent(i.selection.$head)&&(c=i.selection.$anchor.parent.attrs),l?r.setNode(o,c):r.setNode(s,{...c,...t})},_P=(n,e={})=>({state:t,commands:i})=>{const r=yt(n,t.schema);return Tr(t,r,e)?i.lift(r):i.wrapIn(r,e)},RP=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let i=0;i<t.length;i+=1){const r=t[i];let s;if(r.spec.isInputRules&&(s=r.getState(n))){if(e){const o=n.tr,l=s.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(s.text){const c=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,c))}else o.delete(s.from,s.to)}return!0}}return!1},NP=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:i,ranges:r}=t;return i||e&&r.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},PP=(n,e={})=>({tr:t,state:i,dispatch:r})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,c=qi(n,i.schema),{$from:h,empty:d,ranges:p}=l;if(!r)return!0;if(d&&o){let{from:m,to:g}=l;const v=(s=h.marks().find(S=>S.type===c))==null?void 0:s.attrs,w=Sp(h,c,v);w&&(m=w.from,g=w.to),t.removeMark(m,g,c)}else p.forEach(m=>{t.removeMark(m.$from.pos,m.$to.pos,c)});return t.removeStoredMark(c),!0},LP=(n,e={})=>({tr:t,state:i,dispatch:r})=>{let s=null,o=null;const l=Mu(typeof n=="string"?n:n.name,i.schema);return l?(l==="node"&&(s=yt(n,i.schema)),l==="mark"&&(o=qi(n,i.schema)),r&&t.selection.ranges.forEach(c=>{const h=c.$from.pos,d=c.$to.pos;let p,m,g,v;t.selection.empty?i.doc.nodesBetween(h,d,(w,S)=>{s&&s===w.type&&(g=Math.max(S,h),v=Math.min(S+w.nodeSize,d),p=S,m=w)}):i.doc.nodesBetween(h,d,(w,S)=>{S<h&&s&&s===w.type&&(g=Math.max(S,h),v=Math.min(S+w.nodeSize,d),p=S,m=w),S>=h&&S<=d&&(s&&s===w.type&&t.setNodeMarkup(S,void 0,{...w.attrs,...e}),o&&w.marks.length&&w.marks.forEach(E=>{if(o===E.type){const k=Math.max(S,h),I=Math.min(S+w.nodeSize,d);t.addMark(k,I,o.create({...E.attrs,...e}))}}))}),m&&(p!==void 0&&t.setNodeMarkup(p,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(w=>{o===w.type&&t.addMark(g,v,o.create({...w.attrs,...e}))}))}),!0):!1},FP=(n,e={})=>({state:t,dispatch:i})=>{const r=yt(n,t.schema);return XR(r,e)(t,i)},$P=(n,e={})=>({state:t,dispatch:i})=>{const r=yt(n,t.schema);return YR(r,e)(t,i)},r1=at.create({name:"commands",addCommands(){return{...n1}}}),s1=at.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,i,r;const s=()=>{var o,l,c,h;if((h=(c=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,n))!=null?h:n.getMeta("y-sync$"))return;const d=$w(n.before,[n,...e]);Gw(d).forEach(g=>{d.mapping.mapResult(g.oldRange.from).deletedAfter&&d.mapping.mapResult(g.oldRange.to).deletedBefore&&d.before.nodesBetween(g.oldRange.from,g.oldRange.to,(v,w)=>{const S=w+v.nodeSize-2,E=g.oldRange.from<=w&&S<=g.oldRange.to;this.editor.emit("delete",{type:"node",node:v,from:w,to:S,newFrom:d.mapping.map(w),newTo:d.mapping.map(S),deletedRange:g.oldRange,newRange:g.newRange,partial:!E,editor:this.editor,transaction:n,combinedTransform:d})})});const m=d.mapping;d.steps.forEach((g,v)=>{var w,S;if(g instanceof Yn){const E=m.slice(v).map(g.from,-1),k=m.slice(v).map(g.to),I=m.invert().map(E,-1),R=m.invert().map(k),N=(w=d.doc.nodeAt(E-1))==null?void 0:w.marks.some(U=>U.eq(g.mark)),V=(S=d.doc.nodeAt(k))==null?void 0:S.marks.some(U=>U.eq(g.mark));this.editor.emit("delete",{type:"mark",mark:g.mark,from:g.from,to:g.to,deletedRange:{from:I,to:R},newRange:{from:E,to:k},partial:!!(V||N),editor:this.editor,transaction:n,combinedTransform:d})}})};(r=(i=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:i.async)==null||r?setTimeout(s,0):s()}}),o1=at.create({name:"drop",addProseMirrorPlugins(){return[new Ye({key:new tt("tiptapDrop"),props:{handleDrop:(n,e,t,i)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:i})}}})]}}),a1=at.create({name:"editable",addProseMirrorPlugins(){return[new Ye({key:new tt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),l1=new tt("focusEvents"),c1=at.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new Ye({key:l1,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const i=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(i),!1},blur:(e,t)=>{n.isFocused=!1;const i=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(i),!1}}}})]}}),u1=at.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:h}=l,{empty:d,$anchor:p}=c,{pos:m,parent:g}=p,v=p.parent.isTextblock&&m>0?l.doc.resolve(m-1):p,w=v.parent.type.spec.isolating,S=p.pos-p.parentOffset,E=w&&v.parent.childCount===1?S===p.pos:oe.atStart(h).from===m;return!d||!g.type.isTextblock||g.textContent.length||!E||E&&p.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),i={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...i},s={...i,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Tp()||i1()?s:r},addProseMirrorPlugins(){return[new Ye({key:new tt("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(w=>w.getMeta("composition")))return;const i=n.some(w=>w.docChanged)&&!e.doc.eq(t.doc),r=n.some(w=>w.getMeta("preventClearDocument"));if(!i||r)return;const{empty:s,from:o,to:l}=e.selection,c=oe.atStart(e.doc).from,h=oe.atEnd(e.doc).to;if(s||!(o===c&&l===h)||!Ou(t.doc))return;const m=t.tr,g=Tu({state:t,transaction:m}),{commands:v}=new ku({editor:this.editor,state:g});if(v.clearNodes(),!!m.steps.length)return m}})]}}),h1=at.create({name:"paste",addProseMirrorPlugins(){return[new Ye({key:new tt("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),d1=at.create({name:"tabindex",addProseMirrorPlugins(){return[new Ye({key:new tt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),BP=class Fs{constructor(e,t,i=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=i,this.resolvedPos=e,this.editor=t,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,i=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,i=this.to-1}this.editor.commands.insertContentAt({from:t,to:i},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Fs(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Fs(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Fs(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,i)=>{const r=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=this.pos+i+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!r&&l.depth<=this.depth)return;const c=new Fs(l,this.editor,r,r?t:null);r&&(c.actualDepth=this.depth+1),e.push(new Fs(l,this.editor,r,r?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let i=null,r=this.parent;for(;r&&!i;){if(r.node.type.name===e)if(Object.keys(t).length>0){const s=r.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const c=o[l];if(s[c]!==t[c])break}}else i=r;r=r.parent}return i}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},i=!1){let r=[];if(!this.children||this.children.length===0)return r;const s=Object.keys(t);return this.children.forEach(o=>{i&&r.length>0||(o.node.type.name===e&&s.every(c=>t[c]===o.node.attrs[c])&&r.push(o),!(i&&r.length>0)&&(r=r.concat(o.querySelectorAll(e,t,i))))}),r}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},zP=`.ProseMirror { position: relative; } .ProseMirror { word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces; -webkit-font-variant-ligatures: none; font-variant-ligatures: none; font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ } .ProseMirror [contenteditable="false"] { white-space: normal; } .ProseMirror [contenteditable="false"] [contenteditable="true"] { white-space: pre-wrap; } .ProseMirror pre { white-space: pre-wrap; } img.ProseMirror-separator { display: inline !important; border: none !important; margin: 0 !important; width: 0 !important; height: 0 !important; } .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; margin: 0; } .ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid black; animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; } @keyframes ProseMirror-cursor-blink { to { visibility: hidden; } } .ProseMirror-hideselection *::selection { background: transparent; } .ProseMirror-hideselection *::-moz-selection { background: transparent; } .ProseMirror-hideselection * { caret-color: transparent; } .ProseMirror-focused .ProseMirror-gapcursor { display: block; }`;function HP(n,e,t){const i=document.querySelector("style[data-tiptap-style]");if(i!==null)return i;const r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.setAttribute("data-tiptap-style",""),r.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(r),r}var Qv=class extends rN{constructor(n={}){super(),this.css=null,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:i})=>{throw i},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:i,slice:r,moved:s})=>this.options.onDrop(i,r,s)),this.on("paste",({event:i,slice:r})=>this.options.onPaste(i,r)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=Jw(e,this.options.autofocus);this.editorState=Hs.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=HP(zP,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.editorState=this.state.apply(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=zw(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],i=this.state.reconfigure({plugins:t});return this.view.updateState(i),i}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(r=>{const s=typeof r=="string"?`${r}$`:r.key;t=t.filter(o=>!o.key.startsWith(s))}),e.length===t.length)return;const i=this.state.reconfigure({plugins:t});return this.view.updateState(i),i}createExtensionManager(){var n,e;const i=[...this.options.enableCoreExtensions?[a1,t1.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),r1,c1,u1,d1,o1,h1,s1].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new Du(i,this)}createCommandManager(){this.commandManager=new ku({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=kf(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=kf(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){var e;this.editorView=new Ew(n,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState});const t=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(t),this.createNodeViews(),this.prependClass(),this.injectCSS();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(h=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(h)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),i=!this.state.selection.eq(e.selection),r=t.includes(n),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!r)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),i&&this.emit("selectionUpdate",{editor:this,transaction:n});const o=t.findLast(h=>h.getMeta("focus")||h.getMeta("blur")),l=o?.getMeta("focus"),c=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),c&&this.emit("blur",{editor:this,event:c.event,transaction:o}),!(n.getMeta("preventUpdate")||!t.some(h=>h.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return Kw(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,i=typeof n=="string"?e:n;return yN(this.state,t,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return yp(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=` `,textSerializers:t={}}=n||{};return Uw(this.state.doc,{blockSeparator:e,textSerializers:{...bp(this.schema),...t}})}get isEmpty(){return Ou(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new BP(e,this)}get $doc(){return this.$pos(0)}};function eo(n){return new Iu({find:n.find,handler:({state:e,range:t,match:i})=>{const r=Be(n.getAttributes,void 0,i);if(r===!1||r===null)return null;const{tr:s}=e,o=i[i.length-1],l=i[0];if(o){const c=l.search(/\S/),h=t.from+l.indexOf(o),d=h+o.length;if(xp(t.from,t.to,e.doc).filter(g=>g.mark.type.excluded.find(w=>w===n.type&&w!==g.mark.type)).filter(g=>g.to>h).length)return null;d<t.to&&s.delete(d,t.to),h>t.from&&s.delete(t.from+c,h);const m=t.from+c+o.length;s.addMark(t.from+c,m,n.type.create(r||{})),s.removeStoredMark(n.type)}}})}function f1(n){return new Iu({find:n.find,handler:({state:e,range:t,match:i})=>{const r=Be(n.getAttributes,void 0,i)||{},{tr:s}=e,o=t.from;let l=t.to;const c=n.type.create(r);if(i[1]){const h=i[0].lastIndexOf(i[1]);let d=o+h;d>l?d=l:l=d+i[1].length;const p=i[0][i[0].length-1];s.insertText(p,o+i[0].length-1),s.replaceWith(d,l,c)}else if(i[0]){const h=n.type.isInline?o:o-1;s.insert(h,n.type.create(r)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()}})}function Mf(n){return new Iu({find:n.find,handler:({state:e,range:t,match:i})=>{const r=e.doc.resolve(t.from),s=Be(n.getAttributes,void 0,i)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function to(n){return new Iu({find:n.find,handler:({state:e,range:t,match:i,chain:r})=>{const s=Be(n.getAttributes,void 0,i)||{},o=e.tr.delete(t.from,t.to),c=o.doc.resolve(t.from).blockRange(),h=c&&Qf(c,n.type,s);if(!h)return null;if(o.wrap(c,h),n.keepMarks&&n.editor){const{selection:p,storedMarks:m}=e,{splittableMarks:g}=n.editor.extensionManager,v=m||p.$to.parentOffset&&p.$from.marks();if(v){const w=v.filter(S=>g.includes(S.type.name));o.ensureMarks(w)}}if(n.keepAttributes){const p=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";r().updateAttributes(p,s).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&Ar(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(i,d))&&o.join(t.from-1)}})}function VP(n,e){const{selection:t}=n,{$from:i}=t;if(t instanceof ne){const s=i.index();return i.parent.canReplaceWith(s,s+1,e)}let r=i.depth;for(;r>=0;){const s=i.index(r);if(i.node(r).contentMatchAt(s).matchType(e))return!0;r-=1}return!1}function WP(n,e,t={}){const{state:i}=e,{doc:r,tr:s}=i,o=n;r.descendants((l,c)=>{const h=s.mapping.map(c),d=s.mapping.map(c)+l.nodeSize;let p=null;if(l.marks.forEach(g=>{if(g!==o)return!1;p=g}),!p)return;let m=!1;if(Object.keys(t).forEach(g=>{t[g]!==p.attrs[g]&&(m=!0)}),m){const g=n.type.create({...n.attrs,...t});s.removeMark(h,d,n.type),s.addMark(h,d,g)}}),s.docChanged&&e.view.dispatch(s)}var ln=class p1 extends Ep{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new p1(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function as(n){return new TN({find:n.find,handler:({state:e,range:t,match:i,pasteEvent:r})=>{const s=Be(n.getAttributes,void 0,i,r);if(s===!1||s===null)return null;const{tr:o}=e,l=i[i.length-1],c=i[0];let h=t.to;if(l){const d=c.search(/\S/),p=t.from+c.indexOf(l),m=p+l.length;if(xp(t.from,t.to,e.doc).filter(v=>v.mark.type.excluded.find(S=>S===n.type&&S!==v.mark.type)).filter(v=>v.to>p).length)return null;m<t.to&&o.delete(m,t.to),p>t.from&&o.delete(t.from+d,p),h=t.from+d+l.length,o.addMark(t.from+d,h,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}var $c=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...i}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,i,t]},UP=/^\s*>\s$/,qP=ln.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return $c("blockquote",{...ut(this.options.HTMLAttributes,n),children:$c("slot",{})})},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[to({find:UP,type:this.type})]}}),KP=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,GP=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,jP=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,XP=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,YP=cs.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return $c("strong",{...ut(this.options.HTMLAttributes,n),children:$c("slot",{})})},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[eo({find:KP,type:this.type}),eo({find:jP,type:this.type})]},addPasteRules(){return[as({find:GP,type:this.type}),as({find:XP,type:this.type})]}}),JP=/(^|[^`])`([^`]+)`(?!`)/,ZP=/(^|[^`])`([^`]+)`(?!`)/g,QP=cs.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",ut(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[eo({find:JP,type:this.type})]},addPasteRules(){return[as({find:ZP,type:this.type})]}}),eL=/^```([a-z]+)?[\s\n]$/,tL=/^~~~([a-z]+)?[\s\n]$/,nL=ln.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",ut(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:i,empty:r}=t;if(!r||i.parent.type!==this.type)return!1;const s=i.parentOffset===i.parent.nodeSize-2,o=i.parent.textContent.endsWith(` `);return!s||!o?!1:n.chain().command(({tr:l})=>(l.delete(i.pos-2,i.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:i}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type||!(r.parentOffset===r.parent.nodeSize-2))return!1;const l=r.after();return l===void 0?!1:i.nodeAt(l)?n.commands.command(({tr:h})=>(h.setSelection(oe.near(i.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[Mf({find:eL,type:this.type,getAttributes:n=>({language:n[1]})}),Mf({find:tL,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new Ye({key:new tt("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),i=e.clipboardData.getData("vscode-editor-data"),r=i?JSON.parse(i):void 0,s=r?.mode;if(!t||!s)return!1;const{tr:o,schema:l}=n.state,c=l.text(t.replace(/\r\n?/g,` `));return o.replaceSelectionWith(this.type.create({language:s},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(fe.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),iL=ln.create({name:"doc",topNode:!0,content:"block+"}),rL=ln.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",ut(this.options.HTMLAttributes,n)]},renderText(){return` `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:i})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:r,storedMarks:s}=t;if(r.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=i.extensionManager,c=s||r.$to.parentOffset&&r.$from.marks();return e().insertContent({type:this.name}).command(({tr:h,dispatch:d})=>{if(d&&c&&o){const p=c.filter(m=>l.includes(m.type.name));h.ensureMarks(p)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),sL=ln.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ut(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Mf({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),oL=ln.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ut(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!VP(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:i}=t,r=n();return Xw(t)?r.insertContentAt(i.pos,{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:s,dispatch:o})=>{var l;if(o){const{$to:c}=s.selection,h=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(fe.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(ne.create(s.doc,c.pos)):s.setSelection(fe.create(s.doc,c.pos));else{const d=(l=c.parent.type.contentMatch.defaultType)==null?void 0:l.create();d&&(s.insert(h,d),s.setSelection(fe.create(s.doc,h+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[f1({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),aL=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,lL=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,cL=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,uL=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,hL=cs.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ut(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[eo({find:aL,type:this.type}),eo({find:cL,type:this.type})]},addPasteRules(){return[as({find:lL,type:this.type}),as({find:uL,type:this.type})]}});const dL="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",fL="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Of="numeric",If="ascii",Df="alpha",ca="asciinumeric",Go="alphanumeric",_f="domain",m1="emoji",pL="scheme",mL="slashscheme",Hd="whitespace";function gL(n,e){return n in e||(e[n]=[]),e[n]}function Xr(n,e,t){e[Of]&&(e[ca]=!0,e[Go]=!0),e[If]&&(e[ca]=!0,e[Df]=!0),e[ca]&&(e[Go]=!0),e[Df]&&(e[Go]=!0),e[Go]&&(e[_f]=!0),e[m1]&&(e[_f]=!0);for(const i in e){const r=gL(i,t);r.indexOf(n)<0&&r.push(n)}}function yL(n,e){const t={};for(const i in e)e[i].indexOf(n)>=0&&(t[i]=!0);return t}function on(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}on.groups={};on.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let i=0;i<e.jr.length;i++){const r=e.jr[i][0],s=e.jr[i][1];if(s&&r.test(n))return s}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,i){for(let r=0;r<n.length;r++)this.tt(n[r],e,t,i)},tr(n,e,t,i){i=i||on.groups;let r;return e&&e.j?r=e:(r=new on(e),t&&i&&Xr(e,t,i)),this.jr.push([n,r]),r},ts(n,e,t,i){let r=this;const s=n.length;if(!s)return r;for(let o=0;o<s-1;o++)r=r.tt(n[o]);return r.tt(n[s-1],e,t,i)},tt(n,e,t,i){i=i||on.groups;const r=this;if(e&&e.j)return r.j[n]=e,e;const s=e;let o,l=r.go(n);if(l?(o=new on,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new on,s){if(i)if(o.t&&typeof o.t=="string"){const c=Object.assign(yL(o.t,i),t);Xr(s,c,i)}else t&&Xr(s,t,i);o.t=s}return r.j[n]=o,o}};const Ee=(n,e,t,i,r)=>n.ta(e,t,i,r),it=(n,e,t,i,r)=>n.tr(e,t,i,r),e0=(n,e,t,i,r)=>n.ts(e,t,i,r),H=(n,e,t,i,r)=>n.tt(e,t,i,r),_i="WORD",Rf="UWORD",g1="ASCIINUMERICAL",y1="ALPHANUMERICAL",Ea="LOCALHOST",Nf="TLD",Pf="UTLD",dc="SCHEME",$s="SLASH_SCHEME",kp="NUM",Lf="WS",Ap="NL",ua="OPENBRACE",ha="CLOSEBRACE",Bc="OPENBRACKET",zc="CLOSEBRACKET",Hc="OPENPAREN",Vc="CLOSEPAREN",Wc="OPENANGLEBRACKET",Uc="CLOSEANGLEBRACKET",qc="FULLWIDTHLEFTPAREN",Kc="FULLWIDTHRIGHTPAREN",Gc="LEFTCORNERBRACKET",jc="RIGHTCORNERBRACKET",Xc="LEFTWHITECORNERBRACKET",Yc="RIGHTWHITECORNERBRACKET",Jc="FULLWIDTHLESSTHAN",Zc="FULLWIDTHGREATERTHAN",Qc="AMPERSAND",eu="APOSTROPHE",tu="ASTERISK",cr="AT",nu="BACKSLASH",iu="BACKTICK",ru="CARET",pr="COLON",Mp="COMMA",su="DOLLAR",si="DOT",ou="EQUALS",Op="EXCLAMATION",Rn="HYPHEN",da="PERCENT",au="PIPE",lu="PLUS",cu="POUND",fa="QUERY",Ip="QUOTE",v1="FULLWIDTHMIDDLEDOT",Dp="SEMI",oi="SLASH",pa="TILDE",uu="UNDERSCORE",b1="EMOJI",hu="SYM";var w1=Object.freeze({__proto__:null,ALPHANUMERICAL:y1,AMPERSAND:Qc,APOSTROPHE:eu,ASCIINUMERICAL:g1,ASTERISK:tu,AT:cr,BACKSLASH:nu,BACKTICK:iu,CARET:ru,CLOSEANGLEBRACKET:Uc,CLOSEBRACE:ha,CLOSEBRACKET:zc,CLOSEPAREN:Vc,COLON:pr,COMMA:Mp,DOLLAR:su,DOT:si,EMOJI:b1,EQUALS:ou,EXCLAMATION:Op,FULLWIDTHGREATERTHAN:Zc,FULLWIDTHLEFTPAREN:qc,FULLWIDTHLESSTHAN:Jc,FULLWIDTHMIDDLEDOT:v1,FULLWIDTHRIGHTPAREN:Kc,HYPHEN:Rn,LEFTCORNERBRACKET:Gc,LEFTWHITECORNERBRACKET:Xc,LOCALHOST:Ea,NL:Ap,NUM:kp,OPENANGLEBRACKET:Wc,OPENBRACE:ua,OPENBRACKET:Bc,OPENPAREN:Hc,PERCENT:da,PIPE:au,PLUS:lu,POUND:cu,QUERY:fa,QUOTE:Ip,RIGHTCORNERBRACKET:jc,RIGHTWHITECORNERBRACKET:Yc,SCHEME:dc,SEMI:Dp,SLASH:oi,SLASH_SCHEME:$s,SYM:hu,TILDE:pa,TLD:Nf,UNDERSCORE:uu,UTLD:Pf,UWORD:Rf,WORD:_i,WS:Lf});const Ii=/[a-z]/,Po=new RegExp("\\p{L}","u"),Vd=new RegExp("\\p{Emoji}","u"),Di=/\d/,Wd=/\s/,t0="\r",Ud=` `,vL="️",bL="",qd="";let Kl=null,Gl=null;function wL(n=[]){const e={};on.groups=e;const t=new on;Kl==null&&(Kl=n0(dL)),Gl==null&&(Gl=n0(fL)),H(t,"'",eu),H(t,"{",ua),H(t,"}",ha),H(t,"[",Bc),H(t,"]",zc),H(t,"(",Hc),H(t,")",Vc),H(t,"<",Wc),H(t,">",Uc),H(t,"(",qc),H(t,")",Kc),H(t,"「",Gc),H(t,"」",jc),H(t,"『",Xc),H(t,"』",Yc),H(t,"<",Jc),H(t,">",Zc),H(t,"&",Qc),H(t,"*",tu),H(t,"@",cr),H(t,"`",iu),H(t,"^",ru),H(t,":",pr),H(t,",",Mp),H(t,"$",su),H(t,".",si),H(t,"=",ou),H(t,"!",Op),H(t,"-",Rn),H(t,"%",da),H(t,"|",au),H(t,"+",lu),H(t,"#",cu),H(t,"?",fa),H(t,'"',Ip),H(t,"/",oi),H(t,";",Dp),H(t,"~",pa),H(t,"_",uu),H(t,"\\",nu),H(t,"・",v1);const i=it(t,Di,kp,{[Of]:!0});it(i,Di,i);const r=it(i,Ii,g1,{[ca]:!0}),s=it(i,Po,y1,{[Go]:!0}),o=it(t,Ii,_i,{[If]:!0});it(o,Di,r),it(o,Ii,o),it(r,Di,r),it(r,Ii,r);const l=it(t,Po,Rf,{[Df]:!0});it(l,Ii),it(l,Di,s),it(l,Po,l),it(s,Di,s),it(s,Ii),it(s,Po,s);const c=H(t,Ud,Ap,{[Hd]:!0}),h=H(t,t0,Lf,{[Hd]:!0}),d=it(t,Wd,Lf,{[Hd]:!0});H(t,qd,d),H(h,Ud,c),H(h,qd,d),it(h,Wd,d),H(d,t0),H(d,Ud),it(d,Wd,d),H(d,qd,d);const p=it(t,Vd,b1,{[m1]:!0});H(p,"#"),it(p,Vd,p),H(p,vL,p);const m=H(p,bL);H(m,"#"),it(m,Vd,p);const g=[[Ii,o],[Di,r]],v=[[Ii,null],[Po,l],[Di,s]];for(let w=0;w<Kl.length;w++)rr(t,Kl[w],Nf,_i,g);for(let w=0;w<Gl.length;w++)rr(t,Gl[w],Pf,Rf,v);Xr(Nf,{tld:!0,ascii:!0},e),Xr(Pf,{utld:!0,alpha:!0},e),rr(t,"file",dc,_i,g),rr(t,"mailto",dc,_i,g),rr(t,"http",$s,_i,g),rr(t,"https",$s,_i,g),rr(t,"ftp",$s,_i,g),rr(t,"ftps",$s,_i,g),Xr(dc,{scheme:!0,ascii:!0},e),Xr($s,{slashscheme:!0,ascii:!0},e),n=n.sort((w,S)=>w[0]>S[0]?1:-1);for(let w=0;w<n.length;w++){const S=n[w][0],k=n[w][1]?{[pL]:!0}:{[mL]:!0};S.indexOf("-")>=0?k[_f]=!0:Ii.test(S)?Di.test(S)?k[ca]=!0:k[If]=!0:k[Of]=!0,e0(t,S,S,k)}return e0(t,"localhost",Ea,{ascii:!0}),t.jd=new on(hu),{start:t,tokens:Object.assign({groups:e},w1)}}function S1(n,e){const t=SL(e.replace(/[A-Z]/g,l=>l.toLowerCase())),i=t.length,r=[];let s=0,o=0;for(;o<i;){let l=n,c=null,h=0,d=null,p=-1,m=-1;for(;o<i&&(c=l.go(t[o]));)l=c,l.accepts()?(p=0,m=0,d=l):p>=0&&(p+=t[o].length,m++),h+=t[o].length,s+=t[o].length,o++;s-=p,o-=m,h-=p,r.push({t:d.t,v:e.slice(s-h,s),s:s-h,e:s})}return r}function SL(n){const e=[],t=n.length;let i=0;for(;i<t;){let r=n.charCodeAt(i),s,o=r<55296||r>56319||i+1===t||(s=n.charCodeAt(i+1))<56320||s>57343?n[i]:n.slice(i,i+2);e.push(o),i+=o.length}return e}function rr(n,e,t,i,r){let s;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];n.j[c]?s=n.j[c]:(s=new on(i),s.jr=r.slice(),n.j[c]=s),n=s}return s=new on(t),s.jr=r.slice(),n.j[e[o-1]]=s,s}function n0(n){const e=[],t=[];let i=0,r="0123456789";for(;i<n.length;){let s=0;for(;r.indexOf(n[i+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(i,i+s),10);o>0;o--)t.pop();i+=s}else t.push(n[i]),i++}return e}const Ta={defaultProtocol:"http",events:null,format:i0,formatHref:i0,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function _p(n,e=null){let t=Object.assign({},Ta);n&&(t=Object.assign(t,n instanceof _p?n.o:n));const i=t.ignoreTags,r=[];for(let s=0;s<i.length;s++)r.push(i[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=r}_p.prototype={o:Ta,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const i=e!=null;let r=this.o[n];return r&&(typeof r=="object"?(r=t.t in r?r[t.t]:Ta[n],typeof r=="function"&&i&&(r=r(e,t))):typeof r=="function"&&i&&(r=r(e,t.t,t)),r)},getObj(n,e,t){let i=this.o[n];return typeof i=="function"&&e!=null&&(i=i(e,t.t,t)),i},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function i0(n){return n}function x1(n,e){this.t="token",this.v=n,this.tk=e}x1.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),i=n.get("format",e,this);return t&&i.length>t?i.substring(0,t)+"…":i},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Ta.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),i=n.get("formatHref",t,this),r=n.get("tagName",t,e),s=this.toFormattedString(n),o={},l=n.get("className",t,e),c=n.get("target",t,e),h=n.get("rel",t,e),d=n.getObj("attributes",t,e),p=n.getObj("events",t,e);return o.href=i,l&&(o.class=l),c&&(o.target=c),h&&(o.rel=h),d&&Object.assign(o,d),{tagName:r,attributes:o,content:s,eventListeners:p}}};function _u(n,e){class t extends x1{constructor(r,s){super(r,s),this.t=n}}for(const i in e)t.prototype[i]=e[i];return t.t=n,t}const r0=_u("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),s0=_u("text"),xL=_u("nl"),jl=_u("url",{isLink:!0,toHref(n=Ta.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Ea&&n[1].t===pr}}),_n=n=>new on(n);function CL({groups:n}){const e=n.domain.concat([Qc,tu,cr,nu,iu,ru,su,ou,Rn,kp,da,au,lu,cu,oi,hu,pa,uu]),t=[eu,pr,Mp,si,Op,da,fa,Ip,Dp,Wc,Uc,ua,ha,zc,Bc,Hc,Vc,qc,Kc,Gc,jc,Xc,Yc,Jc,Zc],i=[Qc,eu,tu,nu,iu,ru,su,ou,Rn,ua,ha,da,au,lu,cu,fa,oi,hu,pa,uu],r=_n(),s=H(r,pa);Ee(s,i,s),Ee(s,n.domain,s);const o=_n(),l=_n(),c=_n();Ee(r,n.domain,o),Ee(r,n.scheme,l),Ee(r,n.slashscheme,c),Ee(o,i,s),Ee(o,n.domain,o);const h=H(o,cr);H(s,cr,h),H(l,cr,h),H(c,cr,h);const d=H(s,si);Ee(d,i,s),Ee(d,n.domain,s);const p=_n();Ee(h,n.domain,p),Ee(p,n.domain,p);const m=H(p,si);Ee(m,n.domain,p);const g=_n(r0);Ee(m,n.tld,g),Ee(m,n.utld,g),H(h,Ea,g);const v=H(p,Rn);H(v,Rn,v),Ee(v,n.domain,p),Ee(g,n.domain,p),H(g,si,m),H(g,Rn,v);const w=H(g,pr);Ee(w,n.numeric,r0);const S=H(o,Rn),E=H(o,si);H(S,Rn,S),Ee(S,n.domain,o),Ee(E,i,s),Ee(E,n.domain,o);const k=_n(jl);Ee(E,n.tld,k),Ee(E,n.utld,k),Ee(k,n.domain,o),Ee(k,i,s),H(k,si,E),H(k,Rn,S),H(k,cr,h);const I=H(k,pr),R=_n(jl);Ee(I,n.numeric,R);const N=_n(jl),V=_n();Ee(N,e,N),Ee(N,t,V),Ee(V,e,N),Ee(V,t,V),H(k,oi,N),H(R,oi,N);const U=H(l,pr),W=H(c,pr),G=H(W,oi),Y=H(G,oi);Ee(l,n.domain,o),H(l,si,E),H(l,Rn,S),Ee(c,n.domain,o),H(c,si,E),H(c,Rn,S),Ee(U,n.domain,N),H(U,oi,N),H(U,fa,N),Ee(Y,n.domain,N),Ee(Y,e,N),H(Y,oi,N);const le=[[ua,ha],[Bc,zc],[Hc,Vc],[Wc,Uc],[qc,Kc],[Gc,jc],[Xc,Yc],[Jc,Zc]];for(let ke=0;ke<le.length;ke++){const[we,pe]=le[ke],_e=H(N,we);H(V,we,_e),H(_e,pe,N);const de=_n(jl);Ee(_e,e,de);const ce=_n();Ee(_e,t),Ee(de,e,de),Ee(de,t,ce),Ee(ce,e,de),Ee(ce,t,ce),H(de,pe,N),H(ce,pe,N)}return H(r,Ea,k),H(r,Ap,xL),{start:r,tokens:w1}}function EL(n,e,t){let i=t.length,r=0,s=[],o=[];for(;r<i;){let l=n,c=null,h=null,d=0,p=null,m=-1;for(;r<i&&!(c=l.go(t[r].t));)o.push(t[r++]);for(;r<i&&(h=c||l.go(t[r].t));)c=null,l=h,l.accepts()?(m=0,p=l):m>=0&&m++,r++,d++;if(m<0)r-=d,r<i&&(o.push(t[r]),r++);else{o.length>0&&(s.push(Kd(s0,e,o)),o=[]),r-=m,d-=m;const g=p.t,v=t.slice(r-d,r);s.push(Kd(g,e,v))}}return o.length>0&&s.push(Kd(s0,e,o)),s}function Kd(n,e,t){const i=t[0].s,r=t[t.length-1].e,s=e.slice(i,r);return new n(s,t)}const TL=typeof console<"u"&&console&&console.warn||(()=>{}),kL="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",qe={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function AL(){return on.groups={},qe.scanner=null,qe.parser=null,qe.tokenQueue=[],qe.pluginQueue=[],qe.customSchemes=[],qe.initialized=!1,qe}function o0(n,e=!1){if(qe.initialized&&TL(`linkifyjs: already initialized - will not register custom scheme "${n}" ${kL}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" 3. "-" cannot repeat`);qe.customSchemes.push([n,e])}function ML(){qe.scanner=wL(qe.customSchemes);for(let n=0;n<qe.tokenQueue.length;n++)qe.tokenQueue[n][1]({scanner:qe.scanner});qe.parser=CL(qe.scanner.tokens);for(let n=0;n<qe.pluginQueue.length;n++)qe.pluginQueue[n][1]({scanner:qe.scanner,parser:qe.parser});return qe.initialized=!0,qe}function Rp(n){return qe.initialized||ML(),EL(qe.parser.start,n,S1(qe.scanner.start,n))}Rp.scan=S1;function C1(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const i=new _p(t),r=Rp(n),s=[];for(let o=0;o<r.length;o++){const l=r[o];l.isLink&&(!e||l.t===e)&&i.check(l)&&s.push(l.toFormattedObject(i))}return s}var Np="[\0- -\u2029 ]",OL=new RegExp(Np),IL=new RegExp(`${Np}$`),DL=new RegExp(Np,"g");function _L(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function RL(n){return new Ye({key:new tt("autolink"),appendTransaction:(e,t,i)=>{const r=e.some(h=>h.docChanged)&&!t.doc.eq(i.doc),s=e.some(h=>h.getMeta("preventAutolink"));if(!r||s)return;const{tr:o}=i,l=$w(t.doc,[...e]);if(Gw(l).forEach(({newRange:h})=>{const d=oN(i.doc,h,g=>g.isTextblock);let p,m;if(d.length>1)p=d[0],m=i.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ");else if(d.length){const g=i.doc.textBetween(h.from,h.to," "," ");if(!IL.test(g))return;p=d[0],m=i.doc.textBetween(p.pos,h.to,void 0," ")}if(p&&m){const g=m.split(OL).filter(Boolean);if(g.length<=0)return!1;const v=g[g.length-1],w=p.pos+m.lastIndexOf(v);if(!v)return!1;const S=Rp(v).map(E=>E.toObject(n.defaultProtocol));if(!_L(S))return!1;S.filter(E=>E.isLink).map(E=>({...E,from:w+E.start+1,to:w+E.end+1})).filter(E=>i.schema.marks.code?!i.doc.rangeHasMark(E.from,E.to,i.schema.marks.code):!0).filter(E=>n.validate(E.value)).filter(E=>n.shouldAutoLink(E.value)).forEach(E=>{xp(E.from,E.to,i.doc).some(k=>k.mark.type===n.type)||o.addMark(E.from,E.to,n.type.create({href:E.href}))})}}),!!o.steps.length)return o}})}function NL(n){return new Ye({key:new tt("handleClickLink"),props:{handleClick:(e,t,i)=>{var r,s;if(i.button!==0||!e.editable)return!1;let o=null;if(i.target instanceof HTMLAnchorElement)o=i.target;else{let d=i.target;const p=[];for(;d.nodeName!=="DIV";)p.push(d),d=d.parentNode;o=p.find(m=>m.nodeName==="A")}if(!o)return!1;const l=Kw(e.state,n.type.name),c=(r=o?.href)!=null?r:l.href,h=(s=o?.target)!=null?s:l.target;return n.enableClickSelection&&n.editor.commands.extendMarkRange(n.type.name),o&&c?(window.open(c,h),!0):!1}}})}function PL(n){return new Ye({key:new tt("handlePasteLink"),props:{handlePaste:(e,t,i)=>{const{state:r}=e,{selection:s}=r,{empty:o}=s;if(o)return!1;let l="";i.content.forEach(h=>{l+=h.textContent});const c=C1(l,{defaultProtocol:n.defaultProtocol}).find(h=>h.isLink&&h.value===l);return!l||!c?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function Vr(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(i=>{const r=typeof i=="string"?i:i.scheme;r&&t.push(r)}),!n||n.replace(DL,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var LL=cs.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){o0(n);return}o0(n.scheme,n.optionalSlashes)})},onDestroy(){AL()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Vr(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Vr(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Vr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ut(this.options.HTMLAttributes,n),0]:["a",ut(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:i=>!!Vr(i,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:i=>!!Vr(i,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[as({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:i}=this.options,r=C1(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!Vr(o,t),protocols:t,defaultProtocol:i}));r.length&&r.forEach(s=>e.push({text:s.value,data:{href:s.href},index:s.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(RL({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:i=>this.options.isAllowedUri(i,{defaultValidate:r=>!!Vr(r,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(NL({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(PL({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),FL=Object.defineProperty,$L=(n,e)=>{for(var t in e)FL(n,t,{get:e[t],enumerable:!0})},BL="listItem",a0="textStyle",l0=/^\s*([-+*])\s$/,E1=ln.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",ut(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(BL,this.editor.getAttributes(a0)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=to({find:l0,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=to({find:l0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(a0),editor:this.editor})),[n]}}),T1=ln.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",ut(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),zL={};$L(zL,{findListItemPos:()=>Na,getNextListDepth:()=>Pp,handleBackspace:()=>Ff,handleDelete:()=>$f,hasListBefore:()=>k1,hasListItemAfter:()=>HL,hasListItemBefore:()=>A1,listItemHasSubList:()=>M1,nextListIsDeeper:()=>O1,nextListIsHigher:()=>I1});var Na=(n,e)=>{const{$from:t}=e.selection,i=yt(n,e.schema);let r=null,s=t.depth,o=t.pos,l=null;for(;s>0&&l===null;)r=t.node(s),r.type===i?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},Pp=(n,e)=>{const t=Na(n,e);if(!t)return!1;const[,i]=mN(e,n,t.$pos.pos+4);return i},k1=(n,e,t)=>{const{$anchor:i}=n.selection,r=Math.max(0,i.pos-2),s=n.doc.resolve(r).node();return!(!s||!t.includes(s.type.name))},A1=(n,e)=>{var t;const{$anchor:i}=e.selection,r=e.doc.resolve(i.pos-2);return!(r.index()===0||((t=r.nodeBefore)==null?void 0:t.type.name)!==n)},M1=(n,e,t)=>{if(!t)return!1;const i=yt(n,e.schema);let r=!1;return t.descendants(s=>{s.type===i&&(r=!0)}),r},Ff=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Tr(n.state,e)&&k1(n.state,e,t)){const{$anchor:l}=n.state.selection,c=n.state.doc.resolve(l.before()-1),h=[];c.node().descendants((m,g)=>{m.type.name===e&&h.push({node:m,pos:g})});const d=h.at(-1);if(!d)return!1;const p=n.state.doc.resolve(c.start()+d.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},p.end()).joinForward().run()}if(!Tr(n.state,e)||!bN(n.state))return!1;const i=Na(e,n.state);if(!i)return!1;const s=n.state.doc.resolve(i.$pos.pos-2).node(i.depth),o=M1(e,n.state,s);return A1(e,n.state)&&!o?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},O1=(n,e)=>{const t=Pp(n,e),i=Na(n,e);return!i||!t?!1:t>i.depth},I1=(n,e)=>{const t=Pp(n,e),i=Na(n,e);return!i||!t?!1:t<i.depth},$f=(n,e)=>{if(!Tr(n.state,e)||!vN(n.state,e))return!1;const{selection:t}=n.state,{$from:i,$to:r}=t;return!t.empty&&i.sameParent(r)?!1:O1(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():I1(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},HL=(n,e)=>{var t;const{$anchor:i}=e.selection,r=e.doc.resolve(i.pos-i.parentOffset-2);return!(r.index()===r.parent.childCount-1||((t=r.nodeAfter)==null?void 0:t.type.name)!==n)},D1=at.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&$f(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&$f(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:i})=>{n.state.schema.nodes[t]!==void 0&&Ff(n,t,i)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:i})=>{n.state.schema.nodes[t]!==void 0&&Ff(n,t,i)&&(e=!0)}),e}}}}),VL="listItem",c0="textStyle",u0=/^(\d+)\.\s$/,_1=ln.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",ut(this.options.HTMLAttributes,t),0]:["ol",ut(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(VL,this.editor.getAttributes(c0)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=to({find:u0,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=to({find:u0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(c0)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),WL=/^\s*(\[([( |x])?\])\s$/,UL=ln.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",ut(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:i})=>{const r=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),h=d=>{var p,m;l.ariaLabel=((m=(p=this.options.a11y)==null?void 0:p.checkboxLabel)==null?void 0:m.call(p,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return h(n),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!i.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:p}=d.target;i.isEditable&&typeof t=="function"&&i.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const g=t();if(typeof g!="number")return!1;const v=m.doc.nodeAt(g);return m.setNodeMarkup(g,void 0,{...v?.attrs,checked:p}),!0}).run(),!i.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,p)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,p])=>{r.setAttribute(d,p)}),r.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,s.append(l,o),r.append(s,c),Object.entries(e).forEach(([d,p])=>{r.setAttribute(d,p)}),{dom:r,contentDOM:c,update:d=>d.type!==this.type?!1:(r.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,h(d),!0)}}},addInputRules(){return[to({find:WL,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),qL=ln.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",ut(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});at.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(E1.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(T1.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(D1.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(_1.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(UL.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(qL.configure(this.options.taskList)),n}});var KL=ln.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ut(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),GL=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,jL=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,XL=cs.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ut(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[eo({find:GL,type:this.type})]},addPasteRules(){return[as({find:jL,type:this.type})]}}),YL=ln.create({name:"text",group:"inline"}),JL=cs.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ut(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function ZL(n={}){return new Ye({view(e){return new QL(e,n)}})}class QL{constructor(e,t){var i;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(i=t.width)!==null&&i!==void 0?i:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let s=o=>{this[r](o)};return e.dom.addEventListener(r,s),{name:r,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,i,r=this.editorView.dom,s=r.getBoundingClientRect(),o=s.width/r.offsetWidth,l=s.height/r.offsetHeight;if(t){let p=e.nodeBefore,m=e.nodeAfter;if(p||m){let g=this.editorView.nodeDOM(this.cursorPos-(p?p.nodeSize:0));if(g){let v=g.getBoundingClientRect(),w=p?v.bottom:v.top;p&&m&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let S=this.width/2*l;i={left:v.left,right:v.right,top:w-S,bottom:w+S}}}}if(!i){let p=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*o;i={left:p.left-m,right:p.left+m,top:p.top,bottom:p.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let h,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")h=-pageXOffset,d=-pageYOffset;else{let p=c.getBoundingClientRect(),m=p.width/c.offsetWidth,g=p.height/c.offsetHeight;h=p.left-c.scrollLeft*m,d=p.top-c.scrollTop*g}this.element.style.left=(i.left-h)/o+"px",this.element.style.top=(i.top-d)/l+"px",this.element.style.width=(i.right-i.left)/o+"px",this.element.style.height=(i.bottom-i.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),i=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=i&&i.type.spec.disableDropCursor,s=typeof r=="function"?r(this.editorView,t,e):r;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Lb(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ot extends oe{constructor(e){super(e,e)}map(e,t){let i=e.resolve(t.map(this.head));return ot.valid(i)?new ot(i):oe.near(i)}content(){return j.empty}eq(e){return e instanceof ot&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ot(e.resolve(t.pos))}getBookmark(){return new Lp(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!e2(e)||!t2(e))return!1;let i=t.type.spec.allowGapCursor;if(i!=null)return i;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,i=!1){e:for(;;){if(!i&&ot.valid(e))return e;let r=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;r+=t;let c=e.doc.resolve(r);if(ot.valid(c))return c}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!ne.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),i=!1;continue e}break}s=o,r+=t;let l=e.doc.resolve(r);if(ot.valid(l))return l}return null}}}ot.prototype.visible=!1;ot.findFrom=ot.findGapCursorFrom;oe.jsonID("gapcursor",ot);class Lp{constructor(e){this.pos=e}map(e){return new Lp(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ot.valid(t)?new ot(t):oe.near(t)}}function e2(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),i=n.node(e);if(t==0){if(i.type.spec.isolating)return!0;continue}for(let r=i.child(t-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||r.isAtom||r.type.spec.isolating)return!0;if(r.inlineContent)return!1}}return!0}function t2(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),i=n.node(e);if(t==i.childCount){if(i.type.spec.isolating)return!0;continue}for(let r=i.child(t);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||r.isAtom||r.type.spec.isolating)return!0;if(r.inlineContent)return!1}}return!0}function n2(){return new Ye({props:{decorations:o2,createSelectionBetween(n,e,t){return e.pos==t.pos&&ot.valid(t)?new ot(t):null},handleClick:r2,handleKeyDown:i2,handleDOMEvents:{beforeinput:s2}}})}const i2=up({ArrowLeft:Xl("horiz",-1),ArrowRight:Xl("horiz",1),ArrowUp:Xl("vert",-1),ArrowDown:Xl("vert",1)});function Xl(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(i,r,s){let o=i.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof fe){if(!s.endOfTextblock(t)||l.depth==0)return!1;c=!1,l=i.doc.resolve(e>0?l.after():l.before())}let h=ot.findGapCursorFrom(l,e,c);return h?(r&&r(i.tr.setSelection(new ot(h))),!0):!1}}function r2(n,e,t){if(!n||!n.editable)return!1;let i=n.state.doc.resolve(e);if(!ot.valid(i))return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});return r&&r.inside>-1&&ne.isSelectable(n.state.doc.nodeAt(r.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ot(i))),!0)}function s2(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ot))return!1;let{$from:t}=n.state.selection,i=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!i)return!1;let r=z.empty;for(let o=i.length-1;o>=0;o--)r=z.from(i[o].createAndFill(null,r));let s=n.state.tr.replace(t.pos,t.pos,new j(r,0,0));return s.setSelection(fe.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function o2(n){if(!(n.selection instanceof ot))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",et.create(n.doc,[Kt.widget(n.selection.head,e,{key:"gapcursor"})])}var du=200,Ct=function(){};Ct.prototype.append=function(e){return e.length?(e=Ct.from(e),!this.length&&e||e.length<du&&this.leafAppend(e)||this.length<du&&e.leafPrepend(this)||this.appendInner(e)):this};Ct.prototype.prepend=function(e){return e.length?Ct.from(e).append(this):this};Ct.prototype.appendInner=function(e){return new a2(this,e)};Ct.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Ct.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};Ct.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ct.prototype.forEach=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length),t<=i?this.forEachInner(e,t,i,0):this.forEachInvertedInner(e,t,i,0)};Ct.prototype.map=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length);var r=[];return this.forEach(function(s,o){return r.push(e(s,o))},t,i),r};Ct.from=function(e){return e instanceof Ct?e:e&&e.length?new R1(e):Ct.empty};var R1=(function(n){function e(i){n.call(this),this.values=i}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(r,s){return r==0&&s==this.length?this:new e(this.values.slice(r,s))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,s,o,l){for(var c=s;c<o;c++)if(r(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,l){for(var c=s-1;c>=o;c--)if(r(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=du)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=du)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(Ct);Ct.empty=new R1([]);var a2=(function(n){function e(t,i){n.call(this),this.left=t,this.right=i,this.length=t.length+i.length,this.depth=Math.max(t.depth,i.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(i){return i<this.left.length?this.left.get(i):this.right.get(i-this.left.length)},e.prototype.forEachInner=function(i,r,s,o){var l=this.left.length;if(r<l&&this.left.forEachInner(i,r,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(i,Math.max(r-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,s,o){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(i,r-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(i,Math.min(r,l),s,o)===!1)return!1},e.prototype.sliceInner=function(i,r){if(i==0&&r==this.length)return this;var s=this.left.length;return r<=s?this.left.slice(i,r):i>=s?this.right.slice(i-s,r-s):this.left.slice(i,s).append(this.right.slice(0,r-s))},e.prototype.leafAppend=function(i){var r=this.right.leafAppend(i);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(i){var r=this.left.leafPrepend(i);if(r)return new e(r,this.right)},e.prototype.appendInner=function(i){return this.left.depth>=Math.max(this.right.depth,i.depth)+1?new e(this.left,new e(this.right,i)):new e(this,i)},e})(Ct);const l2=500;class Xn{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let r,s;t&&(r=this.remapping(i,this.items.length),s=r.maps.length);let o=e.tr,l,c,h=[],d=[];return this.items.forEach((p,m)=>{if(!p.step){r||(r=this.remapping(i,m+1),s=r.maps.length),s--,d.push(p);return}if(r){d.push(new ai(p.map));let g=p.step.map(r.slice(s)),v;g&&o.maybeStep(g).doc&&(v=o.mapping.maps[o.mapping.maps.length-1],h.push(new ai(v,void 0,void 0,h.length+d.length))),s--,v&&r.appendMap(v,s)}else o.maybeStep(p.step);if(p.selection)return l=r?p.selection.map(r.slice(s)):p.selection,c=new Xn(this.items.slice(0,i).append(d.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,t,i,r){let s=[],o=this.eventCount,l=this.items,c=!r&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let p=e.steps[d].invert(e.docs[d]),m=new ai(e.mapping.maps[d],p,t),g;(g=c&&c.merge(m))&&(m=g,d?s.pop():l=l.slice(0,l.length-1)),s.push(m),t&&(o++,t=void 0),r||(c=m)}let h=o-i.depth;return h>u2&&(l=c2(l,h),o-=h),new Xn(l.append(s),o)}remapping(e,t){let i=new ya;return this.items.forEach((r,s)=>{let o=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?i.maps.length-r.mirrorOffset:void 0;i.appendMap(r.map,o)},e,t),i}addMaps(e){return this.eventCount==0?this:new Xn(this.items.append(e.map(t=>new ai(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(m=>{m.selection&&l--},r);let c=t;this.items.forEach(m=>{let g=s.getMirror(--c);if(g==null)return;o=Math.min(o,g);let v=s.maps[g];if(m.step){let w=e.steps[g].invert(e.docs[g]),S=m.selection&&m.selection.map(s.slice(c+1,g));S&&l++,i.push(new ai(v,w,S))}else i.push(new ai(v))},r);let h=[];for(let m=t;m<o;m++)h.push(new ai(s.maps[m]));let d=this.items.slice(0,r).append(h).append(i),p=new Xn(d,l);return p.emptyItemCount()>l2&&(p=p.compress(this.items.length-i.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),i=t.maps.length,r=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)r.push(o),o.selection&&s++;else if(o.step){let c=o.step.map(t.slice(i)),h=c&&c.getMap();if(i--,h&&t.appendMap(h,i),c){let d=o.selection&&o.selection.map(t.slice(i));d&&s++;let p=new ai(h.invert(),c,d),m,g=r.length-1;(m=r.length&&r[g].merge(p))?r[g]=m:r.push(p)}}else o.map&&i--},this.items.length,0),new Xn(Ct.from(r.reverse()),s)}}Xn.empty=new Xn(Ct.empty,0);function c2(n,e){let t;return n.forEach((i,r)=>{if(i.selection&&e--==0)return t=r,!1}),n.slice(t)}class ai{constructor(e,t,i,r){this.map=e,this.step=t,this.selection=i,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new ai(t.getMap().invert(),t,this.selection)}}}class ur{constructor(e,t,i,r,s){this.done=e,this.undone=t,this.prevRanges=i,this.prevTime=r,this.prevComposition=s}}const u2=20;function h2(n,e,t,i){let r=t.getMeta(ts),s;if(r)return r.historyState;t.getMeta(p2)&&(n=new ur(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(ts))return o.getMeta(ts).redo?new ur(n.done.addTransform(t,void 0,i,fc(e)),n.undone,h0(t.mapping.maps),n.prevTime,n.prevComposition):new ur(n.done,n.undone.addTransform(t,void 0,i,fc(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),c=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-i.newGroupDelay||!d2(t,n.prevRanges)),h=o?Gd(n.prevRanges,t.mapping):h0(t.mapping.maps);return new ur(n.done.addTransform(t,c?e.selection.getBookmark():void 0,i,fc(e)),Xn.empty,h,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new ur(n.done.rebased(t,s),n.undone.rebased(t,s),Gd(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new ur(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Gd(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function d2(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((i,r)=>{for(let s=0;s<e.length;s+=2)i<=e[s+1]&&r>=e[s]&&(t=!0)}),t}function h0(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((i,r,s,o)=>e.push(s,o));return e}function Gd(n,e){if(!n)return null;let t=[];for(let i=0;i<n.length;i+=2){let r=e.map(n[i],1),s=e.map(n[i+1],-1);r<=s&&t.push(r,s)}return t}function f2(n,e,t){let i=fc(e),r=ts.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,i);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),r,i),c=new ur(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(ts,{redo:t,historyState:c})}let jd=!1,d0=null;function fc(n){let e=n.plugins;if(d0!=e){jd=!1,d0=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){jd=!0;break}}return jd}const ts=new tt("history"),p2=new tt("closeHistory");function m2(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Ye({key:ts,state:{init(){return new ur(Xn.empty,Xn.empty,null,0,-1)},apply(e,t,i){return h2(t,i,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let i=t.inputType,r=i=="historyUndo"?P1:i=="historyRedo"?L1:null;return r?(t.preventDefault(),r(e.state,e.dispatch)):!1}}}})}function N1(n,e){return(t,i)=>{let r=ts.getState(t);if(!r||(n?r.undone:r.done).eventCount==0)return!1;if(i){let s=f2(r,t,n);s&&i(e?s.scrollIntoView():s)}return!0}}const P1=N1(!1,!0),L1=N1(!0,!0);at.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const i=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(i)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new Ye({key:new tt("characterCount"),appendTransaction:(e,t,i)=>{if(n)return;const r=this.options.limit;if(r==null||r===0){n=!0;return}const s=this.storage.characters({node:i.doc});if(s>r){const o=s-r,l=0,c=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const h=i.tr.deleteRange(l,c);return n=!0,h}n=!0},filterTransaction:(e,t)=>{const i=this.options.limit;if(!e.docChanged||i===0||i===null||i===void 0)return!0;const r=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=i||r>i&&s>i&&s<=r)return!0;if(r>i&&s>i&&s>r||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=s-i,h=l-c,d=l;return e.deleteRange(h,d),!(this.storage.characters({node:e.doc})>i)}})]}});var g2=at.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ZL(this.options)]}});at.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ye({key:new tt("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:i}=this.editor,{anchor:r}=e,s=[];if(!t||!i)return et.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((c,h)=>{if(c.isText)return;if(!(r>=h&&r<=h+c.nodeSize-1))return!1;o+=1});let l=0;return n.descendants((c,h)=>{if(c.isText||!(r>=h&&r<=h+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(Kt.node(h,h+c.nodeSize,{class:this.options.className}))}),et.create(n,s)}}})]}});var y2=at.create({name:"gapCursor",addProseMirrorPlugins(){return[n2()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Be(te(n,"allowGapCursor",t)))!=null?e:null}}});at.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Ye({key:new tt("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=e,r=[];if(!t)return null;const s=this.editor.isEmpty;return n.descendants((o,l)=>{const c=i>=l&&i<=l+o.nodeSize,h=!o.isLeaf&&Ou(o);if((c||!this.options.showOnlyCurrent)&&h){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const p=Kt.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:c}):this.options.placeholder});r.push(p)}return this.options.includeChildren}),et.create(n,r)}}})]}});at.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new Ye({key:new tt("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||Xw(t.selection)||n.view.dragging?null:et.create(t.doc,[Kt.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function f0({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var v2=at.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const n=new tt(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>(this.options.notAfter||[]).concat(this.options.node).includes(t.name));return[new Ye({key:n,appendTransaction:(t,i,r)=>{const{doc:s,tr:o,schema:l}=r,c=n.getState(r),h=s.content.size,d=l.nodes[this.options.node];if(c)return o.insert(h,d.create())},state:{init:(t,i)=>{const r=i.tr.doc.lastChild;return!f0({node:r,types:e})},apply:(t,i)=>{if(!t.docChanged)return i;const r=t.doc.lastChild;return!f0({node:r,types:e})}}})]}}),b2=at.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>P1(n,e),redo:()=>({state:n,dispatch:e})=>L1(n,e)}},addProseMirrorPlugins(){return[m2(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),w2=at.create({name:"starterKit",addExtensions(){var n,e,t,i;const r=[];return this.options.bold!==!1&&r.push(YP.configure(this.options.bold)),this.options.blockquote!==!1&&r.push(qP.configure(this.options.blockquote)),this.options.bulletList!==!1&&r.push(E1.configure(this.options.bulletList)),this.options.code!==!1&&r.push(QP.configure(this.options.code)),this.options.codeBlock!==!1&&r.push(nL.configure(this.options.codeBlock)),this.options.document!==!1&&r.push(iL.configure(this.options.document)),this.options.dropcursor!==!1&&r.push(g2.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&r.push(y2.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&r.push(rL.configure(this.options.hardBreak)),this.options.heading!==!1&&r.push(sL.configure(this.options.heading)),this.options.undoRedo!==!1&&r.push(b2.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&r.push(oL.configure(this.options.horizontalRule)),this.options.italic!==!1&&r.push(hL.configure(this.options.italic)),this.options.listItem!==!1&&r.push(T1.configure(this.options.listItem)),this.options.listKeymap!==!1&&r.push(D1.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&r.push(LL.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&r.push(_1.configure(this.options.orderedList)),this.options.paragraph!==!1&&r.push(KL.configure(this.options.paragraph)),this.options.strike!==!1&&r.push(XL.configure(this.options.strike)),this.options.text!==!1&&r.push(YL.configure(this.options.text)),this.options.underline!==!1&&r.push(JL.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&r.push(v2.configure((i=this.options)==null?void 0:i.trailingNode)),r}}),p0=w2;const F1=["top","right","bottom","left"],m0=["start","end"],g0=F1.reduce((n,e)=>n.concat(e,e+"-"+m0[0],e+"-"+m0[1]),[]),yi=Math.min,qt=Math.max,fu=Math.round,hi=n=>({x:n,y:n}),S2={left:"right",right:"left",bottom:"top",top:"bottom"},x2={start:"end",end:"start"};function Bf(n,e,t){return qt(n,yi(e,t))}function Ki(n,e){return typeof n=="function"?n(e):n}function $n(n){return n.split("-")[0]}function Jn(n){return n.split("-")[1]}function $1(n){return n==="x"?"y":"x"}function Fp(n){return n==="y"?"height":"width"}const C2=new Set(["top","bottom"]);function li(n){return C2.has($n(n))?"y":"x"}function $p(n){return $1(li(n))}function B1(n,e,t){t===void 0&&(t=!1);const i=Jn(n),r=$p(n),s=Fp(r);let o=r==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=mu(o)),[o,mu(o)]}function E2(n){const e=mu(n);return[pu(n),e,pu(e)]}function pu(n){return n.replace(/start|end/g,e=>x2[e])}const y0=["left","right"],v0=["right","left"],T2=["top","bottom"],k2=["bottom","top"];function A2(n,e,t){switch(n){case"top":case"bottom":return t?e?v0:y0:e?y0:v0;case"left":case"right":return e?T2:k2;default:return[]}}function M2(n,e,t,i){const r=Jn(n);let s=A2($n(n),t==="start",i);return r&&(s=s.map(o=>o+"-"+r),e&&(s=s.concat(s.map(pu)))),s}function mu(n){return n.replace(/left|right|bottom|top/g,e=>S2[e])}function O2(n){return{top:0,right:0,bottom:0,left:0,...n}}function Bp(n){return typeof n!="number"?O2(n):{top:n,right:n,bottom:n,left:n}}function no(n){const{x:e,y:t,width:i,height:r}=n;return{width:i,height:r,top:t,left:e,right:e+i,bottom:t+r,x:e,y:t}}function b0(n,e,t){let{reference:i,floating:r}=n;const s=li(e),o=$p(e),l=Fp(o),c=$n(e),h=s==="y",d=i.x+i.width/2-r.width/2,p=i.y+i.height/2-r.height/2,m=i[l]/2-r[l]/2;let g;switch(c){case"top":g={x:d,y:i.y-r.height};break;case"bottom":g={x:d,y:i.y+i.height};break;case"right":g={x:i.x+i.width,y:p};break;case"left":g={x:i.x-r.width,y:p};break;default:g={x:i.x,y:i.y}}switch(Jn(e)){case"start":g[o]-=m*(t&&h?-1:1);break;case"end":g[o]+=m*(t&&h?-1:1);break}return g}const I2=async(n,e,t)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:o}=t,l=s.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(e));let h=await o.getElementRects({reference:n,floating:e,strategy:r}),{x:d,y:p}=b0(h,i,c),m=i,g={},v=0;for(let w=0;w<l.length;w++){const{name:S,fn:E}=l[w],{x:k,y:I,data:R,reset:N}=await E({x:d,y:p,initialPlacement:i,placement:m,strategy:r,middlewareData:g,rects:h,platform:o,elements:{reference:n,floating:e}});d=k??d,p=I??p,g={...g,[S]:{...g[S],...R}},N&&v<=50&&(v++,typeof N=="object"&&(N.placement&&(m=N.placement),N.rects&&(h=N.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:r}):N.rects),{x:d,y:p}=b0(h,m,c)),w=-1)}return{x:d,y:p,placement:m,strategy:r,middlewareData:g}};async function io(n,e){var t;e===void 0&&(e={});const{x:i,y:r,platform:s,rects:o,elements:l,strategy:c}=n,{boundary:h="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:g=0}=Ki(e,n),v=Bp(g),S=l[m?p==="floating"?"reference":"floating":p],E=no(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(S)))==null||t?S:S.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:h,rootBoundary:d,strategy:c})),k=p==="floating"?{x:i,y:r,width:o.floating.width,height:o.floating.height}:o.reference,I=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),R=await(s.isElement==null?void 0:s.isElement(I))?await(s.getScale==null?void 0:s.getScale(I))||{x:1,y:1}:{x:1,y:1},N=no(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:I,strategy:c}):k);return{top:(E.top-N.top+v.top)/R.y,bottom:(N.bottom-E.bottom+v.bottom)/R.y,left:(E.left-N.left+v.left)/R.x,right:(N.right-E.right+v.right)/R.x}}const D2=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:i,placement:r,rects:s,platform:o,elements:l,middlewareData:c}=e,{element:h,padding:d=0}=Ki(n,e)||{};if(h==null)return{};const p=Bp(d),m={x:t,y:i},g=$p(r),v=Fp(g),w=await o.getDimensions(h),S=g==="y",E=S?"top":"left",k=S?"bottom":"right",I=S?"clientHeight":"clientWidth",R=s.reference[v]+s.reference[g]-m[g]-s.floating[v],N=m[g]-s.reference[g],V=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let U=V?V[I]:0;(!U||!await(o.isElement==null?void 0:o.isElement(V)))&&(U=l.floating[I]||s.floating[v]);const W=R/2-N/2,G=U/2-w[v]/2-1,Y=yi(p[E],G),le=yi(p[k],G),ke=Y,we=U-w[v]-le,pe=U/2-w[v]/2+W,_e=Bf(ke,pe,we),de=!c.arrow&&Jn(r)!=null&&pe!==_e&&s.reference[v]/2-(pe<ke?Y:le)-w[v]/2<0,ce=de?pe<ke?pe-ke:pe-we:0;return{[g]:m[g]+ce,data:{[g]:_e,centerOffset:pe-_e-ce,...de&&{alignmentOffset:ce}},reset:de}}});function _2(n,e,t){return(n?[...t.filter(r=>Jn(r)===n),...t.filter(r=>Jn(r)!==n)]:t.filter(r=>$n(r)===r)).filter(r=>n?Jn(r)===n||(e?pu(r)!==r:!1):!0)}const R2=function(n){return n===void 0&&(n={}),{name:"autoPlacement",options:n,async fn(e){var t,i,r;const{rects:s,middlewareData:o,placement:l,platform:c,elements:h}=e,{crossAxis:d=!1,alignment:p,allowedPlacements:m=g0,autoAlignment:g=!0,...v}=Ki(n,e),w=p!==void 0||m===g0?_2(p||null,g,m):m,S=await io(e,v),E=((t=o.autoPlacement)==null?void 0:t.index)||0,k=w[E];if(k==null)return{};const I=B1(k,s,await(c.isRTL==null?void 0:c.isRTL(h.floating)));if(l!==k)return{reset:{placement:w[0]}};const R=[S[$n(k)],S[I[0]],S[I[1]]],N=[...((i=o.autoPlacement)==null?void 0:i.overflows)||[],{placement:k,overflows:R}],V=w[E+1];if(V)return{data:{index:E+1,overflows:N},reset:{placement:V}};const U=N.map(Y=>{const le=Jn(Y.placement);return[Y.placement,le&&d?Y.overflows.slice(0,2).reduce((ke,we)=>ke+we,0):Y.overflows[0],Y.overflows]}).sort((Y,le)=>Y[1]-le[1]),G=((r=U.filter(Y=>Y[2].slice(0,Jn(Y[0])?2:3).every(le=>le<=0))[0])==null?void 0:r[0])||U[0][0];return G!==l?{data:{index:E+1,overflows:N},reset:{placement:G}}:{}}}},N2=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,i;const{placement:r,middlewareData:s,rects:o,initialPlacement:l,platform:c,elements:h}=e,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:w=!0,...S}=Ki(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const E=$n(r),k=li(l),I=$n(l)===l,R=await(c.isRTL==null?void 0:c.isRTL(h.floating)),N=m||(I||!w?[mu(l)]:E2(l)),V=v!=="none";!m&&V&&N.push(...M2(l,w,v,R));const U=[l,...N],W=await io(e,S),G=[];let Y=((i=s.flip)==null?void 0:i.overflows)||[];if(d&&G.push(W[E]),p){const pe=B1(r,o,R);G.push(W[pe[0]],W[pe[1]])}if(Y=[...Y,{placement:r,overflows:G}],!G.every(pe=>pe<=0)){var le,ke;const pe=(((le=s.flip)==null?void 0:le.index)||0)+1,_e=U[pe];if(_e&&(!(p==="alignment"?k!==li(_e):!1)||Y.every(Oe=>li(Oe.placement)===k?Oe.overflows[0]>0:!0)))return{data:{index:pe,overflows:Y},reset:{placement:_e}};let de=(ke=Y.filter(ce=>ce.overflows[0]<=0).sort((ce,Oe)=>ce.overflows[1]-Oe.overflows[1])[0])==null?void 0:ke.placement;if(!de)switch(g){case"bestFit":{var we;const ce=(we=Y.filter(Oe=>{if(V){const Yt=li(Oe.placement);return Yt===k||Yt==="y"}return!0}).map(Oe=>[Oe.placement,Oe.overflows.filter(Yt=>Yt>0).reduce((Yt,ji)=>Yt+ji,0)]).sort((Oe,Yt)=>Oe[1]-Yt[1])[0])==null?void 0:we[0];ce&&(de=ce);break}case"initialPlacement":de=l;break}if(r!==de)return{reset:{placement:de}}}return{}}}};function w0(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function S0(n){return F1.some(e=>n[e]>=0)}const P2=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:i="referenceHidden",...r}=Ki(n,e);switch(i){case"referenceHidden":{const s=await io(e,{...r,elementContext:"reference"}),o=w0(s,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:S0(o)}}}case"escaped":{const s=await io(e,{...r,altBoundary:!0}),o=w0(s,t.floating);return{data:{escapedOffsets:o,escaped:S0(o)}}}default:return{}}}}};function z1(n){const e=yi(...n.map(s=>s.left)),t=yi(...n.map(s=>s.top)),i=qt(...n.map(s=>s.right)),r=qt(...n.map(s=>s.bottom));return{x:e,y:t,width:i-e,height:r-t}}function L2(n){const e=n.slice().sort((r,s)=>r.y-s.y),t=[];let i=null;for(let r=0;r<e.length;r++){const s=e[r];!i||s.y-i.y>i.height/2?t.push([s]):t[t.length-1].push(s),i=s}return t.map(r=>no(z1(r)))}const F2=function(n){return n===void 0&&(n={}),{name:"inline",options:n,async fn(e){const{placement:t,elements:i,rects:r,platform:s,strategy:o}=e,{padding:l=2,x:c,y:h}=Ki(n,e),d=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(i.reference))||[]),p=L2(d),m=no(z1(d)),g=Bp(l);function v(){if(p.length===2&&p[0].left>p[1].right&&c!=null&&h!=null)return p.find(S=>c>S.left-g.left&&c<S.right+g.right&&h>S.top-g.top&&h<S.bottom+g.bottom)||m;if(p.length>=2){if(li(t)==="y"){const Y=p[0],le=p[p.length-1],ke=$n(t)==="top",we=Y.top,pe=le.bottom,_e=ke?Y.left:le.left,de=ke?Y.right:le.right,ce=de-_e,Oe=pe-we;return{top:we,bottom:pe,left:_e,right:de,width:ce,height:Oe,x:_e,y:we}}const S=$n(t)==="left",E=qt(...p.map(Y=>Y.right)),k=yi(...p.map(Y=>Y.left)),I=p.filter(Y=>S?Y.left===k:Y.right===E),R=I[0].top,N=I[I.length-1].bottom,V=k,U=E,W=U-V,G=N-R;return{top:R,bottom:N,left:V,right:U,width:W,height:G,x:V,y:R}}return m}const w=await s.getElementRects({reference:{getBoundingClientRect:v},floating:i.floating,strategy:o});return r.reference.x!==w.reference.x||r.reference.y!==w.reference.y||r.reference.width!==w.reference.width||r.reference.height!==w.reference.height?{reset:{rects:w}}:{}}}},$2=new Set(["left","top"]);async function B2(n,e){const{placement:t,platform:i,elements:r}=n,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),o=$n(t),l=Jn(t),c=li(t)==="y",h=$2.has(o)?-1:1,d=s&&c?-1:1,p=Ki(e,n);let{mainAxis:m,crossAxis:g,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof v=="number"&&(g=l==="end"?v*-1:v),c?{x:g*d,y:m*h}:{x:m*h,y:g*d}}const z2=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,i;const{x:r,y:s,placement:o,middlewareData:l}=e,c=await B2(e,n);return o===((t=l.offset)==null?void 0:t.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:r+c.x,y:s+c.y,data:{...c,placement:o}}}}},H2=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:i,placement:r}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:l={fn:S=>{let{x:E,y:k}=S;return{x:E,y:k}}},...c}=Ki(n,e),h={x:t,y:i},d=await io(e,c),p=li($n(r)),m=$1(p);let g=h[m],v=h[p];if(s){const S=m==="y"?"top":"left",E=m==="y"?"bottom":"right",k=g+d[S],I=g-d[E];g=Bf(k,g,I)}if(o){const S=p==="y"?"top":"left",E=p==="y"?"bottom":"right",k=v+d[S],I=v-d[E];v=Bf(k,v,I)}const w=l.fn({...e,[m]:g,[p]:v});return{...w,data:{x:w.x-t,y:w.y-i,enabled:{[m]:s,[p]:o}}}}}},V2=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){var t,i;const{placement:r,rects:s,platform:o,elements:l}=e,{apply:c=()=>{},...h}=Ki(n,e),d=await io(e,h),p=$n(r),m=Jn(r),g=li(r)==="y",{width:v,height:w}=s.floating;let S,E;p==="top"||p==="bottom"?(S=p,E=m===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(E=p,S=m==="end"?"top":"bottom");const k=w-d.top-d.bottom,I=v-d.left-d.right,R=yi(w-d[S],k),N=yi(v-d[E],I),V=!e.middlewareData.shift;let U=R,W=N;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(W=I),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(U=k),V&&!m){const Y=qt(d.left,0),le=qt(d.right,0),ke=qt(d.top,0),we=qt(d.bottom,0);g?W=v-2*(Y!==0||le!==0?Y+le:qt(d.left,d.right)):U=w-2*(ke!==0||we!==0?ke+we:qt(d.top,d.bottom))}await c({...e,availableWidth:W,availableHeight:U});const G=await o.getDimensions(l.floating);return v!==G.width||w!==G.height?{reset:{rects:!0}}:{}}}};function Ru(){return typeof window<"u"}function oo(n){return H1(n)?(n.nodeName||"").toLowerCase():"#document"}function Cn(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Gi(n){var e;return(e=(H1(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function H1(n){return Ru()?n instanceof Node||n instanceof Cn(n).Node:!1}function ei(n){return Ru()?n instanceof Element||n instanceof Cn(n).Element:!1}function vi(n){return Ru()?n instanceof HTMLElement||n instanceof Cn(n).HTMLElement:!1}function x0(n){return!Ru()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Cn(n).ShadowRoot}const W2=new Set(["inline","contents"]);function Pa(n){const{overflow:e,overflowX:t,overflowY:i,display:r}=ti(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!W2.has(r)}const U2=new Set(["table","td","th"]);function q2(n){return U2.has(oo(n))}const K2=[":popover-open",":modal"];function Nu(n){return K2.some(e=>{try{return n.matches(e)}catch{return!1}})}const G2=["transform","translate","scale","rotate","perspective"],j2=["transform","translate","scale","rotate","perspective","filter"],X2=["paint","layout","strict","content"];function zp(n){const e=Hp(),t=ei(n)?ti(n):n;return G2.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||j2.some(i=>(t.willChange||"").includes(i))||X2.some(i=>(t.contain||"").includes(i))}function Y2(n){let e=kr(n);for(;vi(e)&&!ro(e);){if(zp(e))return e;if(Nu(e))return null;e=kr(e)}return null}function Hp(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const J2=new Set(["html","body","#document"]);function ro(n){return J2.has(oo(n))}function ti(n){return Cn(n).getComputedStyle(n)}function Pu(n){return ei(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function kr(n){if(oo(n)==="html")return n;const e=n.assignedSlot||n.parentNode||x0(n)&&n.host||Gi(n);return x0(e)?e.host:e}function V1(n){const e=kr(n);return ro(e)?n.ownerDocument?n.ownerDocument.body:n.body:vi(e)&&Pa(e)?e:V1(e)}function W1(n,e,t){var i;e===void 0&&(e=[]);const r=V1(n),s=r===((i=n.ownerDocument)==null?void 0:i.body),o=Cn(r);return s?(zf(o),e.concat(o,o.visualViewport||[],Pa(r)?r:[],[])):e.concat(r,W1(r,[]))}function zf(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function U1(n){const e=ti(n);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=vi(n),s=r?n.offsetWidth:t,o=r?n.offsetHeight:i,l=fu(t)!==s||fu(i)!==o;return l&&(t=s,i=o),{width:t,height:i,$:l}}function q1(n){return ei(n)?n:n.contextElement}function Gs(n){const e=q1(n);if(!vi(e))return hi(1);const t=e.getBoundingClientRect(),{width:i,height:r,$:s}=U1(e);let o=(s?fu(t.width):t.width)/i,l=(s?fu(t.height):t.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const Z2=hi(0);function K1(n){const e=Cn(n);return!Hp()||!e.visualViewport?Z2:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Q2(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==Cn(n)?!1:e}function ka(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),s=q1(n);let o=hi(1);e&&(i?ei(i)&&(o=Gs(i)):o=Gs(n));const l=Q2(s,t,i)?K1(s):hi(0);let c=(r.left+l.x)/o.x,h=(r.top+l.y)/o.y,d=r.width/o.x,p=r.height/o.y;if(s){const m=Cn(s),g=i&&ei(i)?Cn(i):i;let v=m,w=zf(v);for(;w&&i&&g!==v;){const S=Gs(w),E=w.getBoundingClientRect(),k=ti(w),I=E.left+(w.clientLeft+parseFloat(k.paddingLeft))*S.x,R=E.top+(w.clientTop+parseFloat(k.paddingTop))*S.y;c*=S.x,h*=S.y,d*=S.x,p*=S.y,c+=I,h+=R,v=Cn(w),w=zf(v)}}return no({width:d,height:p,x:c,y:h})}function Vp(n,e){const t=Pu(n).scrollLeft;return e?e.left+t:ka(Gi(n)).left+t}function G1(n,e,t){t===void 0&&(t=!1);const i=n.getBoundingClientRect(),r=i.left+e.scrollLeft-(t?0:Vp(n,i)),s=i.top+e.scrollTop;return{x:r,y:s}}function eF(n){let{elements:e,rect:t,offsetParent:i,strategy:r}=n;const s=r==="fixed",o=Gi(i),l=e?Nu(e.floating):!1;if(i===o||l&&s)return t;let c={scrollLeft:0,scrollTop:0},h=hi(1);const d=hi(0),p=vi(i);if((p||!p&&!s)&&((oo(i)!=="body"||Pa(o))&&(c=Pu(i)),vi(i))){const g=ka(i);h=Gs(i),d.x=g.x+i.clientLeft,d.y=g.y+i.clientTop}const m=o&&!p&&!s?G1(o,c,!0):hi(0);return{width:t.width*h.x,height:t.height*h.y,x:t.x*h.x-c.scrollLeft*h.x+d.x+m.x,y:t.y*h.y-c.scrollTop*h.y+d.y+m.y}}function tF(n){return Array.from(n.getClientRects())}function nF(n){const e=Gi(n),t=Pu(n),i=n.ownerDocument.body,r=qt(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=qt(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let o=-t.scrollLeft+Vp(n);const l=-t.scrollTop;return ti(i).direction==="rtl"&&(o+=qt(e.clientWidth,i.clientWidth)-r),{width:r,height:s,x:o,y:l}}function iF(n,e){const t=Cn(n),i=Gi(n),r=t.visualViewport;let s=i.clientWidth,o=i.clientHeight,l=0,c=0;if(r){s=r.width,o=r.height;const h=Hp();(!h||h&&e==="fixed")&&(l=r.offsetLeft,c=r.offsetTop)}return{width:s,height:o,x:l,y:c}}const rF=new Set(["absolute","fixed"]);function sF(n,e){const t=ka(n,!0,e==="fixed"),i=t.top+n.clientTop,r=t.left+n.clientLeft,s=vi(n)?Gs(n):hi(1),o=n.clientWidth*s.x,l=n.clientHeight*s.y,c=r*s.x,h=i*s.y;return{width:o,height:l,x:c,y:h}}function C0(n,e,t){let i;if(e==="viewport")i=iF(n,t);else if(e==="document")i=nF(Gi(n));else if(ei(e))i=sF(e,t);else{const r=K1(n);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return no(i)}function j1(n,e){const t=kr(n);return t===e||!ei(t)||ro(t)?!1:ti(t).position==="fixed"||j1(t,e)}function oF(n,e){const t=e.get(n);if(t)return t;let i=W1(n,[]).filter(l=>ei(l)&&oo(l)!=="body"),r=null;const s=ti(n).position==="fixed";let o=s?kr(n):n;for(;ei(o)&&!ro(o);){const l=ti(o),c=zp(o);!c&&l.position==="fixed"&&(r=null),(s?!c&&!r:!c&&l.position==="static"&&!!r&&rF.has(r.position)||Pa(o)&&!c&&j1(n,o))?i=i.filter(d=>d!==o):r=l,o=kr(o)}return e.set(n,i),i}function aF(n){let{element:e,boundary:t,rootBoundary:i,strategy:r}=n;const o=[...t==="clippingAncestors"?Nu(e)?[]:oF(e,this._c):[].concat(t),i],l=o[0],c=o.reduce((h,d)=>{const p=C0(e,d,r);return h.top=qt(p.top,h.top),h.right=yi(p.right,h.right),h.bottom=yi(p.bottom,h.bottom),h.left=qt(p.left,h.left),h},C0(e,l,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function lF(n){const{width:e,height:t}=U1(n);return{width:e,height:t}}function cF(n,e,t){const i=vi(e),r=Gi(e),s=t==="fixed",o=ka(n,!0,s,e);let l={scrollLeft:0,scrollTop:0};const c=hi(0);function h(){c.x=Vp(r)}if(i||!i&&!s)if((oo(e)!=="body"||Pa(r))&&(l=Pu(e)),i){const g=ka(e,!0,s,e);c.x=g.x+e.clientLeft,c.y=g.y+e.clientTop}else r&&h();s&&!i&&r&&h();const d=r&&!i&&!s?G1(r,l):hi(0),p=o.left+l.scrollLeft-c.x-d.x,m=o.top+l.scrollTop-c.y-d.y;return{x:p,y:m,width:o.width,height:o.height}}function Xd(n){return ti(n).position==="static"}function E0(n,e){if(!vi(n)||ti(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return Gi(n)===t&&(t=t.ownerDocument.body),t}function X1(n,e){const t=Cn(n);if(Nu(n))return t;if(!vi(n)){let r=kr(n);for(;r&&!ro(r);){if(ei(r)&&!Xd(r))return r;r=kr(r)}return t}let i=E0(n,e);for(;i&&q2(i)&&Xd(i);)i=E0(i,e);return i&&ro(i)&&Xd(i)&&!zp(i)?t:i||Y2(n)||t}const uF=async function(n){const e=this.getOffsetParent||X1,t=this.getDimensions,i=await t(n.floating);return{reference:cF(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function hF(n){return ti(n).direction==="rtl"}const dF={convertOffsetParentRelativeRectToViewportRelativeRect:eF,getDocumentElement:Gi,getClippingRect:aF,getOffsetParent:X1,getElementRects:uF,getClientRects:tF,getDimensions:lF,getScale:Gs,isElement:ei,isRTL:hF},Y1=z2,J1=R2,Z1=H2,Q1=N2,eS=V2,tS=P2,nS=D2,iS=F2,rS=(n,e,t)=>{const i=new Map,r={platform:dF,...t},s={...r.platform,_c:i};return I2(n,e,{...r,platform:s})};var fF=class{constructor({editor:n,element:e,view:t,options:i,shouldShow:r}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:s,state:o})=>{const{selection:l}=o,{$anchor:c,empty:h}=l,d=c.depth===1,p=c.parent.isTextblock&&!c.parent.type.spec.code&&!c.parent.textContent&&c.parent.childCount===0&&!this.getTextContent(c.parent);return!(!s.hasFocus()||!h||!d||!p||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(s,o,l,c)=>{const{composing:h}=s;if(h||!o&&!l)return;if(!this.getShouldShow(c)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:s})=>{var o;if(this.preventHide){this.preventHide=!1;return}s?.relatedTarget&&((o=this.element.parentNode)!=null&&o.contains(s.relatedTarget))||s?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=n,this.element=e,this.view=t,this.floatingUIOptions={...this.floatingUIOptions,...i},this.element.tabIndex=0,r&&(this.shouldShow=r),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(t,t.state),this.getShouldShow()&&this.show()}getTextContent(n){return Uw(n,{textSerializers:bp(this.editor.schema)})}get middlewares(){const n=[];return this.floatingUIOptions.flip&&n.push(Q1(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&n.push(Z1(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&n.push(Y1(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&n.push(nS(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&n.push(eS(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&n.push(J1(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&n.push(tS(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&n.push(iS(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),n}getShouldShow(n){var e;const{state:t}=this.view,{selection:i}=t,{ranges:r}=i,s=Math.min(...r.map(c=>c.$from.pos)),o=Math.max(...r.map(c=>c.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:t,oldState:n,from:s,to:o})}updatePosition(){const{selection:n}=this.editor.state,e=Yw(this.view,n.from,n.to);rS({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:r,strategy:s})=>{this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${i}px`,this.element.style.top=`${r}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(n,e){const t=!e?.selection.eq(n.state.selection),i=!e?.doc.eq(n.state.doc);this.updateHandler(n,t,i,e)}show(){var n;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(n=this.view.dom.parentElement)==null||n.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},pF=n=>new Ye({key:typeof n.pluginKey=="string"?new tt(n.pluginKey):n.pluginKey,view:e=>new fF({view:e,...n})}),mF=at.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[pF({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,shouldShow:this.options.shouldShow})]:[]}}),gF=mF,Hf,Vf;if(typeof WeakMap<"u"){let n=new WeakMap;Hf=e=>n.get(e),Vf=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Hf=i=>{for(let r=0;r<n.length;r+=2)if(n[r]==i)return n[r+1]},Vf=(i,r)=>(t==10&&(t=0),n[t++]=i,n[t++]=r)}var Pi=class{constructor(n,e,t,i){this.width=n,this.height=e,this.map=t,this.problems=i}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const i=e%this.width,r=e/this.width|0;let s=i+1,o=r+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:i,top:r,right:s,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:i,right:r,top:s,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?i==0:r==this.width)?null:this.map[s*this.width+(t<0?i-1:r)]:(t<0?s==0:o==this.height)?null:this.map[i+this.width*(t<0?s-1:o)]}rectBetween(n,e){const{left:t,right:i,top:r,bottom:s}=this.findCell(n),{left:o,right:l,top:c,bottom:h}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(r,c),right:Math.max(i,l),bottom:Math.max(s,h)}}cellsInRect(n){const e=[],t={};for(let i=n.top;i<n.bottom;i++)for(let r=n.left;r<n.right;r++){const s=i*this.width+r,o=this.map[s];t[o]||(t[o]=!0,!(r==n.left&&r&&this.map[s-1]==o||i==n.top&&i&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let i=0,r=0;;i++){const s=r+t.child(i).nodeSize;if(i==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<r;)o++;return o==l?s-1:this.map[o]}r=s}}static get(n){return Hf(n)||Vf(n,yF(n))}};function yF(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=vF(n),t=n.childCount,i=[];let r=0,s=null;const o=[];for(let h=0,d=e*t;h<d;h++)i[h]=0;for(let h=0,d=0;h<t;h++){const p=n.child(h);d++;for(let v=0;;v++){for(;r<i.length&&i[r]!=0;)r++;if(v==p.childCount)break;const w=p.child(v),{colspan:S,rowspan:E,colwidth:k}=w.attrs;for(let I=0;I<E;I++){if(I+h>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:d,n:E-I});break}const R=r+I*e;for(let N=0;N<S;N++){i[R+N]==0?i[R+N]=d:(s||(s=[])).push({type:"collision",row:h,pos:d,n:S-N});const V=k&&k[N];if(V){const U=(R+N)%e*2,W=o[U];W==null||W!=V&&o[U+1]==1?(o[U]=V,o[U+1]=1):W==V&&o[U+1]++}}}r+=S,d+=w.nodeSize}const m=(h+1)*e;let g=0;for(;r<m;)i[r++]==0&&g++;g&&(s||(s=[])).push({type:"missing",row:h,n:g}),d++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new Pi(e,t,i,s);let c=!1;for(let h=0;!c&&h<o.length;h+=2)o[h]!=null&&o[h+1]<t&&(c=!0);return c&&bF(l,o,n),l}function vF(n){let e=-1,t=!1;for(let i=0;i<n.childCount;i++){const r=n.child(i);let s=0;if(t)for(let o=0;o<i;o++){const l=n.child(o);for(let c=0;c<l.childCount;c++){const h=l.child(c);o+h.attrs.rowspan>i&&(s+=h.attrs.colspan)}}for(let o=0;o<r.childCount;o++){const l=r.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function bF(n,e,t){n.problems||(n.problems=[]);const i={};for(let r=0;r<n.map.length;r++){const s=n.map[r];if(i[s])continue;i[s]=!0;const o=t.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const c=o.attrs;for(let h=0;h<c.colspan;h++){const d=(r+h)%n.width,p=e[d*2];p!=null&&(!c.colwidth||c.colwidth[h]!=p)&&((l||(l=wF(c)))[h]=p)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function wF(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Wp(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const i=n.nodes[t],r=i.spec.tableRole;r&&(e[r]=i)}}return e}new tt("selectingCells");function SF(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function sS(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function xF(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=SF(e.$head)||CF(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function CF(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function T0(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function oS(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function aS(n,e,t){const i=n.node(-1),r=Pi.get(i),s=n.start(-1),o=r.nextCell(n.pos-s,e,t);return o==null?null:n.node(0).resolve(s+o)}function k0(n,e,t=1){const i={...n,colspan:n.colspan-t};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(e,t),i.colwidth.some(r=>r>0)||(i.colwidth=null)),i}var di=class Ri extends oe{constructor(e,t=e){const i=e.node(-1),r=Pi.get(i),s=e.start(-1),o=r.rectBetween(e.pos-s,t.pos-s),l=e.node(0),c=r.cellsInRect(o).filter(d=>d!=t.pos-s);c.unshift(t.pos-s);const h=c.map(d=>{const p=i.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const m=s+d+1;return new Vb(l.resolve(m),l.resolve(m+p.content.size))});super(h[0].$from,h[0].$to,h),this.$anchorCell=e,this.$headCell=t}map(e,t){const i=e.resolve(t.map(this.$anchorCell.pos)),r=e.resolve(t.map(this.$headCell.pos));if(T0(i)&&T0(r)&&oS(i,r)){const s=this.$anchorCell.node(-1)!=i.node(-1);return s&&this.isRowSelection()?Ri.rowSelection(i,r):s&&this.isColSelection()?Ri.colSelection(i,r):new Ri(i,r)}return fe.between(i,r)}content(){const e=this.$anchorCell.node(-1),t=Pi.get(e),i=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i),s={},o=[];for(let c=r.top;c<r.bottom;c++){const h=[];for(let d=c*t.width+r.left,p=r.left;p<r.right;p++,d++){const m=t.map[d];if(s[m])continue;s[m]=!0;const g=t.findCell(m);let v=e.nodeAt(m);if(!v)throw RangeError(`No cell with offset ${m} found`);const w=r.left-g.left,S=g.right-r.right;if(w>0||S>0){let E=v.attrs;if(w>0&&(E=k0(E,0,w)),S>0&&(E=k0(E,E.colspan-S,S)),g.left<r.left){if(v=v.type.createAndFill(E),!v)throw RangeError(`Could not create cell with attrs ${JSON.stringify(E)}`)}else v=v.type.create(E,v.content)}if(g.top<r.top||g.bottom>r.bottom){const E={...v.attrs,rowspan:Math.min(g.bottom,r.bottom)-Math.max(g.top,r.top)};g.top<r.top?v=v.type.createAndFill(E):v=v.type.create(E,v.content)}h.push(v)}o.push(e.child(c).copy(z.from(h)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new j(z.from(l),1,1)}replace(e,t=j.empty){const i=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){const{$from:l,$to:c}=r[o],h=e.mapping.slice(i);e.replace(h.map(l.pos),h.map(c.pos),o?j.empty:t)}const s=oe.findFrom(e.doc.resolve(e.mapping.slice(i).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new j(z.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),i=Pi.get(t),r=this.$anchorCell.start(-1),s=i.cellsInRect(i.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),r+s[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const i=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(i,r)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const i=e.node(-1),r=Pi.get(i),s=e.start(-1),o=r.findCell(e.pos-s),l=r.findCell(t.pos-s),c=e.node(0);return o.top<=l.top?(o.top>0&&(e=c.resolve(s+r.map[o.left])),l.bottom<r.height&&(t=c.resolve(s+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(t=c.resolve(s+r.map[l.left])),o.bottom<r.height&&(e=c.resolve(s+r.map[r.width*(r.height-1)+o.right-1]))),new Ri(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Pi.get(e),i=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-i),s=t.colCount(this.$headCell.pos-i);if(Math.min(r,s)>0)return!1;const o=r+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof Ri&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const i=e.node(-1),r=Pi.get(i),s=e.start(-1),o=r.findCell(e.pos-s),l=r.findCell(t.pos-s),c=e.node(0);return o.left<=l.left?(o.left>0&&(e=c.resolve(s+r.map[o.top*r.width])),l.right<r.width&&(t=c.resolve(s+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(t=c.resolve(s+r.map[l.top*r.width])),o.right<r.width&&(e=c.resolve(s+r.map[r.width*(o.top+1)-1]))),new Ri(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Ri(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){return new Ri(e.resolve(t),e.resolve(i))}getBookmark(){return new EF(this.$anchorCell.pos,this.$headCell.pos)}};di.prototype.visible=!1;oe.jsonID("cell",di);var EF=class lS{constructor(e,t){this.anchor=e,this.head=t}map(e){return new lS(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),i=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&i.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&i.index()<i.parent.childCount&&oS(t,i)?new di(t,i):oe.near(i,1)}};new tt("fix-tables");function cS(n){const e=n.selection,t=xF(n),i=t.node(-1),r=t.start(-1),s=Pi.get(i);return{...e instanceof di?s.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r):s.findCell(t.pos-r),tableStart:r,map:s,table:i}}function TF(n){return function(e,t){if(!sS(e))return!1;if(t){const i=Wp(e.schema),r=cS(e),s=e.tr,o=r.map.cellsInRect(n=="column"?{left:r.left,top:0,right:r.right,bottom:r.map.height}:n=="row"?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=o.map(c=>r.table.nodeAt(c));for(let c=0;c<o.length;c++)l[c].type==i.header_cell&&s.setNodeMarkup(r.tableStart+o[c],i.cell,l[c].attrs);if(s.steps.length==0)for(let c=0;c<o.length;c++)s.setNodeMarkup(r.tableStart+o[c],i.header_cell,l[c].attrs);t(s)}return!0}}function A0(n,e,t){const i=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let r=0;r<i.length;r++){const s=e.table.nodeAt(i[r]);if(s&&s.type!==t.header_cell)return!1}return!0}function Up(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?TF(n):function(t,i){if(!sS(t))return!1;if(i){const r=Wp(t.schema),s=cS(t),o=t.tr,l=A0("row",s,r),c=A0("column",s,r),d=(n==="column"?l:n==="row"?c:!1)?1:0,p=n=="column"?{left:0,top:d,right:1,bottom:s.map.height}:n=="row"?{left:d,top:0,right:s.map.width,bottom:1}:s,m=n=="column"?c?r.cell:r.header_cell:n=="row"?l?r.cell:r.header_cell:r.cell;s.map.cellsInRect(p).forEach(g=>{const v=g+s.tableStart,w=o.doc.nodeAt(v);w&&o.setNodeMarkup(v,m,w.attrs)}),i(o)}return!0}}Up("row",{useDeprecatedLogic:!0});Up("column",{useDeprecatedLogic:!0});Up("cell",{useDeprecatedLogic:!0});function Yl(n,e){const t=n.selection;if(!(t instanceof di))return!1;if(e){const i=n.tr,r=Wp(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(r)||i.replace(i.mapping.map(o+1),i.mapping.map(o+s.nodeSize-1),new j(r,0,0))}),i.docChanged&&e(i)}return!0}up({ArrowLeft:Jl("horiz",-1),ArrowRight:Jl("horiz",1),ArrowUp:Jl("vert",-1),ArrowDown:Jl("vert",1),"Shift-ArrowLeft":Zl("horiz",-1),"Shift-ArrowRight":Zl("horiz",1),"Shift-ArrowUp":Zl("vert",-1),"Shift-ArrowDown":Zl("vert",1),Backspace:Yl,"Mod-Backspace":Yl,Delete:Yl,"Mod-Delete":Yl});function pc(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Jl(n,e){return(t,i,r)=>{if(!r)return!1;const s=t.selection;if(s instanceof di)return pc(t,i,oe.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=uS(r,n,e);if(o==null)return!1;if(n=="horiz")return pc(t,i,oe.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),c=aS(l,n,e);let h;return c?h=oe.near(c,1):e<0?h=oe.near(t.doc.resolve(l.before(-1)),-1):h=oe.near(t.doc.resolve(l.after(-1)),1),pc(t,i,h)}}}function Zl(n,e){return(t,i,r)=>{if(!r)return!1;const s=t.selection;let o;if(s instanceof di)o=s;else{const c=uS(r,n,e);if(c==null)return!1;o=new di(t.doc.resolve(c))}const l=aS(o.$headCell,n,e);return l?pc(t,i,new di(o.$anchorCell,l)):!1}}function uS(n,e,t){if(!(n.state.selection instanceof fe))return null;const{$head:i}=n.state.selection;for(let r=i.depth-1;r>=0;r--){const s=i.node(r);if((t<0?i.index(r):i.indexAfter(r))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=i.before(r),c=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(c)?l:null}}return null}new tt("tableColumnResizing");function kF(n,e){const t=Math.min(n.top,e.top),i=Math.max(n.bottom,e.bottom),r=Math.min(n.left,e.left),o=Math.max(n.right,e.right)-r,l=i-t,c=r,h=t;return new DOMRect(c,h,o,l)}var AF=class{constructor({editor:n,element:e,view:t,updateDelay:i=250,resizeDelay:r=60,shouldShow:s,appendTo:o,options:l}){this.preventHide=!1,this.isVisible=!1,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:c,state:h,from:d,to:p})=>{const{doc:m,selection:g}=h,{empty:v}=g,w=!m.textBetween(d,p).length&&Cp(h.selection),S=this.element.contains(document.activeElement);return!(!(c.hasFocus()||S)||v||w||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:c})=>{var h;if(this.preventHide){this.preventHide=!1;return}c?.relatedTarget&&((h=this.element.parentNode)!=null&&h.contains(c.relatedTarget))||c?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(c,h)=>{const d=!h?.selection.eq(c.state.selection),p=!h?.doc.eq(c.state.doc);!d&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(c,d,p,h)},this.updateDelay))},this.updateHandler=(c,h,d,p)=>{const{composing:m}=c;if(m||!h&&!d)return;if(!this.getShouldShow(p)){this.hide();return}this.updatePosition(),this.show()},this.editor=n,this.element=e,this.view=t,this.updateDelay=i,this.resizeDelay=r,this.appendTo=o,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),window.addEventListener("resize",this.resizeHandler),this.update(t,t.state),this.getShouldShow()&&this.show()}get middlewares(){const n=[];return this.floatingUIOptions.flip&&n.push(Q1(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&n.push(Z1(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&n.push(Y1(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&n.push(nS(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&n.push(eS(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&n.push(J1(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&n.push(tS(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&n.push(iS(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),n}updatePosition(){const{selection:n}=this.editor.state,e=Yw(this.view,n.from,n.to);let t={getBoundingClientRect:()=>e,getClientRects:()=>[e]};if(n instanceof ne){let i=this.view.nodeDOM(n.from);const r=i.dataset.nodeViewWrapper?i:i.querySelector("[data-node-view-wrapper]");r&&(i=r),i&&(t={getBoundingClientRect:()=>i.getBoundingClientRect(),getClientRects:()=>[i.getBoundingClientRect()]})}if(n instanceof di){const{$anchorCell:i,$headCell:r}=n,s=i?i.pos:r.pos,o=r?r.pos:i.pos,l=this.view.nodeDOM(s),c=this.view.nodeDOM(o);if(!l||!c)return;const h=l===c?l.getBoundingClientRect():kF(l.getBoundingClientRect(),c.getBoundingClientRect());t={getBoundingClientRect:()=>h,getClientRects:()=>[h]}}rS(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:r,strategy:s})=>{this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${i}px`,this.element.style.top=`${r}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(n,e){const{state:t}=n,i=t.selection.from!==t.selection.to;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(n,e);return}const r=!e?.selection.eq(n.state.selection),s=!e?.doc.eq(n.state.doc);this.updateHandler(n,r,s,e)}getShouldShow(n){var e;const{state:t}=this.view,{selection:i}=t,{ranges:r}=i,s=Math.min(...r.map(c=>c.$from.pos)),o=Math.max(...r.map(c=>c.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:n,from:s,to:o})}show(){var n,e;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(e=(n=this.appendTo)!=null?n:this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},MF=n=>new Ye({key:typeof n.pluginKey=="string"?new tt(n.pluginKey):n.pluginKey,view:e=>new AF({view:e,...n})}),OF=at.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[MF({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}}),IF=OF,DF=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,_F=ln.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",ut(this.options.HTMLAttributes,n)]},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[f1({find:DF,type:this.type,getAttributes:n=>{const[,,e,t,i]=n;return{src:t,alt:e,title:i}}})]}}),M0=_F;const RF=({element:n,content:e="",type:t="edit"})=>{let i;return{_updated_at:null,init(){t=="edit"&&Alpine.store("tiptapEditor",this),this.initEditor()},initEditor(){const r=this;i=new Qv({element:n,extensions:[p0.configure({link:{openOnClick:!1,autolink:!0}}),M0.configure({inline:!0}),gF.configure({element:document.querySelector(".tiptap-floating-menu")}),IF.configure({element:document.querySelector(".tiptap-bubble-menu")})],content:e,onUpdate({editor:s}){r._updated_at=Date.now()},onSelectionUpdate({editor:s}){r._updated_at=Date.now()}})},displaySavedData(r,s=""){return new Qv({element:r,extensions:[p0.configure({link:{openOnClick:!1,autolink:!0}}),M0.configure({inline:!0})],editable:!1,content:s})},toggleBold(){i?.chain().focus().toggleBold().run()},toggleItalic(){i?.chain().focus().toggleItalic().run()},toggleHighlight(){i?.chain().focus().toggleHighlight().run()},toggleCode(){i?.chain().focus().toggleCode().run()},toggleStrike(){i?.chain().focus().toggleStrike().run()},toggleUnderline(){i?.chain().focus().toggleUnderline().run()},toggleBlockquote(){i?.chain().focus().toggleBlockquote().run()},toggleBulletList(){i.commands?.toggleBulletList()},toggleOrderedList(){i.commands?.toggleOrderedList()},toggleHeading(r={level:1}){i.chain().focus().toggleHeading(r).run()},toggleCodeBlock(){i.chain().focus().toggleCodeBlock().run()},setParagraph(){i?.commands.setParagraph()},setLink(){if(!i)return;const r=i.getAttributes("link").href,s=window.prompt("URL",r);if(s!==null){if(s===""){i.chain().focus().extendMarkRange("link").unsetLink().run();return}try{i.chain().focus().extendMarkRange("link").setLink({href:s}).run()}catch(o){alert(o.message)}}},unsetLink(){i?.chain().focus().unsetLink().run()},setHeading(r={level:1}){i?.commands.setHeading(r)},setCodeBlock(){i?.chain().focus().setCodeBlock().run()},redo(){i?.chain().focus().redo().run()},canRedo(r){return i?.can().redo()},undo(){i?.chain().focus().undo().run()},canUndo(r){return i?.can().undo()},getTextContent(){return i?.getText()},getHtmlContent(){return i?.getHTML()},setContent(r){i?.commands.setContent(r)},isActive(r,s={}){return s!=null?i.isActive(r,s):i.isActive(r)},download(r){const s=r.currentTarget,o=s.dataset.docType,l=s.dataset.docName||"document";let c=i?.getHTML();const h=window.location.origin,p=new DOMParser().parseFromString(c,"text/html");if(["a","img","video","audio","source"].forEach(S=>{p.querySelectorAll(S).forEach(E=>{const k=S==="a"?"href":"src",I=E.getAttribute(k);I&&!I.startsWith("http")&&E.setAttribute(k,new URL(I,h).href)})}),c=p.documentElement.outerHTML,o==="pdf"){const S=`<div style="margin: 20px;">${c}</div>`;return html2pdf().set({filename:l}).from(S).toPdf().save()}const g=` <html ${this.doctype==="doc"?'xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"':""}> <head> <meta charset="utf-8" /> <title>${l}</title> </head> <body style="margin: 20px;"> ${c} </body> </html>`,v=`${o==="doc"?"data:application/vnd.ms-word;charset=utf-8":"data:text/plain;charset=utf-8"},${encodeURIComponent(g)}`,w=document.createElement("a");document.body.appendChild(w),w.href=v,w.download=`${l}.${o}`,w.click(),document.body.removeChild(w)},getSelectedContent(){const{view:r,state:s}=i,{from:o,to:l}=r.state.selection;return s.doc.textBetween(o,l,"")},replaceSelectedContent(r,s){i.commands.insertContentAt(r,s)},getSelectedRange(){const{view:r,state:s}=i;return r.state.selection}}};window.fetchEventSource=eO;const NF=localStorage.getItem("lqdDarkMode"),PF=localStorage.getItem("docsViewMode"),LF=localStorage.getItem("socialMediaPostsViewMode"),FF=localStorage.getItem("lqdNavbarShrinked"),hS=document.querySelector("body").getAttribute("data-theme"),$F=localStorage.getItem(hS+":lqdFocusModeEnabled");window.collectCreditsToFormData=function(n){document.querySelectorAll('input[name^="entities"]').forEach(t=>{const i=t.name,r=t.type==="checkbox"||t.type==="radio"?t.checked:t.value;n.append(i,r)})};window.Alpine=Z;Z.plugin(tO);Z.plugin(BO);Z.plugin(UO);ae.mount(new wI);document.addEventListener("alpine:init",()=>{const n=Z.$persist;Z.data("modal",e=>xI(e)),Z.data("clipboard",e=>nO(e)),Z.data("assignViewCredits",e=>CI(e)),Z.store("navbarShrink",{active:n(!!FF).as("lqdNavbarShrinked"),toggle(e){this.active=e?e==="shrink":!this.active,document.body.classList.toggle("navbar-shrinked",this.active)}}),Z.data("navbarItem",()=>({dropdownOpen:!1,toggleDropdownOpen(e){this.dropdownOpen=e?e==="collapse":!this.dropdownOpen},item:{"x-ref":"item","@mouseenter"(){if(!Z.store("navbarShrink").active)return;const e=this.$el.getBoundingClientRect(),t=this.$refs.item.querySelector(".lqd-navbar-dropdown");if(["y","height","bottom"].forEach(i=>this.$refs.item.style.setProperty(`--item-${i}`,`${e[i]}px`)),t){const i=t.getBoundingClientRect();["height"].forEach(r=>this.$refs.item.style.setProperty(`--dropdown-${r}`,`${i[r]}px`))}}}})),Z.data("navbarLink",({isDemo:e=!1})=>({isDemo:e,isActive:!1,dropdown:null,dropdownItems:[],dropdownLinks:[],init(){const t=document.querySelector(".lqd-navbar"),i=t?.querySelector(".lqd-navbar-inner");this.dropdown=this.$el.nextElementSibling&&this.$el.nextElementSibling.classList.contains("lqd-navbar-dropdown")&&this.$el.nextElementSibling,this.dropdownItems=this.dropdown?this.dropdown.querySelectorAll(".lqd-navbar-dropdown-link"):[],this.dropdownItems.forEach(r=>this.dropdownLinks.push(r.href)),this.isActive=this.$el.href===window.location.href||this.dropdownLinks.includes(window.location.href),this.$el.classList.toggle("active",this.isActive),this.$nextTick(()=>{this.dropdown?.classList?.toggle("hidden",!this.isActive),!t?.hasAttribute("data-disable-autoscroll")&&i&&!this.isDemo&&this.isActive&&this.$el.parentElement.offsetTop+this.$el.parentElement.offsetHeight>window.innerHeight&&i.scrollTo({top:this.$el.parentElement.offsetTop-window.innerHeight/2})})}})),Z.store("mobileNav",{navCollapse:!0,toggleNav(e){this.navCollapse=e?e==="collapse":!this.navCollapse},templatesCollapse:!0,toggleTemplates(e){this.templatesCollapse=e?e==="collapse":!this.templatesCollapse},searchCollapse:!0,toggleSearch(e){this.searchCollapse=e?e==="collapse":!this.searchCollapse}}),Z.store("darkMode",{on:n(!!NF).as("lqdDarkMode"),toggle(){this.on=!this.on,document.body.classList.toggle("theme-dark",this.on),document.body.classList.toggle("theme-light",!this.on)}}),Z.store("appLoadingIndicator",{showing:!1,show(){this.showing=!0},hide(){this.showing=!1},toggle(){this.showing=!this.showing}}),Z.data("liquidHeaderSearch",()=>({modalOpen:!1,searchTerm:"",isSearching:!1,doneSearching:!1,pending:!1,inputFocused:!1,timer:null,searchResults:"",recentSearchKeys:[],recentLunchedDocs:"",shortcutKey:navigator.userAgent.indexOf("Mac OS X")!=-1?"cmd":"ctrl",init(){this.applyRecentSearch=this.applyRecentSearch.bind(this),sessionStorage.removeItem("headear-recent-lunch"),sessionStorage.removeItem("headear-recent-search-keys"),this.fetchRecentSearchKeys(),this.fetchRecentLunchedDocs(),this.addKeyboardShortcuts()},toggleModal(e){if(e!=null)return this.modalOpen=e;this.modalOpen=!this.modalOpen},handleFocus(){this.inputFocused=!0,this.onlySpaces(this.searchTerm)?(this.pending=!0,this.doneSearching=!1):(this.doneSearching=!0,this.pending=!1)},handleBlur(){this.inputFocused=!1},handleSearch(){this.onlySpaces(this.searchTerm)?(clearTimeout(this.timer),this.isSearching=!1,this.doneSearching=!1,this.pending=!0):(this.isSearching=!0,this.pending=!1,this.doneSearching=!1,clearTimeout(this.timer),this.timer=setTimeout(()=>this.performSearch(),1e3))},addKeyboardShortcuts(){window.addEventListener("keydown",e=>{if((e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)&&e.key==="k"){if(e.preventDefault(),e.stopPropagation(),this.inputFocused)return;this.$el.querySelector(".header-search-input").focus(),this.inputFocused=!0,this.onlySpaces(this.searchTerm)||(this.doneSearching=!0)}if(e.key==="Escape"){if(!this.inputFocused)return;this.$el.querySelector(".header-search-input").blur(),this.inputFocused=!1,this.doneSearching=!1}})},onlySpaces(e){return e.trim().length===0||e===""},async performSearch(){const e=new FormData;e.append("_token",document.querySelector("input[name=_token]")?.value),e.append("search",this.searchTerm);try{const i=await(await fetch("/dashboard/api/search",{method:"POST",body:e})).json();this.searchResults=i.html,this.doneSearching=!0,this.pending=!1,this.isSearching=!1,sessionStorage.setItem("headear-recent-search-keys",JSON.stringify(i.keywords)),this.recentSearchKeys=i.keywords}catch(t){console.error("Search error:",t),this.isSearching=!1}},async fetchRecentSearchKeys(){if(sessionStorage.getItem("headear-recent-search-keys")===null)try{const t=await(await fetch("/dashboard/api/search/recent-search-keys")).json();sessionStorage.setItem("headear-recent-search-keys",JSON.stringify(t.keys)),this.recentSearchKeys=t.keys}catch(e){console.error("Error fetching recent search keys:",e)}else this.recentSearchKeys=JSON.parse(sessionStorage.getItem("headear-recent-search-keys"))},async fetchRecentLunchedDocs(){if(sessionStorage.getItem("headear-recent-lunch")===null)try{const t=await(await fetch("/dashboard/api/search/recent-lunch")).json();sessionStorage.setItem("headear-recent-lunch",t.html),this.recentLunchedDocs=t.html}catch(e){console.error("Error fetching recent launched docs:",e)}else this.recentLunchedDocs=sessionStorage.getItem("headear-recent-lunch")},applyRecentSearch(e){this.searchTerm=e.keyword||e,this.$el.querySelector(".header-search-input").focus(),this.handleSearch()},async deleteRecentSearchKey(e){const t=e.keyword||e;this.recentSearchKeys=this.recentSearchKeys.filter(i=>(i.keyword||i)!==t),sessionStorage.setItem("headear-recent-search-keys",JSON.stringify(this.recentSearchKeys));try{await fetch(`/dashboard/api/search/delete-search-key/${encodeURIComponent(t)}`,{method:"DELETE"})}catch(i){console.error("Error deleting search key:",i)}}})),Z.store("docsViewMode",{docsViewMode:n(PF||"list").as("docsViewMode"),change(e){this.docsViewMode=e}}),Z.store("generatorsFilter",{init(){const e=new URLSearchParams(window.location.search);this.filter=e.get("filter")||"all"},filter:"all",changeFilter(e){if(this.filter!==e){if(!document.startViewTransition)return this.filter=e;document.startViewTransition(()=>this.filter=e)}}}),Z.data("generatorItem",()=>({get isHidden(){return this.$store.generatorsFilter.filter!=="all"&&this.$el.getAttribute("data-filter").search(this.$store.generatorsFilter.filter)<0},updateDataFilter(e,t){const i=this.$el.getAttribute("data-filter"),r=new Set(i.split(","));t?r.add("favorite"):r.delete("favorite"),this.$el.setAttribute("data-filter",Array.from(r).join(","))}})),Z.store("documentsFilter",{init(){const e=new URLSearchParams(window.location.search);this.sort=e.get("sort")||"created_at",this.sortAscDesc=e.get("sortAscDesc")||"desc",this.filter=e.get("filter")||"all",this.page=e.get("page")||"1"},sort:"created_at",sortAscDesc:"desc",filter:"all",page:"1",changeSort(e){e===this.sort?this.sortAscDesc=this.sortAscDesc==="desc"?"asc":"desc":this.sortAscDesc="desc",this.sort=e},changeAscDesc(e){this.ascDesc!==e&&(this.ascDesc=e)},changeFilter(e){this.filter!==e&&(this.filter=e)},changePage(e){(e===">"||e==="<")&&(e=e===">"?Number(this.page)+1:Number(this.page)-1),this.page!==e&&(this.page=e)}}),Z.store("socialMediaPostsViewMode",{socialMediaPostsViewMode:n(LF||"list").as("socialMediaPostsViewMode"),change(e){this.socialMediaPostsViewMode=e}}),Z.store("socialMediaPostsFilter",{init(){const e=new URLSearchParams(window.location.search);this.sort=e.get("sort")||"created_at",this.sortAscDesc=e.get("sortAscDesc")||"desc",this.filter=e.get("filter")||"all",this.page=e.get("page")||"1"},sort:"created_at",sortAscDesc:"desc",filter:"all",page:"1",changeSort(e){e===this.sort?this.sortAscDesc=this.sortAscDesc==="desc"?"asc":"desc":this.sortAscDesc="desc",this.sort=e},changeAscDesc(e){this.ascDesc!==e&&(this.ascDesc=e)},changeFilter(e){this.filter!==e&&(this.filter=e)},changePage(e){(e===">"||e==="<")&&(e=e===">"?Number(this.page)+1:Number(this.page)-1),this.page!==e&&(this.page=e)}}),Z.store("chatsFilter",{init(){const e=new URLSearchParams(window.location.search);this.filter=e.get("filter")||"all",this.setSearchStr(e.get("search")||"")},searchStr:"",setSearchStr(e){this.searchStr=e.trim().toLowerCase()},filter:"all",changeFilter(e){if(this.filter!==e){if(!document.startViewTransition)return this.filter=e;document.startViewTransition(()=>this.filter=e)}}}),Z.data("generatorV2",()=>({itemsSearchStr:"",setItemsSearchStr(e){this.itemsSearchStr=e.trim().toLowerCase(),this.itemsSearchStr!==""?this.$el.closest(".lqd-generator-sidebar").classList.add("lqd-showing-search-results"):this.$el.closest(".lqd-generator-sidebar").classList.remove("lqd-showing-search-results")},sideNavCollapsed:!1,toggleSideNavCollapse(e){this.sideNavCollapsed=e?e==="collapse":!this.sideNavCollapsed,this.sideNavCollapsed&&(typeof tinymce<"u"&&tinymce?.activeEditor?tinymce?.activeEditor?.focus():window.editorJS?.focus())},generatorStep:0,setGeneratorStep(e){if(e!==this.generatorStep){if(!document.startViewTransition)return this.generatorStep=Number(e);document.startViewTransition(()=>this.generatorStep=Number(e))}},selectedGenerator:null})),Z.store("mobileChat",{sidebarOpen:!1,toggleSidebar(e){this.sidebarOpen=e?!1:!this.sidebarOpen}}),Z.data("dropdown",({triggerType:e="hover",preferredAnchor:t="start",offsetY:i="0px",teleport:r=!0})=>({open:!1,triggerType:e||"hover",preferredAnchor:t||"start",offsetY:i.trim()||"0px",teleport:r??!0,parentRect:{top:0,left:0,width:0,height:0},dropdownRect:{top:0,left:0,width:0,height:0},toggle(s){this.open=s?s!=="collapse":!this.open,this.$refs.parent.classList.toggle("lqd-is-active",this.open)},parent:{"@mouseenter"(){this.parentRect=this.$refs.parent.getBoundingClientRect(),this.dropdownRect=this.$el.getBoundingClientRect(),this.$el.classList.toggle("dropdown-anchor-bottom",this.parentRect.bottom+this.dropdownRect.height>window.innerHeight&&this.parentRect.top-this.dropdownRect.height>0),this.triggerType==="hover"&&this.toggle("expand")},"@mouseleave"(s){this.triggerType!=="hover"||s.relatedTarget===this.$refs.dropdown||this.$refs.dropdown.contains(s.relatedTarget)||this.toggle("collapse")},"@click.outside"(s){s.target===this.$refs.dropdown||this.$refs.dropdown.contains(s.target)||this.toggle("collapse")}},trigger:{"@click.prevent"(){this.toggle()}},dropdown:{"@mouseleave"(){e==="hover"&&this.toggle("collapse")},":style"(){if(!this.teleport)return;const s=document.dir==="rtl"||document.documentElement.dir==="rtl";let o="top",l="bottom",c=this.parentRect.top+this.parentRect.height+window.scrollY,h=s?"inset-inline-end":"inset-inline-start",d=s?"inset-inline-start":"inset-inline-end",p=s?window.innerWidth-this.parentRect.right:this.parentRect.left;const m=this.parentRect.bottom+this.dropdownRect.height>window.innerHeight,g=this.parentRect.top-this.dropdownRect.height>0;m&&g&&(o="bottom",l="top",c=window.innerHeight-this.parentRect.top+window.scrollY),this.preferredAnchor==="end"&&(s?(h="inset-inline-start",d="inset-inline-end",p=this.parentRect.left):(h="inset-inline-end",d="inset-inline-start",p=window.innerWidth-this.parentRect.right));const v=this.parentRect.left+this.dropdownRect.width>window.innerWidth,w=this.parentRect.right-this.dropdownRect.width<0;return s?w&&this.preferredAnchor!=="end"&&(h="inset-inline-start",d="inset-inline-end",p=this.parentRect.left):v&&this.preferredAnchor!=="end"&&(h="inset-inline-end",d="inset-inline-start",p=window.innerWidth-this.parentRect.right),{[d]:"auto",[h]:`${p}px`,[l]:"auto",[o]:`calc(${c}px + ${this.offsetY})`}}}})),Z.store("notifications",{notifications:[],loading:!1,add(e){this.notifications.unshift(e)},remove(e){this.notifications.splice(e,1)},markThenHref(e){const t=this.notifications.indexOf(e);if(t!==-1){var i=new FormData;i.append("id",e.id),this.loading=!0,$.ajax({url:"/dashboard/notifications/mark-as-read",type:"POST",data:i,cache:!1,contentType:!1,processData:!1,success:r=>{},error:r=>{console.error(r)},complete:()=>{this.markAsRead(t),window.location=e.link,this.loading=!1}})}},markAsRead(e){this.notifications=this.notifications.map((t,i)=>(i===e&&(t.unread=!1),t))},markAllAsRead(){this.loading=!0,$.ajax({url:"/dashboard/notifications/mark-as-read",type:"POST",success:e=>{e.success&&this.notifications.forEach((t,i)=>{this.markAsRead(i)})},error:e=>{console.error(e)},complete:()=>{this.loading=!1}})},setNotifications(e){this.notifications=e},hasUnread:function(){return this.notifications.some(e=>e.unread)}}),Z.data("notifications",e=>({notifications:e||[]})),Z.store("focusMode",{active:Z.$persist(!!$F).as(hS+":lqdFocusModeEnabled"),toggle(e){this.active=e?e==="activate":!this.active,document.body.classList.toggle("focus-mode",this.active)}}),Z.data("numberCounter",({value:e=0,options:t={}})=>({value:e,options:{delay:0,...t},io:null,numberWrappers:[],numberCols:[],numberAnimators:[],init(){this.$el.innerHTML="",this.buildMarkup(),this.setupIO()},updateValue({value:i,options:r={}}){this.value!==i&&(this.value=i,this.options={...this.options,...r},this.buildMarkup(),this.setupIO())},buildMarkup(){const i=this.value.toString().split(""),r=this.$el.querySelectorAll(".lqd-number-counter-numbers-wrap");function s(){return Array.from({length:10},(l,c)=>`<span class="lqd-number-counter-number inline-flex h-full justify-center">${c}</span>`).join("")}if(i.map((l,c)=>{const h=!isNaN(l);return`<span class="lqd-number-counter-numbers-wrap relative inline-flex h-full w-[1ch]" data-index="${c}" data-value="${l}"><span class="lqd-number-counter-numbers-col absolute start-0 top-[-0.25lh] inline-flex h-[1.5lh] w-full flex-col overflow-hidden py-[0.25lh]"><span class="lqd-number-counter-numbers-animator inline-flex w-full h-full flex-col" data-is-number="${h}" data-value="${l}">${h?s():l}</span></span></span>`}).forEach((l,c)=>{const h=i[c],d=r[c],p=!isNaN(h);if(d){const m=d.querySelector(".lqd-number-counter-numbers-animator");d.setAttribute("data-value",h),m.setAttribute("data-value",h),m.setAttribute("data-is-number",p),m.getAttribute("data-is-number")==="true"&&p?m.innerHTML!==s()&&(m.innerHTML=s()):m.innerHTML!==h&&(m.innerHTML=h);return}this.$el.insertAdjacentHTML("beforeend",l),r.length&&this.$el.querySelector(`.lqd-number-counter-numbers-wrap[data-index="${c}"]`).animate([{translate:"0 0.25lh",opacity:0},{translate:"0 0",opacity:1}],{duration:250,easing:"ease",fill:"both"})}),r.length>i.length)for(let l=i.length;l<r.length;l++)r[l].animate([{translate:"0 -0.25lh",opacity:0}],{duration:250,easing:"ease",fill:"both"}).onfinish=()=>{r[l].remove()};this.numberWrappers=this.$el.querySelectorAll(".lqd-number-counter-numbers-wrap"),this.numberCols=this.$el.querySelectorAll(".lqd-number-counter-numbers-col"),this.numberAnimators=this.$el.querySelectorAll(".lqd-number-counter-numbers-animator")},setupIO(){this.io=new IntersectionObserver(([i],r)=>{i.isIntersecting&&(r.disconnect(),this.animate())}),this.io.observe(this.$el)},animate(){this.numberAnimators.forEach(i=>{if(!(i.getAttribute("data-is-number")==="true"))return;const s=i.getAttribute("data-value");i.animate([{translate:`0 ${s*100*-1}%`}],{duration:800,delay:this.options.delay,easing:"cubic-bezier(.47,1.09,.69,1.07)",fill:"both"})})}})),Z.data("shapeCutout",()=>({init(){this.onResize=this.onResize.bind(this),this.afterResize=bn.debounce(this.afterResize.bind(this),1),this.svgEl=this.$el.querySelector("svg"),this.svgEl&&(this.svgObjects=this.svgEl.querySelectorAll("rect, circle, path, polygon"),this.events())},events(){$(window).on("resize",this.onResize),this.resizeObserver=new ResizeObserver(()=>{this.onResize()}),this.resizeObserver.observe(this.svgEl)},onResize(){this.changeObjAttr("-"),this.afterResize()},afterResize(){this.changeObjAttr("+")},changeObjAttr(e){this.svgObjects.forEach(t=>{t.hasAttribute("x")?t.setAttribute("x",parseFloat(parseFloat(t.getAttribute("x"))+e+"1")):t.hasAttribute("width")?t.setAttribute("width",parseFloat(parseFloat(t.getAttribute("width"))+e+"1")):t.hasAttribute("cx")?t.setAttribute("cx",parseFloat(parseFloat(t.getAttribute("cx"))+e+"1")):t.hasAttribute("r")&&t.setAttribute("r",parseFloat(parseFloat(t.getAttribute("r"))+e+"1"))})}})),Z.data("marquee",(e={})=>({maxWidth:0,position:0,options:{direction:-1,speed:.5,pauseOnHover:!1,...e},async init(){this.direction=this.options.direction,this.cellWidths=[],this.cellHeights=[],this.viewportEl=this.$el.querySelector(".lqd-marquee-viewport"),this.sliderEl=this.$el.querySelector(".lqd-marquee-slider"),this.cells=this.sliderEl.querySelectorAll(".lqd-marquee-cell"),this.sliderElStyles=window.getComputedStyle(this.sliderEl),this.maxWidth=0,this.maxHeight=0,this.onResize=bn.debounce(this.onResize.bind(this),450),await document.fonts.ready,this.sizing(),this.startAnimation()},sizing(){for(let t=0;t<this.cells.length;t++)this.cellHeights.push(this.cells[t].offsetHeight),this.cellWidths.push(this.cells[t].offsetWidth);this.maxHeight=Math.max(...this.cellHeights),this.maxWidth=this.cellWidths.reduce((t,i)=>t+i,0),this.maxWidth+=parseInt(this.sliderElStyles.paddingLeft)+parseInt(this.sliderElStyles.paddingRight),this.maxWidth+=parseInt(this.sliderElStyles.gap)*(this.cells.length-1),this.viewportEl.style.height=`${this.maxHeight+parseInt(this.sliderElStyles.paddingTop)+parseInt(this.sliderElStyles.paddingBottom)}px`,this.sliderEl.classList.add("absolute","top-0","left-0","w-full","h-full"),this.maxWidth-=this.viewportEl.offsetWidth},startAnimation(){this.isAnimating=!0,this.options.pauseOnHover&&(this.sliderEl.addEventListener("pointerenter",()=>{this.isAnimating=!1}),this.sliderEl.addEventListener("pointerleave",()=>{this.isAnimating=!0}));const t=()=>{this.isAnimating&&(this.position+=this.options.speed*this.direction,this.position<=-this.maxWidth?this.direction=1:this.position>=0&&(this.direction=-1),this.sliderEl.style.transform=`translateX(${this.position}px)`),requestAnimationFrame(t)};requestAnimationFrame(t)},onResize(){this.sizing()}})),Z.data("marqueev2",(e={})=>({cells:[],timeline:null,IO:null,active:!1,options:{cellsSelector:".lqd-marquee-cell",...e},init(){this.cells=this.$el.querySelectorAll(this.options.cellsSelector),this.timeline=this.horizontalLoop(this.cells,{repeat:-1,paddingRight:24}),this.IO=new IntersectionObserver(([t])=>{this.active=t.isIntersecting,this.cells.forEach(i=>{i.style.willChange=this.active?"transform":"auto"})}).observe(this.$el),this.createObserver()},createObserver(){Observer.create({onChangeY:t=>{let i=1.5;t.deltaY<0&&(i*=-1),gsap.timeline({defaults:{ease:"none"}}).to(this.timeline,{timeScale:i*2.5,duration:.2,overwrite:!0}).to(this.timeline,{timeScale:i/2.5,duration:1},"+=0.3")}})},horizontalLoop(t,i){t=gsap.utils.toArray(t),i=i||{};let r=gsap.timeline({repeat:i.repeat,paused:i.paused,defaults:{ease:"none"},onReverseComplete:()=>r.totalTime(r.rawTime()+r.duration()*100)}),s=t.length,o=t[0].offsetLeft,l=[],c=[],h=[],d=0,p=(i.speed||1)*100,m=i.snap===!1?R=>R:gsap.utils.snap(i.snap||1),g,v,w,S,E,k;for(gsap.set(t,{xPercent:(R,N)=>{let V=c[R]=parseFloat(gsap.getProperty(N,"width","px"));return h[R]=m(parseFloat(gsap.getProperty(N,"x","px"))/V*100+gsap.getProperty(N,"xPercent")),h[R]}}),gsap.set(t,{x:0}),g=t[s-1].offsetLeft+h[s-1]/100*c[s-1]-o+t[s-1].offsetWidth*gsap.getProperty(t[s-1],"scaleX")+(parseFloat(i.paddingRight)||0),k=0;k<s;k++)E=t[k],v=h[k]/100*c[k],w=E.offsetLeft+v-o,S=w+c[k]*gsap.getProperty(E,"scaleX"),r.to(E,{xPercent:m((v-S)/c[k]*100),duration:S/p},0).fromTo(E,{xPercent:m((v-S+g)/c[k]*100)},{xPercent:h[k],duration:(v-S+g-v)/p,immediateRender:!1},S/p).add("label"+k,w/p),l[k]=w/p;function I(R,N){N=N||{},Math.abs(R-d)>s/2&&(R+=R>d?-s:s);let V=gsap.utils.wrap(0,s,R),U=l[V];return U>r.time()!=R>d&&(N.modifiers={time:gsap.utils.wrap(0,r.duration())},U+=r.duration()*(R>d?1:-1)),d=V,N.overwrite=!0,r.tweenTo(U,N)}return r.next=R=>I(d+1,R),r.previous=R=>I(d-1,R),r.current=()=>d,r.toIndex=(R,N)=>I(R,N),r.times=l,r.progress(1,!0).progress(0,!0),i.reversed&&(r.vars.onReverseComplete(),r.reverse()),r}})),Z.data("curtain",(e="curtain",t={})=>({id:e,activeCurtain:0,options:{itemsSelector:".lqd-curtain-item",contentSelector:".lqd-curtain-item-content",contentWidthOuter:".lqd-curtain-item-content-width-outer",contentWidthInner:".lqd-curtain-item-content-width-inner",activeClassname:"lqd-curtain-item-active",inactiveClassname:"lqd-curtain-item-inactive",duration:.65,ease:"cubic-bezier(0.23, 1, 0.320, 1)",trigger:"pointerenter",...t},init(){this.items=[...this.$el.querySelectorAll(this.options.itemsSelector)],this.items.length&&(this.onElementActive=this.onElementActive.bind(this),this.onWindowResize=bn.debounce(this.onWindowResize.bind(this),450),this.setActiveCurtain(),this.setActiveElement(),this.setActiveContentWidth(),this.events())},events(){const{trigger:i}=this.options,r=bn.throttle(this.onElementActive,50,{leading:!0,trailing:!1});this.items.forEach(s=>{s.addEventListener(i,r)}),window.addEventListener("resize",this.onWindowResize)},setActiveCurtain(){this.activeCurtain=this.items.findIndex(i=>i.classList.contains(this.options.activeClassname)),this.$dispatch(`curtain-changed-${this.id}`,{activeCurtain:this.activeCurtain})},setActiveElement(){this.activeElement=this.items[this.activeCurtain]},setActiveContentWidth(){if(!this.getElDirection().includes("row"))return;const r=this.activeElement.querySelector(this.options.contentWidthOuter).offsetWidth;this.$el.style.setProperty("--active-width",`${r}px`)},onElementActive(i){const{activeClassname:r,inactiveClassname:s}=this.options,o=i.currentTarget;this.items.forEach(l=>{l.classList.remove(r),l.classList.add(s)}),o.classList.remove(s),o.classList.add(r),this.setActiveCurtain(),this.setActiveElement()},getElDirection(){return window.getComputedStyle(this.activeElement).flexDirection},onWindowResize(){this.setActiveContentWidth()}})),Z.data("slideshow",(e="slideshow",t=0,i={})=>({activeSlide:0,totalSlides:t,id:e,options:{...i},init(){this.setActiveSlide=this.setActiveSlide.bind(this)},setActiveSlide(r){r===">"?r=this.activeSlide+1:r==="<"&&(r=this.activeSlide-1),r<0?r=this.totalSlides-1:r>=this.totalSlides&&(r=0),this.activeSlide=r,this.$dispatch(`slide-changed-${this.id}`,{activeSlide:this.activeSlide})}})),Z.data("dynamicInput",(e={relativeValue:!1,value:0,min:null,max:null,step:1,onInput:null})=>({value:e.value??0,_relativeValue:e.relativeValue,originalRelativeValue:null,min:e.min,max:e.max,step:e.step??1,onInputFn:e.onInput,prevMouseX:null,overlay:null,mouseDown:!1,changingDelta:0,prevVal:null,get relativeValue(){const t=this._relativeValue;return typeof t=="function"?t():t},set relativeValue(t){this._relativeValue=t},init(){this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onInput=this.onInput.bind(this),this.revertBackRelativeValue=_.throttle(this.revertBackRelativeValue.bind(this),150,{leading:!1}),this.value!=null&&this.updateValue(this.value),this.events(),this.$watch("mouseDown",t=>{this.$el.classList.toggle("dragging",t)})},events(){const t=this.$refs.dynamicLabel,i=this.$refs.dynamicInput;!t||!i||(t.addEventListener("mousedown",this.onMouseDown),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp),i.addEventListener("keydown",this.onKeyDown),i.addEventListener("input",this.onInput))},updateInputValue(t,i=!0){const r=this.$refs.dynamicInput;if(r){if(!isNaN(t)){let s=0;const o=this.step.toString(),l=t.toString();o.includes(".")&&(s=Math.min(2,o.split(".")[1].length)),l.includes(".")&&(s=Math.min(2,l.split(".")[1].length)),s>0&&(t=parseFloat(t).toFixed(s))}r.value=t,i&&r.dispatchEvent(new Event("input",{bubbles:!0}))}},updateValue(t,i=!0,r=!0){if(t==null||!this.$refs.dynamicInput)return;if(this.relativeValue&&isNaN(t)){this.value=t,this.updateInputValue(this.value,!1);return}let o=parseFloat(t);!this.relativeValue&&this.min!=null&&o<this.min&&(o=this.min),!this.relativeValue&&this.max!=null&&o>this.max&&(o=this.max),this.value=o,i&&this.updateInputValue(this.value,r)},onMouseDown(t){const i=this.$refs.dynamicInput;this.mouseDown=!0,this.prevVal=i.value,t.preventDefault(),this.overlay||(this.overlay=document.createElement("div"),this.overlay.classList.add("fixed","top-0","start-0","w-screen","h-screen","z-10"),this.overlay.style.cursor="ew-resize",document.body.appendChild(this.overlay))},onMouseMove(t){if(!this.mouseDown)return;if(!this.prevMouseX&&this.prevMouseX!==0){this.prevMouseX=t.clientX;return}const i=t.clientX,r=i-this.prevMouseX,s=t.shiftKey,o=t.metaKey||t.ctrlKey,l=this.step*(s?10:o?.1:1);if(r!==0){const c=(r>0?1:-1)*l;let d=(!isNaN(parseFloat(this.value))?parseFloat(this.value):0)+c;this.relativeValue&&(d=c),this.changingDelta+=c,this.updateValue(d),this.prevMouseX=i}},onMouseUp(){this.mouseDown&&(this.relativeValue&&this.updateValue(isNaN(this.prevVal)?this.prevVal:parseFloat(this.prevVal||0)+this.changingDelta,!0,!1),this.mouseDown=!1,this.prevMouseX=null,this.changingDelta=0,this.prevVal=null,this.overlay&&(document.body.removeChild(this.overlay),this.overlay=null))},onKeyDown(t){if(t.key==="Enter"||t.key==="Tab"){if(this.updateValue(this.calculateExpression()),t.key==="Tab")return!0;t.preventDefault()}else if(t.key==="ArrowUp"||t.key==="ArrowDown"){t.preventDefault();const i=t.shiftKey,r=t.metaKey||t.ctrlKey,s=this.step*(i?10:r?.1:1),o=t.key==="ArrowUp"?s:-s,l=t.target.value;let h=(!isNaN(parseFloat(l))?parseFloat(l):0)+o;this.relativeValue&&(h=o),this.updateValue(h)}},onInput(t){this.updateValue(t.target.value,!1),typeof this.onInputFn=="function"&&this.onInputFn.call(this,this.value)},calculateExpression(){const t=this.$refs.dynamicInput.value.trim();let i=t;if(t){if(/[-+*/().]/.test(t)&&/[\d)]$/.test(t))try{if(this.isValidExpression(t)){const r=Function('"use strict"; return ('+t+")")();if(!isNaN(r)&&isFinite(r)){i=r;return}}}catch(r){console.log("Invalid expression:",r)}return i}},isValidExpression(t){let i=0;for(let r=0;r<t.length;r++)if(t[r]==="("&&i++,t[r]===")"&&i--,i<0)return!1;return!(i!==0||/[+\-*/]{2,}/.test(t)||/^[+*/]/.test(t)||/[+\-*/]$/.test(t))},revertBackRelativeValue(){this.originalRelativeValue&&(this.relativeValue=this.originalRelativeValue,this.originalRelativeValue=null)}})),Z.data("splitText",(e={})=>({splitText:null,options:{type:"words",tag:"span",charsClass:"lqd-split-unit lqd-split-char",wordsClass:"lqd-split-unit lqd-split-word",linesClass:"lqd-split-unit lqd-split-line",...e},init(){this.splitText=new SplitText(this.$el,this.options);const t=this.splitText.words.length;this.splitText.words.forEach((i,r)=>{i.setAttribute("data-index",r),i.setAttribute("data-last-index",t-1-r),i.style.setProperty("--word-index",r),i.style.setProperty("--word-last-index",t-1-r)}),this.$dispatch("split-text-done",{splitText:this.splitText})}})),Z.data("liquidColorPicker",(e={colorVal:null,onPick:null})=>({_colorVal:e.colorVal,picker:null,onPick:e.onPick,get colorVal(){return this._colorVal},set colorVal(t){this._colorVal=t},init(){this.checkDarkMode=this.checkDarkMode.bind(this),this.checkDarkMode(),this.initColorPicker(),this.events()},initColorPicker(){this.$refs.colorInput.setAttribute("type","text"),this.picker=new ColorPicker(this.$refs.colorInputWrap??this.$el,{color:this.colorVal,submitMode:"instant",showClearButton:!0})},events(){this.$watch("$store.darkMode.on",()=>{this.checkDarkMode()}),this.picker.on("pick",t=>{this.colorVal=t,typeof this.onPick=="function"&&this.onPick.call(this,t),this.$refs.colorInput&&(this.$refs.colorInput.value=t,this.$refs.colorInput.dispatchEvent(new Event("input",{bubbles:!0})))})},checkDarkMode(){const t=localStorage.getItem("lqdDarkMode")=="true";document.documentElement.setAttribute("data-cp-theme",t?"dark":"light"),document.documentElement.setAttribute("data-bs-theme",t?"dark":"light")}})),Z.data("liquidTextReveal",({splitEl:e=null,splitType:t="chars",start:i="top bottom",end:r="center 65%",animateFrom:s={opacity:.2},animateTo:o={opacity:1}})=>({splitType:t==="chars"?"chars,words":t,start:i,end:r,animateFrom:s,animateTo:o,splittedText:null,splitEl:null,getSplitEl(){return e??this.$el},init(){this.onTextSplitted=this.onTextSplitted.bind(this),this.initSplitText()},initSplitText(){SplitText.create(this.getSplitEl(),{autoSplit:!0,onSplit:this.onTextSplitted})},getAnimations(){const l=this.splittedText[this.splitType==="chars,words"?"chars":this.splitType];return gsap.fromTo(l,{...this.animateFrom},{stagger:.1,...this.animateTo})},onTextSplitted(l){this.splittedText=l,ScrollTrigger.create({animation:this.getAnimations(),trigger:this.getSplitEl(),scrub:!0,start:this.start,end:this.end})}})),Z.data("liquidScrollSmooth",()=>({init(){ScrollSmoother.create({smooth:1,effects:!0,smoothTouch:.1})}})),Z.data("updateAvailable",({routes:e={}})=>({routes:{...e||{}},route:"#",isAvailable:!1,isVersionUpdateAvailable:!1,isExtensionUpdateAvailable:!1,updateAvailableExtensions:[],init(){this.checkAvailability()},async checkAvailability(){const t=await fetch(this.routes.check);if(!t.ok){console.error("Network error: check update availablity");return}const i=await t.json();this.isVersionUpdateAvailable=i.versionUpdateAvailable,this.isExtensionUpdateAvailable=i.extensionUpdateAvailable,this.updateAvailableExtensions=i.updateAvailableExtensions,this.isAvailable=this.isVersionUpdateAvailable||this.isExtensionUpdateAvailable,this.isVersionUpdateAvailable?this.route=this.routes.appUpdate:this.isExtensionUpdateAvailable&&(this.route=this.routes.extensionUpdate)}})),Z.data("liquidMegamenu",()=>({liEl:null,header:null,posAppliedClassname:"sub-pos-applied",prevMouseX:null,init(){this.onWindowMouseMove=this.onWindowMouseMove.bind(this),this.liEl=this.$el.closest("li"),this.header=this.$el.closest(".site-header"),this.nav=this.$el.closest(".site-header-nav"),this.position()},position(){if(this.liEl.classList.remove(this.posAppliedClassname),window.innerWidth<992)return this.liEl.classList.add(this.posAppliedClassname);const e=this.liEl.getBoundingClientRect(),t=this.$el.getBoundingClientRect(),i=this.nav.getBoundingClientRect(),r=window.innerWidth,s=i.bottom-e.bottom;let o=(r-t.width)/2;o<0&&(o=0),o+t.width>r&&(o=r-t.width),o>e.right&&(o=e.left-20),this.$el.style.left=`${o-e.left}px`,this.liEl.style.setProperty("--sub-offset",`${s}px`),this.liEl.classList.add(this.posAppliedClassname)},onWindowMouseMove(e){window.innerWidth<992||(this.prevMouseX!==void 0&&(e.clientX>this.prevMouseX?this.$el.setAttribute("data-direction","right"):e.clientX<this.prevMouseX&&this.$el.setAttribute("data-direction","left")),this.prevMouseX=e.clientX)}})),Z.data("openaiRealtime",BI),Z.data("elevenlabsRealtime",eD),Z.data("tiptapEditor",RF),Z.data("advancedImageEditor",qy),Z.data("creativeSuite",VI),Z.data("advancedImageEditor",qy),Z.data("lqdCustomizer",ZI),Z.data("lqdCustomizerFontPicker",QI)});QM.start();export{WF as g};
Save
Cancel