@ibiz-template-plugin/ai-chat 0.0.113 → 0.0.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(){function e(e,n,i,r){var o=t(s(1&r?e.prototype:e),n,i);return 2&r&&"function"==typeof o?function(e){return o.apply(i,e)}:o}function t(){return t="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},t.apply(null,arguments)}function n(e,t,n){return t=s(t),function(e,t){if(t&&("object"==_(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,o()?Reflect.construct(t,n||[],s(e).constructor):t.apply(e,n))}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}function r(e){var t="function"==typeof Map?new Map:void 0;return r=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(o())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var r=new(e.bind.apply(e,i));return n&&a(r,n.prototype),r}(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)},r(e)}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function c(e){return function(e){if(Array.isArray(e))return w(e)}(e)||l(e)||k(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach(function(t){T(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function h(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var c=i&&i.prototype instanceof s?i:s,l=Object.create(c.prototype);return f(l,"_invoke",function(n,i,r){var o,s,c,l=0,u=r||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,c=e,h.n=n,a}};function f(n,i){for(s=n,c=i,t=0;!d&&l&&!r&&t<u.length;t++){var r,o=u[t],f=h.p,p=o[2];n>3?(r=p===i)&&(c=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((r=n<2&&f<o[1])?(s=0,h.v=i,h.n=o[1]):f<p&&(r=n<3||o[0]>i||i>p)&&(o[4]=n,o[5]=i,h.n=p,s=0))}if(r||n>1)return a;throw d=!0,i}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,p),s=u,c=p;(t=s<2?e:c)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,c)):h.n=c:h.v=c);try{if(l=2,o){if(s||(r="next"),t=o[r]){if(!(t=t.call(o,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);o=e}else if((t=(d=h.n<0)?c:n.call(i,h))!==a)break}catch(t){o=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,r,o),!0),l}var a={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][i]?t(t([][i]())):(f(t={},i,function(){return this}),t),d=l.prototype=s.prototype=Object.create(u);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,f(e,r,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=l,f(d,"constructor",l),f(l,"constructor",c),c.displayName="GeneratorFunction",f(l,r,"GeneratorFunction"),f(d),f(d,r,"Generator"),f(d,i,function(){return this}),f(d,"toString",function(){return"[object Generator]"}),(h=function(){return{w:o,m:p}})()}function f(e,t,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}f=function(e,t,n,i){function o(t,n){f(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},f(e,t,n,i)}function p(e,t,n,i,r,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(i,r)}function v(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function a(e){p(o,i,r,a,s,"next",e)}function s(e){p(o,i,r,a,s,"throw",e)}a(void 0)})}}function m(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=k(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function g(e,t){return b(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],c=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);c=!0);}catch(e){l=!0,r=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return s}}(e,t)||k(e,t)||y()}function y(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function k(e,t){if(e){if("string"==typeof e)return w(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(e,t):void 0}}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function b(e){if(Array.isArray(e))return e}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function S(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,M(i.key),i)}}function x(e,t,n){return t&&S(e.prototype,t),n&&S(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function T(e,t,n){return(t=M(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e){var t=function(e,t){if("object"!=_(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=_(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==_(t)?t:t+""}function _(e){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_(e)}System.register(["interactjs","cherry-markdown","lodash-es","qx-util"],function(t,o){"use strict";var a,s,u,f,p;return{setters:[function(e){a=e.default},function(e){s=e.default},function(e){u=e.isUndefined,f=e.cloneDeep},function(e){p=e.QXEvent}],execute:function(){t("createFlatChat",function(){return new Pw});var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},w=function(e){return e&&e.Math===Math&&e},S=w("object"==("undefined"==typeof globalThis?"undefined":_(globalThis))&&globalThis)||w("object"==("undefined"==typeof window?"undefined":_(window))&&window)||w("object"==("undefined"==typeof self?"undefined":_(self))&&self)||w("object"==_(o)&&o)||w("object"==_(o)&&o)||function(){return this}()||Function("return this")(),M={},N=function(e){try{return!!e()}catch(t){return!0}},O=!N(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),E=!N(function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}),A=E,D=Function.prototype.call,I=A?D.bind(D):function(){return D.apply(D,arguments)},L={},R={}.propertyIsEnumerable,z=Object.getOwnPropertyDescriptor,P=z&&!R.call({1:2},1);L.f=P?function(e){var t=z(this,e);return!!t&&t.enumerable}:R;var B,F,H=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},j=E,V=Function.prototype,W=V.call,$=j&&V.bind.bind(W,W),U=j?$:function(e){return function(){return W.apply(e,arguments)}},q=U,K=q({}.toString),J=q("".slice),G=function(e){return J(K(e),8,-1)},Y=N,X=G,Q=Object,Z=U("".split),ee=Y(function(){return!Q("z").propertyIsEnumerable(0)})?function(e){return"String"===X(e)?Z(e,""):Q(e)}:Q,te=function(e){return null==e},ne=te,ie=TypeError,re=function(e){if(ne(e))throw new ie("Can't call method on "+e);return e},oe=ee,ae=re,se=function(e){return oe(ae(e))},ce="object"==("undefined"==typeof document?"undefined":_(document))&&document.all,le=void 0===ce&&void 0!==ce?function(e){return"function"==typeof e||e===ce}:function(e){return"function"==typeof e},ue=le,de=function(e){return"object"==_(e)?null!==e:ue(e)},he=S,fe=le,pe=function(e,t){return arguments.length<2?(n=he[e],fe(n)?n:void 0):he[e]&&he[e][t];var n},ve=U({}.isPrototypeOf),me=S.navigator,ge=me&&me.userAgent,ye=S,ke=ge?String(ge):"",we=ye.process,be=ye.Deno,Ce=we&&we.versions||be&&be.version,Se=Ce&&Ce.v8;Se&&(F=(B=Se.split("."))[0]>0&&B[0]<4?1:+(B[0]+B[1])),!F&&ke&&(!(B=ke.match(/Edge\/(\d+)/))||B[1]>=74)&&(B=ke.match(/Chrome\/(\d+)/))&&(F=+B[1]);var xe=F,Te=N,Me=S.String,_e=!!Object.getOwnPropertySymbols&&!Te(function(){var e=Symbol("symbol detection");return!Me(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&xe&&xe<41}),Ne=_e&&!Symbol.sham&&"symbol"==_(Symbol.iterator),Oe=pe,Ee=le,Ae=ve,De=Object,Ie=Ne?function(e){return"symbol"==_(e)}:function(e){var t=Oe("Symbol");return Ee(t)&&Ae(t.prototype,De(e))},Le=String,Re=le,ze=function(e){try{return Le(e)}catch(t){return"Object"}},Pe=TypeError,Be=function(e){if(Re(e))return e;throw new Pe(ze(e)+" is not a function")},Fe=Be,He=te,je=I,Ve=le,We=de,$e=TypeError,Ue={exports:{}},qe=S,Ke=Object.defineProperty,Je=function(e,t){try{Ke(qe,e,{value:t,configurable:!0,writable:!0})}catch(n){qe[e]=t}return t},Ge=S,Ye=Je,Xe="__core-js_shared__",Qe=Ue.exports=Ge[Xe]||Ye(Xe,{});(Qe.versions||(Qe.versions=[])).push({version:"3.49.0",mode:"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Ze=Ue.exports,et=Ze,tt=function(e,t){return et[e]||(et[e]=t||{})},nt=re,it=Object,rt=function(e){return it(nt(e))},ot=rt,at=U({}.hasOwnProperty),st=Object.hasOwn||function(e,t){return at(ot(e),t)},ct=U,lt=0,ut=Math.random(),dt=ct(1.1.toString),ht=function(e){return"Symbol("+(void 0===e?"":e)+")_"+dt(++lt+ut,36)},ft=tt,pt=st,vt=ht,mt=_e,gt=Ne,yt=S.Symbol,kt=ft("wks"),wt=gt?yt.for||yt:yt&&yt.withoutSetter||vt,bt=function(e){return pt(kt,e)||(kt[e]=mt&&pt(yt,e)?yt[e]:wt("Symbol."+e)),kt[e]},Ct=I,St=de,xt=Ie,Tt=function(e,t){var n=e[t];return He(n)?void 0:Fe(n)},Mt=function(e,t){var n,i;if("string"===t&&Ve(n=e.toString)&&!We(i=je(n,e)))return i;if(Ve(n=e.valueOf)&&!We(i=je(n,e)))return i;if("string"!==t&&Ve(n=e.toString)&&!We(i=je(n,e)))return i;throw new $e("Can't convert object to primitive value")},_t=TypeError,Nt=bt("toPrimitive"),Ot=function(e,t){if(!St(e)||xt(e))return e;var n,i=Tt(e,Nt);if(i){if(void 0===t&&(t="default"),n=Ct(i,e,t),!St(n)||xt(n))return n;throw new _t("Can't convert object to primitive value")}return void 0===t&&(t="number"),Mt(e,t)},Et=Ie,At=function(e){var t=Ot(e,"string");return Et(t)?t:t+""},Dt=de,It=S.document,Lt=Dt(It)&&Dt(It.createElement),Rt=function(e){return Lt?It.createElement(e):{}},zt=Rt,Pt=!O&&!N(function(){return 7!==Object.defineProperty(zt("div"),"a",{get:function(){return 7}}).a}),Bt=O,Ft=I,Ht=L,jt=H,Vt=se,Wt=At,$t=st,Ut=Pt,qt=Object.getOwnPropertyDescriptor;M.f=Bt?qt:function(e,t){if(e=Vt(e),t=Wt(t),Ut)try{return qt(e,t)}catch(n){}if($t(e,t))return jt(!Ft(Ht.f,e,t),e[t])};var Kt={},Jt=O&&N(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),Gt=de,Yt=String,Xt=TypeError,Qt=function(e){if(Gt(e))return e;throw new Xt(Yt(e)+" is not an object")},Zt=O,en=Pt,tn=Jt,nn=Qt,rn=At,on=TypeError,an=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,cn="enumerable",ln="configurable",un="writable";Kt.f=Zt?tn?function(e,t,n){if(nn(e),t=rn(t),nn(n),"function"==typeof e&&"prototype"===t&&"value"in n&&un in n&&!n[un]){var i=sn(e,t);i&&i[un]&&(e[t]=n.value,n={configurable:ln in n?n[ln]:i[ln],enumerable:cn in n?n[cn]:i[cn],writable:!1})}return an(e,t,n)}:an:function(e,t,n){if(nn(e),t=rn(t),nn(n),en)try{return an(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new on("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var dn=Kt,hn=H,fn=O?function(e,t,n){return dn.f(e,t,hn(1,n))}:function(e,t,n){return e[t]=n,e},pn={exports:{}},vn=O,mn=st,gn=Function.prototype,yn=vn&&Object.getOwnPropertyDescriptor,kn=mn(gn,"name"),wn={EXISTS:kn,PROPER:kn&&"something"===function(){}.name,CONFIGURABLE:kn&&(!vn||vn&&yn(gn,"name").configurable)},bn=le,Cn=Ze,Sn=U(Function.toString);bn(Cn.inspectSource)||(Cn.inspectSource=function(e){return Sn(e)});var xn,Tn,Mn,_n=Cn.inspectSource,Nn=le,On=S.WeakMap,En=Nn(On)&&/native code/.test(String(On)),An=ht,Dn=tt("keys"),In=function(e){return Dn[e]||(Dn[e]=An(e))},Ln={},Rn=En,zn=S,Pn=de,Bn=fn,Fn=st,Hn=Ze,jn=In,Vn=Ln,Wn="Object already initialized",$n=zn.TypeError,Un=zn.WeakMap;if(Rn||Hn.state){var qn=Hn.state||(Hn.state=new Un);qn.get=qn.get,qn.has=qn.has,qn.set=qn.set,xn=function(e,t){if(qn.has(e))throw new $n(Wn);return t.facade=e,qn.set(e,t),t},Tn=function(e){return qn.get(e)||{}},Mn=function(e){return qn.has(e)}}else{var Kn=jn("state");Vn[Kn]=!0,xn=function(e,t){if(Fn(e,Kn))throw new $n(Wn);return t.facade=e,Bn(e,Kn,t),t},Tn=function(e){return Fn(e,Kn)?e[Kn]:{}},Mn=function(e){return Fn(e,Kn)}}var Jn={set:xn,get:Tn,has:Mn,enforce:function(e){return Mn(e)?Tn(e):xn(e,{})},getterFor:function(e){return function(t){var n;if(!Pn(t)||(n=Tn(t)).type!==e)throw new $n("Incompatible receiver, "+e+" required");return n}}},Gn=U,Yn=N,Xn=le,Qn=st,Zn=O,ei=wn.CONFIGURABLE,ti=_n,ni=Jn.enforce,ii=Jn.get,ri=String,oi=Object.defineProperty,ai=Gn("".slice),si=Gn("".replace),ci=Gn([].join),li=Zn&&!Yn(function(){return 8!==oi(function(){},"length",{value:8}).length}),ui=String(String).split("String"),di=pn.exports=function(e,t,n){"Symbol("===ai(ri(t),0,7)&&(t="["+si(ri(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Qn(e,"name")||ei&&e.name!==t)&&(Zn?oi(e,"name",{value:t,configurable:!0}):e.name=t),li&&n&&Qn(n,"arity")&&e.length!==n.arity&&oi(e,"length",{value:n.arity});try{n&&Qn(n,"constructor")&&n.constructor?Zn&&oi(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(r){}var i=ni(e);return Qn(i,"source")||(i.source=ci(ui,"string"==typeof t?t:"")),e};Function.prototype.toString=di(function(){return Xn(this)&&ii(this).source||ti(this)},"toString");var hi=pn.exports,fi=le,pi=Kt,vi=hi,mi=Je,gi={},yi=Math.ceil,ki=Math.floor,wi=Math.trunc||function(e){var t=+e;return(t>0?ki:yi)(t)},bi=wi,Ci=function(e){var t=+e;return t!=t||0===t?0:bi(t)},Si=Ci,xi=Math.max,Ti=Math.min,Mi=Ci,_i=Math.min,Ni=function(e){var t=Mi(e);return t>0?_i(t,9007199254740991):0},Oi=function(e){return Ni(e.length)},Ei=se,Ai=function(e,t){var n=Si(e);return n<0?xi(n+t,0):Ti(n,t)},Di=Oi,Ii=function(e){return function(t,n,i){var r=Ei(t),o=Di(r);if(0===o)return!e&&-1;var a,s=Ai(i,o);if(e&&n!=n){for(;o>s;)if((a=r[s++])!=a)return!0}else for(;o>s;s++)if((e||s in r)&&r[s]===n)return e||s||0;return!e&&-1}},Li={includes:Ii(!0),indexOf:Ii(!1)},Ri=st,zi=se,Pi=Li.indexOf,Bi=Ln,Fi=U([].push),Hi=function(e,t){var n,i=zi(e),r=0,o=[];for(n in i)!Ri(Bi,n)&&Ri(i,n)&&Fi(o,n);for(;t.length>r;)Ri(i,n=t[r++])&&(~Pi(o,n)||Fi(o,n));return o},ji=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Vi=Hi,Wi=ji.concat("length","prototype");gi.f=Object.getOwnPropertyNames||function(e){return Vi(e,Wi)};var $i={};$i.f=Object.getOwnPropertySymbols;var Ui=pe,qi=gi,Ki=$i,Ji=Qt,Gi=U([].concat),Yi=Ui("Reflect","ownKeys")||function(e){var t=qi.f(Ji(e)),n=Ki.f;return n?Gi(t,n(e)):t},Xi=st,Qi=Yi,Zi=M,er=Kt,tr=N,nr=le,ir=/#|\.prototype\./,rr=function(e,t){var n=ar[or(e)];return n===cr||n!==sr&&(nr(t)?tr(t):!!t)},or=rr.normalize=function(e){return String(e).replace(ir,".").toLowerCase()},ar=rr.data={},sr=rr.NATIVE="N",cr=rr.POLYFILL="P",lr=rr,ur=S,dr=M.f,hr=fn,fr=function(e,t,n,i){i||(i={});var r=i.enumerable,o=void 0!==i.name?i.name:t;if(fi(n)&&vi(n,o,i),i.global)r?e[t]=n:mi(t,n);else{try{i.unsafe?e[t]&&(r=!0):delete e[t]}catch(a){}r?e[t]=n:pi.f(e,t,{value:n,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},pr=Je,vr=function(e,t,n){for(var i=Qi(t),r=er.f,o=Zi.f,a=0;a<i.length;a++){var s=i[a];Xi(e,s)||n&&Xi(n,s)||r(e,s,o(t,s))}},mr=lr,gr=G,yr=U,kr=function(e){if("Function"===gr(e))return yr(e)},wr=Be,br=E,Cr=kr(kr.bind),Sr=function(e,t){return wr(e),void 0===t?e:br?Cr(e,t):function(){return e.apply(t,arguments)}},xr=ee,Tr=rt,Mr=Oi,_r=function(e){var t=1===e;return function(n,i,r){for(var o,a=Tr(n),s=xr(a),c=Mr(s),l=Sr(i,r);c-- >0;)if(l(o=s[c],c,a))switch(e){case 0:return o;case 1:return c}return t?-1:void 0}},Nr={findLast:_r(0),findLastIndex:_r(1)},Or={},Er=Hi,Ar=ji,Dr=Object.keys||function(e){return Er(e,Ar)},Ir=O,Lr=Jt,Rr=Kt,zr=Qt,Pr=se,Br=Dr;Or.f=Ir&&!Lr?Object.defineProperties:function(e,t){zr(e);for(var n,i=Pr(t),r=Br(t),o=r.length,a=0;o>a;)Rr.f(e,n=r[a++],i[n]);return e};var Fr,Hr=pe("document","documentElement"),jr=Qt,Vr=Or,Wr=ji,$r=Ln,Ur=Hr,qr=Rt,Kr="prototype",Jr="script",Gr=In("IE_PROTO"),Yr=function(){},Xr=function(e){return"<"+Jr+">"+e+"</"+Jr+">"},Qr=function(e){e.write(Xr("")),e.close();var t=e.parentWindow.Object;return e=null,t},Zr=function(){try{Fr=new ActiveXObject("htmlfile")}catch(r){}var e,t,n;Zr="undefined"!=typeof document?document.domain&&Fr?Qr(Fr):(t=qr("iframe"),n="java"+Jr+":",t.style.display="none",Ur.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(Xr("document.F=Object")),e.close(),e.F):Qr(Fr);for(var i=Wr.length;i--;)delete Zr[Kr][Wr[i]];return Zr()};$r[Gr]=!0;var eo=Object.create||function(e,t){var n;return null!==e?(Yr[Kr]=jr(e),n=new Yr,Yr[Kr]=null,n[Gr]=e):n=Zr(),void 0===t?n:Vr.f(n,t)},to=bt,no=eo,io=Kt.f,ro=to("unscopables"),oo=Array.prototype;void 0===oo[ro]&&io(oo,ro,{configurable:!0,value:no(null)});var ao=Nr.findLast,so=function(e){oo[ro][e]=!0};(function(e,t){var n,i,r,o,a,s=e.target,c=e.global,l=e.stat;if(n=c?ur:l?ur[s]||pr(s,{}):ur[s]&&ur[s].prototype)for(i in t){if(o=t[i],r=e.dontCallGetSet?(a=dr(n,i))&&a.value:n[i],!mr(c?i:s+(l?".":"#")+i,e.forced)&&void 0!==r){if(_(o)==_(r))continue;vr(o,r)}(e.sham||r&&r.sham)&&hr(o,"sham",!0),fr(n,i,o,e)}})({target:"Array",proto:!0},{findLast:function(e){return ao(this,e,arguments.length>1?arguments[1]:void 0)}}),so("findLast");var co=S,lo=U;(function(e,t){lo(co[e].prototype[t])})("Array","findLast");var uo,ho,fo,po,vo,mo,go,yo,ko,wo,bo,Co,So,xo={},To=[],Mo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_o=Array.isArray;function No(e,t){for(var n in t)e[n]=t[n];return e}function Oo(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Eo(e,t,n){var i,r,o,a={};for(o in t)"key"==o?i=t[o]:"ref"==o?r=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?uo.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===a[o]&&(a[o]=e.defaultProps[o]);return Ao(e,a,i,r,null)}function Ao(e,t,n,i,r){var o={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==r?++fo:r,__i:-1,__u:0};return null==r&&null!=ho.vnode&&ho.vnode(o),o}function Do(e){return e.children}function Io(e,t){this.props=e,this.context=t}function Lo(e,t){if(null==t)return e.__?Lo(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?Lo(e):null}function Ro(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return Ro(e)}}function zo(e){(!e.__d&&(e.__d=!0)&&vo.push(e)&&!Po.__r++||mo!=ho.debounceRendering)&&((mo=ho.debounceRendering)||go)(Po)}function Po(){for(var e,t,n,i,r,o,a,s=1;vo.length;)vo.length>s&&vo.sort(yo),e=vo.shift(),s=vo.length,e.__d&&(n=void 0,i=void 0,r=(i=(t=e).__v).__e,o=[],a=[],t.__P&&((n=No({},i)).__v=i.__v+1,ho.vnode&&ho.vnode(n),Uo(t.__P,n,i,t.__n,t.__P.namespaceURI,32&i.__u?[r]:null,o,null==r?Lo(i):r,!!(32&i.__u),a),n.__v=i.__v,n.__.__k[n.__i]=n,Ko(o,n,a),i.__e=i.__=null,n.__e!=r&&Ro(n)));Po.__r=0}function Bo(e,t,n,i,r,o,a,s,c,l,u){var d,h,f,p,v,m,g,y=i&&i.__k||To,k=t.length;for(c=function(e,t,n,i,r){var o,a,s,c,l,u=n.length,d=u,h=0;for(e.__k=new Array(r),o=0;o<r;o++)null!=(a=t[o])&&"boolean"!=typeof a&&"function"!=typeof a?(c=o+h,(a=e.__k[o]="string"==typeof a||"number"==typeof a||"bigint"==typeof a||a.constructor==String?Ao(null,a,null,null,null):_o(a)?Ao(Do,{children:a},null,null,null):null==a.constructor&&a.__b>0?Ao(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,s=null,-1!=(l=a.__i=jo(a,n,c,d))&&(d--,(s=n[l])&&(s.__u|=2)),null==s||null==s.__v?(-1==l&&(r>u?h--:r<u&&h++),"function"!=typeof a.type&&(a.__u|=4)):l!=c&&(l==c-1?h--:l==c+1?h++:(l>c?h--:h++,a.__u|=4))):e.__k[o]=null;if(d)for(o=0;o<u;o++)null!=(s=n[o])&&!(2&s.__u)&&(s.__e==i&&(i=Lo(s)),Xo(s,s));return i}(n,t,y,c,k),d=0;d<k;d++)null!=(f=n.__k[d])&&(h=-1==f.__i?xo:y[f.__i]||xo,f.__i=d,m=Uo(e,f,h,r,o,a,s,c,l,u),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&Yo(h.ref,null,f),u.push(f.ref,f.__c||p,f)),null==v&&null!=p&&(v=p),(g=!!(4&f.__u))||h.__k===f.__k?c=Fo(f,c,e,g):"function"==typeof f.type&&void 0!==m?c=m:p&&(c=p.nextSibling),f.__u&=-7);return n.__e=v,c}function Fo(e,t,n,i){var r,o;if("function"==typeof e.type){for(r=e.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=e,t=Fo(r[o],t,n,i));return t}e.__e!=t&&(i&&(t&&e.type&&!t.parentNode&&(t=Lo(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function Ho(e,t){return t=t||[],null==e||"boolean"==typeof e||(_o(e)?e.some(function(e){Ho(e,t)}):t.push(e)),t}function jo(e,t,n,i){var r,o,a,s=e.key,c=e.type,l=t[n],u=null!=l&&!(2&l.__u);if(null===l&&null==e.key||u&&s==l.key&&c==l.type)return n;if(i>(u?1:0))for(r=n-1,o=n+1;r>=0||o<t.length;)if(null!=(l=t[a=r>=0?r--:o++])&&!(2&l.__u)&&s==l.key&&c==l.type)return a;return-1}function Vo(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||Mo.test(t)?n:n+"px"}function Wo(e,t,n,i,r){var o,a;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof i&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||Vo(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||Vo(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])o=t!=(t=t.replace(ko,"$1")),a=t.toLowerCase(),t=a in e||"onFocusOut"==t||"onFocusIn"==t?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?i?n.u=i.u:(n.u=wo,e.addEventListener(t,o?Co:bo,o)):e.removeEventListener(t,o?Co:bo,o);else{if("http://www.w3.org/2000/svg"==r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function $o(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t.t)t.t=wo++;else if(t.t<n.u)return;return n(ho.event?ho.event(t):t)}}}function Uo(e,t,n,i,r,o,a,s,c,l){var u,d,h,f,p,v,m,g,y,k,w,b,C,S,x,T,M,_=t.type;if(null!=t.constructor)return null;128&n.__u&&(c=!!(32&n.__u),o=[s=t.__e=n.__e]),(u=ho.__b)&&u(t);e:if("function"==typeof _)try{if(g=t.props,y="prototype"in _&&_.prototype.render,k=(u=_.contextType)&&i[u.__c],w=u?k?k.props.value:u.__:i,n.__c?m=(d=t.__c=n.__c).__=d.__E:(y?t.__c=d=new _(g,w):(t.__c=d=new Io(g,w),d.constructor=_,d.render=Qo),k&&k.sub(d),d.props=g,d.state||(d.state={}),d.context=w,d.__n=i,h=d.__d=!0,d.__h=[],d._sb=[]),y&&null==d.__s&&(d.__s=d.state),y&&null!=_.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=No({},d.__s)),No(d.__s,_.getDerivedStateFromProps(g,d.__s))),f=d.props,p=d.state,d.__v=t,h)y&&null==_.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),y&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(y&&null==_.getDerivedStateFromProps&&g!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(g,w),!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(g,d.__s,w)||t.__v==n.__v){for(t.__v!=n.__v&&(d.props=g,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),b=0;b<d._sb.length;b++)d.__h.push(d._sb[b]);d._sb=[],d.__h.length&&a.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(g,d.__s,w),y&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(f,p,v)})}if(d.context=w,d.props=g,d.__P=e,d.__e=!1,C=ho.__r,S=0,y){for(d.state=d.__s,d.__d=!1,C&&C(t),u=d.render(d.props,d.state,d.context),x=0;x<d._sb.length;x++)d.__h.push(d._sb[x]);d._sb=[]}else do{d.__d=!1,C&&C(t),u=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++S<25);d.state=d.__s,null!=d.getChildContext&&(i=No(No({},i),d.getChildContext())),y&&!h&&null!=d.getSnapshotBeforeUpdate&&(v=d.getSnapshotBeforeUpdate(f,p)),T=u,null!=u&&u.type===Do&&null==u.key&&(T=Jo(u.props.children)),s=Bo(e,_o(T)?T:[T],t,n,i,r,o,a,s,c,l),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),m&&(d.__E=d.__=null)}catch(e){if(t.__v=null,c||null!=o)if(e.then){for(t.__u|=c?160:128;s&&8==s.nodeType&&s.nextSibling;)s=s.nextSibling;o[o.indexOf(s)]=null,t.__e=s}else{for(M=o.length;M--;)Oo(o[M]);qo(t)}else t.__e=n.__e,t.__k=n.__k,e.then||qo(t);ho.__e(e,t,n)}else null==o&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Go(n.__e,t,n,i,r,o,a,c,l);return(u=ho.diffed)&&u(t),128&t.__u?void 0:s}function qo(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(qo)}function Ko(e,t,n){for(var i=0;i<n.length;i++)Yo(n[i],n[++i],n[++i]);ho.__c&&ho.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){ho.__e(e,t.__v)}})}function Jo(e){return"object"!=_(e)||null==e||e.__b&&e.__b>0?e:_o(e)?e.map(Jo):No({},e)}function Go(e,t,n,i,r,o,a,s,c){var l,u,d,h,f,p,v,m=n.props,g=t.props,y=t.type;if("svg"==y?r="http://www.w3.org/2000/svg":"math"==y?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),null!=o)for(l=0;l<o.length;l++)if((f=o[l])&&"setAttribute"in f==!!y&&(y?f.localName==y:3==f.nodeType)){e=f,o[l]=null;break}if(null==e){if(null==y)return document.createTextNode(g);e=document.createElementNS(r,y,g.is&&g),s&&(ho.__m&&ho.__m(t,o),s=!1),o=null}if(null==y)m===g||s&&e.data==g||(e.data=g);else{if(o=o&&uo.call(e.childNodes),m=n.props||xo,!s&&null!=o)for(m={},l=0;l<e.attributes.length;l++)m[(f=e.attributes[l]).name]=f.value;for(l in m)if(f=m[l],"children"==l);else if("dangerouslySetInnerHTML"==l)d=f;else if(!(l in g)){if("value"==l&&"defaultValue"in g||"checked"==l&&"defaultChecked"in g)continue;Wo(e,l,null,f,r)}for(l in g)f=g[l],"children"==l?h=f:"dangerouslySetInnerHTML"==l?u=f:"value"==l?p=f:"checked"==l?v=f:s&&"function"!=typeof f||m[l]===f||Wo(e,l,f,m[l],r);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),Bo("template"==t.type?e.content:e,_o(h)?h:[h],t,n,i,"foreignObject"==y?"http://www.w3.org/1999/xhtml":r,o,a,o?o[0]:n.__k&&Lo(n,0),s,c),null!=o)for(l=o.length;l--;)Oo(o[l]);s||(l="value","progress"==y&&null==p?e.removeAttribute("value"):null!=p&&(p!==e[l]||"progress"==y&&!p||"option"==y&&p!=m[l])&&Wo(e,l,p,m[l],r),l="checked",null!=v&&v!=e[l]&&Wo(e,l,v,m[l],r))}return e}function Yo(e,t,n){try{if("function"==typeof e){var i="function"==typeof e.__u;i&&e.__u(),i&&null==t||(e.__u=e(t))}else e.current=t}catch(e){ho.__e(e,n)}}function Xo(e,t,n){var i,r;if(ho.unmount&&ho.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Yo(i,null,t)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){ho.__e(e,t)}i.base=i.__P=null}if(i=e.__k)for(r=0;r<i.length;r++)i[r]&&Xo(i[r],t,n||"function"!=typeof e.type);n||Oo(e.__e),e.__c=e.__=e.__e=void 0}function Qo(e,t,n){return this.constructor(e,n)}function Zo(e,t,n){var i,r,o,a;t==document&&(t=document.documentElement),ho.__&&ho.__(e,t),r=(i="function"==typeof n)?null:n&&n.__k||t.__k,o=[],a=[],Uo(t,e=(!i&&n||t).__k=Eo(Do,null,[e]),r||xo,xo,t.namespaceURI,!i&&n?[n]:r?null:t.firstChild?uo.call(t.childNodes):null,o,!i&&n?n:r?r.__e:t.firstChild,i,a),Ko(o,e,a)}function ea(e){function t(e){var n,i;return this.getChildContext||(n=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,zo(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+So++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}uo=To.slice,ho={__e:function(e,t,n,i){for(var r,o,a;t=t.__;)if((r=t.__c)&&!r.__)try{if((o=r.constructor)&&null!=o.getDerivedStateFromError&&(r.setState(o.getDerivedStateFromError(e)),a=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,i||{}),a=r.__d),a)return r.__E=r}catch(t){e=t}throw e}},fo=0,po=function(e){return null!=e&&null==e.constructor},Io.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=No({},this.state),"function"==typeof e&&(e=e(No({},n),this.props)),e&&No(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),zo(this))},Io.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),zo(this))},Io.prototype.render=Do,vo=[],go="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,yo=function(e,t){return e.__v.__b-t.__v.__b},Po.__r=0,ko=/(PointerCapture)$|Capture$/i,wo=0,bo=$o(!1),Co=$o(!0),So=0;var ta=0;function na(e,t,n,i,r,o){t||(t={});var a,s,c=t;if("ref"in c)for(s in c={},t)"ref"==s?a=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ta,__i:-1,__u:0,__source:r,__self:o};if("function"==typeof e&&(a=e.defaultProps))for(s in a)void 0===c[s]&&(c[s]=a[s]);return ho.vnode&&ho.vnode(l),l}function ia(e,t,n,i,r){var o="".concat(e,"-").concat(t);return n&&(o+="-".concat(n)),i&&(o+="__".concat(i)),r&&(o+="--".concat(r)),o}var ra=function(){return x(function e(t,n){C(this,e),T(this,"namespace",void 0),this.block=t,this.namespace=n||"ibiz"},[{key:"b",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return ia(this.namespace,this.block,e,"","")}},{key:"e",value:function(e){return e?ia(this.namespace,this.block,"",e,""):""}},{key:"m",value:function(e){return e?ia(this.namespace,this.block,"","",e):""}},{key:"be",value:function(e,t){return e&&t?ia(this.namespace,this.block,e,t,""):""}},{key:"em",value:function(e,t){return e&&t?ia(this.namespace,this.block,"",e,t):""}},{key:"bm",value:function(e,t){return e&&t?ia(this.namespace,this.block,e,"",t):""}},{key:"bem",value:function(e,t,n){return e&&t&&n?ia(this.namespace,this.block,e,t,n):""}},{key:"is",value:function(e,t){return e&&t?"".concat("is-").concat(e):""}},{key:"cssVar",value:function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarName(n)]=e[n]);return t}},{key:"cssVarBlock",value:function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarBlockName(n)]=e[n]);return t}},{key:"cssVarName",value:function(e){return"--".concat(this.namespace,"-").concat(e)}},{key:"cssVarBlockName",value:function(e){return"--".concat(this.namespace,"-").concat(this.block,"-").concat(e)}}])}();function oa(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function aa(e,t){for(var n,i="",r=0,o=-1,a=0,s=0;s<=e.length;++s){if(s<e.length)n=e.charCodeAt(s);else{if(47===n)break;n=47}if(47===n){if(o===s-1||1===a);else if(o!==s-1&&2===a){if(i.length<2||2!==r||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2))if(i.length>2){var c=i.lastIndexOf("/");if(c!==i.length-1){-1===c?(i="",r=0):r=(i=i.slice(0,c)).length-1-i.lastIndexOf("/"),o=s,a=0;continue}}else if(2===i.length||1===i.length){i="",r=0,o=s,a=0;continue}t&&(i.length>0?i+="/..":i="..",r=2)}else i.length>0?i+="/"+e.slice(o+1,s):i=e.slice(o+1,s),r=s-o-1;o=s,a=0}else 46===n&&-1!==a?++a:a=-1}return i}var sa={resolve:function(){for(var e,t="",n=!1,i=arguments.length-1;i>=-1&&!n;i--){var r;i>=0?r=arguments[i]:(void 0===e&&(e=process.cwd()),r=e),oa(r),0!==r.length&&(t=r+"/"+t,n=47===r.charCodeAt(0))}return t=aa(t,!n),n?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(oa(e),0===e.length)return".";var t=47===e.charCodeAt(0),n=47===e.charCodeAt(e.length-1);return 0!==(e=aa(e,!t)).length||t||(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return oa(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];oa(n),n.length>0&&(void 0===e?e=n:e+="/"+n)}return void 0===e?".":sa.normalize(e)},relative:function(e,t){if(oa(e),oa(t),e===t)return"";if((e=sa.resolve(e))===(t=sa.resolve(t)))return"";for(var n=1;n<e.length&&47===e.charCodeAt(n);++n);for(var i=e.length,r=i-n,o=1;o<t.length&&47===t.charCodeAt(o);++o);for(var a=t.length-o,s=r<a?r:a,c=-1,l=0;l<=s;++l){if(l===s){if(a>s){if(47===t.charCodeAt(o+l))return t.slice(o+l+1);if(0===l)return t.slice(o+l)}else r>s&&(47===e.charCodeAt(n+l)?c=l:0===l&&(c=0));break}var u=e.charCodeAt(n+l);if(u!==t.charCodeAt(o+l))break;47===u&&(c=l)}var d="";for(l=n+c+1;l<=i;++l)l!==i&&47!==e.charCodeAt(l)||(0===d.length?d+="..":d+="/..");return d.length>0?d+t.slice(o+c):(o+=c,47===t.charCodeAt(o)&&++o,t.slice(o))},_makeLong:function(e){return e},dirname:function(e){if(oa(e),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,i=-1,r=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!r){i=o;break}}else r=!1;return-1===i?n?"/":".":n&&1===i?"//":e.slice(0,i)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');oa(e);var n,i=0,r=-1,o=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,s=-1;for(n=e.length-1;n>=0;--n){var c=e.charCodeAt(n);if(47===c){if(!o){i=n+1;break}}else-1===s&&(o=!1,s=n+1),a>=0&&(c===t.charCodeAt(a)?-1===--a&&(r=n):(a=-1,r=s))}return i===r?r=s:-1===r&&(r=e.length),e.slice(i,r)}for(n=e.length-1;n>=0;--n)if(47===e.charCodeAt(n)){if(!o){i=n+1;break}}else-1===r&&(o=!1,r=n+1);return-1===r?"":e.slice(i,r)},extname:function(e){oa(e);for(var t=-1,n=0,i=-1,r=!0,o=0,a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47!==s)-1===i&&(r=!1,i=a+1),46===s?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!r){n=a+1;break}}return-1===t||-1===i||0===o||1===o&&t===i-1&&t===n+1?"":e.slice(t,i)},format:function(e){if(null===e||"object"!==_(e))throw new TypeError('The "pathObject" argument must be of type Object. Received type '+_(e));return function(e,t){var n=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+i:n+e+i:i}("/",e)},parse:function(e){oa(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var n,i=e.charCodeAt(0),r=47===i;r?(t.root="/",n=1):n=0;for(var o=-1,a=0,s=-1,c=!0,l=e.length-1,u=0;l>=n;--l)if(47!==(i=e.charCodeAt(l)))-1===s&&(c=!1,s=l+1),46===i?-1===o?o=l:1!==u&&(u=1):-1!==o&&(u=-1);else if(!c){a=l+1;break}return-1===o||-1===s||0===u||1===u&&o===s-1&&o===a+1?-1!==s&&(t.base=t.name=0===a&&r?e.slice(1,s):e.slice(a,s)):(0===a&&r?(t.name=e.slice(1,o),t.base=e.slice(1,s)):(t.name=e.slice(a,o),t.base=e.slice(a,s)),t.ext=e.slice(o,s)),a>0?t.dir=e.slice(0,a-1):r&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};function ca(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function la(){return"".concat(ca()+ca(),"-").concat(ca(),"-").concat(ca(),"-").concat(ca(),"-").concat(ca()).concat(ca()).concat(ca())}function ua(e){var t=e.lastIndexOf("@");return-1===t?e:e.substring(0,t)}sa.posix=sa;var da=/<svg\b[^>]*>[\s\S]*?<\/svg>/;function ha(e){return da.test(e)}function fa(e,t){var n="";switch(e){case"TOPIC":n+="topic";break;case"INLINE":n+="inline";break;case"TEMP":n+="temp";break;default:n+="unknow"}return n+="@".concat(t||la(),"@").concat((new Date).getTime())}function pa(e){var t=new URL(e),n={},i={};if(t.searchParams.size>0){var r=t.searchParams.get("srfnavctx");if(r){try{Object.assign(n,JSON.parse(r))}catch(d){console.warn("解析 srfnavctx 参数失败,已做容错处理",{value:r,error:d})}t.searchParams.delete("srfnavctx")}t.searchParams.forEach(function(e,t){i[t]=e})}else if(t.search){var o=function(e){var t={};e.startsWith("?")&&(e=e.substring(1));for(var n=e.split("&"),i=0;i<n.length;i++){var r=g(n[i].split("="),2),o=r[0],a=r[1];t[o]=a}return t}(t.search),a=o.srfnavctx;if(a){try{var s=decodeURIComponent(a);Object.assign(n,JSON.parse(s))}catch(d){console.warn("解析 srfnavctx 参数失败,已做容错处理",{value:a,error:d})}delete o.srfnavctx}Object.keys(o).forEach(function(e){i[e]=o[e]})}var c=g((t.pathname||t.hostname).replace("//","").split("/"),2),l=c[0],u=c[1];return{context:n,params:i,typeId:u||l}}function va(e){var t=(new DOMParser).parseFromString(e,"text/html");var n=Array.from(t.body.childNodes).map(function e(t){if(t.nodeType===Node.TEXT_NODE)return t.textContent||"";if(t.nodeType!==Node.ELEMENT_NODE)return"";var n=t,i=n.tagName.toLowerCase(),r=Array.from(n.childNodes).map(function(t){return e(t)}).join("");switch(i){case"p":return"".concat(r,"\n");case"br":return"\n";case"img":var o=n.getAttribute("src")||"",a=n.getAttribute("alt")||"";return o?"\n![".concat(a,"](").concat(o,")\n"):"";default:return t.textContent||""}}).join("").replace(/\n+/g,"\n").replace(/^\n|\n$/g,"");return n}function ma(e){var t,n=[],i="",r=m(e.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1">').split("\n"));try{for(r.s();!(t=r.n()).done;){var o=t.value.trim();o?o.startsWith("<img")&&o.endsWith(">")?(i&&(n.push("<p>".concat(i,"</p>")),i=""),n.push(o)):i?i+="<br>".concat(o):i=o:i&&(n.push("<p>".concat(i,"</p>")),i="")}}catch(a){r.e(a)}finally{r.f()}return i&&n.push("<p>".concat(i,"</p>")),n.join("")}function ga(e){if("string"!=typeof e||!e.trim())return{};var t=e.length,n=0;function i(){for(;n<t&&/\s/.test(e[n]);)n+=1}function r(){var i=function(n){for(var i="{"===e[n]?"}":"]",r=0,o=n;o<t;o+=1)if(e[o]===e[n])r+=1;else if(e[o]===i&&0==(r-=1))return o;return-1}(n);if(-1!==i)try{var r=JSON.parse(e.slice(n,i+1));return n=i+1,r}catch(o){return}}function o(){var a=arguments.length>0&&void 0!==arguments[0]&&arguments[0];i();var s=e[n];if("{"===s){var c=r();return void 0!==c?c:function(){var r={};if(n+=1,i(),"}"===e[n])return n+=1,r;for(;n<t;){i();for(var a=n;n<t&&"="!==e[n]&&","!==e[n]&&"}"!==e[n];)n+=1;var s=e.slice(a,n).trim();if(!s||"="!==e[n])break;if(n+=1,r[s]=o(),i(),","!==e[n]){"}"===e[n]&&(n+=1);break}n+=1}return r}()}if("["===s){for(var l=n+1;l<t&&/\s/.test(e[l]);)l+=1;if("]"===e[l]||"{"===e[l]){var u=r();return void 0!==u?u:function(){var r=[];if(n+=1,i(),"]"===e[n])return n+=1,r;for(;n<t;){if(r.push(o(!0)),i(),","!==e[n]){"]"===e[n]&&(n+=1);break}n+=1}return r}()}}for(var d,h=n;n<t&&","!==e[n]&&"}"!==e[n]&&(!a||"]"!==e[n]);)n+=1;return"true"===(d=e.slice(h,n).trim())||"false"!==d&&("null"===d?null:/^-?\d+$/.test(d)&&!/^-?0\d/.test(d)||/^-?\d+\.\d+$/.test(d)?Number(d):d)}i();var a=o();return"object"!==_(a)||null===a||Array.isArray(a)?{}:a}var ya=function(){return x(function e(){C(this,e)},null,[{key:"copy",value:function(e){return this.element||(this.element=document.createElement("textarea"),this.element.style.position="absolute",this.element.style.left="-9999px",document.body.appendChild(this.element)),this.element.value=e,this.element.select(),document.execCommand("copy")}}])}();T(ya,"element",null);var ka=function(){function e(){C(this,e)}return x(e,null,[{key:"checkDataBaseExists",value:(u=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,indexedDB.databases();case 1:return n=e.v,e.a(2,n.some(function(e){return e.name===t}));case 2:return e.p=2,i=e.v,console.error("检查数据库是否存在时出错:",i),e.a(2,!1)}},e,null,[[0,2]])})),function(e){return u.apply(this,arguments)})},{key:"deleteDatabase",value:(l=v(h().m(function t(n){var i,r;return h().w(function(t){for(;;)if(0===t.n)return e.lastLink&&(null===(i=(r=e.lastLink).close)||void 0===i||i.call(r)),t.a(2,new Promise(function(e,t){var i=indexedDB.deleteDatabase(n);i.onsuccess=function(){e(!0)},i.onerror=function(){e(!1)},i.onblocked=function(){console.warn("删除数据库 ".concat(n," 被阻塞,可能有其他连接正在使用该数据库。")),t(new Error("删除数据库 ".concat(n," 被阻塞")))}}))},t)})),function(e){return l.apply(this,arguments)})},{key:"checkTableExists",value:(c=v(h().m(function t(n,i){return h().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.checkDataBaseExists(n);case 1:if(t.v){t.n=2;break}return t.a(2,!1);case 2:return t.a(2,new Promise(function(t,r){var o=indexedDB.open(n);o.onupgradeneeded=function(t){e.db=t.target.result,e.version=e.db.version},o.onsuccess=function(n){e.db=n.target.result,e.lastLink=o.result;var r=e.db.objectStoreNames.contains(i);o.result.close(),t(r)},o.onerror=function(e){r(e.target.error)}}))}},t)})),function(e,t){return c.apply(this,arguments)})},{key:"createTable",value:(s=v(h().m(function t(n,i,r){var o,a=arguments;return h().w(function(t){for(;;)if(0===t.n)return o=a.length>3&&void 0!==a[3]&&a[3],t.a(2,new Promise(function(t){var a,s;e.version+=1,e.lastLink&&(null===(a=(s=e.lastLink).close)||void 0===a||a.call(s));var c=indexedDB.open(n,e.version);c.onupgradeneeded=function(t){if(e.db=t.target.result,!e.db.objectStoreNames.contains(i)){var n={};r?n.keyPath=r:o&&(n.autoIncrement=!0),e.db.createObjectStore(i,n)}},c.onsuccess=function(){e.lastLink=c.result,c.result.close(),t(!0)},c.onerror=function(){t(!1)}}))},t)})),function(e,t,n){return s.apply(this,arguments)})},{key:"deleteTable",value:(a=v(h().m(function t(n,i){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t){var r,o;e.version+=1,e.lastLink&&(null===(r=(o=e.lastLink).close)||void 0===r||r.call(o));var a=indexedDB.open(n,e.version);a.onupgradeneeded=function(t){e.db=t.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(i)&&e.db.deleteObjectStore(i)},a.onsuccess=function(n){e.db=n.target.result,e.lastLink=a.result,a.result.close(),t(!0)},a.onerror=function(){a.result.close(),t(!1)}}))},t)})),function(e,t){return a.apply(this,arguments)})},{key:"addData",value:(o=v(h().m(function t(n,i,r){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(i)){var o=e.db.transaction([i],"readwrite").objectStore(i).add(r);o.onsuccess=function(e){t(r)},o.onerror=function(){t(null)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return o.apply(this,arguments)})},{key:"deleteData",value:(r=v(h().m(function t(n,i,r){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(i)){var o=e.db.transaction([i],"readwrite").objectStore(i).delete(r);o.onsuccess=function(e){t(!0)},o.onerror=function(){t(!1)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return r.apply(this,arguments)})},{key:"updateData",value:(i=v(h().m(function t(n,i,r){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(i)){var o=e.db.transaction([i],"readwrite").objectStore(i).put(r);o.onsuccess=function(e){t(r)},o.onerror=function(){t(r)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return i.apply(this,arguments)})},{key:"getData",value:(n=v(h().m(function t(n,i,r){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(i)){var s=e.db.transaction([i],"readonly").objectStore(i).get(r);s.onsuccess=function(e){t(s.result)},s.onerror=function(){o(new Error("未找到数据".concat(r)))}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,i){return n.apply(this,arguments)})},{key:"getAllData",value:(t=v(h().m(function t(n,i){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,r){var o=indexedDB.open(n);o.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=o.result,e.db.objectStoreNames.contains(i)){var r=e.db.transaction([i],"readonly").objectStore(i).getAll();r.onsuccess=function(e){t(r.result)},r.onerror=function(){t([])}}o.result.close()},o.onerror=function(){o.result.close(),r()}}))},t)})),function(e,n){return t.apply(this,arguments)})}]);var t,n,i,r,o,a,s,c,l,u}();T(ka,"version",1),T(ka,"db",null),T(ka,"lastLink",void 0);var wa=function(){return x(function e(t){C(this,e),T(this,"options",void 0),this.options=d({multiple:!0,accept:"*/*",maxSize:5242880},t)},[{key:"openFilePicker",value:function(){var e=this,t=document.createElement("input");t.type="file",t.multiple=this.options.multiple,t.accept=this.options.accept||"",t.onchange=function(t){var n=Array.from(t.target.files||[]);e.handleFiles(n)},t.click()}},{key:"handleFiles",value:(t=v(h().m(function e(t){var n,i,r,o=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(0!==t.length){e.n=1;break}return e.a(2);case 1:return r=t.filter(function(e){var t,n;return!(o.options.maxSize&&e.size>o.options.maxSize&&(null===(t=(n=o.options).onError)||void 0===t||t.call(n,new Error("文件大小超过限制 (".concat(o.formatSize(e.size)," > ").concat(o.formatSize(o.options.maxSize),")")),e),1))}),null===(n=(i=this.options).onSelect)||void 0===n||n.call(i,r),e.n=2,Promise.all(r.map(function(e){return o.processFile(e)}));case 2:return e.a(2)}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"processFile",value:(e=v(h().m(function e(t){var n,i,r,o,a,s,c,l,u,d=this;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,a=function(e){var n,i;null===(n=(i=d.options).onProgress)||void 0===n||n.call(i,t,e)},e.n=1,this.options.onUpload(t,a);case 1:s=e.v,null===(n=(i=this.options).onProgress)||void 0===n||n.call(i,t,100),null===(r=(o=this.options).onSuccess)||void 0===r||r.call(o,s,t),e.n=3;break;case 2:e.p=2,u=e.v,null===(c=(l=this.options).onError)||void 0===c||c.call(l,u instanceof Error?u:new Error("上传失败"),t);case 3:return e.a(2)}},e,this,[[0,2]])})),function(t){return e.apply(this,arguments)})},{key:"formatSize",value:function(e){if(0===e)return"0 B";var t=Math.floor(Math.log(e)/Math.log(1024));return"".concat((e/Math.pow(1024,t)).toFixed(2)," ").concat(["B","KB","MB","GB"][t])}}]);var e,t}(),ba=function(){return x(function e(){C(this,e)},null,[{key:"getCdataContent",value:function(e){if(!e)return null;var t=Array.from(e.childNodes).find(function(e){return e.nodeType===e.CDATA_SECTION_NODE});return(null==t?void 0:t.nodeValue)||e.textContent}},{key:"parse",value:function(e){var t=this,n=(new DOMParser).parseFromString(e,"text/xml");return Array.from(n.querySelectorAll("resource")).map(function(e){var n=e.getAttribute("type")||"",i=e.querySelector("data"),r=e.querySelector("metadata"),o=t.getCdataContent(i),a=t.getCdataContent(r),s={},c={};try{o&&(s=JSON.parse(o))}catch(vs){console.warn("解析 resource data 失败,已做容错处理",{value:o,error:vs})}try{a&&(c=JSON.parse(a))}catch(vs){console.warn("解析 resource metadata 失败,已做容错处理",{value:a,error:vs})}return{id:s.id,type:n,data:s,metadata:c}})}},{key:"parseMixedContent",value:function(e){if(!e)return{resources:[],remainingText:"",hasResources:!1};var t=/<resources\b[^>]*>[\s\S]*?<\/resources>/i.exec(e);if(!t)return{resources:[],remainingText:e,hasResources:!1};var n=g(t,1)[0],i=t.index,r=i+n.length,o=(e.slice(0,i)+e.slice(r)).replace(/\n/g,"").replace(/(!\[[^\]]*\]\([^)]+\))/g,"\n$1\n").replace(/\n+/g,"\n").replace(/^\n|\n$/g,"");try{return{resources:this.parse(n),remainingText:o,hasResources:!0}}catch(a){return{resources:[],remainingText:o,hasResources:!0,error:"资源解析失败: ".concat(a.message)}}}},{key:"stringify",value:function(e){var t=document.implementation.createDocument(null,null,null),n=t.createElement("resources");n.setAttribute("version","1.0");var i=function(e){return"\n".concat(" ".repeat(e))};return e.forEach(function(e){n.appendChild(t.createTextNode(i(1)));var r=t.createElement("resource");r.setAttribute("type",e.type),r.setAttribute("version","1.0");var o=function(e,n){var r=t.createElement(e);r.appendChild(t.createTextNode(i(2)));var o=t.createCDATASection(JSON.stringify(n));return r.appendChild(o),r.appendChild(t.createTextNode(i(1))),r};r.appendChild(t.createTextNode(i(2))),r.appendChild(o("data",e.data)),r.appendChild(t.createTextNode(i(2))),r.appendChild(o("metadata",e.metadata)),r.appendChild(t.createTextNode(i(1))),n.appendChild(r)}),n.appendChild(t.createTextNode("\n")),t.appendChild(n),(new XMLSerializer).serializeToString(t).replace(/></g,">\n<")}}])}(),Ca=function(){return x(function e(){C(this,e)},null,[{key:"getCdataContent",value:function(e){if(!e)return null;var t=Array.from(e.childNodes).find(function(e){return e.nodeType===e.CDATA_SECTION_NODE});return(null==t?void 0:t.nodeValue)||e.textContent}},{key:"parse",value:function(e){var t=this,n=(new DOMParser).parseFromString(e,"text/xml");return Array.from(n.querySelectorAll("suggestion")).map(function(e){var n=e.getAttribute("type")||"",i=e.querySelector("data"),r=e.querySelector("metadata"),o=t.getCdataContent(i),a=t.getCdataContent(r),s={},c={};try{o&&(s=JSON.parse(o))}catch(vs){console.warn("解析 suggestion data 失败,已做容错处理",{value:o,error:vs})}try{a&&(c=JSON.parse(a))}catch(vs){console.warn("解析 suggestion metadata 失败,已做容错处理",{value:a,error:vs})}return{type:n,data:s,metadata:c}})}},{key:"parseMixedContent",value:function(e){var t=/<suggestions\b[^>]*>[\s\S]*?<\/suggestions>/i.exec(e);if(!t)return{suggestions:[],remainingText:e,hasSuggestions:!1};var n=g(t,1)[0],i=t.index,r=i+n.length,o=(e.slice(0,i)+e.slice(r)).replace(/\n/g,"");try{return{suggestions:this.parse(n),remainingText:o,hasSuggestions:!0}}catch(a){return{suggestions:[],remainingText:o,hasSuggestions:!0,error:"资源解析失败: ".concat(a.message)}}}},{key:"stringify",value:function(e){var t=document.implementation.createDocument(null,null,null),n=t.createElement("suggestions");n.setAttribute("version","1.0");var i=function(e){return"\n".concat(" ".repeat(e))};return e.forEach(function(e){n.appendChild(t.createTextNode(i(1)));var r=t.createElement("suggestion");r.setAttribute("type",e.type),r.setAttribute("version","1.0");var o=function(e,n){var r=t.createElement(e);r.appendChild(t.createTextNode(i(2)));var o=t.createCDATASection(JSON.stringify(n));return r.appendChild(o),r.appendChild(t.createTextNode(i(1))),r};r.appendChild(t.createTextNode(i(2))),r.appendChild(o("data",e.data)),r.appendChild(t.createTextNode(i(2))),r.appendChild(o("metadata",e.metadata)),r.appendChild(t.createTextNode(i(1))),n.appendChild(r)}),n.appendChild(t.createTextNode("\n")),t.appendChild(n),(new XMLSerializer).serializeToString(t).replace(/></g,">\n<")}}])}();function Sa(e){return e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1}function xa(e,t,n,i){var r=e/window.innerWidth,o=t/window.innerHeight;return{x:Math.max(0,Math.min(r,1-n)),y:Math.max(0,Math.min(o,1-i))}}var Ta=function(){return x(function e(){C(this,e)},null,[{key:"parse",value:function(e){var t,n=e.replace(/<think>[\s\S]*?<\/think>/g,"").replace(/<chatstep>[\s\S]*?<\/chatstep>/g,""),i=(n.match(/<tool_call>/g)||[]).length===(n.match(/<\/tool_call>/g)||[]).length,r=new RegExp("<tool_call>\\s*({[\\s\\S]*?})\\s*</tool_call>","g"),o=[],a=m(n.matchAll(r));try{for(a.s();!(t=a.n()).done;){var s=t.value;try{var c=JSON.parse(s[1]),l={name:c.name,parameters:c.parameters,error:c.error||!1,type:c.type};if(c.result){var u=c.result;try{["desc_oss_image","fetch_chunks"].includes(c.type)&&(u=JSON.parse(c.result))}catch(d){console.warn("解析 ".concat(l.type," 工具调用结果失败,已做容错处理"),{value:c.result,error:d})}finally{Object.assign(l,{result:u})}}o.push(l)}catch(vs){console.warn("解析工具调用失败,已做容错处理",{value:s[1],error:vs})}}}catch(h){a.e(h)}finally{a.f()}return{completed:i,toolCalls:o}}}])}(),Ma=function(){return x(function e(){C(this,e)},null,[{key:"parse",value:function(e){var t,n=(e.match(/<chatstep>/g)||[]).length===(e.match(/<\/chatstep>/g)||[]).length,i=new RegExp("<chatstep>\\s*({[\\s\\S]*?})\\s*</chatstep>","g"),r=[],o=m(e.matchAll(i));try{for(o.s();!(t=o.n()).done;){var a=t.value;try{var s=JSON.parse(a[1]),c={title:s.title,content:s.content,status:s.status||"success"};r.push(c)}catch(vs){console.warn("解析聊天步骤失败,已做容错处理",{value:a[1],error:vs})}}}catch(p){o.e(p)}finally{o.f()}if(!n){for(var l=[],u=0;-1!==(u=e.indexOf("<chatstep>",u));)l.push(u),u+=10;var d=[];for(u=0;-1!==(u=e.indexOf("</chatstep>",u));)d.push(u),u+=11;for(var h=l.filter(function(e){return!d.find(function(t){return t>e})}),f=0;f<h.length;f++)r.push({title:"",content:"",status:"pending"})}return r}}])}(),_a=function(){return x(function e(){C(this,e)},null,[{key:"parse",value:function(e){var t=[],n=e.indexOf("<chatuiaction>"),i=e.indexOf("</chatuiaction>");if(-1===n||-1===i)return t;var r=e.substring(n,i+17);r=r.replace(/\\r/g,"\r").replace(/\\n/g,"\n");var o,a=new RegExp("<chatuiaction>\\s*({[\\s\\S]*?})\\s*</chatuiaction>","g"),s=m(r.matchAll(a));try{for(s.s();!(o=s.n()).done;){var l=o.value;try{var u=l[1].replace(/\\/g,"").replace(/"\[/g,"[").replace(/\]"/g,"]").replace(/\n/g,""),d=JSON.parse(u);d&&d.content&&d.content.length>0&&(t=c(d.content))}catch(vs){console.warn("解析聊天界面操作失败,已做容错处理",{value:l[1],error:vs})}}}catch(h){s.e(h)}finally{s.f()}return t}}])}(),Na=function(){function e(){C(this,e)}return x(e,null,[{key:"protect",value:function(t){return t?e.rules.reduce(function(e,t){return t(e)},t):t}},{key:"protectMermaid",value:function(e){return e.replace(/(```mermaid[^\n]*\n)([\s\S]*?)(```)/g,function(e,t,n,i){var r=n.replace(/([A-Za-z_][\w-]*)\s*(\[|\{)([^"'`\n[\]{}]+)(\]|\})/g,'$1$2"$3"$4');return"".concat(t).concat(r).concat(i)})}}])}();T(Na,"rules",[Na.protectMermaid]);var Oa,Ea,Aa,Da,Ia=0,La=[],Ra=ho,za=Ra.__b,Pa=Ra.__r,Ba=Ra.diffed,Fa=Ra.__c,Ha=Ra.unmount,ja=Ra.__;function Va(e,t){Ra.__h&&Ra.__h(Ea,e,Ia||t),Ia=0;var n=Ea.__H||(Ea.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Wa(e){return Ia=1,function(e,t,n){var i=Va(Oa++,2);if(i.t=e,!i.__c&&(i.__=[n?n(t):is(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],n=i.t(t,e);t!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=Ea,!Ea.__f)){var r=function(e,t,n){if(!i.__c.__H)return!0;var r=i.__c.__H.__.filter(function(e){return!!e.__c});if(r.every(function(e){return!e.__N}))return!o||o.call(this,e,t,n);var a=i.__c.props!==e;return r.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(a=!0)}}),o&&o.call(this,e,t,n)||a};Ea.__f=!0;var o=Ea.shouldComponentUpdate,a=Ea.componentWillUpdate;Ea.componentWillUpdate=function(e,t,n){if(this.__e){var i=o;o=void 0,r(e,t,n),o=i}a&&a.call(this,e,t,n)},Ea.shouldComponentUpdate=r}return i.__N||i.__}(is,e)}function $a(e,t){var n=Va(Oa++,3);!Ra.__s&&ns(n.__H,t)&&(n.__=e,n.u=t,Ea.__H.__h.push(n))}function Ua(e,t){var n=Va(Oa++,4);!Ra.__s&&ns(n.__H,t)&&(n.__=e,n.u=t,Ea.__h.push(n))}function qa(e){return Ia=5,Ja(function(){return{current:e}},[])}function Ka(e,t,n){Ia=6,Ua(function(){if("function"==typeof e){var n=e(t());return function(){e(null),n&&"function"==typeof n&&n()}}if(e)return e.current=t(),function(){return e.current=null}},null==n?n:n.concat(e))}function Ja(e,t){var n=Va(Oa++,7);return ns(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ga(e,t){return Ia=8,Ja(function(){return e},t)}function Ya(e){var t=Ea.context[e.__c],n=Va(Oa++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(Ea)),t.props.value):e.__}function Xa(){for(var e;e=La.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(es),e.__H.__h.forEach(ts),e.__H.__h=[]}catch(as){e.__H.__h=[],Ra.__e(as,e.__v)}}Ra.__b=function(e){Ea=null,za&&za(e)},Ra.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ja&&ja(e,t)},Ra.__r=function(e){Pa&&Pa(e),Oa=0;var t=(Ea=e.__c).__H;t&&(Aa===Ea?(t.__h=[],Ea.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(es),t.__h.forEach(ts),t.__h=[],Oa=0)),Aa=Ea},Ra.diffed=function(e){Ba&&Ba(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==La.push(t)&&Da===Ra.requestAnimationFrame||((Da=Ra.requestAnimationFrame)||Za)(Xa)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Aa=Ea=null},Ra.__c=function(e,t){t.some(function(e){try{e.__h.forEach(es),e.__h=e.__h.filter(function(e){return!e.__||ts(e)})}catch(Ea){t.some(function(e){e.__h&&(e.__h=[])}),t=[],Ra.__e(Ea,e.__v)}}),Fa&&Fa(e,t)},Ra.unmount=function(e){Ha&&Ha(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{es(e)}catch(e){t=e}}),n.__H=void 0,t&&Ra.__e(t,n.__v))};var Qa="function"==typeof requestAnimationFrame;function Za(e){var t,n=function(){clearTimeout(i),Qa&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,35);Qa&&(t=requestAnimationFrame(n))}function es(e){var t=Ea,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Ea=t}function ts(e){var t=Ea;e.__c=e.__(),Ea=t}function ns(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function is(e,t){return"function"==typeof t?t(e):t}var rs=Symbol.for("preact-signals");function as(){if(hs>1)hs--;else{for(var e,t=!1;void 0!==ds;){var n=ds;for(ds=void 0,fs++;void 0!==n;){var i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&ys(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=i}}if(fs=0,hs--,t)throw e}}var ss=void 0;function cs(e){var t=ss;ss=void 0;try{return e()}finally{ss=t}}var ls,us,ds=void 0,hs=0,fs=0,ps=0;function vs(e){if(void 0!==ss){var t=e.n;if(void 0===t||t.t!==ss)return t={i:0,S:e,p:ss.s,n:void 0,t:ss,e:void 0,x:void 0,r:t},void 0!==ss.s&&(ss.s.n=t),ss.s=t,e.n=t,32&ss.f&&e.S(t),t;if(-1===t.i)return t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=ss.s,t.n=void 0,ss.s.n=t,ss.s=t),t}}function ms(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function gs(e,t){return new ms(e,t)}function ys(e){for(var t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function ks(e){for(var t=e.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function ws(e){for(var t=e.s,n=void 0;void 0!==t;){var i=t.p;-1===t.i?(t.S.U(t),void 0!==i&&(i.n=t.n),void 0!==t.n&&(t.n.p=i)):n=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=i}e.s=n}function bs(e,t){ms.call(this,void 0),this.x=e,this.s=void 0,this.g=ps-1,this.f=4,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function Cs(e,t){return new bs(e,t)}function Ss(e){var t=e.u;if(e.u=void 0,"function"==typeof t){hs++;var n=ss;ss=void 0;try{t()}catch(as){throw e.f&=-2,e.f|=8,xs(e),as}finally{ss=n,as()}}}function xs(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ss(e)}function Ts(e){if(ss!==this)throw new Error("Out-of-order effect");ws(this),ss=e,this.f&=-2,8&this.f&&xs(this),as()}function Ms(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==t?void 0:t.name}function _s(e,t){var n=new Ms(e,t);try{n.c()}catch(e){throw n.d(),e}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}function Ns(e,t){ho[e]=t.bind(null,ho[e]||function(){})}function Os(e){us&&us(),us=e&&e.S()}function Es(e){var t=this,n=e.data,i=Ds(n);i.value=n;var r=Ja(function(){for(var e=t.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return t.__$u.c=function(){var e,n=t.__$u.S(),i=r.value;n(),po(i)||3!==(null==(e=t.base)?void 0:e.nodeType)?(t.__$f|=1,t.setState({})):t.base.data=i},Cs(function(){var e=i.value.value;return 0===e?0:!0===e?"":e||""})},[]);return r.value}function As(e,t,n,i){var r=t in e&&void 0===e.ownerSVGElement,o=gs(n);return{o:function(e,t){o.value=e,i=t},d:_s(function(){var n=o.value.value;i[t]!==n&&(i[t]=n,r?e[t]=n:n?e.setAttribute(t,n):e.removeAttribute(t))})}}function Ds(e){return Ja(function(){return gs(e)},[])}function Is(e){var t=qa(e);return t.current=e,ls.__$f|=4,Ja(function(){return Cs(function(){return t.current()})},[])}ms.prototype.brand=rs,ms.prototype.h=function(){return!0},ms.prototype.S=function(e){var t=this,n=this.t;n!==e&&void 0===e.e&&(e.x=n,this.t=e,void 0!==n?n.e=e:cs(function(){var e;null==(e=t.W)||e.call(t)}))},ms.prototype.U=function(e){var t=this;if(void 0!==this.t){var n=e.e,i=e.x;void 0!==n&&(n.x=i,e.e=void 0),void 0!==i&&(i.e=n,e.x=void 0),e===this.t&&(this.t=i,void 0===i&&cs(function(){var e;null==(e=t.Z)||e.call(t)}))}},ms.prototype.subscribe=function(e){var t=this;return _s(function(){var n=t.value,i=ss;ss=void 0;try{e(n)}finally{ss=i}},{name:"sub"})},ms.prototype.valueOf=function(){return this.value},ms.prototype.toString=function(){return this.value+""},ms.prototype.toJSON=function(){return this.value},ms.prototype.peek=function(){var e=ss;ss=void 0;try{return this.value}finally{ss=e}},Object.defineProperty(ms.prototype,"value",{get:function(){var e=vs(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(fs>100)throw new Error("Cycle detected");this.v=e,this.i++,ps++,hs++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{as()}}}}),bs.prototype=new ms,bs.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===ps)return!0;if(this.g=ps,this.f|=1,this.i>0&&!ys(this))return this.f&=-2,!0;var e=ss;try{ks(this),ss=this;var t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return ss=e,ws(this),this.f&=-2,!0},bs.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}ms.prototype.S.call(this,e)},bs.prototype.U=function(e){if(void 0!==this.t&&(ms.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}},bs.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(bs.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=vs(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Ms.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.u=t)}finally{e()}},Ms.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ss(this),ks(this),hs++;var e=ss;return ss=this,Ts.bind(this,e)},Ms.prototype.N=function(){2&this.f||(this.f|=2,this.o=ds,ds=this)},Ms.prototype.d=function(){this.f|=8,1&this.f||xs(this)},Ms.prototype.dispose=function(){this.d()},Es.displayName="_st",Object.defineProperties(ms.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Es},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Ns("__b",function(e,t){if("string"==typeof t.type){var n,i=t.props;for(var r in i)if("children"!==r){var o=i[r];o instanceof ms&&(n||(t.__np=n={}),n[r]=o,i[r]=o.peek())}}e(t)}),Ns("__r",function(e,t){Os();var n,i=t.__c;i&&(i.__$f&=-2,void 0===(n=i.__$u)&&(i.__$u=n=function(){var e;return _s(function(){e=this}),e.c=function(){i.__$f|=1,i.setState({})},e}())),ls=i,Os(n),e(t)}),Ns("__e",function(e,t,n,i){Os(),ls=void 0,e(t,n,i)}),Ns("diffed",function(e,t){var n;if(Os(),ls=void 0,"string"==typeof t.type&&(n=t.__e)){var i=t.__np,r=t.props;if(i){var o=n.U;if(o)for(var a in o){var s=o[a];void 0===s||a in i||(s.d(),o[a]=void 0)}else n.U=o={};for(var c in i){var l=o[c],u=i[c];void 0===l?(l=As(n,c,u,r),o[c]=l):l.o(u,r)}}}e(t)}),Ns("unmount",function(e,t){if("string"==typeof t.type){var n=t.__e;if(n){var i=n.U;if(i)for(var r in n.U=void 0,i){var o=i[r];o&&o.d()}}}else{var a=t.__c;if(a){var s=a.__$u;s&&(a.__$u=void 0,s.d())}}e(t)}),Ns("__h",function(e,t,n,i){(i<3||9===i)&&(t.__$f|=2),e(t,n,i)}),Io.prototype.shouldComponentUpdate=function(e,t){var n=this.__$u,i=n&&void 0!==n.s;for(var r in t)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(i||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(i||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var o in e)if("__source"!==o&&e[o]!==this.props[o])return!0;for(var a in this.props)if(!(a in e))return!0;return!1};var Ls=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M843.904 783.573333 783.573333 843.904 512.042667 572.373333 240.512 843.904 180.181333 783.573333 451.712 512.042667 180.181333 240.512 240.512 180.181333 512.042667 451.712 783.573333 180.181333 843.904 240.512 572.373333 512.042667 843.904 783.573333Z"})})},Rs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M900.64 379.808l-263.072-256.032c-36.448-35.328-105.76-35.392-142.304 0.096l-327.04 319.904c-56.416 54.72-70.72 76.704-70.72 150.976l0 143.936c0 132.768 26.976 192 186.912 192l131.872 0c81.12 0 128.448-46.656 193.952-111.264l290.016-297.696c18.592-17.984 29.248-43.968 29.248-71.264C929.504 423.36 918.976 397.6 900.64 379.808zM323.008 786.752c-52.928 0-96-43.072-96-96s43.072-96 96-96 96 43.072 96 96S375.936 786.752 323.008 786.752z"})})},zs=function(e){return na("svg",{viewBox:"0 0 1024 1024",id:"send",className:e.className,version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M931.4 498.9L94.9 79.5c-3.4-1.7-7.3-2.1-11-1.2-8.5 2.1-13.8 10.7-11.7 19.3l86.2 352.2c1.3 5.3 5.2 9.6 10.4 11.3l147.7 50.7-147.6 50.7c-5.2 1.8-9.1 6-10.3 11.3L72.2 926.5c-0.9 3.7-0.5 7.6 1.2 10.9 3.9 7.9 13.5 11.1 21.5 7.2l836.5-417c3.1-1.5 5.6-4.1 7.2-7.1 3.9-8 0.7-17.6-7.2-21.6zM170.8 826.3l50.3-205.6 295.2-101.3c2.3-0.8 4.2-2.6 5-5 1.4-4.2-0.8-8.7-5-10.2L221.1 403 171 198.2l628 314.9-628.2 313.2z"})})},Ps=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M962 197.61H747v-60c0-55.14-44.86-100-100-100H377c-55.14 0-100 44.86-100 100v60H62c-11.05 0-20 8.95-20 20s8.95 20 20 20h60v630.57c0 66.17 53.83 120 120 120h540c66.17 0 120-53.83 120-120V237.61h60c11.05 0 20-8.95 20-20s-8.95-20-20-20zM637.34 457.66v260c0 12.01-10.72 21.63-23.06 19.77-9.84-1.48-16.94-10.25-16.94-20.2V458.09c0-9.95 7.1-18.72 16.94-20.2 12.34-1.86 23.06 7.76 23.06 19.77z m-210.68 0v260c0 11-9 20-20 20s-20-9-20-20v-260c0-11 9-20 20-20s20 9 20 20zM317 137.61c0-33.08 26.92-60 60-60h270c33.08 0 60 26.92 60 60v60H317v-60z"})})},Bs=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M511.582491 63.413262C265.134543 63.413262 64.62588 263.921925 64.62588 510.369873s200.508663 446.957635 446.957635 446.957635 446.957635-200.508663 446.957635-446.957635S758.031463 63.413262 511.582491 63.413262zM509.001713 751.859903c-98.517781 0-182.467775-62.623269-214.771505-150.056598l0.327458-0.134053c-2.007727-4.036943-3.38305-8.422833-3.38305-13.237489 0-16.647145 13.494339-30.142507 30.142507-30.142507 13.389962 0 24.358781 8.877181 28.2893 20.955264l0.422625-0.172939c23.269983 65.442478 85.645612 112.503307 158.972665 112.503307 93.106538 0 168.845523-75.738985 168.845523-168.845523s-75.738985-168.845523-168.845523-168.845523c-20.432355 0-39.874149 3.980661-58.013275 10.66899l21.248953 40.742936c2.486634 2.677992 4.0175 6.2831 4.0175 10.243295 0 8.417717-8.404414 14.921851-15.365966 15.07023-0.102331 0-0.206708 0-0.309038 0-0.220011 0-0.427742 0-0.647753-0.013303l-150.579507-6.463202c-5.372358-0.234337-10.229992-3.310396-12.716626-8.093329-2.486634-4.76963-2.236947-10.509355 0.647753-15.055904l80.890308-127.179564c2.8847-4.533246 8.006348-7.151887 13.365402-6.960529 5.372358 0.234337 10.227945 3.312442 12.71458 8.095375l18.580171 35.625382c26.629497-10.855232 55.683207-16.963347 86.168522-16.963347 126.338407 0 229.130537 102.791108 229.130537 229.130537S635.340119 751.859903 509.001713 751.859903z"})})},Fs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M746.932 698.108",fill:"#A9B7B7"}),na("path",{d:"M925.731 288.698c-1.261-1.18-3.607-3.272-6.902-6.343-5.486-5.112-11.615-10.758-18.236-16.891-18.921-17.526-38.003-35.028-56.046-51.397-2.038-1.848-2.038-1.835-4.077-3.682-24.075-21.795-44.156-39.556-58.996-52.076-8.682-7.325-15.517-12.807-20.539-16.426-3.333-2.402-6.043-4.13-8.715-5.396-3.365-1.595-6.48-2.566-10.905-2.483C729.478 134.227 720 143.77 720 155.734l0 42.475 0 42.475 0 84.95L720 347l21.205 0L890 347l0 595L358.689 942C323.429 942 295 913.132 295 877.922L295 177l361.205 0c11.736 0 21.25-9.771 21.25-21.5s-9.514-21.5-21.25-21.5l-382.5 0L252 134l0 21.734L252 813l-52.421 0C166.646 813 140 786.928 140 754.678L140 72l566.286 0C739.29 72 766 98.154 766 130.404L766 134l40 0 0-3.596C806 76.596 761.271 33 706.286 33L119.958 33 100 33l0 19.506 0 702.172C100 808.463 144.642 852 199.579 852L252 852l0 25.922C252 936.612 299.979 984 358.689 984l552.515 0L932 984l0-21.237L932 325.635 932 304l0.433 0C932.432 299 930.196 292.878 925.731 288.698zM762 304l0-63.315L762 198.21l0-0.273c14 11.479 30.3 26.369 49.711 43.942 2.022 1.832 2.136 1.832 4.157 3.665 17.923 16.259 36.957 33.492 55.779 50.926 2.878 2.666 5.713 5.531 8.391 7.531L762 304.001z",fill:"currentColor"}),na("path",{d:"M816.936 436 407.295 436c-10.996 0-19.91 8.727-19.91 19.5 0 10.77 8.914 19.5 19.91 19.5l409.641 0c11 0 19.914-8.73 19.914-19.5C836.85 444.727 827.936 436 816.936 436z",fill:"currentColor"}),na("path",{d:"M816.936 553 407.295 553c-10.996 0-19.91 8.727-19.91 19.5 0 10.774 8.914 19.5 19.91 19.5l409.641 0c11 0 19.914-8.726 19.914-19.5C836.85 561.727 827.936 553 816.936 553z",fill:"currentColor"}),na("path",{d:"M816.936 689 407.295 689c-10.996 0-19.91 8.729-19.91 19.503 0 10.769 8.914 19.497 19.91 19.497l409.641 0c11 0 19.914-8.729 19.914-19.497C836.85 697.729 827.936 689 816.936 689z",fill:"currentColor"})]})},Hs=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M547.4 197.4v46l200.3 0.1L546.1 444l32.4 32.6 201.9-200.7v200.9h46V197.5zM471.4 584.4l-32.6-32.6L243.6 747V547.9h-46v278.7h279v-46H275z"})})},js=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M544 480V282.944h52.224l0.064 107.968L763.072 224l36.928 36.928-166.976 166.976 108.032-0.128V480H544zM260.928 800l-36.928-36.928 166.912-166.784-107.968-0.064V544H480v197.056h-52.224l0.064-107.968L260.928 800z"})})},Vs=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M960 544H64a32 32 0 1 1 0-64h896a32 32 0 1 1 0 64"})})},Ws=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[na("path",{d:"M481.0752 263.3728l50.9952 1.024 1.8432-105.8816-50.9952-0.8192z"}),na("path",{d:"M486.441426 180.895362a66.56 66.56 0 1 0 42.091944-126.290153 66.56 66.56 0 1 0-42.091944 126.290153Z"}),na("path",{d:"M138.8544 664.3712c-52.8384 0-95.8464-43.008-95.8464-95.8464s43.008-95.8464 95.8464-95.8464M880.0256 472.6784c52.8384 0 95.8464 43.008 95.8464 95.8464s-43.008 95.8464-95.8464 95.8464"}),na("path",{d:"M507.4944 220.5696c-220.16 0-398.7456 162.816-398.7456 363.7248s178.5856 363.7248 398.7456 363.7248 398.7456-162.816 398.7456-363.7248-178.5856-363.7248-398.7456-363.7248z m0 559.9232c-166.2976 0-301.2608-100.5568-301.2608-224.4608s134.9632-224.4608 301.2608-224.4608S808.7552 432.128 808.7552 556.032 673.792 780.4928 507.4944 780.4928z"}),na("path",{d:"M319.6928 556.032a47.9232 38.912 90 1 0 77.824 0 47.9232 38.912 90 1 0-77.824 0Z"}),na("path",{d:"M617.472 556.032a47.9232 38.912 90 1 0 77.824 0 47.9232 38.912 90 1 0-77.824 0Z"})]})},$s=function(){return na("svg",{viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[na("path",{d:"M5.856 17.121a.979.979 0 0 1-.327-.06.839.839 0 0 1-.283-.177.739.739 0 0 1-.187-.255.724.724 0 0 1-.07-.303l-.02-1.609a4.663 4.663 0 0 1-1.446-.455 4.252 4.252 0 0 1-.637-.401c-.199-.146-.385-.31-.553-.492a4.442 4.442 0 0 1-.45-.577 4.303 4.303 0 0 1-.327-.637 3.823 3.823 0 0 1-.206-.686 3.729 3.729 0 0 1-.064-.704V6.478c0-.261.025-.516.077-.771a4.43 4.43 0 0 1 .244-.747 4.062 4.062 0 0 1 .932-1.28c.2-.183.418-.347.65-.493.23-.145.482-.267.739-.364a4.21 4.21 0 0 1 .81-.225c.27-.054.553-.078.835-.078H8.55c.103 0 .2.018.29.054a.7.7 0 0 1 .411.376.667.667 0 0 1-.161.766.736.736 0 0 1-.25.151.764.764 0 0 1-.29.055H5.573c-.186 0-.366.012-.54.049-.18.03-.353.079-.52.145-.167.061-.328.14-.482.237-.148.091-.29.2-.418.316a2.897 2.897 0 0 0-.347.388c-.097.14-.187.286-.257.444a2.473 2.473 0 0 0-.206.977v4.287c0 .17.013.333.051.503a2.549 2.549 0 0 0 .772 1.33 2.721 2.721 0 0 0 .913.559c.167.066.347.115.527.152.18.03.36.048.546.048a.904.904 0 0 1 .61.23.848.848 0 0 1 .194.262.84.84 0 0 1 .07.303l.007.99 1.915-1.293a2.877 2.877 0 0 1 1.64-.492h2.372c.186 0 .366-.018.54-.048.18-.03.353-.08.52-.146.168-.067.329-.146.483-.237.148-.091.29-.2.418-.316.128-.121.244-.249.347-.388a2.8 2.8 0 0 0 .257-.444 2.47 2.47 0 0 0 .206-.977V8.585a.646.646 0 0 1 .225-.492.679.679 0 0 1 .244-.152.814.814 0 0 1 .585 0c.09.03.174.085.244.152a.657.657 0 0 1 .225.492V10.8c0 .261-.032.516-.083.771a4.192 4.192 0 0 1-.245.74c-.109.244-.244.468-.398.687a3.735 3.735 0 0 1-.534.6c-.2.183-.418.347-.65.493a4.134 4.134 0 0 1-.738.364 4.7 4.7 0 0 1-.81.225c-.27.054-.553.079-.836.079h-1.877c-.604 0-1.144.164-1.633.491l-2.54 1.713a.913.913 0 0 1-.514.157z",fill:"currentColor"}),na("path",{d:"M15.866 4.125h-4.174c-.41 0-.741.313-.741.7 0 .387.332.7.741.7h4.174c.41 0 .742-.313.742-.7 0-.387-.332-.7-.742-.7z",fill:"currentColor"}),na("path",{d:"M14.537 2.932c0-.396-.34-.717-.759-.717s-.758.32-.758.717v3.786c0 .396.34.717.758.717.42 0 .76-.321.76-.717V2.932z",fill:"currentColor"})]})},Us=function(){return na("svg",{viewBox:"64 64 896 896",focusable:"false",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",children:na("path",{d:"M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"})})},qs=function(){var e=1e3,t=140,n=250,i=.8;return na("svg",{fill:"currentColor",viewBox:"0 0 ".concat(e," ").concat(e),xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",children:Array.from({length:4}).map(function(e,r){return na("rect",{fill:"currentColor",rx:70,ry:70,height:n,width:t,x:r*(440/3+t),y:375,children:[na("animate",{attributeName:"height",values:"".concat(n,"; ").concat(500,"; ").concat(n),keyTimes:"0; 0.5; 1",dur:"".concat(i,"s"),begin:"".concat(.2*r,"s"),repeatCount:"indefinite"}),na("animate",{attributeName:"y",values:"".concat(375,"; ").concat(250,"; ").concat(375),keyTimes:"0; 0.5; 1",dur:"".concat(i,"s"),begin:"".concat(.2*r,"s"),repeatCount:"indefinite"})]},r)})})},Ks=function(e){return na("svg",{className:e.className,onClick:e.onClick,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M128 384a128 128 0 1 1 0 256 128 128 0 0 1 0-256z m768 0a128 128 0 1 1 0 256 128 128 0 0 1 0-256z m-372.4288 0a128 128 0 1 1 0 256 128 128 0 0 1 0-256z"})})},Js=function(e){return na("svg",{className:e.className,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M498.33984 607.8464c-10.99776-32.9728-50.09408-73.5232-82.6368-85.74976L150.9376 422.8096c-38.54336-14.4384-36.98688-69.46816 2.27328-81.73568L844.92288 124.90752c33.30048-10.40384 64.57344 20.8896 54.1696 54.1696L682.92608 870.78912a43.2128 43.2128 0 0 1-81.36704 3.25632 121682.5344 121682.5344 0 0 1-103.2192-266.19904z"})})},Gs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M972.657609 209.348408C987.158609 209.36839 998.930114 197.571202 998.949999 182.99865 998.969882 168.426097 987.230618 156.59651 972.729617 156.576528L32.457975 155.280806C17.956974 155.260823 6.18547 167.058012 6.165585 181.630564 6.1457 196.203116 17.884965 208.032703 32.385966 208.052686L972.657609 209.348408ZM180.466902 992.356169 180.466902 1019.014859 206.993296 1018.74074 833.361858 1012.267947 859.348284 1011.999407 859.348284 985.883377 859.348284 289.397297C859.348284 274.824732 847.59289 263.011332 833.091874 263.011332 818.590859 263.011332 806.835465 274.824732 806.835465 289.397297L806.835465 985.883377 832.82189 959.498805 206.453329 965.971599 232.979723 992.356169 232.979723 282.67005C232.979723 268.097483 221.224329 256.284085 206.723313 256.284085 192.222298 256.284085 180.466902 268.097483 180.466902 282.67005L180.466902 992.356169ZM656.410257 847.079027C656.410257 861.651593 668.165651 873.464992 682.666667 873.464992 697.167682 873.464992 708.923076 861.651593 708.923076 847.079027L708.923076 372.131659C708.923076 357.559091 697.167682 345.745694 682.666667 345.745694 668.165651 345.745694 656.410257 357.559091 656.410257 372.131659L656.410257 847.079027ZM341.333333 847.079027C341.333333 861.651593 353.08873 873.464992 367.589743 873.464992 382.090758 873.464992 393.846155 861.651593 393.846155 847.079027L393.846155 372.131659C393.846155 357.559091 382.090758 345.745694 367.589743 345.745694 353.08873 345.745694 341.333333 357.559091 341.333333 372.131659L341.333333 847.079027ZM498.871795 847.079027C498.871795 861.651593 510.627189 873.464992 525.128205 873.464992 539.62922 873.464992 551.384614 861.651593 551.384614 847.079027L551.384614 372.131659C551.384614 357.559091 539.62922 345.745694 525.128205 345.745694 510.627189 345.745694 498.871795 357.559091 498.871795 372.131659L498.871795 847.079027ZM392.147755 116.721777C392.147755 102.063669 403.758665 90.363507 418.40134 90.363507L622.925796 90.363507C637.408947 90.363507 649.179381 102.1619 649.179381 116.549585L649.179381 171.644875 701.692203 171.644875 701.692203 116.549585C701.692203 72.986607 666.38105 37.591577 622.925796 37.591577L418.40134 37.591577C374.724427 37.591577 339.634933 72.950804 339.634933 116.721777L339.634933 165.310801 392.147755 165.310801 392.147755 116.721777Z"})})},Ys=function(e){return na("svg",{className:e.className,width:"16",height:"16",viewBox:"0 0 50 50",xmlns:"http://www.w3.org/2000/svg",children:na("circle",{cx:"25",cy:"25",r:"20",stroke:"currentColor",strokeWidth:"5",fill:"none",strokeDasharray:"31.415, 31.415",strokeLinecap:"round",children:na("animateTransform",{attributeName:"transform",type:"rotate",from:"0 25 25",to:"360 25 25",dur:"1s",repeatCount:"indefinite"})})})},Xs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M512 61.44a40.96 40.96 0 0 1 40.96 40.96v122.88a40.96 40.96 0 1 1-81.92 0V102.4A40.96 40.96 0 0 1 512 61.44z",fill:"currentColor",opacity:".9"}),na("path",{d:"M737.28 121.792a40.96 40.96 0 0 1 14.992 55.952l-61.44 106.432a40.96 40.96 0 1 1-70.944-40.96l61.44-106.432a40.96 40.96 0 0 1 55.952-14.992z",fill:"currentColor",opacity:".8"}),na("path",{d:"M902.208 286.72a40.96 40.96 0 0 1-14.992 55.952l-106.432 61.44a40.96 40.96 0 0 1-40.96-70.944l106.432-61.44a40.96 40.96 0 0 1 55.952 14.992z",fill:"currentColor",opacity:".76"}),na("path",{d:"M962.56 512a40.96 40.96 0 0 1-40.96 40.96h-122.88a40.96 40.96 0 1 1 0-81.92h122.88A40.96 40.96 0 0 1 962.56 512z",fill:"currentColor",opacity:".7"}),na("path",{d:"M902.208 737.28a40.96 40.96 0 0 1-55.952 14.992l-106.432-61.44a40.96 40.96 0 1 1 40.96-70.944l106.432 61.44a40.96 40.96 0 0 1 14.992 55.952z",fill:"currentColor",opacity:".6"}),na("path",{d:"M737.28 902.208a40.96 40.96 0 0 1-55.952-14.992l-61.44-106.432a40.96 40.96 0 0 1 70.944-40.96l61.44 106.432a40.96 40.96 0 0 1-14.992 55.952z",fill:"currentColor",opacity:".5"}),na("path",{d:"M512 962.56a40.96 40.96 0 0 1-40.96-40.96v-122.88a40.96 40.96 0 1 1 81.92 0v122.88A40.96 40.96 0 0 1 512 962.56z",fill:"currentColor",opacity:".4"}),na("path",{d:"M286.72 902.208a40.96 40.96 0 0 1-14.992-55.952l61.44-106.432a40.96 40.96 0 1 1 70.944 40.96l-61.44 106.432a40.96 40.96 0 0 1-55.952 14.992z",fill:"currentColor",opacity:".3"}),na("path",{d:"M121.792 737.28a40.96 40.96 0 0 1 14.992-55.952l106.432-61.44a40.96 40.96 0 0 1 40.96 70.944l-106.432 61.44a40.96 40.96 0 0 1-55.952-14.992z",fill:"currentColor",opacity:".2"}),na("path",{d:"M61.44 512a40.96 40.96 0 0 1 40.96-40.96h122.88a40.96 40.96 0 1 1 0 81.92H102.4A40.96 40.96 0 0 1 61.44 512z",fill:"currentColor",opacity:".1"}),na("path",{d:"M121.792 286.72a40.96 40.96 0 0 1 55.952-14.992l106.432 61.44a40.96 40.96 0 1 1-40.96 70.944l-106.432-61.44a40.96 40.96 0 0 1-14.992-55.952z",fill:"currentColor",opacity:".04"}),na("path",{d:"M286.72 121.792a40.96 40.96 0 0 1 55.952 14.992l61.44 106.432a40.96 40.96 0 0 1-70.944 40.96l-61.44-106.432a40.96 40.96 0 0 1 14.992-55.952z",fill:"currentColor"})]})},Qs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:na("path",{d:"M704 256v490.666667a170.666667 170.666667 0 0 1-170.666667 170.666666 170.666667 170.666667 0 0 1-170.666666-170.666666V213.333333A106.666667 106.666667 0 0 1 469.333333 106.666667 106.666667 106.666667 0 0 1 576 213.333333v448a42.666667 42.666667 0 0 1-42.666667 42.666667 42.666667 42.666667 0 0 1-42.666666-42.666667V256H426.666667v405.333333a106.666667 106.666667 0 0 0 106.666666 106.666667 106.666667 106.666667 0 0 0 106.666667-106.666667V213.333333a170.666667 170.666667 0 0 0-170.666667-170.666666 170.666667 170.666667 0 0 0-170.666666 170.666666v533.333334a234.666667 234.666667 0 0 0 234.666666 234.666666 234.666667 234.666667 0 0 0 234.666667-234.666666V256h-64z"})})},Zs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[na("path",{d:"M842.666667 285.866667l-187.733334-187.733334c-14.933333-14.933333-32-21.333333-53.333333-21.333333H234.666667C194.133333 74.666667 160 108.8 160 149.333333v725.333334c0 40.533333 34.133333 74.666667 74.666667 74.666666h554.666666c40.533333 0 74.666667-34.133333 74.666667-74.666666V337.066667c0-19.2-8.533333-38.4-21.333333-51.2z m-44.8 44.8c-2.133333 2.133333-4.266667 0-8.533334 0h-170.666666c-6.4 0-10.666667-4.266667-10.666667-10.666667V149.333333c0-2.133333 0-6.4-2.133333-8.533333 0 0 2.133333 0 2.133333 2.133333l189.866667 187.733334z m-8.533334 554.666666H234.666667c-6.4 0-10.666667-4.266667-10.666667-10.666666V149.333333c0-6.4 4.266667-10.666667 10.666667-10.666666h311.466666c-2.133333 4.266667-2.133333 6.4-2.133333 10.666666v170.666667c0 40.533333 34.133333 74.666667 74.666667 74.666667h170.666666c4.266667 0 6.4 0 10.666667-2.133334V874.666667c0 6.4-4.266667 10.666667-10.666667 10.666666z",fill:"currentColor"}),na("path",{d:"M640 693.333333H341.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h298.666667c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM640 522.666667H341.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h298.666667c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM341.333333 416h85.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-85.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32z",fill:"currentColor"})]})},ec=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:na("path",{d:"M557.248 511.68l135.776-135.744-45.248-45.28L512 466.432l-135.776-135.776-45.248 45.28 135.776 135.744-135.776 135.776 45.248 45.248L512 556.928l135.776 135.776 45.248-45.248-135.776-135.776zM512 64c247.136 0 448 200.864 448 448s-200.864 448-448 448S64 759.136 64 512 264.864 64 512 64z",fill:"currentColor"})})},tc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:na("path",{d:"M512.43945313 904.51953125c-6.06445313 0-12.12890625-1.58203125-17.57812501-4.74609375L136.70703125 689.71484375c-10.63476563-6.24023438-17.13867188-17.66601563-17.13867188-29.97070313s6.50390625-23.73046875 17.13867188-29.97070312l76.37695313-44.91210938L136.97070312 540.125c-10.63476563-6.24023438-17.13867188-17.66601563-17.13867187-29.97070313s6.50390625-23.73046875 17.13867188-29.97070312l73.38867187-43.15429688-73.125-42.890625C126.51171875 387.81054687 120.0078125 376.38476562 120.0078125 364.08007812c0-12.3046875 6.50390625-23.73046875 17.13867188-29.97070312L495.828125 122.99609375c10.8984375-6.41601563 24.34570313-6.41601563 35.24414063 0l358.15429687 210.05859375c10.63476563 6.24023438 17.13867188 17.66601563 17.13867188 29.97070313s-6.50390625 23.73046875-17.13867188 29.97070312l-73.38867188 43.15429688 73.12500001 42.890625c10.63476563 6.24023438 17.13867188 17.66601563 17.13867187 29.97070312s-6.50390625 23.73046875-17.13867187 29.97070313L812.5859375 583.89453125l76.11328125 44.6484375c10.63476563 6.24023438 17.13867188 17.66601563 17.13867188 29.97070313s-6.50390625 23.73046875-17.13867188 29.97070312l-358.59375 211.2890625c-5.44921875 3.1640625-11.6015625 4.74609375-17.66601563 4.74609375zM223.015625 659.65625l289.42382813 169.8046875 290.12695312-170.77148438-58.44726563-34.27734374L530.28125 750.18359375a34.67285156 34.67285156 0 0 1-35.24414063 0L281.7265625 625.02734375 223.015625 659.65625z m76.90429688-104.58984375l212.69531249 124.8046875 290.12695313-170.77148438-55.546875-32.60742187-216.65039063 127.6171875a34.67285156 34.67285156 0 0 1-35.24414062 0L279.00195312 477.28320312l-55.81054687 32.78320313 75.49804688 44.296875c0.43945313 0.26367188 0.79101563 0.52734375 1.23046874 0.703125z m-2.81250001-147.83203125l215.68359376 126.5625 216.12304687-127.17773438c0.3515625-0.26367188 0.703125-0.43945313 1.0546875-0.61523437l72.86132813-42.890625-289.33593751-169.8046875-290.12695312 170.68359375 72.59765625 42.62695313c0.43945313 0.17578125 0.79101563 0.43945313 1.14257813 0.61523437z"})})},nc=function(e){return na("svg",{className:e.className,id:"stop",viewBox:"0 0 1025 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[na("path",{d:"M512.268258 1022.835842c-68.658678 0-135.399619-13.564433-198.369591-40.316509-60.752236-25.809077-115.373446-62.712976-162.346233-109.685763-46.971763-46.971763-83.875662-101.592974-109.685763-162.346233C15.115619 647.517366 1.551186 580.777449 1.551186 512.118771S15.115619 376.719151 41.866671 313.74918c25.810101-60.752236 62.714-115.373446 109.685763-162.346233 46.972787-46.971763 101.593997-83.875662 162.346233-109.685763 62.969971-26.751052 129.710912-40.315485 198.369591-40.315485s135.398595 13.564433 198.368567 40.315485c60.752236 25.810101 115.373446 62.714 162.346233 109.685763 46.971763 46.972787 83.875662 101.593997 109.685763 162.346233 26.752076 62.969971 40.316509 129.710912 40.316509 198.369591s-13.564433 135.398595-40.316509 198.368567c-25.809077 60.75326-62.712976 115.37447-109.685763 162.346233-46.971763 46.972787-101.592974 83.876686-162.346233 109.685763C647.666853 1009.27141 580.925912 1022.835842 512.268258 1022.835842zM512.268258 50.548195c-62.018782 0-122.293887 12.247716-179.152287 36.403219-54.923257 23.333323-104.317532 56.709936-146.810821 99.204249s-75.870926 91.888588-99.204249 146.810821c-24.155503 56.8584-36.403219 117.133505-36.403219 179.152287 0 62.017758 12.247716 122.292863 36.403219 179.152287 23.333323 54.923257 56.709936 104.317532 99.204249 146.811845 42.493289 42.493289 91.888588 75.870926 146.810821 99.204249 56.8584 24.155503 117.133505 36.403219 179.152287 36.403219 62.017758 0 122.292863-12.247716 179.152287-36.403219 54.923257-23.333323 104.317532-56.71096 146.811845-99.204249 42.493289-42.494313 75.870926-91.888588 99.204249-146.811845 24.155503-56.8584 36.403219-117.133505 36.403219-179.152287s-12.247716-122.293887-36.403219-179.152287c-23.334347-54.923257-56.71096-104.317532-99.205273-146.810821-42.493289-42.493289-91.887565-75.870926-146.810821-99.204249C634.561121 62.795911 574.286016 50.548195 512.268258 50.548195z",fill:"currentColor"}),na("path",{d:"M655.434047 694.244421 367.12637 694.244421c-21.046987 0-38.170445-17.123458-38.170445-38.170445L328.955925 367.766298c0-21.046987 17.123458-38.170445 38.170445-38.170445l288.307678 0c21.048011 0 38.170445 17.123458 38.170445 38.170445l0 288.307678C693.604492 677.120962 676.482058 694.244421 655.434047 694.244421zM380.150191 643.050154l262.260035 0L642.410226 380.79012 380.150191 380.79012 380.150191 643.050154z",fill:"currentColor"})]})},ic=function(e){return na("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,viewBox:"0 0 512 512",children:na("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})})},rc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[na("path",{d:"M394.688 126.208a32 32 0 0 1 32-32h170.688a32 32 0 0 1 32 32v138.624h288a32 32 0 0 1 32 32v170.688a32 32 0 0 1-32 32H106.688a32 32 0 0 1-32-32V296.832a32 32 0 0 1 32-32h288V126.208z m64 32v138.624a32 32 0 0 1-32 32h-288v106.688h746.688V328.832h-288a32 32 0 0 1-32-32V158.208H458.688z"}),na("path",{d:"M138.688 469.376a32 32 0 0 1 32-32h682.688a32 32 0 0 1 32 32v384a32 32 0 0 1-32 32H170.688a32 32 0 0 1-32-32v-384z m64 32v320h618.688v-320H202.688z"}),na("path",{d:"M341.376 691.52a32 32 0 0 1 32 32V851.2a32 32 0 1 1-64 0v-127.68a32 32 0 0 1 32-32zM512 691.2a32 32 0 0 1 32 32v128a32 32 0 0 1-64 0v-128a32 32 0 0 1 32-32zM682.688 691.52a32 32 0 0 1 32 32V851.2a32 32 0 1 1-64 0v-127.68a32 32 0 0 1 32-32z"})]})},oc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:na("path",{d:"M843.251 424.407l43.828-74.898c10.194-17.946 32.596-22.158 48.956-11.598 16.298 10.499 23.44 32.658 14.223 49.566l-113.11 195.212-61.164-40.044-126.418-82.285c-16.115-11.598-20.632-34.428-10.194-51.702 9.705-17.397 31.009-23.501 47.857-13.734l89.67 59.028C748.576 295.547 615.81 180.667 461.008 180.667c-177.387 0-320.042 148.758-320.042 331.335 0 183.613 143.692 331.334 319.981 331.334 107.861 0.184 208.58-56.158 268.034-149.858 1.099-1.038 1.099-2.075 2.075-2.075 6.348-9.949 17.092-15.871 28.568-15.81 19.35 0 35.648 16.848 35.648 36.93 0 7.508-2.137 14.833-6.104 21.059-72.823 114.698-196.066 183.675-328.099 183.614-216.088 0-391.4-181.478-391.4-405.195 0-223.718 175.312-405.195 391.339-405.195 183.125-0.427 342.016 131.606 382.243 317.601z"})})},ac=function(){return na("svg",{version:"1.1",className:"icon",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M627.498667 55.168l170.666666 170.666667a42.624 42.624 0 0 1 0 60.330666l-469.333333 469.333334A42.538667 42.538667 0 0 1 298.666667 768H128a42.666667 42.666667 0 0 1-42.666667-42.666667v-170.666666c0-11.306667 4.48-22.186667 12.501334-30.165334l469.333333-469.333333a42.624 42.624 0 0 1 60.330667 0zM896 896a42.666667 42.666667 0 0 1 0 85.333333H128a42.666667 42.666667 0 0 1 0-85.333333h768zM597.333333 145.664l-426.666666 426.666667V682.666667h110.336l426.666666-426.666667L597.333333 145.664z"})})},sc=function(e){return na("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,viewBox:"0 0 512 512",children:na("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M184 112l144 144-144 144"})})},cc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M896 870.4l-128-128c55.467-68.267 89.6-149.333 89.6-238.933 0-98.134-38.4-192-110.933-264.534-149.334-149.333-384-149.333-533.334-4.266-145.066 145.066-145.066 384 0 529.066 72.534 72.534 166.4 110.934 264.534 110.934 89.6 0 174.933-29.867 238.933-89.6l128 128c4.267 4.266 12.8 8.533 21.333 8.533s17.067-4.267 21.334-8.533c17.066-8.534 17.066-29.867 8.533-42.667zM260.267 721.067c-119.467-123.734-119.467-320 0-439.467 59.733-59.733 140.8-89.6 217.6-89.6 81.066 0 157.866 29.867 217.6 89.6 59.733 59.733 89.6 136.533 89.6 217.6 0 81.067-34.134 162.133-89.6 217.6-55.467 59.733-132.267 93.867-217.6 93.867-81.067 0-157.867-34.134-217.6-89.6z"})})},lc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",width:"1em",height:"1em",children:na("path",{d:"M497.0496 55.7056a38.4 38.4 0 0 1 38.912 0l362.7008 213.2992c11.776 6.912 18.944 19.456 18.944 33.1264v426.6496a38.4 38.4 0 0 1-18.944 33.0752l-362.6496 213.3504a38.4 38.4 0 0 1-38.912 0L134.3488 761.856a38.4 38.4 0 0 1-18.944-33.0752V302.1312a38.4 38.4 0 0 1 18.944-33.1264z m19.456 77.6192L192.3072 324.096v382.72l324.3008 190.7712 324.2496-190.7712V324.096l-324.2496-190.7712zM345.9584 370.3296c7.68 0 14.848 2.2528 20.8384 6.144l149.6576 93.696 149.8624-93.696a38.4512 38.4512 0 0 1 49.1008 58.2656l-1.792 1.792a38.6048 38.6048 0 0 1-6.656 5.12l-152.0128 94.976v170.4448a38.4 38.4 0 0 1-0.1536 3.7376l-0.512 3.7376a38.0928 38.0928 0 0 1-23.04 27.9552 38.0928 38.0928 0 0 1-35.9936-3.5328 38.1952 38.1952 0 0 1-17.0496-31.8976v-170.2912l-152.064-95.1296a38.4 38.4 0 0 1 19.7632-71.3216z"})})},uc=function(){return na("svg",{className:"icon",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",width:"1em",height:"1em",children:na("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})},dc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[na("path",{d:"M190.193225 471.411583c14.446014 0 26.139334-11.718903 26.139334-26.13831 0-14.44499-11.69332-26.164916-26.139334-26.164916-0.271176 0-0.490164 0.149403-0.73678 0.149403l-62.496379 0.146333c-1.425466-0.195451-2.90005-0.295735-4.373611-0.295735-19.677155 0-35.621289 16.141632-35.621289 36.114522L86.622358 888.550075c0 19.949354 15.96767 35.597753 35.670407 35.597753 1.916653 0 3.808746 0.292666 5.649674 0l61.022819 0.022513c0.099261 0 0.148379 0.048095 0.24764 0.048095 0.097214 0 0.146333-0.048095 0.24457-0.048095l0.73678 0 0-0.148379c13.413498-0.540306 24.174586-11.422144 24.174586-24.960485 0-13.55983-10.760065-24.441669-24.174586-24.981974l0-0.393973-50.949392 0 1.450025-402.275993L190.193225 471.409536z"}),na("path",{d:"M926.52241 433.948343c-19.283182-31.445176-47.339168-44.172035-81.289398-45.546336-1.77032-0.246617-3.536546-0.39295-5.380544-0.39295l-205.447139-0.688685c13.462616-39.059598 22.698978-85.58933 22.698978-129.317251 0-28.349675-3.193739-55.962569-9.041934-82.542948l-0.490164 0.049119c-10.638291-46.578852-51.736315-81.31498-100.966553-81.31498-57.264215 0-95.466282 48.15065-95.466282 106.126063 0 3.241834-0.294712 6.387477 0 9.532097-2.996241 108.386546-91.240027 195.548698-196.23636 207.513194l0 54.881958-0.785899 222.227314 0 229.744521 10.709923 0 500.025271 0.222057 8.746198-0.243547c19.35686 0.049119 30.239721-4.817726 47.803749-16.116049 16.682961-10.761088 29.236881-25.50079 37.490869-42.156122 2.260483-3.341095 4.028757-7.075139 5.106298-11.20111l77.018118-344.324116c1.056052-4.053316 1.348718-8.181333 1.056052-12.160971C943.643346 476.446249 938.781618 453.944769 926.52241 433.948343zM893.82573 486.837924l-82.983993 367.783411-0.099261-0.049119c-2.555196 6.141884-6.879688 11.596106-12.872169 15.427364-4.177136 2.727111-8.773827 4.351098-13.414521 4.964058-1.49812-0.195451-3.046383 0-4.620227 0l-477.028511-0.540306-0.171915-407.408897c89.323375-40.266076 154.841577-79.670527 188.596356-173.661202 0.072655 0.024559 0.124843 0.049119 0.195451 0.072655 2.99931-9.137101 6.313799-20.73423 8.697079-33.164331 5.551436-29.185716 5.258771-58.123792 5.258771-58.123792-4.937452-37.98001 25.940812-52.965306 44.364417-52.965306 25.304316 0.860601 50.263777 33.656541 50.263777 52.326762 0 0 5.600555 27.563776 5.649674 57.190537 0.048095 37.366026-4.6673 56.847729-4.6673 56.847729l-0.466628 0c-5.872754 30.879288-16.214287 60.138682-30.464849 86.964654l0.36839 0.342808c-2.358721 4.815679-3.709485 10.220782-3.709485 15.943111 0 19.922748 19.088754 21.742187 38.765909 21.742187l238.761895 0.270153c0 0 14.666024 0.465604 14.690584 0.465604l0 0.100284c12.132318-0.638543 24.221658 5.207605 31.100322 16.409738 5.504364 9.016351 6.437619 19.6045 3.486404 28.988218L893.82573 486.837924z"}),na("path",{d:"M264.827039 924.31872c0.319272 0.024559 0.441045 0.024559 0.295735-0.024559 0.243547-0.048095 0.367367-0.074701-0.295735-0.074701s-0.539282 0.026606-0.271176 0.074701C264.43409 924.343279 264.532327 924.343279 264.827039 924.31872z"})]})},hc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:na("path",{d:"M190.208 552.576a26.176 26.176 0 0 1 0 52.288L189.44 604.8l-62.464-0.128a35.84 35.84 0 0 1-40-35.84l-0.384-433.28c0-19.968 16-35.648 35.712-35.648 1.92 0 3.84-0.256 5.632 0h62.272v0.128c13.44 0.576 24.192 11.456 24.192 24.96a25.024 25.024 0 0 1-24.192 24.96v0.448h-50.944l1.408 402.24h49.536z m736.32 37.504c-19.264 31.36-47.36 44.16-81.28 45.504a38.656 38.656 0 0 1-5.376 0.384l-205.44 0.704c13.44 39.04 22.656 85.568 22.656 129.28 0 28.416-3.2 56-9.024 82.56h-0.512a103.936 103.936 0 0 1-100.928 81.28c-57.28 0-95.488-48.128-95.488-106.112 0-3.2-0.32-6.4 0-9.536-3.008-108.352-91.264-195.52-196.224-207.488V551.68L254.08 329.6v-229.76h10.688l500.032-0.192 8.704 0.192c19.392 0 30.272 4.864 47.808 16.128 16.704 10.752 29.248 25.536 37.504 42.176 2.304 3.328 4.032 7.04 5.12 11.2l76.992 344.32a37.568 37.568 0 0 1 1.088 12.16c1.536 21.76-3.328 44.288-15.552 64.32z m-32.704-52.928l-83.008-367.744h-0.064a33.408 33.408 0 0 0-26.24-20.352c-1.536 0.192-3.072 0-4.672 0l-477.056 0.512-0.128 407.424c89.28 40.32 154.88 79.68 188.544 173.632h0.256c2.944 9.088 6.272 20.672 8.64 33.088 5.568 29.184 5.312 58.176 5.312 58.176-4.992 37.952 25.92 52.928 44.352 52.928 25.28-0.832 50.24-33.664 50.24-52.288 0 0 5.632-27.584 5.632-57.216 0.064-37.376-4.608-56.832-4.608-56.832h-0.512a307.84 307.84 0 0 0-30.464-87.04l0.384-0.256a36.16 36.16 0 0 1-3.712-16c0-19.84 19.072-21.76 38.784-21.76l238.72-0.192 14.72-0.512v-0.064c12.16 0.64 24.192-5.248 31.104-16.448a35.2 35.2 0 0 0 3.456-28.992h0.32zM267.52 96.768c2.048-0.192 2.816-0.192 1.92 0.128 1.536 0.32 2.304 0.512-1.92 0.512s-3.456-0.192-1.728-0.512c-0.768-0.32-0.192-0.32 1.728-0.128z"})})},fc=function(){return na("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[na("path",{d:"M8.65991 0.963799L14.9886 7.29249L13.2306 7.64409L9.71469 11.16L9.20318 14.2291C9.12295 14.7105 8.53216 14.8998 8.18708 14.5547L1.39767 7.76533C1.05258 7.42024 1.24191 6.82946 1.72329 6.74923L4.79237 6.23771L8.30831 2.72177L8.65991 0.963799Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",fill:"#fff"}),na("path",{d:"M4.41056 12.8146C3.98733 12.3893 3.56409 11.964 3.14085 11.5388C3.0912 11.6014 3.04156 11.664 2.99192 11.7266C2.09834 12.854 1.20476 13.9814 0.311181 15.1087C0.261538 15.1713 0.211895 15.234 0.162251 15.2966C0.320966 15.4561 0.479681 15.6156 0.638396 15.775C0.701265 15.7257 0.764135 15.6764 0.827004 15.627C1.95865 14.7389 3.09031 13.8508 4.22196 12.9626C4.28483 12.9133 4.3477 12.864 4.41056 12.8146Z",fill:"currentColor"})]})},pc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M342.464 368.576l73.344 42.368-8.512 7.936a32 32 0 0 1-14.272 7.68l-5.44 0.832-2.88 0.192-19.456 2.24a442.88 442.88 0 0 0-53.504 10.688 245.12 245.12 0 0 0-64.32 25.984l-7.488 4.928 150.144 86.784a32 32 0 0 1 15.808 31.168l-1.024 5.312-61.568 215.168 155.584-160.896a32 32 0 0 1 34.112-7.744l4.928 2.304 152.32 87.872 1.472-8.192c4.992-38.272-7.68-83.456-31.552-128.832l-6.784-12.416a32 32 0 0 1-3.456-23.04l2.56-11.328 78.016 44.992c27.328 61.44 36.672 122.816 15.168 177.856l-5.12 11.84-6.208 11.648a32 32 0 0 1-43.712 11.712l-163.072-94.272-227.2 235.072c-21.632 22.336-57.728 3.84-55.04-24.768l1.28-6.272L336.448 600.96l-163.072-94.08a32 32 0 0 1-14.144-38.464l2.432-5.248c23.936-41.6 71.36-67.84 133.504-84.48 20.48-5.568 41.28-9.6 61.312-12.288l-14.016 2.112zM267.968 218.688l609.664 352a32 32 0 1 1-32 55.424l-609.664-352a32 32 0 1 1 32-55.424z m258.816-106.24a32 32 0 0 1 40.384-42.752l5.056 2.432 295.552 170.624a32 32 0 0 1-12.16 59.52l-83.584 9.984-31.68 138.24-57.984-33.408 32.32-140.992a32 32 0 0 1 21.76-23.424l5.632-1.216 10.56-1.344-129.28-74.624 4.16 9.856a32 32 0 0 1-3.84 31.808l-3.84 4.224L513.92 319.808l-57.984-33.472 104-96.64z"})})},vc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M509.4 900.5c-11.6 0-21-9.4-21-21v-168c0-11.6 9.4-21 21-21s21 9.4 21 21v168c0 11.6-9.4 21-21 21z"}),na("path",{d:"M509.4 933.3c-5.4 0-10.7-2.1-14.8-6.2-8.2-8.2-8.2-21.5 0-29.7l74.2-74.3c8.2-8.2 21.5-8.2 29.7 0s8.2 21.5 0 29.7l-74.2 74.3c-4.2 4.1-9.6 6.2-14.9 6.2z"}),na("path",{d:"M509.4 933.3c-5.4 0-10.7-2.1-14.8-6.2l-74.2-74.2c-8.2-8.2-8.2-21.5 0-29.7s21.5-8.2 29.7 0l74.2 74.2c8.2 8.2 8.2 21.5 0 29.7-4.2 4.1-9.6 6.2-14.9 6.2zM742.7 803.1c-56 0-110.1-20.3-152.2-57.2-8.7-7.6-9.6-20.9-1.9-29.6 7.6-8.7 20.9-9.6 29.6-1.9 34.4 30.2 78.6 46.8 124.5 46.8 104.2 0 189-84.8 189-189 0-91.8-65.6-170-156.1-185.9l-16.2-2.8-1.1-16.4c-9.2-131.4-119.5-234.3-251.1-234.3-120.4 0-224.4 85.7-247.3 203.8l-2.7 13.8-13.8 2.8C155.8 371 92.2 448.9 92.2 538.4c0 104.2 84.8 189 189 189 43.1 0 83.6-14.1 117.3-40.9 9.1-7.2 22.3-5.7 29.5 3.4 7.2 9.1 5.7 22.3-3.4 29.5-41.2 32.7-90.7 50-143.4 50-127.4 0-231-103.6-231-231 0-104.8 71.3-196.5 171.4-223.2C253.4 184.3 371.4 90.7 507.2 90.7c148.3 0 273.3 111.8 291.5 257.5 102.3 25.4 175 117.1 175 224 0 127.3-103.6 230.9-231 230.9z"})]})},mc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M934.4 770.133333L605.866667 181.333333C586.666667 147.2 550.4 128 512 128s-74.666667 21.333333-93.866667 53.333333L89.6 770.133333c-19.2 34.133333-19.2 76.8 0 110.933334S145.066667 938.666667 183.466667 938.666667h657.066666c40.533333 0 74.666667-21.333333 93.866667-57.6 19.2-34.133333 19.2-76.8 0-110.933334zM480 362.666667c0-17.066667 14.933333-32 32-32s29.866667 12.8 32 29.866666V640c0 17.066667-14.933333 32-32 32s-29.866667-12.8-32-29.866667V362.666667zM512 832c-23.466667 0-42.666667-19.2-42.666667-42.666667s19.2-42.666667 42.666667-42.666666 42.666667 19.2 42.666667 42.666666-19.2 42.666667-42.666667 42.666667z",fill:"red"})})},gc=na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"red",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:"margin-left: 6px;",children:[na("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),na("path",{d:"M12 9v4"}),na("path",{d:"M12 17h.01"})]}),yc=na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"rgb(0, 185, 107)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-check","aria-hidden":"true",style:"margin-left: 6px;",children:na("path",{d:"M20 6 9 17l-5-5"})}),kc=na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:"margin-left: 6px;",children:[na("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),na("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]}),wc=function(e){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:e.style,children:na("path",{d:"m9 18 6-6-6-6"})})},bc=na("svg",{className:"icon",title:"知识库",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",xmlnsXlink:"http://www.w3.org/1999/xlink",children:na("path",{d:"M849.2 80H267.7c-73.8 0.1-133.6 58.2-133.6 129.9v606.7c0.1 70.3 58.6 127.2 130.9 127.3h584.3c22.5 0 40.8-17.8 40.8-39.7V119.6C890 97.8 871.7 80 849.2 80z m-40.9 784.6H264.8c-27.2 0-49.2-21.5-49.2-47.9s22-47.9 49.2-47.9h543.5v95.8z m0-175.1H264.8c-16.9 0-33.6 3.1-49.2 9.3V209.9c0-27.9 23.3-50.5 52-50.6h276.8v224.4c0 5.9 6.3 9.8 11.6 7.2l67.7-33.8c4.5-2.3 9.8-2.3 14.3 0l67.7 33.8c5.3 2.7 11.6-1.2 11.6-7.2V159.4h91.1l-0.1 530.1z"})}),Cc=na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M85.312 85.312h853.376v853.376H85.312V85.312z m85.376 768h579.648L384 487.04l-213.312 213.376v152.96z m682.624-17.664V170.688H170.688v408.96L384 366.336l469.312 469.312z m-179.328-526.336a42.688 42.688 0 1 0 0 85.376 42.688 42.688 0 0 0 0-85.376z m-128 42.688a128 128 0 1 1 256 0 128 128 0 0 1-256 0z",fill:"currentColor"})}),Sc=na("svg",{viewBox:"0 0 79 86",version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",children:[na("defs",{children:[na("linearGradient",{id:"linearGradient-1-el-id-655-578",x1:"38.8503086%",y1:"0%",x2:"61.1496914%",y2:"100%",children:[na("stop",{stopColor:"var(--el-empty-fill-color-1)",offset:"0%"}),na("stop",{stopColor:"var(--el-empty-fill-color-4)",offset:"100%"})]}),na("linearGradient",{id:"linearGradient-2-el-id-655-578",x1:"0%",y1:"9.5%",x2:"100%",y2:"90.5%",children:[na("stop",{stopColor:"var(--el-empty-fill-color-1)",offset:"0%"}),na("stop",{stopColor:"var(--el-empty-fill-color-6)",offset:"100%"})]}),na("rect",{id:"path-3-el-id-655-578",x:"0",y:"0",width:"17",height:"36"})]}),na("g",{id:"Illustrations",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:na("g",{id:"B-type",transform:"translate(-1268.000000, -535.000000)",children:na("g",{id:"Group-2",transform:"translate(1268.000000, 535.000000)",children:[na("path",{id:"Oval-Copy-2",d:"M39.5,86 C61.3152476,86 79,83.9106622 79,81.3333333 C79,78.7560045 57.3152476,78 35.5,78 C13.6847524,78 0,78.7560045 0,81.3333333 C0,83.9106622 17.6847524,86 39.5,86 Z",fill:"var(--el-empty-fill-color-3)"}),na("polygon",{id:"Rectangle-Copy-14",fill:"var(--el-empty-fill-color-7)",transform:"translate(27.500000, 51.500000) scale(1, -1) translate(-27.500000, -51.500000) ",points:"13 58 53 58 42 45 2 45"}),na("g",{id:"Group-Copy",transform:"translate(34.500000, 31.500000) scale(-1, 1) rotate(-25.000000) translate(-34.500000, -31.500000) translate(7.000000, 10.000000)",children:[na("polygon",{id:"Rectangle-Copy-10",fill:"var(--el-empty-fill-color-7)",transform:"translate(11.500000, 5.000000) scale(1, -1) translate(-11.500000, -5.000000) ",points:"2.84078316e-14 3 18 3 23 7 5 7"}),na("polygon",{id:"Rectangle-Copy-11",fill:"var(--el-empty-fill-color-5)",points:"-3.69149156e-15 7 38 7 38 43 -3.69149156e-15 43"}),na("rect",{id:"Rectangle-Copy-12",fill:"var(--el-empty-fill-color-3)",transform:"translate(46.500000, 25.000000) scale(-1, 1) translate(-46.500000, -25.000000) ",x:"38",y:"7",width:"17",height:"36"}),na("polygon",{id:"Rectangle-Copy-13",fill:"var(--el-empty-fill-color-2)",transform:"translate(39.500000, 3.500000) scale(-1, 1) translate(-39.500000, -3.500000) ",points:"24 7 41 7 55 -3.63806207e-12 38 -3.63806207e-12"})]}),na("rect",{id:"Rectangle-Copy-15",fill:"var(--el-empty-fill-color-2)",x:"13",y:"45",width:"40",height:"36"}),na("g",{id:"Rectangle-Copy-17",transform:"translate(53.000000, 45.000000)",children:[na("use",{id:"Mask",fill:"var(--el-empty-fill-color-8)",transform:"translate(8.500000, 18.000000) scale(-1, 1) translate(-8.500000, -18.000000) ",xlinkHref:"#path-3-el-id-655-578"}),na("polygon",{id:"Rectangle-Copy",fill:"var(--el-empty-fill-color-9)",mask:"var(--el-empty-fill-color-5)",transform:"translate(12.000000, 9.000000) scale(-1, 1) translate(-12.000000, -9.000000) ",points:"7 0 24 0 20 18 7 16.5"})]}),na("polygon",{id:"Rectangle-Copy-18",fill:"var(--el-empty-fill-color-2)",transform:"translate(66.000000, 51.500000) scale(-1, 1) translate(-66.000000, -51.500000) ",points:"62 45 79 45 70 58 53 58"})]})})})]}),xc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M516.461 20.457c-274.346 0-496.742 222.394-496.742 496.742s222.394 496.742 496.742 496.742 496.742-222.394 496.742-496.742-222.394-496.742-496.742-496.742zM516.461 964.278c-246.527 0-447.079-200.547-447.079-447.079s200.547-447.079 447.079-447.079 447.079 200.547 447.079 447.079-200.547 447.079-447.079 447.079z",fill:""}),na("path",{d:"M741.978 291.67c-12.099-12.117-31.79-12.117-43.905 0l-181.633 181.633-181.633-181.633c-12.102-12.117-31.795-12.117-43.905 0-12.117 12.102-12.117 31.79 0 43.905l181.633 181.633-181.633 181.633c-12.117 12.102-12.117 31.79 0 43.905 6.032 6.061 13.984 9.073 21.942 9.073 7.926 0 15.886-3.03 21.942-9.073l181.633-181.633 181.633 181.633c6.061 6.061 14.002 9.073 21.942 9.073s15.886-3.03 21.942-9.073c12.117-12.102 12.117-31.79 0-43.905l-181.669-181.633 181.633-181.633c12.117-12.102 12.117-31.79 0-43.905z",fill:""})]})},Tc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M512 85.333333C276.48 85.333333 85.333333 276.48 85.333333 512S276.48 938.666667 512 938.666667 938.666667 747.52 938.666667 512 747.52 85.333333 512 85.333333z m0 796.444445c-203.662222 0-369.777778-166.115556-369.777778-369.777778S308.337778 142.222222 512 142.222222 881.777778 308.337778 881.777778 512 715.662222 881.777778 512 881.777778z"}),na("path",{d:"M678.115556 385.706667L461.937778 591.644444l-116.053334-110.364444c-11.377778-11.377778-29.582222-10.24-39.822222 1.137778-11.377778 11.377778-10.24 29.582222 1.137778 39.822222l135.395556 129.706667c5.688889 5.688889 12.515556 7.964444 19.342222 7.964444s13.653333-2.275556 19.342222-7.964444L716.8 426.666667c11.377778-11.377778 11.377778-28.444444 1.137778-39.822223-10.24-12.515556-28.444444-12.515556-39.822222-1.137777z"})]})},Mc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M896 170.688c47.104 0 85.312 38.144 85.312 85.312v512c0 47.104-38.208 85.312-85.312 85.312H128A85.312 85.312 0 0 1 42.688 768V256c0-47.168 38.208-85.312 85.312-85.312h768z m-533.312 64H128c-10.496 0-19.2 7.488-20.992 17.472L106.688 256v512c0 10.496 7.552 19.2 17.472 20.992l3.84 0.32h234.688V234.688z m533.312 0H426.688v554.624H896c10.496 0 19.2-7.552 20.992-17.472l0.32-3.84V256c0-10.496-7.552-19.2-17.472-20.992L896 234.624zM298.688 469.248a21.312 21.312 0 0 1 0 42.688h-128a21.312 21.312 0 1 1 0-42.688h128z m0-85.312a21.312 21.312 0 0 1 0 42.688h-128a21.312 21.312 0 1 1 0-42.688h128z m0-85.312a21.312 21.312 0 0 1 0 42.624h-128a21.312 21.312 0 1 1 0-42.688h128z",fill:"currentColor"})})},_c=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M204.288 285.696c9.728 0 19.456-3.584 27.136-11.264 48.64-49.152 110.592-84.48 179.712-101.888 20.48-5.12 32.768-26.112 27.648-46.08-5.12-20.48-26.112-32.768-46.08-27.648-82.432 20.992-156.672 62.976-215.04 121.856-14.848 14.848-14.848 38.912 0.512 53.76 7.168 7.68 16.384 11.264 26.112 11.264zM602.112 92.16c-20.48-4.096-40.448 9.728-44.544 30.208-4.096 20.48 9.728 40.448 30.208 44.544 72.192 13.824 138.24 46.08 190.976 94.208 7.168 6.656 16.384 9.728 25.6 9.728 10.24 0 20.48-4.096 28.16-12.288 14.336-15.36 13.312-39.424-2.56-53.76-62.464-57.344-141.824-96.256-227.84-112.64zM948.736 386.56c-6.656-19.968-28.16-30.72-48.128-24.576-19.968 6.656-30.72 28.16-24.576 48.128 10.752 32.768 15.872 67.072 15.872 101.376 0 42.496-8.192 83.456-24.064 122.88-7.68 19.456 1.536 41.472 20.992 49.664 4.608 2.048 9.728 2.56 14.336 2.56 14.848 0 29.184-9.216 35.328-24.064 19.456-48.128 29.184-99.328 29.184-151.552 0.512-41.472-6.144-83.968-18.944-124.416zM775.168 765.952c-52.224 46.592-117.248 77.824-187.904 91.136-20.48 3.584-34.304 23.552-30.208 44.544 3.584 18.432 19.456 31.232 37.376 31.232 2.048 0 4.608 0 7.168-0.512 84.48-15.872 161.792-53.248 224.768-109.056 15.872-13.824 16.896-37.888 3.072-53.76-14.336-16.384-38.4-17.408-54.272-3.584zM415.232 851.968c-2.048-0.512-4.608-1.024-7.68-2.048-13.312-3.584-27.136-5.632-40.96-5.632H166.4l35.328-98.816c4.608-12.8 2.56-27.136-5.632-37.888-12.288-16.896-36.352-20.992-53.248-8.704-9.216 6.656-14.848 16.896-15.36 27.648l-49.152 138.24c-4.608 12.8-2.56 26.624 5.12 37.376 7.68 10.752 20.48 17.408 33.792 17.408h240.128c11.776 0 24.064 1.024 35.84 4.096 6.144 1.536 11.776 2.56 12.8 2.56 16.896 0 32.768-11.776 36.864-29.184 5.12-19.456-7.168-39.936-27.648-45.056zM108.032 651.264c3.584 0 7.168-0.512 10.752-1.536 19.968-5.632 31.744-27.136 26.112-47.104-8.704-29.696-12.8-59.904-12.8-91.136 0-33.792 5.12-66.56 15.36-98.816 6.144-19.968-4.608-41.472-24.576-47.616-19.968-6.144-41.472 4.608-47.616 24.576-12.288 39.424-18.944 80.384-18.944 121.344 0 37.888 5.12 75.776 15.872 112.128 4.096 17.408 19.456 28.16 35.84 28.16z"})})},Nc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M204.288 285.184c9.728 0 19.456-3.584 27.136-11.264 48.64-49.152 111.104-84.48 179.712-101.888 20.48-5.12 32.768-26.112 27.648-46.08-5.12-20.48-26.112-32.768-46.08-27.648-82.432 20.992-156.672 62.976-215.04 121.856-14.848 14.848-14.848 38.912 0.512 53.76 6.656 7.68 16.384 11.264 26.112 11.264zM602.624 92.16c-20.48-4.096-40.448 9.728-44.544 30.208-4.096 20.48 9.728 40.448 30.208 44.544 72.192 13.824 138.24 46.08 190.976 94.72 7.168 6.656 16.384 9.728 25.6 9.728 10.24 0 20.48-4.096 28.16-12.288 14.336-15.36 13.312-39.424-2.56-53.76-62.976-57.856-141.824-97.28-227.84-113.152zM949.248 386.56c-6.656-19.968-28.16-30.72-48.128-24.576-19.968 6.656-30.72 28.16-24.576 48.128 10.752 32.768 15.872 67.072 15.872 101.888 0 42.496-8.192 83.968-24.064 122.88-7.68 19.456 1.536 41.472 20.992 49.664 4.608 2.048 9.728 2.56 14.336 2.56 14.848 0 29.184-9.216 35.328-24.064 19.456-48.64 29.696-99.328 29.696-151.552 0-42.496-6.656-84.48-19.456-124.928zM775.68 765.952c-52.224 46.592-117.248 77.824-187.904 91.136-20.48 3.584-34.304 23.552-30.72 44.544 3.584 18.432 19.456 31.232 37.376 31.232 2.048 0 4.608 0 7.168-0.512 84.48-15.872 162.304-53.248 224.768-109.056 15.872-13.824 17.408-37.888 3.072-53.76-14.336-15.872-38.4-17.408-53.76-3.584zM415.232 852.48c-2.048-0.512-4.608-1.024-7.68-2.048-13.312-3.584-27.136-5.632-40.96-5.632H166.4l35.328-98.816c4.608-12.8 2.56-27.136-5.632-37.888-12.288-16.896-36.352-20.992-53.248-8.704-9.216 6.656-14.848 16.896-15.36 27.648l-49.664 138.24c-4.608 12.8-2.56 26.624 5.12 37.376 7.68 10.752 20.48 17.408 33.792 17.408h240.64c11.776 0 24.064 1.024 35.84 4.096 6.144 1.536 11.776 2.56 13.312 2.56 16.896 0 32.768-11.776 36.864-29.184 4.608-19.456-8.192-39.936-28.16-45.056zM107.52 651.776c3.584 0 7.168-0.512 10.752-1.536 19.968-5.632 31.744-27.136 26.112-47.104-8.704-29.696-12.8-59.904-12.8-91.136 0-33.792 5.12-67.072 15.36-98.816 6.144-19.968-4.608-41.472-25.088-47.616-19.968-6.144-41.472 4.608-47.616 25.088-12.288 39.424-18.944 80.384-18.944 121.856 0 37.888 5.12 75.776 15.872 112.128 4.608 15.872 19.968 27.136 36.352 27.136zM658.944 390.656c-17.408-11.776-40.96-7.168-52.736 10.752l-141.824 212.48-71.68-71.68c-14.848-14.848-38.912-14.848-53.76 0-14.848 14.848-14.848 38.912 0 53.76l104.96 104.96c7.168 7.168 16.896 11.264 27.136 11.264h3.584c11.264-1.024 21.504-7.168 28.16-16.896l167.424-251.392c10.752-17.92 6.144-41.472-11.264-53.248z"})})},Oc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",children:na("path",{d:"M811.097325 675.11798a38.455724 38.455724 0 0 1-54.382232 0L511.992078 430.406848 267.269064 675.11798a38.453744 38.453744 0 0 1-54.383222-54.380252l271.91116-271.899277a38.454734 38.454734 0 0 1 54.383222 0l271.911159 271.899277a38.450773 38.450773 0 0 1 0.005942 54.380252z",fill:"currentColor"})})},Ec=function(){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-lightbulb","aria-hidden":"true",style:"transition: width, height, 150ms;",children:[na("path",{fill:"none",d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}),na("path",{d:"M9 18h6"}),na("path",{d:"M10 22h4"})]})},Ac=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M671.744 107.666286a128 128 0 1 1 177.371429 183.369143l-87.478858 87.478857L580.608 197.485714l90.477714-90.477714 0.658286 0.658286z m-362.642286 723.382857v0.146286H128V650.093714L535.405714 242.761143l181.028572 181.028571-407.259429 407.259429zM0 896h1024V1024H0v-128z",fill:"currentColor"})})},Dc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M1008.64 993.28h-117.76v-460.8c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v460.8h-150.016v-209.92c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v209.92h-150.016v-250.88c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v250.88H349.696v-296.96c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v296.96H168.96v-174.08c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v174.08H30.72V107.52c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v901.12c0 8.192 6.656 15.36 15.36 15.36h993.28c8.704 0 15.36-7.168 15.36-15.36 0-8.704-6.656-15.36-15.36-15.36z"}),na("path",{d:"M153.6 450.56c3.584 0 7.168-1.536 10.24-4.096l169.984-155.136 168.96 125.44c2.56 2.048 5.12 3.072 8.192 3.072l184.32 10.24c5.12 0.512 10.24-2.048 13.312-6.656l179.2-256c5.12-7.168 3.072-16.384-3.584-21.504-7.168-5.12-16.384-3.072-21.504 3.584l-174.08 248.832-171.008-9.728-175.616-129.536c-6.144-4.608-14.336-4.096-19.456 1.024l-179.2 163.84c-6.144 5.632-6.656 15.36-1.024 21.504 3.072 3.584 7.168 5.12 11.264 5.12z"})]})},Ic=function(){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[na("path",{d:"M3 3v18h18"}),na("path",{d:"M7 16V12"}),na("path",{d:"M11 16V8"}),na("path",{d:"M15 16V4"}),na("path",{d:"M19 16v-6"})]})},Lc=function(){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[na("path",{d:"M12 3v14"}),na("path",{d:"m5 10 7 7 7-7"}),na("path",{d:"M5 21h14"})]})},Rc=function(){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[na("path",{d:"M12 21V7"}),na("path",{d:"m5 14 7-7 7 7"}),na("path",{d:"M5 3h14"})]})},zc=function(){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:na("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})})},Pc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M849.558588 496.941176a26.352941 26.352941 0 0 1 3.312941 52.495059l-3.312941 0.210824h-421.647059a26.352941 26.352941 0 0 1-3.312941-52.495059l3.312941-0.210824h421.647059z",fill:"currentColor"}),na("path",{d:"M849.558588 742.912a26.352941 26.352941 0 0 1 3.312941 52.495059l-3.312941 0.210823h-421.647059a26.352941 26.352941 0 0 1-3.312941-52.525176l3.312941-0.180706h421.647059z",fill:"currentColor"}),na("path",{d:"M849.558588 250.970353a26.352941 26.352941 0 0 1 3.312941 52.525176l-3.312941 0.180706h-421.647059a26.352941 26.352941 0 0 1-3.312941-52.495059l3.312941-0.210823h421.647059zM287.382588 672.617412H146.823529a26.352941 26.352941 0 0 0-26.352941 26.352941v140.559059c0 14.546824 11.806118 26.352941 26.352941 26.352941h140.559059a26.352941 26.352941 0 0 0 26.352941-26.352941v-140.559059a26.352941 26.352941 0 0 0-26.352941-26.352941z m-26.383059 52.705882V813.176471H173.176471v-87.853177h87.823058zM287.382588 426.676706H146.823529a26.352941 26.352941 0 0 0-26.352941 26.352941v140.528941c0 14.576941 11.806118 26.352941 26.352941 26.352941h140.559059a26.352941 26.352941 0 0 0 26.352941-26.352941v-140.528941a26.352941 26.352941 0 0 0-26.352941-26.352941z m-26.383059 52.675765v87.853176H173.176471v-87.853176h87.823058zM287.382588 180.705882H146.823529A26.352941 26.352941 0 0 0 120.470588 207.058824v140.559058c0 14.546824 11.806118 26.352941 26.352941 26.352942h140.559059a26.352941 26.352941 0 0 0 26.352941-26.352942V207.058824A26.352941 26.352941 0 0 0 287.382588 180.705882z m-26.383059 52.705883v87.823059H173.176471V233.411765h87.823058z",fill:"currentColor"})]})},Bc=function(){return na("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[na("path",{d:"M4.89417 7.25418L2.48694 7.65555L8.34338 13.5139L8.74475 11.1057L9.96155 12.3216L9.69299 13.9358C9.51911 14.9787 8.23949 15.3883 7.49182 14.6409L1.35999 8.50809C0.612717 7.76035 1.02323 6.48076 2.06604 6.30692L3.67737 6.03738L4.89417 7.25418ZM8.28381 1.00711C8.53085 0.932418 8.79958 0.999393 8.98206 1.18192L14.817 7.01883C14.9991 7.20132 15.0665 7.46932 14.9918 7.71609C14.917 7.96306 14.7116 8.14878 14.4586 8.19949L13.0455 8.48172L11.5631 9.96414L10.5739 8.97488L12.2057 7.34305L12.2838 7.27567C12.3663 7.2145 12.4616 7.17202 12.5631 7.15164L12.902 7.08328L8.91663 3.09695L8.84924 3.43582C8.82213 3.57112 8.75536 3.69562 8.65784 3.79324L7.02502 5.42508L6.03479 4.43387L7.51721 2.95242L7.80042 1.53934L7.82581 1.44754C7.89864 1.23769 8.06759 1.0726 8.28381 1.00711Z",fill:"currentColor"}),na("path",{d:"M4.65713 12.6155C4.23145 12.1927 3.80577 11.7698 3.38008 11.347C3.34021 11.4005 3.30033 11.4539 3.26045 11.5074C2.54263 12.4699 1.82481 13.4324 1.107 14.3948C1.06712 14.4483 1.02724 14.5018 0.987361 14.5553C1.14699 14.7138 1.30662 14.8724 1.46625 15.031C1.51943 14.9907 1.57262 14.9504 1.6258 14.9102C2.58306 14.1855 3.54032 13.4609 4.49758 12.7363C4.55077 12.696 4.60395 12.6558 4.65713 12.6155Z",fill:"currentColor"}),na("path",{d:"M1.85059 2.22839L13.77 14.1506",stroke:"currentColor",strokeWidth:"1.4"})]})},Fc=function(){return na("svg",{viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M7 1.167v11.666M1.167 7h11.666",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})},Hc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M582.9 801.3l359-470.3c29.9-39.2 22.4-95.2-16.8-125.1a89.244 89.244 0 0 0-54.2-18.3H153.1c-49.3 0-89.3 40-89.3 89.3 0 19.6 6.4 38.6 18.3 54.2L441 801.3c30 39.2 86 46.7 125.2 16.8 6.3-4.8 11.9-10.5 16.7-16.8z",fill:"currentColor"})})},jc=function(e){var t=e.text,n=g(Wa(t),2),i=n[0],r=n[1],o=qa(null);return $a(function(){return o.current&&clearTimeout(o.current),o.current=setTimeout(function(){r(t)},100),function(){o.current&&clearTimeout(o.current)}},[t]),na("div",{className:"streaming-content",children:i})},Vc={disabled:"Disabled",enable:"Enable",automatic:"Automatic",customize:"Customize",default:"Default",recallSettings:"Recall settings",chunkRerank:"Recall and reordering",chunkPageIndex:"Data catalog recall",maxChunks:"Maximum recall quantity",chunkThreshold:"Recall similarity threshold",aiAssistant:"AI assistant",minimize:"Minimize",exitFullscreen:"Exit fullscreen",fullscreen:"Fullscreen",close:"Close",loading:"Loading...",agent:"Agent",knowledge:"Knowledge",knowledgeSearch:"Knowledge search",uploadDocument:"Upload document",documentation:"Documentation",voiceInput:"Voice input",voiceInputProgress:"Voice input progress...",stopGenerating:"Stop generating",sendMessage:"Send message",instantSteer:"Instant steer",instantSteerTip:"Send supplementary content without interrupting the current conversation",meterialResources:"Meterial resources",preview:"Preview",uploadSuccess:"Upload success",uploading:"Uploading",uploadFailed:"Upload failed",unknownState:"Unknown state",download:"Download",thinkThrough:"Think through",stopThinking:"Stop thinking",thinking:"Thinking",requestTimeout:"Request timeout",unsupportedMessageType:"Message types not currently supported: {type}",me:"Me",retry:"Failed to send, please try again",expand:"Expand",foldUp:"Foldup",stepExpand:"Expand the execution steps",stepFoldUp:"Execute step contraction",expandAll:"Expand all",copy:"Copy",copyMarkdown:"Copy Markdown",copied:"Copied",used:"Used",second:"Second",agentTool:"Intelligent agent tool call execution in progress",toolCallContraction:"Tool call contraction",toolCallExpansion:"Tool call expansion",summaryGeneration:"Intelligent summary generated from {count} original paragraphs",guidance:"[Guidance]",vector:"(Vector{count})",abstract:"[Abstract]",hitParagraph:"Hit the {count} sub paragraph",noData:"No data",knowledgeRetrieval:"Knowledge base retrieval:",imageContent:"Image content recognition",more:"More",resetConversation:"Reset conversation",resetTopicConfirmTip:"Resetting will delete all chat history in this conversation. Are you sure you want to reset?",clearConversation:"Clear the conversation",clearTopicConfirmTip:"Clearing will delete all chat history in this conversation. Are you sure you want to clear?",refresh:"Refresh",delete:"Delete",backfill:"Backfill",pinTop:"Pin to top",unpin:"Unpin",rename:"Rename",deleteTopic:"Delete topic",jumpMainView:"Jump to the main view",openSidebar:"Open the sidebar",enterSession:"Enter temporary session",exitSession:"Exit temporary session",collapseSidebar:"Collapse the sidebar",newConversation:"New conversation",historySession:"History session ({count})",newCreateConversation:"Create new conversation",searchTopics:"Search topics",noTopic:"No topic at the moment",clearSession:"Clear conversation",clearSessionConfirmTip:"Are you sure you want to clear all session data except the currently active one?",clearSessionWithGroupConfirmTip:"Are you sure you want to clear all session and group data except the currently active one?",deleteConversation:"Delete conversation",deleteConversationConfirmTip:"Once deleted, this conversation cannot be recovered. Are you sure you want to delete?",batchDeleteConversation:"Delete {count} selected conversations",batchDeleteSession:"Batch delete conversations",batchDeleteConversationConfirmTip:"Once deleted, the selected conversations cannot be recovered. Are you sure you want to delete?",multiSelect:"Multi-select",selectedCount:"{count} conversations selected",cancelMultiSelect:"Exit multi-select",unclassifiedTopic:"Unclassified",newGroup:"New Group",deleteGroup:"Delete Group",deleteGroupConfirmTip:"Once deleted, this group and all conversations under it cannot be recovered. Are you sure you want to delete?",deleteScope:"Delete Catalog",deleteScopeConfirmTip:"Once deleted, all groups and conversations under this catalog cannot be recovered. Are you sure you want to delete?",selectScope:"Select Catalog",selectScopePlaceholder:"Please select a catalog",selectScopeTip:"The conversation will be assigned to the selected catalog",searchScopePlaceholder:"Search catalogs",confirm:"Confirm",temporarySession:"Temporary session",like:"Like",downvote:"Downvote",search:"Search",searchFailed:"Search failed",errorOccurred:"An error occurred",protocol:"Not currently supporting {protocol} type protocols",downloadCannotEmpty:"The download action identifier [downloadactionid] cannot be empty",downloadExContext:"Download extension context [downloadContext] parameter parsing exception, correct format such as abc: 123; cde:456",userInterrupt:"User interrupt",actionIdCannotEmpty:"[actionid] cannot be empty",actionExContext:"Exception in parsing the parameter for behavior extension context [action_comtext], correct format: abc: 123; cde:456",notSupportingType:"Not supporting {type} recommendation type",chunkView:"The document fragment viewing interface does not exist. Please confirm if chunkView is configured",chunkEntity:"The document fragment entity identifier does not exist. Please confirm if chunkEntity is configured",extensionToolbarClick:"Extension toolbar click event not found",temporarySessionFailed:"Temporary session failed, no topic configuration backup configuration",reedit:"Re edit",cancel:"Cancel",questionPrev:"Previous",questionNext:"Next",questionSubmit:"Done",questionInputPlaceholder:"Please enter",questionOther:"Other",questionNoData:"No questions",send:"Send",unknownError:"Unknown error",statistics:"Statistics",totalTokens:"Total tokens",inputTokens:"Input tokens",outputTokens:"Output tokens",toolCallCount:"Tool calls",notCounted:"Not counted",notCalled:"Not called",noResearchContent:"There is currently no research content available",light:"Light",dark:"Dark",generateVisualReport:"Generate visual report",sourceMaterial:"Find the source of {docCount} article information",searchKeyword:"Search keywords: {keyword}",deepResearch:"Depth research report",textReport:"Text report",deepResearchReport:"In depth research report",noTextReportContent:"No text report content available at the moment",chatInputPlaceholder:"Ask AI",projectPlaceholder:"Please select project"},Wc={disabled:"禁用",enable:"启用",automatic:"自动",customize:"自定义",default:"默认",recallSettings:"召回设置",chunkRerank:"召回重排",chunkPageIndex:"资料目录召回",maxChunks:"最大召回数量",chunkThreshold:"召回相似度阈值",aiAssistant:"AI助手",minimize:"最小化",exitFullscreen:"退出全屏",fullscreen:"全屏",close:"关闭",loading:"加载中...",agent:"智能体",knowledge:"知识库",knowledgeSearch:"知识库搜索",uploadDocument:"上传资料",documentation:"文件资料",voiceInput:"语音输入",voiceInputProgress:"语音输入中...",stopGenerating:"停止生成",sendMessage:"发送消息",instantSteer:"即时引导",instantSteerTip:"发送补充内容,不中断当前对话",meterialResources:"素材资源",preview:"预览",uploadSuccess:"上传成功",uploading:"上传中",uploadFailed:"上传失败",unknownState:"未知状态",download:"下载",thinkThrough:"思考完成",stopThinking:"思考停止",thinking:"思考中",requestTimeout:"请求超时",unsupportedMessageType:"暂未支持的消息类型: {type}",me:"我",retry:"未发送成功,请重试",expand:"展开",foldUp:"收起",stepExpand:"执行步骤 展开",stepFoldUp:"执行步骤 收缩",expandAll:"展开全部",copy:"复制",copyMarkdown:"复制 Markdown",copied:"已复制",used:"已用",second:"秒",agentTool:"智能体工具调用执行中",toolCallContraction:"工具调用 收缩",toolCallExpansion:"工具调用 展开",summaryGeneration:"由{count}个原文段落智能总结生成",guidance:"[引导]",vector:"(向量{count})",abstract:"[摘要]",hitParagraph:"命中 {count} 个子段落",noData:"无数据",knowledgeRetrieval:"知识库检索:",imageContent:"图片内容识别",more:"更多",resetConversation:"重置对话",resetTopicConfirmTip:"重置操作会删除本会话内全部历史聊天记录,确认要重置么?",clearConversation:"清空对话",clearTopicConfirmTip:"清空操作会删除本会话内全部历史聊天记录,确认要清空么?",refresh:"刷新",delete:"删除",backfill:"回填",pinTop:"置顶",unpin:"取消置顶",rename:"重命名",deleteTopic:"删除话题",jumpMainView:"跳转主视图",openSidebar:"打开侧边栏",enterSession:"进入临时会话",exitSession:"退出临时会话",collapseSidebar:"收起侧边栏",newConversation:"新会话",historySession:"历史会话({count})",newCreateConversation:"新建对话",searchTopics:"搜索话题",noTopic:"暂无话题",clearSession:"清空会话",clearSessionConfirmTip:"确认清空除当前激活项外的所有会话数据?",clearSessionWithGroupConfirmTip:"确认清空除当前激活项外的所有会话及分组数据?",deleteConversation:"删除对话",deleteConversationConfirmTip:"删除后,该对话将不可恢复。确认删除吗?",batchDeleteConversation:"删除选择的 {count} 个对话",batchDeleteSession:"批量删除会话",batchDeleteConversationConfirmTip:"删除后,选中的对话将不可恢复,确定删除吗?",multiSelect:"多选",selectedCount:"已选择 {count} 个对话",cancelMultiSelect:"退出多选",unclassifiedTopic:"无分类会话",newGroup:"新建分组",deleteGroup:"删除分组",deleteGroupConfirmTip:"删除后,该分组及其下所有会话数据将不可恢复。确认删除吗?",deleteScope:"删除目录",deleteScopeConfirmTip:"删除后,该目录下所有分组与会话数据将不可恢复。确认删除吗?",selectScope:"选择目录",selectScopePlaceholder:"请选择目录",selectScopeTip:"会话将归属到所选目录",searchScopePlaceholder:"搜索目录",confirm:"确认",temporarySession:"临时会话",like:"点赞",downvote:"点踩",search:"搜索",searchFailed:"搜索失败",errorOccurred:"发生错误",protocol:"暂不支持{protocol}类型协议",downloadCannotEmpty:"下载行为标识 [downloadactionid] 不能为空",downloadExContext:"下载扩展上下文 [downloadContext] 参数解析异常,正确格式如:abc:123;cde:456",userInterrupt:"用户中断",actionIdCannotEmpty:"行为标识 [actionid] 不能为空",actionExContext:"行为扩展上下文 [action_context] 参数解析异常,正确格式如:abc:123;cde:456",notSupportingType:"不支持{type}推荐类型",chunkView:"文档分片查看界面不存在,请确认chunkView是否配置",chunkEntity:"文档分片实体标识不存在,请确认chunkEntity是否配置",extensionToolbarClick:"未找到扩展工具栏点击事件",temporarySessionFailed:"临时会话失败,无话题配置备份配置",reedit:"重新编辑",cancel:"取消",questionPrev:"上一步",questionNext:"下一个",questionSubmit:"完成",questionInputPlaceholder:"请输入",questionOther:"其它",questionNoData:"暂无问题",send:"发送",unknownError:"未知错误",statistics:"统计",totalTokens:"Token消耗总数",inputTokens:"输入Token消耗",outputTokens:"输出Token消耗",toolCallCount:"工具调用次数",notCounted:"未统计",notCalled:"未调用",noResearchContent:"暂无研究内容",light:"亮色",dark:"暗色",generateVisualReport:"生成可视化报告",sourceMaterial:"找到 {docCount} 篇资料来源",searchKeyword:"搜索关键词:{keyword}",deepResearch:"深度研报",textReport:"文本报告",deepResearchReport:"深度研究报告",noTextReportContent:"暂无文本报告内容",chatInputPlaceholder:"问问 AI",projectPlaceholder:"请选择项目"},$c=function(){return x(function e(){var t=this;C(this,e),T(this,"locale",gs("zh-CN")),T(this,"language",T(T({},"en",Vc),"zh-CN",Wc)),T(this,"t",Cs(function(){var e=t.locale.value;return function(n,i){var r=t.language[e][n];return r?"function"==typeof r?r(i):i?r.replace(/\{(\w+)\}/g,function(e,t){return void 0!==i[t]?String(i[t]):e}):r:n}}))},[{key:"setLocale",value:function(e){this.locale.value=e}},{key:"setLanguage",value:function(e){var t=this;Object.keys(e).forEach(function(n){t.language.hasOwnProperty(n)?Object.assign(t.language[n],e[n]):t.language[n]=e[n]})}}])}(),Uc=new $c,qc=function(e){var t,n=e.item,i=new ra("chat-think"),r=qa(null),o=Ds(""),a=Ds(n.collapse||!0),s=Ds(!1);$a(function(){if(n.beginTime){var e=n.endTime||Date.now();o.value=((e-n.beginTime)/1e3).toFixed(1)}var t;n.done||((t=r.current)&&n.collapse&&t.scrollTo({top:t.scrollHeight,behavior:"auto"}),n.description&&(n.description=n.description.replace(/^\n+/,"").replace(/\n\n/g,"\n"))),u(n.collapse)||(a.value=n.collapse)},[n]);if(n.description)return na("div",{className:"".concat(i.b()," ").concat(i.is("collapsed",a.value)," ").concat(i.is("loading",!n.done)),children:[na("div",{className:i.e("header"),children:[na("div",{className:i.e("icon"),children:na(Ec,{})}),na("div",{className:i.e("title"),onClick:function(){return a.value=!a.value,void(n.collapse=a.value)},children:[n.title,o.value?na("span",{className:i.e("time"),children:["(",Uc.t.value("used")," ",o.value," ",Uc.t.value("second"),")"]}):null,na(wc,{})]})]}),na("div",{className:i.e("content"),ref:r,children:na(jc,{text:n.description})}),na("span",{title:Uc.t.value("copy"),className:i.e("copy"),onClick:function(i){return function(i){var r;i.stopPropagation(),s.value||(t&&clearTimeout(t),s.value=!0,ya.copy(JSON.stringify(n.description,void 0,2)),null===(r=e.controller.opts.utils)||void 0===r||r.message.success(Uc.t.value("copied")),t=setTimeout(function(){s.value=!1},2e3))}(i)},children:s.value?yc:kc})]})},Kc=function(e){var t=e.suggestions,n=e.onSuggestionClick,i=e.uiactions,r=e.onUIActionClick,o=new ra("chat-suggestions");return na("div",{className:"".concat(o.b()),children:[t&&t.length>0&&t.map(function(e,t){return na("div",{className:"".concat(o.e("item")," ").concat(o.is("action","action"===e.type)),onClick:function(t){return function(e,t){null==n||n(e,t)}(e,t)},title:e.metadata.content_name,children:[e.metadata.content_name,na(sc,{className:"".concat(o.e("item-icon"))})]},t)}),i&&i.length>0&&i.map(function(e,t){return na("div",{className:"".concat(o.e("item")," ").concat(o.is("action","action"===e.type)),onClick:function(t){return function(e,t){null==r||r(e,t)}(e,t)},title:e.metadata.content_name,children:[e.metadata.content_name,na(sc,{className:"".concat(o.e("item-icon"))})]},"action-".concat(t))})]})},Jc=function(e){var t,n,i,r=new ra("default-tool-call"),o=Ds(!1),a=Ds(!1);$a(function(){return function(){i&&clearTimeout(i)}},[]);var s=function(e){return"string"==typeof e?e.includes("Failed")||e.includes("Error")||e.includes("ERR_")?'<span class="error">"'.concat(e,'"</span>'):'<span class="string">"'.concat(e,'"</span>'):"number"==typeof e?'<span class="number">'.concat(e,"</span>"):"boolean"==typeof e?'<span class="boolean">'.concat(e,"</span>"):null===e?'<span class="null">null</span>':""},l=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=" ".repeat(t),i=[];if(Array.isArray(e)){if(0===e.length)return["".concat(n,'<span class="array">[]</span>')];i.push("".concat(n,'<span class="array">[</span>')),e.forEach(function(n,r){var o=l(n,t+1),a=r<e.length-1?",":"";"object"===_(n)&&null!==n?(i.push.apply(i,c(o.slice(0,-1))),i.push("".concat(o[o.length-1]).concat(a))):i.push("".concat(o[0]).concat(a))}),i.push("".concat(n,'<span class="array">]</span>'))}else if("object"===_(e)&&null!==e){var r=Object.keys(e);if(0===r.length)return["".concat(n,'<span class="property">{}</span>')];i.push("".concat(n,'<span class="property">{</span>')),r.forEach(function(o,a){var u=e[o],d=a<r.length-1?",":"",h='<span class="json-key">"'.concat(o,'":</span>');if("object"===_(u)&&null!==u){var f=l(u,t+1);i.push("".concat(n," ").concat(h," ").concat(f[0].trim())),f.length>1&&(i.push.apply(i,c(f.slice(1,-1))),i.push("".concat(f[f.length-1]).concat(d)))}else{var p=s(u);i.push("".concat(n," ").concat(h," ").concat(p).concat(d))}}),i.push("".concat(n,'<span class="property">}</span>'))}else i.push("".concat(n).concat(s(e)));return i},u=Is(function(){return l(e.item,0).map(function(e,t){return'<span class="line-number">'.concat(t+1,"</span>").concat(e)})});return na("div",{className:"".concat(r.b()," ").concat(e.className||""),children:[na("div",{className:r.e("header"),onClick:function(){return o.value=!o.value,void(null===(t=e.onCollapseChange)||void 0===t||t.call(e,o.value));var t},children:[na("div",{className:r.e("header-left"),children:[na("div",{className:r.em("header-left","caption"),children:e.item.name}),na("div",{className:r.em("header-left","desc"),title:(null===(t=e.item.parameters)||void 0===t?void 0:t.desc)||"",children:(null===(n=e.item.parameters)||void 0===n?void 0:n.desc)||""})]}),na("div",{className:r.e("header-right"),children:[e.item.error&&na("span",{style:"color: red;",children:Uc.t.value("errorOccurred")}),e.item.error&&gc,na("span",{title:Uc.t.value("copy"),className:r.e("copy"),onClick:function(t){return function(t){var n;t.stopPropagation(),a.value||(i&&clearTimeout(i),a.value=!0,ya.copy(JSON.stringify(e.item,void 0,2)),null===(n=e.controller.opts.utils)||void 0===n||n.message.success(Uc.t.value("copied")),i=setTimeout(function(){a.value=!1},2e3))}(t)},children:a.value?yc:kc}),na(wc,{style:{"margin-left":" 6px",transform:o.value?"rotate(90deg)":"rotate(0deg)"}})]})]}),o.value&&na("div",{className:r.e("content"),children:u.value.map(function(e,t){return na("div",{className:"code-line",dangerouslySetInnerHTML:{__html:e}},t)})})]})},Gc=function(e){var t,n,i,r=new ra("chunk-tool-call"),o=Ds([]),a=Ds(!1),s=Ds(!1);$a(function(){var t,n=f((null===(t=e.item.result)||void 0===t?void 0:t.chunks)||[]),i=n.filter(function(e){return"SOURCE"===e.type}),r=n.filter(function(e){return"SOURCE"!==e.type});r.forEach(function(e){"CLUSTER"===e.type&&(e.children=i.filter(function(t){return t.pid===e.id}),e.isExpand=!1)}),o.value=r},[e.item]),$a(function(){return function(){i&&clearTimeout(i)}},[]);var l=function(t){return na("div",{onClick:function(t){return e.onLinkClick(t)},dangerouslySetInnerHTML:{__html:t.replace(/\[(.+?)\]\((.+?)\)/g,function(e,t,n){return'<a href="'.concat(n,'">').concat(t,"</a>")})}})},u=function(e){return na("div",{className:r.e("footer"),children:["CLUSTER"===e.type&&(e.source_count||0===e.source_count)&&na("div",{className:r.em("footer","description"),children:Uc.t.value("summaryGeneration",{count:e.source_count})}),na("div",{className:r.em("footer","docname"),children:e.docname})]})},d=function(e){var t;return na("div",{className:"".concat(r.e("item")," ").concat(r.em("item",(null===(t=e.type)||void 0===t?void 0:t.toLowerCase())||"default")),children:["KBGUIDANCE"===e.type?na("div",{className:r.e("kbguidance"),children:Uc.t.value("guidance")}):na("div",{className:r.e("similarity"),style:"--percent: ".concat((100*(e.similarity||0)).toFixed(2),"%;"),children:"SCORE ".concat((e.similarity||0).toFixed(2))}),e.original&&na("div",{className:r.e("original"),children:Uc.t.value("vector",{count:(e.original||0).toFixed(2)})}),na("div",{className:r.em("item","content"),title:e.content,children:l(e.content)})]},e.id)},h=function(e){var t,n;return"CLUSTER"===e.type?na("div",{className:"".concat(r.e("chunk")," ").concat(r.e("cluster")),children:[na("div",{className:r.em("cluster","header"),children:[na("div",{className:r.e("similarity"),style:"--percent: ".concat((100*(e.similarity||0)).toFixed(2),"%;"),children:"SCORE ".concat((e.similarity||0).toFixed(2))}),e.original&&na("div",{className:r.e("original"),children:Uc.t.value("vector",{count:(e.original||0).toFixed(2)})}),na("div",{className:r.em("cluster","title"),children:Uc.t.value("abstract")}),na("div",{className:r.em("cluster","summary"),title:e.content,children:l(e.content)})]}),na("div",{className:r.em("cluster","content"),children:[na("div",{className:r.em("cluster","icon"),onClick:function(t){return function(e,t){e.stopPropagation(),t.isExpand=!t.isExpand,o.value=c(o.value)}(t,e)},children:[na(wc,{style:{transform:e.isExpand?"rotate(90deg)":"rotate(0deg)"}}),Uc.t.value("hitParagraph",{count:(null===(t=e.children)||void 0===t?void 0:t.length)||0})]}),e.isExpand&&na("div",{className:r.em("cluster","children"),children:null===(n=e.children)||void 0===n?void 0:n.map(function(e){return d(e)})})]}),u(e)]},e.id):na("div",{className:"".concat(r.e("chunk")," ").concat(r.e("default")),children:[d(e),u(e)]},e.id)};return na("div",{className:"".concat(r.b()," ").concat(e.className||""),children:[na("div",{className:r.e("header"),onClick:function(){return a.value=!a.value,void(null===(t=e.onCollapseChange)||void 0===t||t.call(e,a.value));var t},children:[na("div",{className:r.e("header-left"),children:[na("div",{className:r.em("header-left","icon"),children:bc}),na("div",{className:r.em("header-left","caption"),children:Uc.t.value("knowledgeRetrieval")}),na("div",{className:r.em("header-left","desc"),title:null===(t=e.item.result)||void 0===t?void 0:t.query,children:null===(n=e.item.result)||void 0===n?void 0:n.query})]}),na("div",{className:r.e("header-right"),children:[e.item.error&&na("span",{style:"color: red;",children:Uc.t.value("errorOccurred")}),e.item.error&&gc,na("span",{title:Uc.t.value("copy"),className:r.e("copy"),onClick:function(t){return function(t){var n;t.stopPropagation(),s.value||(i&&clearTimeout(i),s.value=!0,ya.copy(JSON.stringify(e.item,void 0,2)),null===(n=e.controller.opts.utils)||void 0===n||n.message.success(Uc.t.value("copied")),i=setTimeout(function(){s.value=!1},2e3))}(t)},children:s.value?yc:kc}),na(wc,{style:{"margin-left":" 6px",transform:a.value?"rotate(90deg)":"rotate(0deg)"}})]})]}),a.value&&na("div",{className:r.e("content"),children:e.item.error?na("div",{className:"".concat(r.e("error")," ").concat(r.e("center-text")),children:e.item.result}):o.value.length>0?o.value.map(function(e){return h(e)}):na("div",{className:"".concat(r.e("center-text")),children:Uc.t.value("noData")})})]})},Yc=function(e){var t=new ra("chat-image-preview");return na("div",{className:"el-image-viewer__wrapper ".concat(t.b()),children:[na("div",{className:"el-image-viewer__mask",onClick:function(t){var n;return null===(n=e.onClose)||void 0===n?void 0:n.call(e,t)}}),na("span",{className:"el-image-viewer__btn el-image-viewer__close",onClick:function(t){var n;return null===(n=e.onClose)||void 0===n?void 0:n.call(e,t)},children:na("i",{className:"el-icon",children:na("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",children:na("path",{fill:"currentColor",d:"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"})})})}),na("div",{className:"el-image-viewer__canvas",onClick:function(e){return e.stopPropagation()},children:na("img",{src:e.src,className:"el-image-viewer__img",style:"transform: scale(1) rotate(0deg) translate(0px, 0px);"})})]})},Xc=function(e){var t,n,i,r,o=new ra("image-tool-call"),a=Ds(!1),s=Ds(!1),c=Ds(!1);$a(function(){return function(){r&&clearTimeout(r)}},[]);var l,u,d,h,f=function(){var t;null!==(t=e.item.result)&&void 0!==t&&t.image_url&&(a.value=!a.value)};return na("div",{className:"".concat(o.b()," ").concat(e.className||""),children:[na("div",{className:o.e("header"),onClick:function(){return s.value=!s.value,void(null===(t=e.onCollapseChange)||void 0===t||t.call(e,s.value));var t},children:[na("div",{className:o.e("header-left"),children:[na("div",{className:o.em("header-left","icon"),children:Cc}),na("div",{className:o.em("header-left","caption"),children:Uc.t.value("imageContent")}),na("div",{className:o.em("header-left","desc"),title:(null===(t=e.item.parameters)||void 0===t?void 0:t.desc)||"",children:(null===(n=e.item.parameters)||void 0===n?void 0:n.desc)||""})]}),na("div",{className:o.e("header-right"),children:[e.item.error&&na("span",{style:"color: red;",children:Uc.t.value("errorOccurred")}),e.item.error&&gc,na("span",{title:Uc.t.value("copy"),className:o.e("copy"),onClick:function(t){return function(t){var n;t.stopPropagation(),c.value||(r&&clearTimeout(r),c.value=!0,ya.copy(JSON.stringify(e.item,void 0,2)),null===(n=e.controller.opts.utils)||void 0===n||n.message.success(Uc.t.value("copied")),r=setTimeout(function(){c.value=!1},2e3))}(t)},children:c.value?yc:kc}),na(wc,{style:{"margin-left":" 6px",transform:s.value?"rotate(90deg)":"rotate(0deg)"}})]})]}),s.value&&na("div",{className:o.e("content"),children:e.item.error?na("div",{className:"".concat(o.e("error")," ").concat(o.e("center-text")),children:e.item.result}):null!==(l=e.item.result)&&void 0!==l&&l.image_url||null!==(u=e.item.result)&&void 0!==u&&u.content?[na("img",{className:o.e("image"),src:null===(d=e.item.result)||void 0===d?void 0:d.image_url,onClick:f},"image"),na("div",{className:o.e("description"),children:null===(h=e.item.result)||void 0===h?void 0:h.content},"description")]:na("div",{className:"".concat(o.e("center-text")),children:Uc.t.value("noData")})}),a.value&&na(Yc,{src:null===(i=e.item.result)||void 0===i?void 0:i.image_url,onClose:f})]})},Qc=function(e){var t=new ra("chat-tool-call-item"),n=null;switch(e.item.type){case"fetch_chunks":n=Gc;break;case"desc_oss_image":n=Xc;break;default:n=Jc}return Eo(n,{item:e.item,className:t.b(),controller:e.controller,onLinkClick:function(t){e.onLinkClick(t)},onCollapseChange:function(t){var n;null===(n=e.onCollapseChange)||void 0===n||n.call(e,t)}})},Zc=function(e){var t=e.items,n=e.onLinkClick,i=e.onCollapseChange,r=new ra("chat-tool-call"),o=Ds([]),a=Ds(!1),s=Ds(!1),c=function(e){null==n||n(e)};$a(function(){o.value=t.filter(function(e){return e}),s.value=t.length>4},[t]);var l=Is(function(){return s.value&&!a.value?o.value.slice(0,4):o.value});return na("div",{className:"".concat(r.b()),children:[!e.toolcallCompleted&&na("div",{className:r.e("loading-container"),children:[na("div",{className:r.e("loading-text"),children:Uc.t.value("agentTool")}),na("div",{className:r.e("loading-dot")}),na("div",{className:r.e("loading-dot")}),na("div",{className:r.e("loading-dot")})]}),e.toolcallCompleted&&l.value.map(function(t,n){return na(Qc,{item:t,controller:e.controller,onLinkClick:c,onCollapseChange:function(e){return null==i?void 0:i(e)}},n)}),e.toolcallCompleted&&s.value&&na("div",{className:r.e("toggle"),onClick:function(){a.value=!a.value},children:na("span",{className:r.e("toggle-label"),children:a.value?Uc.t.value("toolCallContraction"):Uc.t.value("toolCallExpansion")})})]})},el=new ra("chat-search"),tl=function(e){var t=e.value,n=e.className,i=e.placeholder,r=e.autoFocus,o=void 0!==r&&r,a=e.onChange,s=e.onEnter,c=g(Wa(!1),2),l=c[0],u=c[1],d=qa(null);$a(function(){var e;o&&(null===(e=d.current)||void 0===e||e.focus())},[]);var h=function(e){var t;e.stopPropagation(),null==a||a(null===(t=e.target)||void 0===t?void 0:t.value)};return na("div",{className:"".concat(el.b()," ").concat(el.is("focus",l)," ").concat(n||""),children:[na("div",{className:el.e("prefix"),children:na(cc,{})}),na("input",{value:t,ref:d,className:el.e("inner"),placeholder:i,onFocus:function(){return u(!0)},onBlur:function(){return u(!1)},onChange:function(e){return h(e)},onKeyDown:function(e){var t;"Enter"===e.code&&(null==s||s(null===(t=e.target)||void 0===t?void 0:t.value))}})]})},nl=new ra("chat-loading"),il=function(e){var t=e.size,n=void 0===t?24:t;return na("div",{className:nl.b(),children:na("div",{className:nl.e("spinner"),style:{width:"".concat(n,"px"),height:"".concat(n,"px")},children:na(Xs,{})})})},rl=new ra("chat-single-select"),ol=function(e){var t,n=e.value,i=e.options,r=e.popperStyle,o=e.className,a=void 0===o?"":o,s=e.disabled,c=void 0!==s&&s,l=e.showBorder,u=void 0===l||l,d=e.enableSearch,f=void 0!==d&&d,p=e.placeholder,m=void 0===p?"请选择":p,y=e.icon,k=e.onChange,w=e.onSearch,b=!!i.length&&!c,C=qa(null),S=qa(null),x=Ds(""),T=g(Wa(n),2),M=T[0],_=T[1],N=g(Wa(i),2),O=N[0],E=N[1],A=g(Wa(!1),2),D=A[0],I=A[1],L=g(Wa(!1),2),R=L[0],z=L[1],P=(null===(t=i.find(function(e){return e.value===M}))||void 0===t?void 0:t.label)||m;$a(function(){!1===D&&(x.value="",E(i))},[D]),$a(function(){_(n)},[n]),$a(function(){E(i)},[i]),$a(function(){var e=function(e){var t,n;!b||c||null!==(t=S.current)&&void 0!==t&&t.contains(e.target)||(null!==(n=C.current)&&void 0!==n&&n.contains(e.target)?I(function(e){return!e}):I(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var B=function(){var e=v(h().m(function e(t){var n,r;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,z(!0),n=[],!w){e.n=2;break}return e.n=1,w(t);case 1:n=e.v,e.n=3;break;case 2:n=i.filter(function(e){return e.label.toLowerCase().includes(t.toLowerCase())});case 3:E(n),e.n=5;break;case 4:e.p=4,r=e.v,E([]),console.error(Uc.t.value("searchFailed"),r);case 5:return e.p=5,z(!1),e.f(5);case 6:return e.a(2)}},e,null,[[0,4,5,6]])}));return function(t){return e.apply(this,arguments)}}();return na("div",{className:"".concat(rl.b()," ").concat(a),children:[na("div",{className:"".concat(rl.e("button")," ").concat(u?rl.em("button","border"):""," ").concat(rl.is("focus",D)),ref:C,children:[y?na("span",{className:"".concat(rl.em("button","icon")," ").concat(rl.em("button","prefix")),children:y()}):null,na("span",{title:P,className:rl.em("button","caption"),children:P}),b?na("span",{className:"".concat(rl.em("button","icon")," ").concat(rl.em("button","suffix")),children:D?Oc():uc()}):null]}),D?na("div",{className:rl.e("dropdown"),ref:S,style:r,children:[f?na("div",{className:rl.em("dropdown","search"),children:na(tl,{placeholder:Uc.t.value("search"),autoFocus:!0,value:x.value,onEnter:B,onChange:function(e){x.value=e}})}):null,na("ul",{className:rl.em("dropdown","list"),children:R?na(il,{}):O.length?O.map(function(e){return na("li",{title:e.label,onClick:function(){return function(e){_(e.value),null==k||k(e.value),I(!1)}(e)},className:"".concat(rl.em("dropdown","item")," ").concat(rl.is("active",e.value===M)),children:e.label},e.value)}):na("li",{className:"el-empty ".concat(rl.e("empty")),children:[Sc,na("div",{className:rl.em("empty","text"),children:Uc.t.value("noData")})]})})]}):null]})},al=new ra("chat-multiple-select"),sl=function(e){var t=e.value,n=e.options,i=e.placeholder,r=e.popperStyle,o=e.enableSearch,a=void 0!==o&&o,s=e.icon,l=e.onChange,u=e.onSearch,d=qa(null),f=qa(null),p=Ds(""),y=g(Wa(!1),2),k=y[0],w=y[1],b=g(Wa(!1),2),C=b[0],S=b[1],x=g(Wa(t||[]),2),T=x[0],M=x[1],_=g(Wa(n),2),N=_[0],O=_[1];$a(function(){M(t||[])},[t]),$a(function(){O(n)},[n]),$a(function(){var e=function(e){var t,n;e.stopPropagation(),e.target&&null!==(t=f.current)&&void 0!==t&&t.contains(e.target)||(null!==(n=d.current)&&void 0!==n&&n.contains(e.target)?w(function(e){return!e}):w(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var E=function(e){var n,i=new Set(t||[]),r=[],o=[],a=m(e);try{for(a.s();!(n=a.n()).done;){var s=n.value;i.has(s.value)?r.push(s):o.push(s)}}catch(c){a.e(c)}finally{a.f()}return[].concat(r,o)},A=function(){var e=v(h().m(function e(t){var i,r;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,S(!0),i=[],!u){e.n=2;break}return e.n=1,u(t);case 1:i=e.v,i=E(i),e.n=3;break;case 2:i=n.filter(function(e){return e.label.toLowerCase().includes(t.toLowerCase())});case 3:O(i),e.n=5;break;case 4:e.p=4,r=e.v,O([]),console.error(Uc.t.value("searchFailed"),r);case 5:return e.p=5,S(!1),e.f(5);case 6:return e.a(2)}},e,null,[[0,4,5,6]])}));return function(t){return e.apply(this,arguments)}}();$a(function(){!0===k&&(p.value="",A(p.value))},[k]);return na("div",{className:"".concat(al.b()," ").concat(e.className?e.className:""),children:[na("div",{className:al.e("button"),ref:d,title:i,children:[s?na("span",{className:"".concat(al.em("button","icon")," ").concat(al.em("button","prefix")),children:s()}):null,i?[na("span",{className:al.em("button","caption"),children:i},"placeholder"),na("span",{className:"".concat(al.em("button","icon")," ").concat(al.em("button","suffix")),children:k?Oc():uc()},"icon")]:null]}),k?na("div",{className:al.e("dropdown"),ref:f,style:r,children:[a?na("div",{className:al.em("dropdown","search"),children:na(tl,{placeholder:Uc.t.value("search"),autoFocus:!0,value:p.value,onEnter:A,onChange:function(e){p.value=e}})}):null,na("ul",{className:al.em("dropdown","list"),children:C?na(il,{}):N.length?N.map(function(e){return na("li",{title:e.label,className:"".concat(al.em("dropdown","item")," ").concat(al.is("active",T.includes(e.value))),onClick:function(){return function(e){var t=T.includes(e.value)?T.filter(function(t){return t!==e.value}):[].concat(c(T),[e.value]);M(t),null==l||l(t)}(e)},children:[na("input",{type:"checkbox",value:e.value,className:al.em("dropdown","item-checkbox"),checked:T.includes(e.value)}),na("div",{className:al.em("dropdown","item-label"),children:e.label})]},e.value)}):na("li",{className:"el-empty ".concat(al.e("empty")),children:[Sc,na("div",{className:al.em("empty","text"),children:Uc.t.value("noData")})]})})]}):null]})};function cl(e,t){for(var n in t)e[n]=t[n];return e}function ll(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var i in t)if("__source"!==i&&e[i]!==t[i])return!0;return!1}function ul(e,t){this.props=e,this.context=t}(ul.prototype=new Io).isPureReactComponent=!0,ul.prototype.shouldComponentUpdate=function(e,t){return ll(this.props,e)||ll(this.state,t)};var dl=ho.__b;ho.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),dl&&dl(e)};var hl="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function fl(e){function t(t){var n=cl({},t);return delete n.ref,e(n,t.ref||null)}return t.$$typeof=hl,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var pl=ho.__e;ho.__e=function(e,t,n,i){if(e.then)for(var r,o=t;o=o.__;)if((r=o.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t);pl(e,t,n,i)};var vl=ho.unmount;function ml(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),e.__c.__H=null),null!=(e=cl({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return ml(e,t,n)})),e}function gl(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return gl(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function yl(){this.__u=0,this.o=null,this.__b=null}function kl(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function wl(){this.i=null,this.l=null}ho.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),vl&&vl(e)},(yl.prototype=new Io).__c=function(e,t){var n=t.__c,i=this;null==i.o&&(i.o=[]),i.o.push(n);var r=kl(i.__v),o=!1,a=function(){o||(o=!0,n.__R=null,r?r(s):s())};n.__R=a;var s=function(){if(! --i.__u){if(i.state.__a){var e=i.state.__a;i.__v.__k[0]=gl(e,e.__c.__P,e.__c.__O)}var t;for(i.setState({__a:i.__b=null});t=i.o.pop();)t.forceUpdate()}};i.__u++||32&t.__u||i.setState({__a:i.__b=i.__v.__k[0]}),e.then(a,a)},yl.prototype.componentWillUnmount=function(){this.o=[]},yl.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=ml(this.__b,n,i.__O=i.__P)}this.__b=null}var r=t.__a&&Eo(Do,null,e.fallback);return r&&(r.__u&=-33),[Eo(Do,null,t.__a?null:e.children),r]};var bl=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function Cl(e){return this.getChildContext=function(){return e.context},e.children}function Sl(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Zo(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var i=t.__v;null!==i&&!i.__m&&null!==i.__;)i=i.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:i.__m},contains:function(){return!0},insertBefore:function(e,n){this.childNodes.push(e),t.h.insertBefore(e,n)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),t.h.removeChild(e)}}}Zo(Eo(Cl,{context:t.context},e.__v),t.v)}function xl(e,t){var n=Eo(Sl,{__v:e,h:t});return n.containerInfo=t,n}(wl.prototype=new Io).__a=function(e){var t=this,n=kl(t.__v),i=t.l.get(e);return i[0]++,function(r){var o=function(){t.props.revealOrder?(i.push(r),bl(t,e,i)):r()};n?n(o):o()}},wl.prototype.render=function(e){this.i=null,this.l=new Map;var t=Ho(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},wl.prototype.componentDidUpdate=wl.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){bl(e,n,t)})};var Tl="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,Ml=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,_l=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Nl=/[A-Z0-9]/g,Ol="undefined"!=typeof document,El=function(e){return("undefined"!=typeof Symbol&&"symbol"==_(Symbol())?/fil|che|rad/:/fil|che|ra/).test(e)};Io.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(Io.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Al=ho.event;function Dl(){}function Il(){return this.cancelBubble}function Ll(){return this.defaultPrevented}ho.event=function(e){return Al&&(e=Al(e)),e.persist=Dl,e.isPropagationStopped=Il,e.isDefaultPrevented=Ll,e.nativeEvent=e};var Rl={enumerable:!1,configurable:!0,get:function(){return this.class}},zl=ho.vnode;ho.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,i={},r=-1===n.indexOf("-");for(var o in t){var a=t[o];if(!("value"===o&&"defaultValue"in t&&null==a||Ol&&"children"===o&&"noscript"===n||"class"===o||"className"===o)){var s=o.toLowerCase();"defaultValue"===o&&"value"in t&&null==t.value?o="value":"download"===o&&!0===a?a="":"translate"===s&&"no"===a?a=!1:"o"===s[0]&&"n"===s[1]?"ondoubleclick"===s?o="ondblclick":"onchange"!==s||"input"!==n&&"textarea"!==n||El(t.type)?"onfocus"===s?o="onfocusin":"onblur"===s?o="onfocusout":_l.test(o)&&(o=s):s=o="oninput":r&&Ml.test(o)?o=o.replace(Nl,"-$&").toLowerCase():null===a&&(a=void 0),"oninput"===s&&i[o=s]&&(o="oninputCapture"),i[o]=a}}"select"==n&&i.multiple&&Array.isArray(i.value)&&(i.value=Ho(t.children).forEach(function(e){e.props.selected=-1!=i.value.indexOf(e.props.value)})),"select"==n&&null!=i.defaultValue&&(i.value=Ho(t.children).forEach(function(e){e.props.selected=i.multiple?-1!=i.defaultValue.indexOf(e.props.value):i.defaultValue==e.props.value})),t.class&&!t.className?(i.class=t.class,Object.defineProperty(i,"className",Rl)):(t.className&&!t.class||t.class&&t.className)&&(i.class=i.className=t.className),e.props=i}(e),e.$$typeof=Tl,zl&&zl(e)};var Pl=ho.__r;ho.__r=function(e){Pl&&Pl(e),e.__c};var Bl=ho.diffed;ho.diffed=function(e){Bl&&Bl(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value)};var Fl=function(e){var t=e.triggerMode,n=e.children,i=e.actions,r=e.content,o=e.position,a=void 0===o?"bottom":o,s=e.isOpen,c=e.onToggleOpen,l=e.onAction,u=new ra("pop"),h=Ya(ab),f=g(Wa(s||!1),2),p=f[0],v=f[1],m=qa(null),y=qa(null),k=qa(null);$a(function(){void 0!==s&&v(s)},[s]),$a(function(){return y.current||(y.current=document.createElement("div"),y.current.className=u.b("content-container"),document.body.appendChild(y.current)),function(){y.current&&document.body.removeChild(y.current)}},[]),$a(function(){var e=function(e){!m.current||m.current.contains(e.target)||e.target.closest(".".concat(u.b()))||e.target.closest(".ibiz-quick-edit")||e.target.closest(".ibiz-picker__transfer")||(v(!1),null==c||c(!1))};return p&&document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[p,c]);var w=function(){k.current&&"hover"===t&&(clearTimeout(k.current),k.current=null)},b=function(){"hover"===t&&(w(),k.current=setTimeout(function(){v(!1),null==c||c(!1)},100))};return na("span",{className:"".concat(u.b("trigger-container")),children:[na("span",{className:"".concat(u.b("trigger-element")),ref:m,onClick:function(e){!function(e){if("click"===t){e.stopPropagation();var n=!p;v(n),null==c||c(n)}}(e)},onMouseEnter:function(e){!function(e){if("hover"===t){e.stopPropagation(),w();var n=!0;v(n),null==c||c(n)}}(e)},onMouseLeave:function(e){e.stopPropagation(),b()},children:n}),p&&y.current&&xl(na("div",{className:"".concat(u.b()," pop-").concat(a),style:function(){if(!m.current)return{};var e=m.current.getBoundingClientRect(),t={position:"absolute",zIndex:h.zIndex+1},n={bottom:{top:e.bottom+window.scrollY,left:e.left+window.scrollX},top:{bottom:window.innerHeight-e.top+window.scrollY,left:e.left+window.scrollX},left:{top:e.top+window.scrollY,right:window.innerWidth-e.left+window.scrollX},right:{top:e.top+window.scrollY,left:e.right+window.scrollX},"top-left":{bottom:window.innerHeight-e.top+window.scrollY,right:window.innerWidth-e.left+window.scrollX}};return d(d({},t),n[a])}(),onMouseEnter:w,onMouseLeave:b,children:r||(null==i?void 0:i.map(function(e){return na("div",{className:"".concat(u.e("item")," ").concat(u.em("item",e.id.toLowerCase())),onMouseDown:function(t){t.stopPropagation(),null==l||l(e.id,t)},children:[e.icon,na("div",{className:u.em("item","caption"),children:e.caption})]},e.id)}))}),y.current)]})},Hl=new ra("messsage-toolbar"),jl=function(e){var t=e.controller,n=e.message,i=e.onCopy,r=g(Wa(!1),2),o=r[0],a=r[1],s=g(Wa(!1),2),c=s[0],l=s[1],u=[{id:"markdown",caption:Uc.t.value("copyMarkdown")},{id:"default",caption:Uc.t.value("copy")}],d=[{id:"islike",label:Uc.t.value("like"),title:Uc.t.value("like"),icon:function(){return na(dc,{})},onClick:function(){t.messageLike(n._origin)}},{id:"isdislike",label:Uc.t.value("downvote"),title:Uc.t.value("downvote"),icon:function(){return na(hc,{})},onClick:function(){t.messageDisLike(n._origin)}}],h=function(e){var t,n,i,r;return"function"==typeof e.icon?e.icon():null!==(t=e.icon)&&void 0!==t&&t.showIcon&&null!==(n=e.icon)&&void 0!==n&&n.cssClass?na("i",{className:e.icon.cssClass}):null!==(i=e.icon)&&void 0!==i&&i.showIcon&&null!==(r=e.icon)&&void 0!==r&&r.imagePath?ha(e.icon.imagePath)?na("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):na("img",{src:e.icon.imagePath}):void 0},f=Ja(function(){return 20===n.state&&!0!==n.completed},[n.state,n.completed]),p="REMOTE"!==t.resourceMode||t.currentTopicDisableStorage;return f?na(Do,{}):na("div",{className:"".concat(Hl.b()),children:[na(Fl,{position:"top",triggerMode:"hover",isOpen:o,actions:u,onToggleOpen:a,onAction:function(e,t){return i(e)},children:na("div",{title:Uc.t.value("copy"),className:"".concat(Hl.e("item")),children:na(Fs,{})})}),!p&&d.map(function(e,i){var r="islike"===e.id&&"1"===n.islike||"isdislike"===e.id&&"1"===n.isdislike;return na("div",{title:e.title,onClick:function(i){return function(e,i){var r;null===(r=i.onClick)||void 0===r||r.call(i,e,i,t.context,t.params,n)}(i,e)},className:"".concat(Hl.e("item")," ").concat(Hl.is("actived",r)),children:h(e)},i)}),n.usage&&na(Fl,{position:"top",triggerMode:"hover",isOpen:c,onToggleOpen:l,content:na("div",{className:Hl.b("statistics"),children:[na("div",{className:Hl.be("statistics","item"),children:[na("span",{className:Hl.be("statistics","icon"),children:na(Ic,{})}),na("span",{className:Hl.be("statistics","label"),children:Uc.t.value("totalTokens")}),na("span",{className:Hl.be("statistics","value"),children:n.usage.totaltokens||Uc.t.value("notCounted")})]}),na("div",{className:Hl.be("statistics","item"),children:[na("span",{className:Hl.be("statistics","icon"),children:na(Lc,{})}),na("span",{className:Hl.be("statistics","label"),children:Uc.t.value("inputTokens")}),na("span",{className:Hl.be("statistics","value"),children:n.usage.prompttokens||Uc.t.value("notCounted")})]}),na("div",{className:Hl.be("statistics","item"),children:[na("span",{className:Hl.be("statistics","icon"),children:na(Rc,{})}),na("span",{className:Hl.be("statistics","label"),children:Uc.t.value("outputTokens")}),na("span",{className:Hl.be("statistics","value"),children:n.usage.completiontokens||Uc.t.value("notCounted")})]}),na("div",{className:Hl.be("statistics","item"),children:[na("span",{className:Hl.be("statistics","icon"),children:na(zc,{})}),na("span",{className:Hl.be("statistics","label"),children:Uc.t.value("toolCallCount")}),na("span",{className:Hl.be("statistics","value"),children:n.usage.toolcalls||Uc.t.value("notCalled")})]})]}),children:na("div",{title:Uc.t.value("statistics"),className:"".concat(Hl.e("item")),children:na(Dc,{})})})]})},Vl=new ra("chat-slider"),Wl=fl(function(e,t){var n=e.min,i=e.max,r=e.step,o=e.onChange,a=qa(null),s=Ds(e.value),c=Math.max.apply(null,[n,i,r].map(function(e){var t="".concat(e).split(".")[1];return t?t.length:0})),l=qa({dragging:!1,startX:0,newPosition:0,startPosition:0}),u=Is(function(){return"".concat((s.value-n)/(i-n)*100,"%")});$a(function(){s.value=e.value},[e.value]);var d=function(e){var t,n;return e.type.startsWith("touch")?(n=e.touches[0].clientY,t=e.touches[0].clientX):(n=e.clientY,t=e.clientX),{clientX:t,clientY:n}},f=function(){var t=v(h().m(function t(a){var s,l,u;return h().w(function(t){for(;;)switch(t.n){case 0:if(null!==a&&!Number.isNaN(+a)){t.n=1;break}return t.a(2);case 1:a<0?a=0:a>100&&(a=100),s=100/((i-n)/r),l=Math.round(a/s),u=l*s*(i-n)*.01+n,(u=Number.parseFloat(u.toFixed(c)))!==e.value&&o(u);case 2:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),p=function(e){if(l.current.dragging){var t=d(e).clientX,n=a.current.parentElement.clientWidth,i=(t-l.current.startX)/n*100;l.current.newPosition=l.current.startPosition+i,f(l.current.newPosition)}},m=function(){l.current.dragging&&(l.current.dragging=!1,window.removeEventListener("mousemove",p),window.removeEventListener("touchmove",p),window.removeEventListener("mouseup",m),window.removeEventListener("touchend",m))},g=function(e){e.preventDefault(),function(e){var t=d(e).clientX,n=Number.parseFloat(u.value);Object.assign(l.current,{dragging:!0,startX:t,startPosition:n,newPosition:n})}(e),window.addEventListener("mousemove",p),window.addEventListener("touchmove",p),window.addEventListener("mouseup",m),window.addEventListener("touchend",m),a.current.focus()};return Ka(t,function(){return{state:l,onButtonDown:g,setPosition:f}}),na("div",{ref:a,className:Vl.e("button-wrapper"),onMouseDown:g,onTouchStart:g,style:{left:u.value},children:na("div",{className:Vl.e("button")})})}),$l=new ra("chat-slider"),Ul=function(e){var t=e.step,n=void 0===t?1:t,i=e.min,r=void 0===i?0:i,o=e.max,a=void 0===o?100:o,s=e.value,c=void 0===s?0:s,l=e.showText,u=void 0!==l&&l,d=e.className,h=void 0===d?"":d,f=e.onChange,p=qa(null),v=qa(null),m=Ds(c),g=Is(function(){return{width:"".concat(100*(m.value-r)/(a-r),"%"),left:"0%"}});$a(function(){void 0!==c&&(m.value=c)},[c]);var y=function(e){var t,n;if(v.current&&!v.current.state.current.dragging){var i,r=null!==(t=null===(n=e.touches)||void 0===n||null===(n=n.item(0))||void 0===n?void 0:n.clientX)&&void 0!==t?t:e.clientX,o=p.current.getBoundingClientRect();(i=(r-o.left)/o.width*100)<0||i>100||(v.current.setPosition(i),setTimeout(function(){v.current.onButtonDown(e)},0))}};return na("div",{className:"".concat($l.b()," ").concat(h),title:"".concat(m.value),children:[na("div",{ref:p,className:$l.e("runway"),onMouseDown:y,onTouchStart:y,children:[na("div",{className:$l.e("bar"),style:g.value}),na(Wl,{min:r,max:a,step:n,ref:v,value:m.value,onChange:function(e){m.value=e,null==f||f(e)}})]}),u?na("div",{className:$l.e("text"),children:m.value}):void 0]})},ql=new ra("chat-switch"),Kl=function(e){var t=e.value,n=e.className,i=void 0===n?"":n,r=e.showText,o=void 0!==r&&r,a=e.onChange,s=g(Wa(void 0),2),c=s[0],l=s[1],u=g(Wa(t),2),d=u[0],h=u[1];$a(function(){h(t)},[t]);return na("div",{className:"".concat(ql.b()," ").concat(i),children:[na("div",{onClick:function(){var e;void 0===d&&(e=1===c?0:1),l(d),h(e),null==a||a(e)},className:"".concat(ql.e("wrapper")," ").concat(ql.is(0===d?"left":1===d?"right":"center",!0))}),o?na("div",{className:ql.e("text"),children:[0===d?Uc.t.value("disabled"):void 0,1===d?Uc.t.value("enable"):void 0]}):void 0]})},Jl=new ra("chat-step-item"),Gl=function(e){var t=e.element,n=g(Wa(t.title),2),i=n[0],r=n[1],o=g(Wa(!1),2),a=o[0],s=o[1],c=g(Wa(!1),2),l=c[0],u=c[1],d=g(Wa(0),2),h=d[0],f=d[1],p=Ds(t.content),v=Ds([]),m=Ds({title:Uc.t.value("thinkThrough"),description:"",done:!0,collapse:!0}),y=qa(null),k=qa(null),w=function(){if(y.current){var e=y.current;f(e.clientHeight)}};$a(function(){w(),function(){if(k.current){var e=k.current;e.style.display="block";var t=e.scrollHeight;e.style.display="-webkit-box";var n=e.clientHeight;s(!!(t>n))}}(),function(){var e="",n=t.content||"",i=n.indexOf("<think>"),r=n.indexOf("</think>");-1!==i&&-1!==r&&(e=n.slice(i+7,r),n=n.slice(r+8));var o=Ta.parse(n).toolCalls||[];n=n.replace(/<tool_call>[\s\S]*?<\/tool_call>/g,""),m.value.description=e||"",p.value=n||"",v.value=o}(),function(){var e="";t.title?e=t.title:p.value&&(e=p.value);var n=(e=e.replace(/<tool_call>[\s\S]*?<\/tool_call>/g,"")).indexOf("<tool_call>");-1!==n&&-1===e.indexOf("</tool_call>")&&(e=e.substring(0,n)),r(e)}()},[]),$a(function(){setTimeout(function(){w()},0)},[e.element.content]);return na("div",{ref:y,className:"".concat(Jl.b()),style:{"--ibiz-chat-step-item-height":"".concat(h,"px")},children:[na("div",{className:"".concat(Jl.e("left")),children:na("div",{className:"".concat(Jl.e("icon")),children:["success"===t.status&&na(Tc,{}),"failed"===t.status&&na(xc,{}),"pending"===t.status&&na(Ys,{})]})}),na("div",{className:"".concat(Jl.e("right")," ").concat("pending"===t.status?"is-loadding":""),children:["pending"!==t.status&&na("div",{className:"".concat(Jl.e("title")),title:i,children:i}),"pending"!==t.status&&na("div",{className:"".concat(Jl.e("content")),children:[na("div",{ref:k,className:"".concat(Jl.e("content-text")," ").concat(l?"expanded":""),children:[v.value.length>0&&l&&na("div",{className:"".concat(Jl.e("content-tool-call-container")),children:na(Zc,{toolcallCompleted:!0,items:v.value,controller:e.controller,onLinkClick:e.onLinkClick,onCollapseChange:function(e){setTimeout(function(){w()},0)}})}),m.value.description&&l&&na("div",{className:"".concat(Jl.e("content-think-container")),children:na(qc,{item:m.value,controller:e.controller})}),p.value||""]}),a&&na("button",{className:"".concat(Jl.e("toggle-btn")),onClick:function(){u(!l),setTimeout(function(){w()},0)},children:l?Uc.t.value("foldUp"):Uc.t.value("expandAll")})]}),"pending"===t.status&&na("div",{className:"".concat(Jl.e("loadding-text")),children:Uc.t.value("loading")})]})]})},Yl=new ra("chat-step"),Xl=function(e){var t=e.items,n=Ds(!1),i=Ds(!0),r=Ds([]);$a(function(){n.value=t.length>1,r.value=n.value&&!i.value?[t[t.length-1]]:t},[t]);return na("div",{className:"".concat(Yl.b()),children:[na("div",{className:Yl.e("container"),children:r.value.map(function(t,n){return na(Gl,{element:t,controller:e.controller,onLinkClick:e.onLinkClick},"".concat(t.title,"_").concat(t.content,"_").concat(n))})}),n.value&&na("div",{className:Yl.e("toggle"),onClick:function(){i.value=!i.value,r.value=n.value&&!i.value?[t[t.length-1]]:t},children:na("span",{className:Yl.e("toggle-label"),children:i.value?Uc.t.value("stepFoldUp"):Uc.t.value("stepExpand")})})]})},Ql=new ra("ossfile-material"),Zl=function(e){var t=Is(function(){return e.material.data.name}),n=Is(function(){var t,n=e.material.metadata.size;return(t=n)>=1048576?"".concat((t/1048576).toFixed(2),"M"):t>=1024?"".concat((t/1024).toFixed(2),"K"):"".concat(t,"B")}),i=Is(function(){return e.material.metadata.state}),r=Is(function(){var t=e.material.metadata.state;return"successed"===t?Uc.t.value("uploadSuccess"):"uploading"===t?Uc.t.value("uploading"):"failed"===t?Uc.t.value("uploadFailed"):Uc.t.value("unknownState")}),o=Is(function(){switch(e.material.metadata.state){case"successed":return"#1890ff";case"uploading":return"#52c41a";default:return"#ff4d4f"}});return na("div",{className:Ql.b(),children:[na("div",{className:Ql.b("left"),children:na(Zs,{})}),na("div",{className:Ql.b("right"),children:[na("div",{className:Ql.e("name"),title:t,children:t}),na("div",{className:Ql.b("metadata"),children:[na("div",{children:n}),"successed"!==i.value&&na("div",{style:{color:o.value},children:r}),"successed"===i.value&&na("div",{className:Ql.be("metadata","img"),title:Uc.t.value("download"),onClick:function(){var t=e.material.metadata;e.controller.opts.uploader.onDownLoad(t,{context:e.controller.context,params:e.controller.params})},children:na(vc,{})})]})]})]})},eu=new ra("common-material"),tu=function(e){var t,n,i,r,o=null===(t=e.controller.opts.questionToolbarItems)||void 0===t?void 0:t.find(function(t){return t.id===e.material.metadata.actionId}),a=Is(function(){return e.material.metadata.name}),s=Is(function(){return e.material.metadata.downloadactionid});return na("div",{className:eu.b(),children:[na("div",{className:eu.b("left"),children:o&&o.icon?"function"==typeof o.icon?o.icon():(null===(n=o.icon)||void 0===n?void 0:n.showIcon)&&na(Do,{children:null!==(i=o.icon)&&void 0!==i&&i.cssClass?na("i",{className:o.icon.cssClass}):null!==(r=o.icon)&&void 0!==r&&r.imagePath?ha(o.icon.imagePath)?na("div",{dangerouslySetInnerHTML:{__html:o.icon.imagePath}}):na("img",{src:o.icon.imagePath}):null}):na(tc,{})}),na("div",{className:eu.b("right"),children:[na("div",{className:eu.e("name"),title:a,children:a}),na("div",{className:eu.b("metadata"),children:[na("div",{children:(null==o?void 0:o.label)||Uc.t.value("meterialResources")}),s&&na("div",{className:eu.be("metadata","img"),title:Uc.t.value("preview"),onClick:function(t){var n=e.material.metadata,i=e.controller.opts.extendToolbarClick;if(i&&"function"==typeof i){var r=n.downloadactionid;if(!s)throw new Error(Uc.t.value("downloadCannotEmpty"));var o=n.downloadAppId,a=d({},e.controller.context);if(n.downloadContext)try{var c=n.downloadContext.split(";").reduce(function(e,t){if(t.trim()){var n=g(t.split(":"),2),i=n[0],r=n[1];i&&r&&(e[i.trim()]=r.trim())}return e},{});c&&Object.keys(c).length>0&&Object.assign(a,c)}catch(l){throw new Error(Uc.t.value("downloadExContext"))}i(t,{id:r,isPluginApp:!!o,appId:o||a.srfappid},a,e.controller.params,{})}},children:na(vc,{})})]})]})]})},nu=new ra("chat-input-material-item"),iu=function(e){var t=e.material,n=null;if("ossfile"===t.type)n=Zl;else n=tu;return na("div",{className:"".concat(nu.b()," ").concat(nu.is("disabled",e.disabled)),children:[na("div",{className:nu.e("icon"),onClick:function(){e.controller.deleteMaterial(t)},children:na(ec,{})}),Eo(n,{material:t,controller:e.controller})]})},ru=new ra("markdown-message"),ou=function(e){var t=e.message,n=e.size,i=qa(null),r=Ds(null),o=Ds(""),a=Ds({resources:[],remainingText:"",hasResources:!1}),c=function(e){var t=ba.parseMixedContent(e),n=t.resources,i=t.remainingText,r=t.hasResources,o=t.error;a.value={resources:n,remainingText:i,hasResources:r,error:o}},l=Ja(function(){return 20===t.state&&!0!==t.completed},[t.state,t.completed]),u=Ja(function(){return 20===t.state&&!0===t.completed},[t.state,t.completed]);t.think||(t.think={title:"",description:"",collapse:!0});var h=function(e,n){t.think=d(d({},t.think),{},{title:e?Uc.t.value("thinkThrough"):!0===t.completed?Uc.t.value("stopThinking"):Uc.t.value("thinking"),description:n||"",done:e||!0===t.completed}),t.think.done||(t.think.beginTime||(t.think.beginTime=Date.now()),t.think.endTime=void 0),t.think.done&&!t.think.endTime&&(t.think.endTime=Date.now(),t.think.collapse=!0)},f=Ds({hasSuggestions:!1,suggestions:[]}),p=function(e){var t=e.indexOf("<think>"),n=e.indexOf("</think>"),i="",r="",o=!1;return-1===n?(o=!1,i=e.slice(t+7),r=""):(o=!0,i=e.slice(t+7,n),r=e.slice(n+8)),{isThoughtCompleted:o,thoughtContent:i,answerContent:r}},v=function(t){var n=t.target,i=null==n?void 0:n.closest('a[href^="chunkview://"], a[href^="view://"], a[href^="action://"]');if(i){t.preventDefault();var r=i.getAttribute("href");if(r){var o="";switch(r.startsWith("chunkview://")?o="chunkview":r.startsWith("view://")?o="view":r.startsWith("action://")&&(o="action"),o){case"chunkview":case"view":case"action":e.controller.handlePredefinedClick(o,r,e.message,t);break;default:console.error(Uc.t.value("protocol",{protocol:o}))}}return!1}};$a(function(){if(t.content&&-1!==t.content.indexOf("<think>")){var n=p(t.content),i=n.isThoughtCompleted,r=n.thoughtContent,a=n.answerContent;h(i,r),c(a)}else c(t.content);!function(){var n="";if(t.agent_tag&&(n=t.agent_tag),n){var i=e.controller.agentList.value.find(function(e){return e.id===n});o.value=(null==i?void 0:i.caption)||""}}()},[]),$a(function(){var e;e=Na.protect(a.value.remainingText||""),r.value?r.value.setMarkdown(e):r.value=new s({el:i.current,value:e,editor:{defaultModel:"previewOnly",codemirror:{autofocus:!1}},themeSettings:{mainTheme:"dark",codeBlockTheme:"dark"},previewer:{enablePreviewerBubble:!1},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}},callback:{onClickPreview:v}})},[a.value.remainingText]),$a(function(){if(n>=0&&r.value){if(t.content&&-1!==t.content.indexOf("<think>")){var e=p(t.content),i=e.isThoughtCompleted,o=e.thoughtContent,a=e.answerContent;h(i,o),c(a)}else c(t.content);(s=t.suggestions)&&s.length>0?f.value={hasSuggestions:!0,suggestions:s}:f.value={hasSuggestions:!1,suggestions:[]}}var s},[t,n]);return na("div",{className:"".concat(ru.b()," ").concat(ru.is("loading",l)),children:[na("div",{className:ru.b("header"),children:[na("div",{className:ru.be("header","caption"),children:["AI",o.value&&" | ".concat(o.value)]}),e.children,u?na("div",{className:ru.be("header","timeout"),children:Uc.t.value("requestTimeout")}):null]}),na("div",{className:"".concat(ru.b("content")," pre-wrap-container"),children:[a.value.hasResources&&na("div",{className:"content-material-container",children:a.value.resources.map(function(t){return na(iu,{material:t,disabled:!0,controller:e.controller},t.id)})}),t.chatsteps&&t.chatsteps.length>0&&na(Xl,{items:t.chatsteps||[],controller:e.controller,onLinkClick:v}),na(Zc,{toolcallCompleted:!!t.toolcallcompleted,items:t.toolcalls||[],controller:e.controller,onLinkClick:v}),na(qc,{item:t.think,controller:e.controller}),na("div",{className:ru.e("markdown"),ref:i})]}),na("div",{className:ru.b("footer"),children:[na(jl,{onCopy:function(n){var o,a,s=("markdown"===n?null===(o=r.value)||void 0===o?void 0:o.getMarkdown():null===(a=i.current)||void 0===a?void 0:a.innerText)||"";e.controller.copyMessage(s,t)},message:t,controller:e.controller},"".concat(t.messageid,"_").concat(t.islike,"_").concat(t.isdislike)),f.value.hasSuggestions||t.chatuiactions&&t.chatuiactions.length>0?na(Kc,{uiactions:t.chatuiactions||[],suggestions:f.value.suggestions,onSuggestionClick:function(t,n){!function(t,n){e.controller.handleSuggestionClick(e.message,t,n)}(t,n)},onUIActionClick:function(t,n){!function(t,n){e.controller.handleUIActionClick(e.message,t,n)}(t,n)}}):null]})]})};function au(e){this.content=e}function su(e,t,n){for(var i=0;;i++){if(i==e.childCount||i==t.childCount)return e.childCount==t.childCount?null:n;var r=e.child(i),o=t.child(i);if(r!=o){if(!r.sameMarkup(o))return n;if(r.isText&&r.text!=o.text){for(var a=0;r.text[a]==o.text[a];a++)n++;return n}if(r.content.size||o.content.size){var s=su(r.content,o.content,n+1);if(null!=s)return s}n+=r.nodeSize}else n+=r.nodeSize}}function cu(e,t,n,i){for(var r=e.childCount,o=t.childCount;;){if(0==r||0==o)return r==o?null:{a:n,b:i};var a=e.child(--r),s=t.child(--o),c=a.nodeSize;if(a!=s){if(!a.sameMarkup(s))return{a:n,b:i};if(a.isText&&a.text!=s.text){for(var l=0,u=Math.min(a.text.length,s.text.length);l<u&&a.text[a.text.length-l-1]==s.text[s.text.length-l-1];)l++,n--,i--;return{a:n,b:i}}if(a.content.size||s.content.size){var d=cu(a.content,s.content,n-1,i-1);if(d)return d}n-=c,i-=c}else n-=c,i-=c}}au.prototype={constructor:au,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var i=n&&n!=e?this.remove(n):this,r=i.find(e),o=i.content.slice();return-1==r?o.push(n||e,t):(o[r+1]=t,n&&(o[r]=n)),new au(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new au(n)},addToStart:function(e,t){return new au([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new au(n)},addBefore:function(e,t,n){var i=this.remove(t),r=i.content.slice(),o=i.find(e);return r.splice(-1==o?r.length:o,0,t,n),new au(r)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=au.from(e)).size?new au(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=au.from(e)).size?new au(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=au.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},au.from=function(e){if(e instanceof au)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new au(t)};var lu=function(){function e(t,n){if(C(this,e),this.content=t,this.size=n||0,null==n)for(var i=0;i<t.length;i++)this.size+=t[i].nodeSize}return x(e,[{key:"nodesBetween",value:function(e,t,n){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4?arguments[4]:void 0,o=0,a=0;a<t;o++){var s=this.content[o],c=a+s.nodeSize;if(c>e&&!1!==n(s,i+a,r||null,o)&&s.content.size){var l=a+1;s.nodesBetween(Math.max(0,e-l),Math.min(s.content.size,t-l),n,i+l)}a=c}}},{key:"descendants",value:function(e){this.nodesBetween(0,this.size,e)}},{key:"textBetween",value:function(e,t,n,i){var r="",o=!0;return this.nodesBetween(e,t,function(a,s){var c=a.isText?a.text.slice(Math.max(e,s)-s,t-s):a.isLeaf?i?"function"==typeof i?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&n&&(o?o=!1:r+=n),r+=c},0),r}},{key:"append",value:function(t){if(!t.size)return this;if(!this.size)return t;var n=this.lastChild,i=t.firstChild,r=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(i)&&(r[r.length-1]=n.withText(n.text+i.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new e(r,this.size+t.size)}},{key:"cut",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size;if(0==t&&n==this.size)return this;var i=[],r=0;if(n>t)for(var o=0,a=0;a<n;o++){var s=this.content[o],c=a+s.nodeSize;c>t&&((a<t||c>n)&&(s=s.isText?s.cut(Math.max(0,t-a),Math.min(s.text.length,n-a)):s.cut(Math.max(0,t-a-1),Math.min(s.content.size,n-a-1))),i.push(s),r+=s.nodeSize),a=c}return new e(i,r)}},{key:"cutByIndex",value:function(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}},{key:"replaceChild",value:function(t,n){var i=this.content[t];if(i==n)return this;var r=this.content.slice(),o=this.size+n.nodeSize-i.nodeSize;return r[t]=n,new e(r,o)}},{key:"addToStart",value:function(t){return new e([t].concat(this.content),this.size+t.nodeSize)}},{key:"addToEnd",value:function(t){return new e(this.content.concat(t),this.size+t.nodeSize)}},{key:"eq",value:function(e){if(this.content.length!=e.content.length)return!1;for(var t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}},{key:"firstChild",get:function(){return this.content.length?this.content[0]:null}},{key:"lastChild",get:function(){return this.content.length?this.content[this.content.length-1]:null}},{key:"childCount",get:function(){return this.content.length}},{key:"child",value:function(e){var t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}},{key:"maybeChild",value:function(e){return this.content[e]||null}},{key:"forEach",value:function(e){for(var t=0,n=0;t<this.content.length;t++){var i=this.content[t];e(i,n,t),n+=i.nodeSize}}},{key:"findDiffStart",value:function(e){return su(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0)}},{key:"findDiffEnd",value:function(e){return cu(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size,arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.size)}},{key:"findIndex",value:function(e){if(0==e)return du(0,e);if(e==this.size)return du(this.content.length,e);if(e>this.size||e<0)throw new RangeError("Position ".concat(e," outside of fragment (").concat(this,")"));for(var t=0,n=0;;t++){var i=n+this.child(t).nodeSize;if(i>=e)return i==e?du(t+1,i):du(t,n);n=i}}},{key:"toString",value:function(){return"<"+this.toStringInner()+">"}},{key:"toStringInner",value:function(){return this.content.join(", ")}},{key:"toJSON",value:function(){return this.content.length?this.content.map(function(e){return e.toJSON()}):null}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new e(n.map(t.nodeFromJSON))}},{key:"fromArray",value:function(t){if(!t.length)return e.empty;for(var n,i=0,r=0;r<t.length;r++){var o=t[r];i+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(n||(n=t.slice(0,r)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,i)}},{key:"from",value:function(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}])}();lu.empty=new lu([],0);var uu={index:0,offset:0};function du(e,t){return uu.index=e,uu.offset=t,uu}function hu(e,t){if(e===t)return!0;if(!e||"object"!=_(e)||!t||"object"!=_(t))return!1;var n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(var i=0;i<e.length;i++)if(!hu(e[i],t[i]))return!1}else{for(var r in e)if(!(r in t)||!hu(e[r],t[r]))return!1;for(var o in t)if(!(o in e))return!1}return!0}var fu=function(){function e(t,n){C(this,e),this.type=t,this.attrs=n}return x(e,[{key:"addToSet",value:function(e){for(var t,n=!1,i=0;i<e.length;i++){var r=e[i];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,i));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(r)}}return t||(t=e.slice()),n||t.push(this),t}},{key:"removeFromSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}},{key:"eq",value:function(e){return this==e||this.type==e.type&&hu(this.attrs,e.attrs)}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");var n=e.marks[t.type];if(!n)throw new RangeError("There is no mark type ".concat(t.type," in this schema"));var i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}},{key:"sameSet",value:function(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}},{key:"setFrom",value:function(t){if(!t||Array.isArray(t)&&0==t.length)return e.none;if(t instanceof e)return[t];var n=t.slice();return n.sort(function(e,t){return e.type.rank-t.type.rank}),n}}])}();fu.none=[];var pu=function(e){function t(){return C(this,t),n(this,t,arguments)}return i(t,e),x(t)}(r(Error)),vu=function(){function e(t,n,i){C(this,e),this.content=t,this.openStart=n,this.openEnd=i}return x(e,[{key:"size",get:function(){return this.content.size-this.openStart-this.openEnd}},{key:"insertAt",value:function(t,n){var i=gu(this.content,t+this.openStart,n);return i&&new e(i,this.openStart,this.openEnd)}},{key:"removeBetween",value:function(t,n){return new e(mu(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}},{key:"eq",value:function(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}},{key:"toString",value:function(){return this.content+"("+this.openStart+","+this.openEnd+")"}},{key:"toJSON",value:function(){if(!this.content.size)return null;var e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;var i=n.openStart||0,r=n.openEnd||0;if("number"!=typeof i||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new e(lu.fromJSON(t,n.content),i,r)}},{key:"maxOpen",value:function(t){for(var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=0,r=0,o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)i++;for(var a=t.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)r++;return new e(t,i,r)}}])}();function mu(e,t,n){var i=e.findIndex(t),r=i.index,o=i.offset,a=e.maybeChild(r),s=e.findIndex(n),c=s.index,l=s.offset;if(o==t||a.isText){if(l!=n&&!e.child(c).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=c)throw new RangeError("Removing non-flat range");return e.replaceChild(r,a.copy(mu(a.content,t-o-1,n-o-1)))}function gu(e,t,n,i){var r=e.findIndex(t),o=r.index,a=r.offset,s=e.maybeChild(o);if(a==t||s.isText)return i&&!i.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));var c=gu(s.content,t-a-1,n,s);return c&&e.replaceChild(o,s.copy(c))}function yu(e,t,n){if(n.openStart>e.depth)throw new pu("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new pu("Inconsistent open depths");return ku(e,t,n,0)}function ku(e,t,n,i){var r=e.index(i),o=e.node(i);if(r==t.index(i)&&i<e.depth-n.openStart){var a=ku(e,t,n,i+1);return o.copy(o.content.replaceChild(r,a))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=i||t.depth!=i){var s=function(e,t){for(var n=t.depth-e.openStart,i=t.node(n).copy(e.content),r=n-1;r>=0;r--)i=t.node(r).copy(lu.from(i));return{start:i.resolveNoCache(e.openStart+n),end:i.resolveNoCache(i.content.size-e.openEnd-n)}}(n,e);return xu(o,Tu(e,s.start,s.end,t,i))}var c=e.parent,l=c.content;return xu(c,l.cut(0,e.parentOffset).append(n.content).append(l.cut(t.parentOffset)))}return xu(o,Mu(e,t,i))}function wu(e,t){if(!t.type.compatibleContent(e.type))throw new pu("Cannot join "+t.type.name+" onto "+e.type.name)}function bu(e,t,n){var i=e.node(n);return wu(i,t.node(n)),i}function Cu(e,t){var n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Su(e,t,n,i){var r=(t||e).node(n),o=0,a=t?t.index(n):r.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(Cu(e.nodeAfter,i),o++));for(var s=o;s<a;s++)Cu(r.child(s),i);t&&t.depth==n&&t.textOffset&&Cu(t.nodeBefore,i)}function xu(e,t){return e.type.checkContent(t),e.copy(t)}function Tu(e,t,n,i,r){var o=e.depth>r&&bu(e,t,r+1),a=i.depth>r&&bu(n,i,r+1),s=[];return Su(null,e,r,s),o&&a&&t.index(r)==n.index(r)?(wu(o,a),Cu(xu(o,Tu(e,t,n,i,r+1)),s)):(o&&Cu(xu(o,Mu(e,t,r+1)),s),Su(t,n,r,s),a&&Cu(xu(a,Mu(n,i,r+1)),s)),Su(i,null,r,s),new lu(s)}function Mu(e,t,n){var i=[];(Su(null,e,n,i),e.depth>n)&&Cu(xu(bu(e,t,n+1),Mu(e,t,n+1)),i);return Su(t,null,n,i),new lu(i)}vu.empty=new vu(lu.empty,0,0);var _u=function(){function e(t,n,i){C(this,e),this.pos=t,this.path=n,this.parentOffset=i,this.depth=n.length/3-1}return x(e,[{key:"resolveDepth",value:function(e){return null==e?this.depth:e<0?this.depth+e:e}},{key:"parent",get:function(){return this.node(this.depth)}},{key:"doc",get:function(){return this.node(0)}},{key:"node",value:function(e){return this.path[3*this.resolveDepth(e)]}},{key:"index",value:function(e){return this.path[3*this.resolveDepth(e)+1]}},{key:"indexAfter",value:function(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}},{key:"start",value:function(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}},{key:"end",value:function(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}},{key:"before",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}},{key:"after",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}},{key:"textOffset",get:function(){return this.pos-this.path[this.path.length-1]}},{key:"nodeAfter",get:function(){var e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;var n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}},{key:"nodeBefore",get:function(){var e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}},{key:"posAtIndex",value:function(e,t){t=this.resolveDepth(t);for(var n=this.path[3*t],i=0==t?0:this.path[3*t-1]+1,r=0;r<e;r++)i+=n.child(r).nodeSize;return i}},{key:"marks",value:function(){var e=this.parent,t=this.index();if(0==e.content.size)return fu.none;if(this.textOffset)return e.child(t).marks;var n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){var r=n;n=i,i=r}for(var o=n.marks,a=0;a<o.length;a++)!1!==o[a].type.spec.inclusive||i&&o[a].isInSet(i.marks)||(o=o[a--].removeFromSet(o));return o}},{key:"marksAcross",value:function(e){var t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;for(var n=t.marks,i=e.parent.maybeChild(e.index()),r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||i&&n[r].isInSet(i.marks)||(n=n[r--].removeFromSet(n));return n}},{key:"sharedDepth",value:function(e){for(var t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}},{key:"blockRange",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this,t=arguments.length>1?arguments[1]:void 0;if(e.pos<this.pos)return e.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Au(this,e,n);return null}},{key:"sameParent",value:function(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}},{key:"max",value:function(e){return e.pos>this.pos?e:this}},{key:"min",value:function(e){return e.pos<this.pos?e:this}},{key:"toString",value:function(){for(var e="",t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}}],[{key:"resolve",value:function(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");for(var i=[],r=0,o=n,a=t;;){var s=a.content.findIndex(o),c=s.index,l=s.offset,u=o-l;if(i.push(a,c,r+l),!u)break;if((a=a.child(c)).isText)break;o=u-1,r+=l+1}return new e(n,i,o)}},{key:"resolveCached",value:function(t,n){var i=Eu.get(t);if(i)for(var r=0;r<i.elts.length;r++){var o=i.elts[r];if(o.pos==n)return o}else Eu.set(t,i=new Nu);var a=i.elts[i.i]=e.resolve(t,n);return i.i=(i.i+1)%Ou,a}}])}(),Nu=x(function e(){C(this,e),this.elts=[],this.i=0}),Ou=12,Eu=new WeakMap,Au=function(){return x(function e(t,n,i){C(this,e),this.$from=t,this.$to=n,this.depth=i},[{key:"start",get:function(){return this.$from.before(this.depth+1)}},{key:"end",get:function(){return this.$to.after(this.depth+1)}},{key:"parent",get:function(){return this.$from.node(this.depth)}},{key:"startIndex",get:function(){return this.$from.index(this.depth)}},{key:"endIndex",get:function(){return this.$to.indexAfter(this.depth)}}])}(),Du=Object.create(null),Iu=function(){function e(t,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:fu.none;C(this,e),this.type=t,this.attrs=n,this.marks=r,this.content=i||lu.empty}return x(e,[{key:"children",get:function(){return this.content.content}},{key:"nodeSize",get:function(){return this.isLeaf?1:2+this.content.size}},{key:"childCount",get:function(){return this.content.childCount}},{key:"child",value:function(e){return this.content.child(e)}},{key:"maybeChild",value:function(e){return this.content.maybeChild(e)}},{key:"forEach",value:function(e){this.content.forEach(e)}},{key:"nodesBetween",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.content.nodesBetween(e,t,n,i,this)}},{key:"descendants",value:function(e){this.nodesBetween(0,this.content.size,e)}},{key:"textContent",get:function(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}},{key:"textBetween",value:function(e,t,n,i){return this.content.textBetween(e,t,n,i)}},{key:"firstChild",get:function(){return this.content.firstChild}},{key:"lastChild",get:function(){return this.content.lastChild}},{key:"eq",value:function(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}},{key:"sameMarkup",value:function(e){return this.hasMarkup(e.type,e.attrs,e.marks)}},{key:"hasMarkup",value:function(e,t,n){return this.type==e&&hu(this.attrs,t||e.defaultAttrs||Du)&&fu.sameSet(this.marks,n||fu.none)}},{key:"copy",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}},{key:"mark",value:function(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}},{key:"cut",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size;return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}},{key:"slice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e==t)return vu.empty;var i=this.resolve(e),r=this.resolve(t),o=n?0:i.sharedDepth(t),a=i.start(o),s=i.node(o).content.cut(i.pos-a,r.pos-a);return new vu(s,i.depth-o,r.depth-o)}},{key:"replace",value:function(e,t,n){return yu(this.resolve(e),this.resolve(t),n)}},{key:"nodeAt",value:function(e){for(var t=this;;){var n=t.content.findIndex(e),i=n.index,r=n.offset;if(!(t=t.maybeChild(i)))return null;if(r==e||t.isText)return t;e-=r+1}}},{key:"childAfter",value:function(e){var t=this.content.findIndex(e),n=t.index,i=t.offset;return{node:this.content.maybeChild(n),index:n,offset:i}}},{key:"childBefore",value:function(e){if(0==e)return{node:null,index:0,offset:0};var t=this.content.findIndex(e),n=t.index,i=t.offset;if(i<e)return{node:this.content.child(n),index:n,offset:i};var r=this.content.child(n-1);return{node:r,index:n-1,offset:i-r.nodeSize}}},{key:"resolve",value:function(e){return _u.resolveCached(this,e)}},{key:"resolveNoCache",value:function(e){return _u.resolve(this,e)}},{key:"rangeHasMark",value:function(e,t,n){var i=!1;return t>e&&this.nodesBetween(e,t,function(e){return n.isInSet(e.marks)&&(i=!0),!i}),i}},{key:"isBlock",get:function(){return this.type.isBlock}},{key:"isTextblock",get:function(){return this.type.isTextblock}},{key:"inlineContent",get:function(){return this.type.inlineContent}},{key:"isInline",get:function(){return this.type.isInline}},{key:"isText",get:function(){return this.type.isText}},{key:"isLeaf",get:function(){return this.type.isLeaf}},{key:"isAtom",get:function(){return this.type.isAtom}},{key:"toString",value:function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ru(this.marks,e)}},{key:"contentMatchAt",value:function(e){var t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}},{key:"canReplace",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:lu.empty,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:n.childCount,o=this.contentMatchAt(e).matchFragment(n,i,r),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(var s=i;s<r;s++)if(!this.type.allowsMarks(n.child(s).marks))return!1;return!0}},{key:"canReplaceWith",value:function(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;var r=this.contentMatchAt(e).matchType(n),o=r&&r.matchFragment(this.content,t);return!!o&&o.validEnd}},{key:"canAppend",value:function(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}},{key:"check",value:function(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);for(var e=fu.none,t=0;t<this.marks.length;t++){var n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!fu.sameSet(e,this.marks))throw new RangeError("Invalid collection of marks for node ".concat(this.type.name,": ").concat(this.marks.map(function(e){return e.type.name})));this.content.forEach(function(e){return e.check()})}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var 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(function(e){return e.toJSON()})),e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");var n=void 0;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}var i=lu.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,i,n);return r.type.checkAttrs(r.attrs),r}}])}();Iu.prototype.text=void 0;var Lu=function(t){function r(e,t,i,o){var a;if(C(this,r),a=n(this,r,[e,t,null,o]),!i)throw new RangeError("Empty text nodes are not allowed");return a.text=i,a}return i(r,t),x(r,[{key:"toString",value:function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ru(this.marks,JSON.stringify(this.text))}},{key:"textContent",get:function(){return this.text}},{key:"textBetween",value:function(e,t){return this.text.slice(e,t)}},{key:"nodeSize",get:function(){return this.text.length}},{key:"mark",value:function(e){return e==this.marks?this:new r(this.type,this.attrs,this.text,e)}},{key:"withText",value:function(e){return e==this.text?this:new r(this.type,this.attrs,e,this.marks)}},{key:"cut",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.text.length;return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}},{key:"eq",value:function(e){return this.sameMarkup(e)&&this.text==e.text}},{key:"toJSON",value:function(){var t=e(r,"toJSON",this,3)([]);return t.text=this.text,t}}])}(Iu);function Ru(e,t){for(var n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var zu=function(){function e(t){C(this,e),this.validEnd=t,this.next=[],this.wrapCache=[]}return x(e,[{key:"matchType",value:function(e){for(var t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}},{key:"matchFragment",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.childCount,i=this,r=t;i&&r<n;r++)i=i.matchType(e.child(r).type);return i}},{key:"inlineContent",get:function(){return 0!=this.next.length&&this.next[0].type.isInline}},{key:"defaultType",get:function(){for(var e=0;e<this.next.length;e++){var t=this.next[e].type;if(!t.isText&&!t.hasRequiredAttrs())return t}return null}},{key:"compatible",value:function(e){for(var t=0;t<this.next.length;t++)for(var n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}},{key:"fillBefore",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=[this];return function r(o,a){var s=o.matchFragment(e,n);if(s&&(!t||s.validEnd))return lu.from(a.map(function(e){return e.createAndFill()}));for(var c=0;c<o.next.length;c++){var l=o.next[c],u=l.type,d=l.next;if(!u.isText&&!u.hasRequiredAttrs()&&-1==i.indexOf(d)){i.push(d);var h=r(d,a.concat(u));if(h)return h}}return null}(this,[])}},{key:"findWrapping",value:function(e){for(var t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];var n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}},{key:"computeWrapping",value:function(e){for(var t=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var i=n.shift(),r=i.match;if(r.matchType(e)){for(var o=[],a=i;a.type;a=a.via)o.push(a.type);return o.reverse()}for(var s=0;s<r.next.length;s++){var c=r.next[s],l=c.type,u=c.next;l.isLeaf||l.hasRequiredAttrs()||l.name in t||i.type&&!u.validEnd||(n.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}},{key:"edgeCount",get:function(){return this.next.length}},{key:"edge",value:function(e){if(e>=this.next.length)throw new RangeError("There's no ".concat(e,"th edge in this content match"));return this.next[e]}},{key:"toString",value:function(){var e=[];return function t(n){e.push(n);for(var i=0;i<n.next.length;i++)-1==e.indexOf(n.next[i].next)&&t(n.next[i].next)}(this),e.map(function(t,n){for(var i=n+(t.validEnd?"*":" ")+" ",r=0;r<t.next.length;r++)i+=(r?", ":"")+t.next[r].type.name+"->"+e.indexOf(t.next[r].next);return i}).join("\n")}}],[{key:"parse",value:function(t,n){var i=new Pu(t,n);if(null==i.next)return e.empty;var r=Bu(i);i.next&&i.err("Unexpected trailing text");var o=Uu(function(e){var t=[[]];return r(o(e,0),n()),t;function n(){return t.push([])-1}function i(e,n,i){var r={term:i,to:n};return t[e].push(r),r}function r(e,t){e.forEach(function(e){return e.to=t})}function o(e,t){if("choice"==e.type)return e.exprs.reduce(function(e,n){return e.concat(o(n,t))},[]);if("seq"!=e.type){if("star"==e.type){var a=n();return i(t,a),r(o(e.expr,a),a),[i(a)]}if("plus"==e.type){var s=n();return r(o(e.expr,t),s),r(o(e.expr,s),s),[i(s)]}if("opt"==e.type)return[i(t)].concat(o(e.expr,t));if("range"==e.type){for(var c=t,l=0;l<e.min;l++){var u=n();r(o(e.expr,c),u),c=u}if(-1==e.max)r(o(e.expr,c),c);else for(var d=e.min;d<e.max;d++){var h=n();i(c,h),r(o(e.expr,c),h),c=h}return[i(c)]}if("name"==e.type)return[i(t,void 0,e.value)];throw new Error("Unknown expr type")}for(var f=0;;f++){var p=o(e.exprs[f],t);if(f==e.exprs.length-1)return p;r(p,t=n())}}}(r));return function(e,t){for(var n=0,i=[e];n<i.length;n++){for(var r=i[n],o=!r.validEnd,a=[],s=0;s<r.next.length;s++){var c=r.next[s],l=c.type,u=c.next;a.push(l.name),!o||l.isText||l.hasRequiredAttrs()||(o=!1),-1==i.indexOf(u)&&i.push(u)}o&&t.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,i),o}}])}();zu.empty=new zu(!0);var Pu=function(){return x(function e(t,n){C(this,e),this.string=t,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},[{key:"next",get:function(){return this.tokens[this.pos]}},{key:"eat",value:function(e){return this.next==e&&(this.pos++||!0)}},{key:"err",value:function(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}])}();function Bu(e){var t=[];do{t.push(Fu(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function Fu(e){var t=[];do{t.push(Hu(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function Hu(e){for(var t=function(e){if(e.eat("(")){var t=Bu(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(e,t){var n=e.nodeTypes,i=n[t];if(i)return[i];var r=[];for(var o in n){var a=n[o];a.isInGroup(t)&&r.push(a)}0==r.length&&e.err("No node type or group '"+t+"' found");return r}(e,e.next).map(function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}});return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}(e);;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=Vu(e,t)}return t}function ju(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");var t=Number(e.next);return e.pos++,t}function Vu(e,t){var n=ju(e),i=n;return e.eat(",")&&(i="}"!=e.next?ju(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:t}}function Wu(e,t){return t-e}function $u(e,t){var n=[];return function t(i){var r=e[i];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(i);for(var o=0;o<r.length;o++){var a=r[o],s=a.term,c=a.to;s||-1!=n.indexOf(c)||t(c)}}(t),n.sort(Wu)}function Uu(e){var t=Object.create(null);return function n(i){var r=[];i.forEach(function(t){e[t].forEach(function(t){var n=t.term,i=t.to;if(n){for(var o,a=0;a<r.length;a++)r[a][0]==n&&(o=r[a][1]);$u(e,i).forEach(function(e){o||r.push([n,o=[]]),-1==o.indexOf(e)&&o.push(e)})}})});for(var o=t[i.join(",")]=new zu(i.indexOf(e.length-1)>-1),a=0;a<r.length;a++){var s=r[a][1].sort(Wu);o.next.push({type:r[a][0],next:t[s.join(",")]||n(s)})}return o}($u(e,0))}function qu(e){var t=Object.create(null);for(var n in e){var i=e[n];if(!i.hasDefault)return null;t[n]=i.default}return t}function Ku(e,t){var n=Object.create(null);for(var i in e){var r=t&&t[i];if(void 0===r){var o=e[i];if(!o.hasDefault)throw new RangeError("No value supplied for attribute "+i);r=o.default}n[i]=r}return n}function Ju(e,t,n,i){for(var r in t)if(!(r in e))throw new RangeError("Unsupported attribute ".concat(r," for ").concat(n," of type ").concat(r));for(var o in e){var a=e[o];a.validate&&a.validate(t[o])}}function Gu(e,t){var n=Object.create(null);if(t)for(var i in t)n[i]=new Xu(e,i,t[i]);return n}var Yu=function(){function e(t,n,i){C(this,e),this.name=t,this.schema=n,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Gu(t,i.attrs),this.defaultAttrs=qu(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||"text"==t),this.isText="text"==t}return x(e,[{key:"isInline",get:function(){return!this.isBlock}},{key:"isTextblock",get:function(){return this.isBlock&&this.inlineContent}},{key:"isLeaf",get:function(){return this.contentMatch==zu.empty}},{key:"isAtom",get:function(){return this.isLeaf||!!this.spec.atom}},{key:"isInGroup",value:function(e){return this.groups.indexOf(e)>-1}},{key:"whitespace",get:function(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}},{key:"hasRequiredAttrs",value:function(){for(var e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}},{key:"compatibleContent",value:function(e){return this==e||this.contentMatch.compatible(e.contentMatch)}},{key:"computeAttrs",value:function(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ku(this.attrs,e)}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Iu(this,this.computeAttrs(e),lu.from(t),fu.setFrom(n))}},{key:"createChecked",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;return t=lu.from(t),this.checkContent(t),new Iu(this,this.computeAttrs(e),t,fu.setFrom(n))}},{key:"createAndFill",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(e=this.computeAttrs(e),(t=lu.from(t)).size){var i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}var r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(lu.empty,!0);return o?new Iu(this,e,t.append(o),fu.setFrom(n)):null}},{key:"validContent",value:function(e){var t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(var n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}},{key:"checkContent",value:function(e){if(!this.validContent(e))throw new RangeError("Invalid content for node ".concat(this.name,": ").concat(e.toString().slice(0,50)))}},{key:"checkAttrs",value:function(e){Ju(this.attrs,e,"node",this.name)}},{key:"allowsMarkType",value:function(e){return null==this.markSet||this.markSet.indexOf(e)>-1}},{key:"allowsMarks",value:function(e){if(null==this.markSet)return!0;for(var t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}},{key:"allowedMarks",value:function(e){if(null==this.markSet)return e;for(var t,n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:fu.none:e}}],[{key:"compile",value:function(t,n){var i=Object.create(null);t.forEach(function(t,r){return i[t]=new e(t,n,r)});var r=n.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(var o in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}}])}();var Xu=function(){return x(function e(t,n,i){C(this,e),this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate="string"==typeof i.validate?function(e,t,n){var i=n.split("|");return function(n){var r=null===n?"null":_(n);if(i.indexOf(r)<0)throw new RangeError("Expected value of type ".concat(i," for attribute ").concat(t," on type ").concat(e,", got ").concat(r))}}(t,n,i.validate):i.validate},[{key:"isRequired",get:function(){return!this.hasDefault}}])}(),Qu=function(){function e(t,n,i,r){C(this,e),this.name=t,this.rank=n,this.schema=i,this.spec=r,this.attrs=Gu(t,r.attrs),this.excluded=null;var o=qu(this.attrs);this.instance=o?new fu(this,o):null}return x(e,[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return!e&&this.instance?this.instance:new fu(this,Ku(this.attrs,e))}},{key:"removeFromSet",value:function(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}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(e[t].type==this)return e[t]}},{key:"checkAttrs",value:function(e){Ju(this.attrs,e,"mark",this.name)}},{key:"excludes",value:function(e){return this.excluded.indexOf(e)>-1}}],[{key:"compile",value:function(t,n){var i=Object.create(null),r=0;return t.forEach(function(t,o){return i[t]=new e(t,r++,n,o)}),i}}])}(),Zu=function(){return x(function e(t){var n=this;C(this,e),this.linebreakReplacement=null,this.cached=Object.create(null);var i=this.spec={};for(var r in t)i[r]=t[r];i.nodes=au.from(t.nodes),i.marks=au.from(t.marks||{}),this.nodes=Yu.compile(this.spec.nodes,this),this.marks=Qu.compile(this.spec.marks,this);var o=Object.create(null);for(var a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");var s=this.nodes[a],c=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=o[c]||(o[c]=zu.parse(c,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?ed(this,l.split(" ")):""!=l&&s.inlineContent?null:[]}for(var u in this.marks){var d=this.marks[u],h=d.spec.excludes;d.excluded=null==h?[d]:""==h?[]:ed(this,h.split(" "))}this.nodeFromJSON=function(e){return Iu.fromJSON(n,e)},this.markFromJSON=function(e){return fu.fromJSON(n,e)},this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)},[{key:"node",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Yu))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,i)}},{key:"text",value:function(e,t){var n=this.nodes.text;return new Lu(n,n.defaultAttrs,e,fu.setFrom(t))}},{key:"mark",value:function(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}},{key:"nodeType",value:function(e){var t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}])}();function ed(e,t){for(var n=[],i=0;i<t.length;i++){var r=t[i],o=e.marks[r],a=o;if(o)n.push(o);else for(var s in e.marks){var c=e.marks[s];("_"==r||c.spec.group&&c.spec.group.split(" ").indexOf(r)>-1)&&n.push(a=c)}if(!a)throw new SyntaxError("Unknown mark type: '"+t[i]+"'")}return n}var td=function(){function e(t,n){var i=this;C(this,e),this.schema=t,this.rules=n,this.tags=[],this.styles=[];var r=this.matchedStyles=[];n.forEach(function(e){if(function(e){return null!=e.tag}(e))i.tags.push(e);else if(function(e){return null!=e.style}(e)){var t=/[^=]*/.exec(e.style)[0];r.indexOf(t)<0&&r.push(t),i.styles.push(e)}}),this.normalizeLists=!this.tags.some(function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)})}return x(e,[{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new sd(this,t,!1);return n.addAll(e,fu.none,t.from,t.to),n.finish()}},{key:"parseSlice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new sd(this,t,!0);return n.addAll(e,fu.none,t.from,t.to),vu.maxOpen(n.finish())}},{key:"matchTag",value:function(e,t,n){for(var i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){var r=this.tags[i];if(cd(e,r.tag)&&(void 0===r.namespace||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){var o=r.getAttrs(e);if(!1===o)continue;r.attrs=o||void 0}return r}}}},{key:"matchStyle",value:function(e,t,n,i){for(var r=i?this.styles.indexOf(i)+1:0;r<this.styles.length;r++){var o=this.styles[r],a=o.style;if(!(0!=a.indexOf(e)||o.context&&!n.matchesContext(o.context)||a.length>e.length&&(61!=a.charCodeAt(e.length)||a.slice(e.length+1)!=t))){if(o.getAttrs){var s=o.getAttrs(t);if(!1===s)continue;o.attrs=s||void 0}return o}}}}],[{key:"schemaRules",value:function(e){var t=[];function n(e){for(var n=null==e.priority?50:e.priority,i=0;i<t.length;i++){var r=t[i];if((null==r.priority?50:r.priority)<n)break}t.splice(i,0,e)}var i=function(t){var i=e.marks[t].spec.parseDOM;i&&i.forEach(function(e){n(e=ld(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})};for(var r in e.marks)i(r);var o=function(t){var i=e.nodes[t].spec.parseDOM;i&&i.forEach(function(e){n(e=ld(e)),e.node||e.ignore||e.mark||(e.node=t)})};for(var a in e.nodes)o(a);return t}},{key:"fromSchema",value:function(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}}])}(),nd={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},id={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},rd={ol:!0,ul:!0};function od(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}var ad=function(){return x(function e(t,n,i,r,o,a){C(this,e),this.type=t,this.attrs=n,this.marks=i,this.solid=r,this.options=a,this.content=[],this.activeMarks=fu.none,this.match=o||(4&a?null:t.contentMatch)},[{key:"findWrapping",value:function(e){if(!this.match){if(!this.type)return[];var t=this.type.contentMatch.fillBefore(lu.from(e));if(!t){var n,i=this.type.contentMatch;return(n=i.findWrapping(e.type))?(this.match=i,n):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}},{key:"finish",value:function(e){if(!(1&this.options)){var t,n=this.content[this.content.length-1];if(n&&n.isText&&(t=/[ \t\r\n\u000c]+$/.exec(n.text))){var i=n;n.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-t[0].length))}}var r=lu.from(this.content);return!e&&this.match&&(r=r.append(this.match.fillBefore(lu.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}},{key:"inlineContext",value:function(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!nd.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}])}(),sd=function(){return x(function e(t,n,i){C(this,e),this.parser=t,this.options=n,this.isOpen=i,this.open=0,this.localPreserveWS=!1;var r,o=n.topNode,a=od(null,n.preserveWhitespace,0)|(i?4:0);r=o?new ad(o.type,o.attrs,fu.none,!0,n.topMatch||o.type.contentMatch,a):new ad(i?null:t.schema.topNodeType,null,fu.none,!0,null,a),this.nodes=[r],this.find=n.findPositions,this.needsBlock=!1},[{key:"top",get:function(){return this.nodes[this.open]}},{key:"addDOM",value:function(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}},{key:"addTextNode",value:function(e,t){var n=e.nodeValue,i=this.top,r=2&i.options?"full":this.localPreserveWS||(1&i.options)>0,o=this.parser.schema;if("full"===r||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r)if("full"===r)n=n.replace(/\r\n?/g,"\n");else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){for(var a=n.split(/\r?\n|\r/),s=0;s<a.length;s++)s&&this.insertNode(o.linebreakReplacement.create(),t,!0),a[s]&&this.insertNode(o.text(a[s]),t,!/\S/.test(a[s]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){var c=i.content[i.content.length-1],l=e.previousSibling;(!c||l&&"BR"==l.nodeName||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}},{key:"addElement",value:function(e,t,n){var i=this.localPreserveWS,r=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);var o,a=e.nodeName.toLowerCase();rd.hasOwnProperty(a)&&this.parser.normalizeLists&&function(e){for(var t=e.firstChild,n=null;t;t=t.nextSibling){var i=1==t.nodeType?t.nodeName.toLowerCase():null;i&&rd.hasOwnProperty(i)&&n?(n.appendChild(t),t=n):"li"==i?n=t:i&&(n=null)}}(e);var s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(s?s.ignore:id.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);var c,l=this.needsBlock;if(nd.hasOwnProperty(a))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),c=!0,r.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}var u=s&&s.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(r),this.needsBlock=l}else{var d=this.readStyles(e,t);d&&this.addElementByRule(e,s,d,!1===s.consuming?o:void 0)}this.localPreserveWS=i}},{key:"leafFallback",value:function(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}},{key:"ignoreFallback",value:function(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}},{key:"readStyles",value:function(e,t){var n=this,i=e.style;if(i&&i.length)for(var r=0;r<this.parser.matchedStyles.length;r++){var o=this.parser.matchedStyles[r],a=i.getPropertyValue(o);if(a)for(var s,c=function(e){var i=n.parser.matchStyle(o,a,n,e);return i?i.ignore?{v:null}:(t=i.clearMark?t.filter(function(e){return!i.clearMark(e)}):t.concat(n.parser.schema.marks[i.mark].create(i.attrs)),!1!==i.consuming?(l=e,0):void(l=e=i)):(l=e,0)},l=void 0;0!==(s=c(l));)if(s)return s.v}return t}},{key:"addElementByRule",value:function(e,t,n,i){var r,o,a=this;if(t.node)if((o=this.parser.schema.nodes[t.node]).isLeaf)this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{var s=this.enter(o,t.attrs||null,n,t.preserveWhitespace);s&&(r=!0,n=s)}else{var c=this.parser.schema.marks[t.mark];n=n.concat(c.create(t.attrs))}var l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(function(e){return a.insertNode(e,n,!1)});else{var u=e;"string"==typeof t.contentElement?u=e.querySelector(t.contentElement):"function"==typeof t.contentElement?u=t.contentElement(e):t.contentElement&&(u=t.contentElement),this.findAround(e,u,!0),this.addAll(u,n),this.findAround(e,u,!1)}r&&this.sync(l)&&this.open--}},{key:"addAll",value:function(e,t,n,i){for(var r=n||0,o=n?e.childNodes[n]:e.firstChild,a=null==i?null:e.childNodes[i];o!=a;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o,t);this.findAtPoint(e,r)}},{key:"findPlace",value:function(e,t,n){for(var i,r,o=this.open,a=0;o>=0;o--){var s=this.nodes[o],c=s.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,r=s,!c.length))break;if(s.solid){if(n)break;a+=2}}if(!i)return null;this.sync(r);for(var l=0;l<i.length;l++)t=this.enterInner(i[l],null,t,!1);return t}},{key:"insertNode",value:function(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){var i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}var r=this.findPlace(e,t,n);if(r){this.closeExtra();var o=this.top;o.match&&(o.match=o.match.matchType(e.type));var a,s=fu.none,c=m(r.concat(e.marks));try{for(c.s();!(a=c.n()).done;){var l=a.value;(o.type?o.type.allowsMarkType(l.type):ud(l.type,e.type))&&(s=l.addToSet(s))}}catch(u){c.e(u)}finally{c.f()}return o.content.push(e.mark(s)),!0}return!1}},{key:"enter",value:function(e,t,n,i){var r=this.findPlace(e.create(t),n,!1);return r&&(r=this.enterInner(e,t,n,!0,i)),r}},{key:"enterInner",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0;this.closeExtra();var o=this.top;o.match=o.match&&o.match.matchType(e);var a=od(e,r,o.options);4&o.options&&0==o.content.length&&(a|=4);var s=fu.none;return n=n.filter(function(t){return!(o.type?o.type.allowsMarkType(t.type):ud(t.type,e))||(s=t.addToSet(s),!1)}),this.nodes.push(new ad(e,t,s,i,null,a)),this.open++,n}},{key:"closeExtra",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],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}}},{key:"finish",value:function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}},{key:"sync",value:function(e){for(var t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}},{key:"currentPos",get:function(){this.closeExtra();for(var e=0,t=this.open;t>=0;t--){for(var n=this.nodes[t].content,i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}},{key:"findAtPoint",value:function(e,t){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}},{key:"findInside",value:function(e){if(this.find)for(var t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}},{key:"findAround",value:function(e,t,n){if(e!=t&&this.find)for(var i=0;i<this.find.length;i++){if(null==this.find[i].pos&&1==e.nodeType&&e.contains(this.find[i].node))t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}}},{key:"findInText",value:function(e){if(this.find)for(var 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))}},{key:"matchesContext",value:function(e){var t=this;if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);var n=e.split("/"),i=this.options.context,r=!(this.isOpen||i&&i.parent.type!=this.nodes[0].type),o=-(i?i.depth+1:0)+(r?0:1),a=function(e,s){for(;e>=0;e--){var c=n[e];if(""==c){if(e==n.length-1||0==e)continue;for(;s>=o;s--)if(a(e-1,s))return!0;return!1}var l=s>0||0==s&&r?t.nodes[s].type:i&&s>=o?i.node(s-o).type:null;if(!l||l.name!=c&&!l.isInGroup(c))return!1;s--}return!0};return a(n.length-1,this.open)}},{key:"textblockFromContext",value:function(){var e=this.options.context;if(e)for(var t=e.depth;t>=0;t--){var n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var i in this.parser.schema.nodes){var r=this.parser.schema.nodes[i];if(r.isTextblock&&r.defaultAttrs)return r}}}])}();function cd(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ld(e){var t={};for(var n in e)t[n]=e[n];return t}function ud(e,t){var n,i=t.schema.nodes,r=function(){var n=i[o];if(!n.allowsMarkType(e))return 0;var r=[],a=function(e){r.push(e);for(var n=0;n<e.edgeCount;n++){var i=e.edge(n),o=i.type,s=i.next;if(o==t)return!0;if(r.indexOf(s)<0&&a(s))return!0}};return a(n.contentMatch)?{v:!0}:void 0};for(var o in i)if(0!==(n=r())&&n)return n.v}var dd=function(){function e(t,n){C(this,e),this.nodes=t,this.marks=n}return x(e,[{key:"serializeFragment",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;i||(i=fd(n).createDocumentFragment());var r=i,o=[];return e.forEach(function(e){if(o.length||e.marks.length){for(var i=0,a=0;i<o.length&&a<e.marks.length;){var s=e.marks[a];if(t.marks[s.type.name]){if(!s.eq(o[i][0])||!1===s.type.spec.spanning)break;i++,a++}else a++}for(;i<o.length;)r=o.pop()[1];for(;a<e.marks.length;){var c=e.marks[a++],l=t.serializeMark(c,e.isInline,n);l&&(o.push([c,r]),r.appendChild(l.dom),r=l.contentDOM||l.dom)}}r.appendChild(t.serializeNodeInner(e,n))}),i}},{key:"serializeNodeInner",value:function(e,t){var n=md(fd(t),this.nodes[e.type.name](e),null,e.attrs),i=n.dom,r=n.contentDOM;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}},{key:"serializeNode",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.serializeNodeInner(e,t),i=e.marks.length-1;i>=0;i--){var r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}},{key:"serializeMark",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.marks[e.type.name];return i&&md(fd(n),i(e,t),null,e.attrs)}}],[{key:"renderSpec",value:function(e,t){return md(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,arguments.length>3?arguments[3]:void 0)}},{key:"fromSchema",value:function(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}},{key:"nodesFromSchema",value:function(e){var t=hd(e.nodes);return t.text||(t.text=function(e){return e.text}),t}},{key:"marksFromSchema",value:function(e){return hd(e.marks)}}])}();function hd(e){var t={};for(var n in e){var i=e[n].spec.toDOM;i&&(t[n]=i)}return t}function fd(e){return e.document||window.document}var pd=new WeakMap;function vd(e){var t=pd.get(e);return void 0===t&&pd.set(e,t=function(e){var t=null;function n(e){if(e&&"object"==_(e))if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(var i=0;i<e.length;i++)n(e[i]);else for(var r in e)n(e[r])}return n(e),t}(e)),t}function md(e,t,n,i){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;var r,o=t[0];if("string"!=typeof o)throw new RangeError("Invalid array passed to renderSpec");if(i&&(r=vd(i))&&r.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");var a,s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));var c=n?e.createElementNS(n,o):e.createElement(o),l=t[1],u=1;if(l&&"object"==_(l)&&null==l.nodeType&&!Array.isArray(l))for(var d in u=2,l)if(null!=l[d]){var h=d.indexOf(" ");h>0?c.setAttributeNS(d.slice(0,h),d.slice(h+1),l[d]):"style"==d&&c.style?c.style.cssText=l[d]:c.setAttribute(d,l[d])}for(var f=u;f<t.length;f++){var p=t[f];if(0===p){if(f<t.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}var v=md(e,p,n,i),m=v.dom,g=v.contentDOM;if(c.appendChild(m),g){if(a)throw new RangeError("Multiple content holes");a=g}}return{dom:c,contentDOM:a}}var gd=Math.pow(2,16);function yd(e,t){return e+t*gd}function kd(e){return 65535&e}var wd=function(){return x(function e(t,n,i){C(this,e),this.pos=t,this.delInfo=n,this.recover=i},[{key:"deleted",get:function(){return(8&this.delInfo)>0}},{key:"deletedBefore",get:function(){return(5&this.delInfo)>0}},{key:"deletedAfter",get:function(){return(6&this.delInfo)>0}},{key:"deletedAcross",get:function(){return(4&this.delInfo)>0}}])}(),bd=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(C(this,e),this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}return x(e,[{key:"recover",value:function(e){var t=0,n=kd(e);if(!this.inverted)for(var i=0;i<n;i++)t+=this.ranges[3*i+2]-this.ranges[3*i+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/gd}(e)}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!0)}},{key:"_map",value:function(e,t,n){for(var i=0,r=this.inverted?2:1,o=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var s=this.ranges[a]-(this.inverted?i:0);if(s>e)break;var c=this.ranges[a+r],l=this.ranges[a+o],u=s+c;if(e<=u){var d=s+i+((c?e==s?-1:e==u?1:t:t)<0?0:l);if(n)return d;var h=e==(t<0?s:u)?null:yd(a/3,e-s),f=e==s?2:e==u?1:4;return(t<0?e!=s:e!=u)&&(f|=8),new wd(d,f,h)}i+=l-c}return n?e+i:new wd(e+i,0,null)}},{key:"touches",value:function(e,t){for(var n=0,i=kd(t),r=this.inverted?2:1,o=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var s=this.ranges[a]-(this.inverted?n:0);if(s>e)break;var c=this.ranges[a+r];if(e<=s+c&&a==3*i)return!0;n+=this.ranges[a+o]-c}return!1}},{key:"forEach",value:function(e){for(var t=this.inverted?2:1,n=this.inverted?1:2,i=0,r=0;i<this.ranges.length;i+=3){var o=this.ranges[i],a=o-(this.inverted?r:0),s=o+(this.inverted?0:r),c=this.ranges[i+t],l=this.ranges[i+n];e(a,a+c,s,s+l),r+=l-c}}},{key:"invert",value:function(){return new e(this.ranges,!this.inverted)}},{key:"toString",value:function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}}],[{key:"offset",value:function(t){return 0==t?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}}])}();bd.empty=new bd([]);var Cd=function(){function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t?t.length:0;C(this,e),this.mirror=n,this.from=i,this.to=r,this._maps=t||[],this.ownData=!(t||n)}return x(e,[{key:"maps",get:function(){return this._maps}},{key:"slice",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.maps.length;return new e(this._maps,this.mirror,t,n)}},{key:"appendMap",value:function(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),null!=t&&this.setMirror(this._maps.length-1,t)}},{key:"appendMapping",value:function(e){for(var t=0,n=this._maps.length;t<e._maps.length;t++){var i=e.getMirror(t);this.appendMap(e._maps[t],null!=i&&i<t?n+i:void 0)}}},{key:"getMirror",value:function(e){if(this.mirror)for(var t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}},{key:"setMirror",value:function(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}},{key:"appendMappingInverted",value:function(e){for(var t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){var i=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=i&&i>t?n-i-1:void 0)}}},{key:"invert",value:function(){var t=new e;return t.appendMappingInverted(this),t}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.mirror)return this._map(e,t,!0);for(var n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"_map",value:function(e,t,n){for(var i=0,r=this.from;r<this.to;r++){var o=this._maps[r].mapResult(e,t);if(null!=o.recover){var a=this.getMirror(r);if(null!=a&&a>r&&a<this.to){r=a,e=this._maps[a].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return n?e:new wd(e,i,null)}}])}(),Sd=Object.create(null),xd=function(){return x(function e(){C(this,e)},[{key:"getMap",value:function(){return bd.empty}},{key:"merge",value:function(e){return null}}],[{key:"fromJSON",value:function(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=Sd[t.stepType];if(!n)throw new RangeError("No step type ".concat(t.stepType," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in Sd)throw new RangeError("Duplicate use of step JSON ID "+e);return Sd[e]=t,t.prototype.jsonID=e,t}}])}(),Td=function(){function e(t,n){C(this,e),this.doc=t,this.failed=n}return x(e,null,[{key:"ok",value:function(t){return new e(t,null)}},{key:"fail",value:function(t){return new e(null,t)}},{key:"fromReplace",value:function(t,n,i,r){try{return e.ok(t.replace(n,i,r))}catch(vs){if(vs instanceof pu)return e.fail(vs.message);throw vs}}}])}();function Md(e,t,n){for(var i=[],r=0;r<e.childCount;r++){var o=e.child(r);o.content.size&&(o=o.copy(Md(o.content,t,o))),o.isInline&&(o=t(o,n,r)),i.push(o)}return lu.fromArray(i)}var _d=function(e){function t(e,i,r){var o;return C(this,t),(o=n(this,t)).from=e,o.to=i,o.mark=r,o}return i(t,e),x(t,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),i=e.resolve(this.from),r=i.node(i.sharedDepth(this.to)),o=new vu(Md(n.content,function(e,n){return e.isAtom&&n.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e},r),n.openStart,n.openEnd);return Td.fromReplace(e,this.from,this.to,o)}},{key:"invert",value:function(){return new Nd(this.from,this.to,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new t(n.pos,i.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}},{key:"toJSON",value:function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}}])}(xd);xd.jsonID("addMark",_d);var Nd=function(e){function t(e,i,r){var o;return C(this,t),(o=n(this,t)).from=e,o.to=i,o.mark=r,o}return i(t,e),x(t,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),i=new vu(Md(n.content,function(e){return e.mark(t.mark.removeFromSet(e.marks))},e),n.openStart,n.openEnd);return Td.fromReplace(e,this.from,this.to,i)}},{key:"invert",value:function(){return new _d(this.from,this.to,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new t(n.pos,i.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}},{key:"toJSON",value:function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}}])}(xd);xd.jsonID("removeMark",Nd);var Od=function(e){function t(e,i){var r;return C(this,t),(r=n(this,t)).pos=e,r.mark=i,r}return i(t,e),x(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return Td.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Td.fromReplace(e,this.pos,this.pos+1,new vu(lu.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var n=e.nodeAt(this.pos);if(n){var i=this.mark.addToSet(n.marks);if(i.length==n.marks.length){for(var r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(i))return new t(this.pos,n.marks[r]);return new t(this.pos,this.mark)}}return new Ed(this.pos,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}}])}(xd);xd.jsonID("addNodeMark",Od);var Ed=function(e){function t(e,i){var r;return C(this,t),(r=n(this,t)).pos=e,r.mark=i,r}return i(t,e),x(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return Td.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Td.fromReplace(e,this.pos,this.pos+1,new vu(lu.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new Od(this.pos,this.mark):this}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}}])}(xd);xd.jsonID("removeNodeMark",Ed);var Ad=function(e){function t(e,i,r){var o,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return C(this,t),(o=n(this,t)).from=e,o.to=i,o.slice=r,o.structure=a,o}return i(t,e),x(t,[{key:"apply",value:function(e){return this.structure&&Id(e,this.from,this.to)?Td.fail("Structure replace would overwrite content"):Td.fromReplace(e,this.from,this.to,this.slice)}},{key:"getMap",value:function(){return new bd([this.from,this.to-this.from,this.slice.size])}},{key:"invert",value:function(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deletedAcross&&i.deletedAcross?null:new t(n.pos,Math.max(n.pos,i.pos),this.slice,this.structure)}},{key:"merge",value:function(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;var n=this.slice.size+e.slice.size==0?vu.empty:new vu(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}var i=this.slice.size+e.slice.size==0?vu.empty:new vu(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),i,this.structure)}},{key:"toJSON",value:function(){var e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,vu.fromJSON(e,n.slice),!!n.structure)}}])}(xd);xd.jsonID("replace",Ad);var Dd=function(e){function t(e,i,r,o,a,s){var c,l=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return C(this,t),(c=n(this,t)).from=e,c.to=i,c.gapFrom=r,c.gapTo=o,c.slice=a,c.insert=s,c.structure=l,c}return i(t,e),x(t,[{key:"apply",value:function(e){if(this.structure&&(Id(e,this.from,this.gapFrom)||Id(e,this.gapTo,this.to)))return Td.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Td.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,t.content);return n?Td.fromReplace(e,this.from,this.to,n):Td.fail("Content does not fit in gap")}},{key:"getMap",value:function(){return new bd([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}},{key:"invert",value:function(e){var n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1),r=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return n.deletedAcross&&i.deletedAcross||r<n.pos||o>i.pos?null:new t(n.pos,i.pos,r,o,this.slice,this.insert,this.structure)}},{key:"toJSON",value:function(){var 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}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,vu.fromJSON(e,n.slice),n.insert,!!n.structure)}}])}(xd);function Id(e,t,n){for(var i=e.resolve(t),r=n-t,o=i.depth;r>0&&o>0&&i.indexAfter(o)==i.node(o).childCount;)o--,r--;if(r>0)for(var a=i.node(o).maybeChild(i.indexAfter(o));r>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,r--}return!1}function Ld(e,t,n){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n.contentMatch,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=e.doc.nodeAt(t),a=[],s=t+1,c=0;c<o.childCount;c++){var l=o.child(c),u=s+l.nodeSize,d=i.matchType(l.type);if(d){i=d;for(var h=0;h<l.marks.length;h++)n.allowsMarkType(l.marks[h].type)||e.step(new Nd(s,u,l.marks[h]));if(r&&l.isText&&"pre"!=n.whitespace)for(var f=void 0,p=/\r?\n|\r/g,v=void 0;f=p.exec(l.text);)v||(v=new vu(lu.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),a.push(new Ad(s+f.index,s+f.index+f[0].length,v))}else a.push(new Ad(s,u,vu.empty));s=u}if(!i.validEnd){var m=i.fillBefore(lu.empty,!0);e.replace(s,s,new vu(m,0,0))}for(var g=a.length-1;g>=0;g--)e.step(a[g])}function Rd(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function zd(e){for(var t=e.parent.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth,i=0,r=0;;--n){var o=e.$from.node(n),a=e.$from.index(n)+i,s=e.$to.indexAfter(n)-r;if(n<e.depth&&o.canReplace(a,s,t))return n;if(0==n||o.type.spec.isolating||!Rd(o,a,s))break;a&&(i=1),s<o.childCount&&(r=1)}return null}function Pd(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e,r=function(e,t){var n=e.parent,i=e.startIndex,r=e.endIndex,o=n.contentMatchAt(i).findWrapping(t);if(!o)return null;var a=o.length?o[0]:t;return n.canReplaceWith(i,r,a)?o:null}(e,t),o=r&&function(e,t){var n=e.parent,i=e.startIndex,r=e.endIndex,o=n.child(i),a=t.contentMatch.findWrapping(o.type);if(!a)return null;for(var s=(a.length?a[a.length-1]:t).contentMatch,c=i;s&&c<r;c++)s=s.matchType(n.child(c).type);return s&&s.validEnd?a:null}(i,t);return o?r.map(Bd).concat({type:t,attrs:n}).concat(o.map(Bd)):null}function Bd(e){return{type:e,attrs:null}}function Fd(e,t,n,i){t.forEach(function(r,o){if(r.isText)for(var a,s=/\r?\n|\r/g;a=s.exec(r.text);){var c=e.mapping.slice(i).map(n+1+o+a.index);e.replaceWith(c,c+1,t.type.schema.linebreakReplacement.create())}})}function Hd(e,t,n,i){t.forEach(function(r,o){if(r.type==r.type.schema.linebreakReplacement){var a=e.mapping.slice(i).map(n+1+o);e.replaceWith(a,a+1,t.type.schema.text("\n"))}})}function jd(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3?arguments[3]:void 0,r=e.resolve(t),o=r.depth-n,a=i&&i[i.length-1]||r.parent;if(o<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!a.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(var s=r.depth-1,c=n-2;s>o;s--,c--){var l=r.node(s),u=r.index(s);if(l.type.spec.isolating)return!1;var d=l.content.cutByIndex(u,l.childCount),h=i&&i[c+1];h&&(d=d.replaceChild(0,h.type.create(h.attrs)));var f=i&&i[c]||l;if(!l.canReplace(u+1,l.childCount)||!f.type.validContent(d))return!1}var p=r.indexAfter(o),v=i&&i[0];return r.node(o).canReplaceWith(p,p,v?v.type:r.node(o+1).type)}function Vd(e,t){var n=e.resolve(t),i=n.index();return Wd(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(i,i+1)}function Wd(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);for(var n=e.contentMatchAt(e.childCount),i=e.type.schema.linebreakReplacement,r=0;r<t.childCount;r++){var o=t.child(r),a=o.type==i?e.type.schema.nodes.text:o.type;if(!(n=n.matchType(a)))return!1;if(!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(e,t))}function $d(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=e.resolve(t),r=i.depth;;r--){var o=void 0,a=void 0,s=i.index(r);if(r==i.depth?(o=i.nodeBefore,a=i.nodeAfter):n>0?(o=i.node(r+1),s++,a=i.node(r).maybeChild(s)):(o=i.node(r).maybeChild(s-1),a=i.node(r+1)),o&&!o.isTextblock&&Wd(o,a)&&i.node(r).canReplace(s,s+1))return t;if(0==r)break;t=n<0?i.before(r):i.after(r)}}function Ud(e,t,n){var i=e.resolve(t);if(!n.content.size)return t;for(var r=n.content,o=0;o<n.openStart;o++)r=r.firstChild.content;for(var a=1;a<=(0==n.openStart&&n.size?2:1);a++)for(var s=i.depth;s>=0;s--){var c=s==i.depth?0:i.pos<=(i.start(s+1)+i.end(s+1))/2?-1:1,l=i.index(s)+(c>0?1:0),u=i.node(s),d=!1;if(1==a)d=u.canReplace(l,l,r);else{var h=u.contentMatchAt(l).findWrapping(r.firstChild.type);d=h&&u.canReplaceWith(l,l,h[0])}if(d)return 0==c?i.pos:c<0?i.before(s+1):i.after(s+1)}return null}function qd(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:vu.empty;if(t==n&&!i.size)return null;var r=e.resolve(t),o=e.resolve(n);return Kd(r,o,i)?new Ad(t,n,i):new Jd(r,o,i).fit()}function Kd(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}xd.jsonID("replaceAround",Dd);var Jd=function(){return x(function e(t,n,i){C(this,e),this.$from=t,this.$to=n,this.unplaced=i,this.frontier=[],this.placed=lu.empty;for(var r=0;r<=t.depth;r++){var o=t.node(r);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(r))})}for(var a=t.depth;a>0;a--)this.placed=lu.from(t.node(a).copy(this.placed))},[{key:"depth",get:function(){return this.frontier.length-1}},{key:"fit",value:function(){for(;this.unplaced.size;){var e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}var t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,i=this.$from,r=this.close(t<0?this.$to:i.doc.resolve(t));if(!r)return null;for(var o=this.placed,a=i.depth,s=r.depth;a&&s&&1==o.childCount;)o=o.firstChild.content,a--,s--;var c=new vu(o,a,s);return t>-1?new Dd(i.pos,t,this.$to.pos,this.$to.end(),c,n):c.size||i.pos!=this.$to.pos?new Ad(i.pos,r.pos,c):null}},{key:"findFittable",value:function(){for(var e=this.unplaced.openStart,t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){var r=t.firstChild;if(t.childCount>1&&(i=0),r.type.spec.isolating&&i<=n){e=n;break}t=r.content}for(var o=1;o<=2;o++)for(var a=1==o?e:this.unplaced.openStart;a>=0;a--)for(var s=null,c=(a?(s=Xd(this.unplaced.content,a-1).firstChild).content:this.unplaced.content).firstChild,l=this.depth;l>=0;l--){var u=this.frontier[l],d=u.type,h=u.match,f=void 0,p=null;if(1==o&&(c?h.matchType(c.type)||(p=h.fillBefore(lu.from(c),!1)):s&&d.compatibleContent(s.type)))return{sliceDepth:a,frontierDepth:l,parent:s,inject:p};if(2==o&&c&&(f=h.findWrapping(c.type)))return{sliceDepth:a,frontierDepth:l,parent:s,wrap:f};if(s&&h.matchType(s.type))break}}},{key:"openMore",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,i=e.openEnd,r=Xd(t,n);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new vu(t,n+1,Math.max(i,r.size+n>=t.size-i?n+1:0)),!0)}},{key:"dropNode",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,i=e.openEnd,r=Xd(t,n);if(r.childCount<=1&&n>0){var o=t.size-n<=n+r.size;this.unplaced=new vu(Gd(t,n-1,1),n-1,o?n-1:i)}else this.unplaced=new vu(Gd(t,n,1),n,i)}},{key:"placeNodes",value:function(e){for(var t=e.sliceDepth,n=e.frontierDepth,i=e.parent,r=e.inject,o=e.wrap;this.depth>n;)this.closeFrontierNode();if(o)for(var a=0;a<o.length;a++)this.openFrontierNode(o[a]);var s=this.unplaced,c=i?i.content:s.content,l=s.openStart-t,u=0,d=[],h=this.frontier[n],f=h.match,p=h.type;if(r){for(var v=0;v<r.childCount;v++)d.push(r.child(v));f=f.matchFragment(r)}for(var m=c.size+t-(s.content.size-s.openEnd);u<c.childCount;){var g=c.child(u),y=f.matchType(g.type);if(!y)break;(++u>1||0==l||g.content.size)&&(f=y,d.push(Qd(g.mark(p.allowedMarks(g.marks)),1==u?l:0,u==c.childCount?m:-1)))}var k=u==c.childCount;k||(m=-1),this.placed=Yd(this.placed,n,lu.from(d)),this.frontier[n].match=f,k&&m<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var w=0,b=c;w<m;w++){var C=b.lastChild;this.frontier.push({type:C.type,match:C.contentMatchAt(C.childCount)}),b=C.content}this.unplaced=k?0==t?vu.empty:new vu(Gd(s.content,t-1,1),t-1,m<0?s.openEnd:t-1):new vu(Gd(s.content,t,u),s.openStart,s.openEnd)}},{key:"mustMoveInline",value:function(){if(!this.$to.parent.isTextblock)return-1;var e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Zd(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;for(var n=this.$to.depth,i=this.$to.after(n);n>1&&i==this.$to.end(--n);)++i;return i}},{key:"findCloseLevel",value:function(e){e:for(var t=Math.min(this.depth,e.depth);t>=0;t--){var n=this.frontier[t],i=n.match,r=n.type,o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Zd(e,t,r,i,o);if(a){for(var s=t-1;s>=0;s--){var c=this.frontier[s],l=c.match,u=Zd(e,s,c.type,l,!0);if(!u||u.childCount)continue e}return{depth:t,fit:a,move:o?e.doc.resolve(e.after(t+1)):e}}}}},{key:"close",value:function(e){var t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Yd(this.placed,t.depth,t.fit)),e=t.move;for(var n=t.depth+1;n<=e.depth;n++){var i=e.node(n),r=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,r)}return e}},{key:"openFrontierNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Yd(this.placed,this.depth,lu.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}},{key:"closeFrontierNode",value:function(){var e=this.frontier.pop().match.fillBefore(lu.empty,!0);e.childCount&&(this.placed=Yd(this.placed,this.frontier.length,e))}}])}();function Gd(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Gd(e.firstChild.content,t-1,n)))}function Yd(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Yd(e.lastChild.content,t-1,n)))}function Xd(e,t){for(var n=0;n<t;n++)e=e.firstChild.content;return e}function Qd(e,t,n){if(t<=0)return e;var i=e.content;return t>1&&(i=i.replaceChild(0,Qd(i.firstChild,t-1,1==i.childCount?n-1:0))),t>0&&(i=e.type.contentMatch.fillBefore(i).append(i),n<=0&&(i=i.append(e.type.contentMatch.matchFragment(i).fillBefore(lu.empty,!0)))),e.copy(i)}function Zd(e,t,n,i,r){var o=e.node(t),a=r?e.indexAfter(t):e.index(t);if(a==o.childCount&&!n.compatibleContent(o.type))return null;var s=i.fillBefore(o.content,!0,a);return s&&!function(e,t,n){for(var i=n;i<t.childCount;i++)if(!e.allowsMarks(t.child(i).marks))return!0;return!1}(n,o.content,a)?s:null}function eh(e){return e.spec.defining||e.spec.definingForContent}function th(e,t,n,i,r){if(t<n){var o=e.firstChild;e=e.replaceChild(0,o.copy(th(o.content,t+1,n,i,o)))}if(t>i){var a=r.contentMatchAt(0),s=a.fillBefore(e).append(e);e=s.append(a.matchFragment(s).fillBefore(lu.empty,!0))}return e}function nh(e,t){for(var n=[],i=Math.min(e.depth,t.depth);i>=0;i--){var r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var ih=function(e){function t(e,i,r){var o;return C(this,t),(o=n(this,t)).pos=e,o.attr=i,o.value=r,o}return i(t,e),x(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return Td.fail("No node at attribute step's position");var n=Object.create(null);for(var i in t.attrs)n[i]=t.attrs[i];n[this.attr]=this.value;var r=t.type.create(n,null,t.marks);return Td.fromReplace(e,this.pos,this.pos+1,new vu(lu.from(r),0,t.isLeaf?0:1))}},{key:"getMap",value:function(){return bd.empty}},{key:"invert",value:function(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}},{key:"toJSON",value:function(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos||"string"!=typeof n.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}}])}(xd);xd.jsonID("attr",ih);var rh=function(e){function t(e,i){var r;return C(this,t),(r=n(this,t)).attr=e,r.value=i,r}return i(t,e),x(t,[{key:"apply",value:function(e){var t=Object.create(null);for(var n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;var i=e.type.create(t,e.content,e.marks);return Td.ok(i)}},{key:"getMap",value:function(){return bd.empty}},{key:"invert",value:function(e){return new t(this.attr,e.attrs[this.attr])}},{key:"map",value:function(e){return this}},{key:"toJSON",value:function(){return{stepType:"docAttr",attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(e,n){if("string"!=typeof n.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}}])}(xd);xd.jsonID("docAttr",rh);var oh=Error;((oh=function e(t){var n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype)).constructor=oh,oh.prototype.name="TransformError";var ah=function(){return x(function e(t){C(this,e),this.doc=t,this.steps=[],this.docs=[],this.mapping=new Cd},[{key:"before",get:function(){return this.docs.length?this.docs[0]:this.doc}},{key:"step",value:function(e){var t=this.maybeStep(e);if(t.failed)throw new oh(t.failed);return this}},{key:"maybeStep",value:function(e){var t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}},{key:"docChanged",get:function(){return this.steps.length>0}},{key:"addStep",value:function(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}},{key:"replace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:vu.empty,i=qd(this.doc,e,t,n);return i&&this.step(i),this}},{key:"replaceWith",value:function(e,t,n){return this.replace(e,t,new vu(lu.from(n),0,0))}},{key:"delete",value:function(e,t){return this.replace(e,t,vu.empty)}},{key:"insert",value:function(e,t){return this.replaceWith(e,e,t)}},{key:"replaceRange",value:function(e,t,n){return function(e,t,n,i){if(!i.size)return e.deleteRange(t,n);var r=e.doc.resolve(t),o=e.doc.resolve(n);if(Kd(r,o,i))return e.step(new Ad(t,n,i));var a=nh(r,o);0==a[a.length-1]&&a.pop();var s=-(r.depth+1);a.unshift(s);for(var c=r.depth,l=r.pos-1;c>0;c--,l--){var u=r.node(c).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;a.indexOf(c)>-1?s=c:r.before(c)==l&&a.splice(1,0,-c)}for(var d=a.indexOf(s),h=[],f=i.openStart,p=i.content,v=0;;v++){var m=p.firstChild;if(h.push(m),v==i.openStart)break;p=m.content}for(var g=f-1;g>=0;g--){var y=h[g],k=eh(y.type);if(k&&!y.sameMarkup(r.node(Math.abs(s)-1)))f=g;else if(k||!y.type.isTextblock)break}for(var w=i.openStart;w>=0;w--){var b=(w+f+1)%(i.openStart+1),C=h[b];if(C)for(var S=0;S<a.length;S++){var x=a[(S+d)%a.length],T=!0;x<0&&(T=!1,x=-x);var M=r.node(x-1),_=r.index(x-1);if(M.canReplaceWith(_,_,C.type,C.marks))return e.replace(r.before(x),T?o.after(x):n,new vu(th(i.content,0,i.openStart,b),b,i.openEnd))}}for(var N=e.steps.length,O=a.length-1;O>=0&&(e.replace(t,n,i),!(e.steps.length>N));O--){var E=a[O];E<0||(t=r.before(E),n=o.after(E))}}(this,e,t,n),this}},{key:"replaceRangeWith",value:function(e,t,n){return function(e,t,n,i){if(!i.isInline&&t==n&&e.doc.resolve(t).parent.content.size){var r=function(e,t,n){var i=e.resolve(t);if(i.parent.canReplaceWith(i.index(),i.index(),n))return t;if(0==i.parentOffset)for(var r=i.depth-1;r>=0;r--){var o=i.index(r);if(i.node(r).canReplaceWith(o,o,n))return i.before(r+1);if(o>0)return null}if(i.parentOffset==i.parent.content.size)for(var a=i.depth-1;a>=0;a--){var s=i.indexAfter(a);if(i.node(a).canReplaceWith(s,s,n))return i.after(a+1);if(s<i.node(a).childCount)return null}return null}(e.doc,t,i.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new vu(lu.from(i),0,0))}(this,e,t,n),this}},{key:"deleteRange",value:function(e,t){return function(e,t,n){for(var i=e.doc.resolve(t),r=e.doc.resolve(n),o=nh(i,r),a=0;a<o.length;a++){var s=o[a],c=a==o.length-1;if(c&&0==s||i.node(s).type.contentMatch.validEnd)return e.delete(i.start(s),r.end(s));if(s>0&&(c||i.node(s-1).canReplace(i.index(s-1),r.indexAfter(s-1))))return e.delete(i.before(s),r.after(s))}for(var l=1;l<=i.depth&&l<=r.depth;l++)if(t-i.start(l)==i.depth-l&&n>i.end(l)&&r.end(l)-n!=r.depth-l&&i.start(l-1)==r.start(l-1)&&i.node(l-1).canReplace(i.index(l-1),r.index(l-1)))return e.delete(i.before(l),n);e.delete(t,n)}(this,e,t),this}},{key:"lift",value:function(e,t){return function(e,t,n){for(var i=t.$from,r=t.$to,o=t.depth,a=i.before(o+1),s=r.after(o+1),c=a,l=s,u=lu.empty,d=0,h=o,f=!1;h>n;h--)f||i.index(h)>0?(f=!0,u=lu.from(i.node(h).copy(u)),d++):c--;for(var p=lu.empty,v=0,m=o,g=!1;m>n;m--)g||r.after(m+1)<r.end(m)?(g=!0,p=lu.from(r.node(m).copy(p)),v++):l++;e.step(new Dd(c,l,a,s,new vu(u.append(p),d,v),u.size-d,!0))}(this,e,t),this}},{key:"join",value:function(e){return function(e,t,n){var i=null,r=e.doc.type.schema.linebreakReplacement,o=e.doc.resolve(t-n),a=o.node().type;if(r&&a.inlineContent){var s="pre"==a.whitespace,c=!!a.contentMatch.matchType(r);s&&!c?i=!1:!s&&c&&(i=!0)}var l=e.steps.length;if(!1===i){var u=e.doc.resolve(t+n);Hd(e,u.node(),u.before(),l)}a.inlineContent&&Ld(e,t+n-1,a,o.node().contentMatchAt(o.index()),null==i);var d=e.mapping.slice(l),h=d.map(t-n);if(e.step(new Ad(h,d.map(t+n,-1),vu.empty,!0)),!0===i){var f=e.doc.resolve(h);Fd(e,f.node(),f.before(),e.steps.length)}}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1),this}},{key:"wrap",value:function(e,t){return function(e,t,n){for(var i=lu.empty,r=n.length-1;r>=0;r--){if(i.size){var o=n[r].type.contentMatch.matchFragment(i);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=lu.from(n[r].type.create(n[r].attrs,i))}var a=t.start,s=t.end;e.step(new Dd(a,s,a,s,new vu(i,0,0),n.length,!0))}(this,e,t),this}},{key:"setBlockType",value:function(e){return function(e,t,n,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var o=e.steps.length;e.doc.nodesBetween(t,n,function(t,n){var a="function"==typeof r?r(t):r;if(t.isTextblock&&!t.hasMarkup(i,a)&&function(e,t,n){var i=e.resolve(t),r=i.index();return i.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(o).map(n),i)){var s=null;if(i.schema.linebreakReplacement){var c="pre"==i.whitespace,l=!!i.contentMatch.matchType(i.schema.linebreakReplacement);c&&!l?s=!1:!c&&l&&(s=!0)}!1===s&&Hd(e,t,n,o),Ld(e,e.mapping.slice(o).map(n,1),i,void 0,null===s);var u=e.mapping.slice(o),d=u.map(n,1),h=u.map(n+t.nodeSize,1);return e.step(new Dd(d,h,d+1,h-1,new vu(lu.from(i.create(a,null,t.marks)),0,0),1,!0)),!0===s&&Fd(e,t,n,o),!1}})}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,arguments.length>2?arguments[2]:void 0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null),this}},{key:"setNodeMarkup",value:function(e,t){return function(e,t,n,i,r){var o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);var a=n.create(i,null,r||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,a);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Dd(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new vu(lu.from(a),0,0),1,!0))}(this,e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,arguments.length>3?arguments[3]:void 0),this}},{key:"setNodeAttribute",value:function(e,t,n){return this.step(new ih(e,t,n)),this}},{key:"setDocAttribute",value:function(e,t){return this.step(new rh(e,t)),this}},{key:"addNodeMark",value:function(e,t){return this.step(new Od(e,t)),this}},{key:"removeNodeMark",value:function(e,t){var n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof fu)t.isInSet(n.marks)&&this.step(new Ed(e,t));else{for(var i,r=n.marks,o=[];i=t.isInSet(r);)o.push(new Ed(e,i)),r=i.removeFromSet(r);for(var a=o.length-1;a>=0;a--)this.step(o[a])}return this}},{key:"split",value:function(e){return function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3?arguments[3]:void 0,r=e.doc.resolve(t),o=lu.empty,a=lu.empty,s=r.depth,c=r.depth-n,l=n-1;s>c;s--,l--){o=lu.from(r.node(s).copy(o));var u=i&&i[l];a=lu.from(u?u.type.create(u.attrs,a):r.node(s).copy(a))}e.step(new Ad(t,t,new vu(o.append(a),n,n),!0))}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,arguments.length>2?arguments[2]:void 0),this}},{key:"addMark",value:function(e,t,n){return function(e,t,n,i){var r,o,a=[],s=[];e.doc.nodesBetween(t,n,function(e,c,l){if(e.isInline){var u=e.marks;if(!i.isInSet(u)&&l.type.allowsMarkType(i.type)){for(var d=Math.max(c,t),h=Math.min(c+e.nodeSize,n),f=i.addToSet(u),p=0;p<u.length;p++)u[p].isInSet(f)||(r&&r.to==d&&r.mark.eq(u[p])?r.to=h:a.push(r=new Nd(d,h,u[p])));o&&o.to==d?o.to=h:s.push(o=new _d(d,h,i))}}}),a.forEach(function(t){return e.step(t)}),s.forEach(function(t){return e.step(t)})}(this,e,t,n),this}},{key:"removeMark",value:function(e,t,n){return function(e,t,n,i){var r=[],o=0;e.doc.nodesBetween(t,n,function(e,a){if(e.isInline){o++;var s=null;if(i instanceof Qu)for(var c,l=e.marks;c=i.isInSet(l);)(s||(s=[])).push(c),l=c.removeFromSet(l);else i?i.isInSet(e.marks)&&(s=[i]):s=e.marks;if(s&&s.length)for(var u=Math.min(a+e.nodeSize,n),d=0;d<s.length;d++){for(var h=s[d],f=void 0,p=0;p<r.length;p++){var v=r[p];v.step==o-1&&h.eq(r[p].style)&&(f=v)}f?(f.to=u,f.step=o):r.push({style:h,from:Math.max(a,t),to:u,step:o})}}}),r.forEach(function(t){return e.step(new Nd(t.from,t.to,t.style))})}(this,e,t,n),this}},{key:"clearIncompatible",value:function(e,t,n){return Ld(this,e,t,n),this}}])}(),sh=Object.create(null),ch=function(){return x(function e(t,n,i){C(this,e),this.$anchor=t,this.$head=n,this.ranges=i||[new lh(t.min(n),t.max(n))]},[{key:"anchor",get:function(){return this.$anchor.pos}},{key:"head",get:function(){return this.$head.pos}},{key:"from",get:function(){return this.$from.pos}},{key:"to",get:function(){return this.$to.pos}},{key:"$from",get:function(){return this.ranges[0].$from}},{key:"$to",get:function(){return this.ranges[0].$to}},{key:"empty",get:function(){for(var e=this.ranges,t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}},{key:"content",value:function(){return this.$from.doc.slice(this.from,this.to,!0)}},{key:"replace",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vu.empty,n=t.content.lastChild,i=null,r=0;r<t.openEnd;r++)i=n,n=n.lastChild;for(var o=e.steps.length,a=this.ranges,s=0;s<a.length;s++){var c=a[s],l=c.$from,u=c.$to,d=e.mapping.slice(o);e.replaceRange(d.map(l.pos),d.map(u.pos),s?vu.empty:t),0==s&&kh(e,o,(n?n.isInline:i&&i.isTextblock)?-1:1)}}},{key:"replaceWith",value:function(e,t){for(var n=e.steps.length,i=this.ranges,r=0;r<i.length;r++){var o=i[r],a=o.$from,s=o.$to,c=e.mapping.slice(n),l=c.map(a.pos),u=c.map(s.pos);r?e.deleteRange(l,u):(e.replaceRangeWith(l,u,t),kh(e,n,t.isInline?-1:1))}}},{key:"getBookmark",value:function(){return hh.between(this.$anchor,this.$head).getBookmark()}}],[{key:"findFrom",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e.parent.inlineContent?new hh(e):yh(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(var r=e.depth-1;r>=0;r--){var o=t<0?yh(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):yh(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}},{key:"near",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.findFrom(e,t)||this.findFrom(e,-t)||new mh(e.node(0))}},{key:"atStart",value:function(e){return yh(e,e,0,0,1)||new mh(e)}},{key:"atEnd",value:function(e){return yh(e,e,e.content.size,e.childCount,-1)||new mh(e)}},{key:"fromJSON",value:function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=sh[t.type];if(!n)throw new RangeError("No selection type ".concat(t.type," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in sh)throw new RangeError("Duplicate use of selection JSON ID "+e);return sh[e]=t,t.prototype.jsonID=e,t}}])}();ch.prototype.visible=!0;var lh=x(function e(t,n){C(this,e),this.$from=t,this.$to=n}),uh=!1;function dh(e){uh||e.parent.inlineContent||(uh=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}var hh=function(t){function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return C(this,r),dh(e),dh(t),n(this,r,[e,t])}return i(r,t),x(r,[{key:"$cursor",get:function(){return this.$anchor.pos==this.$head.pos?this.$head:null}},{key:"map",value:function(e,t){var n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return ch.near(n);var i=e.resolve(t.map(this.anchor));return new r(i.parent.inlineContent?i:n,n)}},{key:"replace",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vu.empty;if(e(r,"replace",this,3)([t,n]),n==vu.empty){var i=this.$from.marksAcross(this.$to);i&&t.ensureMarks(i)}}},{key:"eq",value:function(e){return e instanceof r&&e.anchor==this.anchor&&e.head==this.head}},{key:"getBookmark",value:function(){return new fh(this.anchor,this.head)}},{key:"toJSON",value:function(){return{type:"text",anchor:this.anchor,head:this.head}}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new r(e.resolve(t.anchor),e.resolve(t.head))}},{key:"create",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}},{key:"between",value:function(e,t,n){var i=e.pos-t.pos;if(n&&!i||(n=i>=0?1:-1),!t.parent.inlineContent){var o=ch.findFrom(t,n,!0)||ch.findFrom(t,-n,!0);if(!o)return ch.near(t,n);t=o.$head}return e.parent.inlineContent||(0==i||(e=(ch.findFrom(e,-n,!0)||ch.findFrom(e,n,!0)).$anchor).pos<t.pos!=i<0)&&(e=t),new r(e,t)}}])}(ch);ch.jsonID("text",hh);var fh=function(){function e(t,n){C(this,e),this.anchor=t,this.head=n}return x(e,[{key:"map",value:function(t){return new e(t.map(this.anchor),t.map(this.head))}},{key:"resolve",value:function(e){return hh.between(e.resolve(this.anchor),e.resolve(this.head))}}])}(),ph=function(e){function t(e){var i;C(this,t);var r=e.nodeAfter,o=e.node(0).resolve(e.pos+r.nodeSize);return(i=n(this,t,[e,o])).node=r,i}return i(t,e),x(t,[{key:"map",value:function(e,n){var i=n.mapResult(this.anchor),r=i.deleted,o=i.pos,a=e.resolve(o);return r?ch.near(a):new t(a)}},{key:"content",value:function(){return new vu(lu.from(this.node),0,0)}},{key:"eq",value:function(e){return e instanceof t&&e.anchor==this.anchor}},{key:"toJSON",value:function(){return{type:"node",anchor:this.anchor}}},{key:"getBookmark",value:function(){return new vh(this.anchor)}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}},{key:"create",value:function(e,n){return new t(e.resolve(n))}},{key:"isSelectable",value:function(e){return!e.isText&&!1!==e.type.spec.selectable}}])}(ch);ph.prototype.visible=!1,ch.jsonID("node",ph);var vh=function(){function e(t){C(this,e),this.anchor=t}return x(e,[{key:"map",value:function(t){var n=t.mapResult(this.anchor),i=n.deleted,r=n.pos;return i?new fh(r,r):new e(r)}},{key:"resolve",value:function(e){var t=e.resolve(this.anchor),n=t.nodeAfter;return n&&ph.isSelectable(n)?new ph(t):ch.near(t)}}])}(),mh=function(t){function r(e){return C(this,r),n(this,r,[e.resolve(0),e.resolve(e.content.size)])}return i(r,t),x(r,[{key:"replace",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vu.empty;if(n==vu.empty){t.delete(0,t.doc.content.size);var i=ch.atStart(t.doc);i.eq(t.selection)||t.setSelection(i)}else e(r,"replace",this,3)([t,n])}},{key:"toJSON",value:function(){return{type:"all"}}},{key:"map",value:function(e){return new r(e)}},{key:"eq",value:function(e){return e instanceof r}},{key:"getBookmark",value:function(){return gh}}],[{key:"fromJSON",value:function(e){return new r(e)}}])}(ch);ch.jsonID("all",mh);var gh={map:function(){return this},resolve:function(e){return new mh(e)}};function yh(e,t,n,i,r){var o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(t.inlineContent)return hh.create(e,n);for(var a=i-(r>0?0:1);r>0?a<t.childCount:a>=0;a+=r){var s=t.child(a);if(s.isAtom){if(!o&&ph.isSelectable(s))return ph.create(e,n-(r<0?s.nodeSize:0))}else{var c=yh(e,s,n+r,r<0?s.childCount:0,r,o);if(c)return c}n+=s.nodeSize*r}return null}function kh(e,t,n){var i=e.steps.length-1;if(!(i<t)){var r,o=e.steps[i];if(o instanceof Ad||o instanceof Dd)e.mapping.maps[i].forEach(function(e,t,n,i){null==r&&(r=i)}),e.setSelection(ch.near(e.doc.resolve(r),n))}}var wh=function(t){function r(e){var t;return C(this,r),(t=n(this,r,[e.doc])).curSelectionFor=0,t.updated=0,t.meta=Object.create(null),t.time=Date.now(),t.curSelection=e.selection,t.storedMarks=e.storedMarks,t}return i(r,t),x(r,[{key:"selection",get:function(){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}},{key:"setSelection",value:function(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=-3&this.updated|1,this.storedMarks=null,this}},{key:"selectionSet",get:function(){return(1&this.updated)>0}},{key:"setStoredMarks",value:function(e){return this.storedMarks=e,this.updated|=2,this}},{key:"ensureMarks",value:function(e){return fu.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}},{key:"addStoredMark",value:function(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}},{key:"removeStoredMark",value:function(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}},{key:"storedMarksSet",get:function(){return(2&this.updated)>0}},{key:"addStep",value:function(t,n){e(r,"addStep",this,3)([t,n]),this.updated=-3&this.updated,this.storedMarks=null}},{key:"setTime",value:function(e){return this.time=e,this}},{key:"replaceSelection",value:function(e){return this.selection.replace(this,e),this}},{key:"replaceSelectionWith",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||fu.none))),n.replaceWith(this,e),this}},{key:"deleteSelection",value:function(){return this.selection.replace(this),this}},{key:"insertText",value:function(e,t,n){var i=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();if(null==n&&(n=t),!e)return this.deleteRange(t,n);var r=this.storedMarks;if(!r){var o=this.doc.resolve(t);r=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,r)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(ch.near(this.selection.$to)),this}},{key:"setMeta",value:function(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}},{key:"getMeta",value:function(e){return this.meta["string"==typeof e?e:e.key]}},{key:"isGeneric",get:function(){for(var e in this.meta)return!1;return!0}},{key:"scrollIntoView",value:function(){return this.updated|=4,this}},{key:"scrolledIntoView",get:function(){return(4&this.updated)>0}}])}(ah);function bh(e,t){return t&&e?e.bind(t):e}var Ch=x(function e(t,n,i){C(this,e),this.name=t,this.init=bh(n.init,i),this.apply=bh(n.apply,i)}),Sh=[new Ch("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new Ch("selection",{init:function(e,t){return e.selection||ch.atStart(t.doc)},apply:function(e){return e.selection}}),new Ch("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,n,i){return i.selection.$cursor?e.storedMarks:null}}),new Ch("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],xh=x(function e(t,n){var i=this;C(this,e),this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Sh.slice(),n&&n.forEach(function(e){if(i.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");i.plugins.push(e),i.pluginsByKey[e.key]=e,e.spec.state&&i.fields.push(new Ch(e.key,e.spec.state,e))})}),Th=function(){function e(t){C(this,e),this.config=t}return x(e,[{key:"schema",get:function(){return this.config.schema}},{key:"plugins",get:function(){return this.config.plugins}},{key:"apply",value:function(e){return this.applyTransaction(e).state}},{key:"filterTransaction",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=0;n<this.config.plugins.length;n++)if(n!=t){var i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}},{key:"applyTransaction",value:function(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};for(var t=[e],n=this.applyInner(e),i=null;;){for(var r=!1,o=0;o<this.config.plugins.length;o++){var a=this.config.plugins[o];if(a.spec.appendTransaction){var s=i?i[o].n:0,c=i?i[o].state:this,l=s<t.length&&a.spec.appendTransaction.call(a,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,o)){if(l.setMeta("appendedTransaction",e),!i){i=[];for(var u=0;u<this.config.plugins.length;u++)i.push(u<o?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),r=!0}i&&(i[o]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}},{key:"applyInner",value:function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var n=new e(this.config),i=this.config.fields,r=0;r<i.length;r++){var o=i[r];n[o.name]=o.apply(t,this[o.name],this,n)}return n}},{key:"tr",get:function(){return new wh(this)}},{key:"reconfigure",value:function(t){for(var n=new xh(this.schema,t.plugins),i=n.fields,r=new e(n),o=0;o<i.length;o++){var a=i[o].name;r[a]=this.hasOwnProperty(a)?this[a]:i[o].init(t,r)}return r}},{key:"toJSON",value:function(e){var t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(function(e){return e.toJSON()})),e&&"object"==_(e))for(var n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var i=e[n],r=i.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(i,this[i.key]))}return t}}],[{key:"create",value:function(t){for(var n=new xh(t.doc?t.doc.type.schema:t.schema,t.plugins),i=new e(n),r=0;r<n.fields.length;r++)i[n.fields[r].name]=n.fields[r].init(t,i);return i}},{key:"fromJSON",value:function(t,n,i){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var r=new xh(t.schema,t.plugins),o=new e(r);return r.fields.forEach(function(e){if("doc"==e.name)o.doc=Iu.fromJSON(t.schema,n.doc);else if("selection"==e.name)o.selection=ch.fromJSON(o.doc,n.selection);else if("storedMarks"==e.name)n.storedMarks&&(o.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(i)for(var r in i){var a=i[r],s=a.spec.state;if(a.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,r))return void(o[e.name]=s.fromJSON.call(a,t,n[r],o))}o[e.name]=e.init(t,o)}}),o}}])}();function Mh(e,t,n){for(var i in e){var r=e[i];r instanceof Function?r=r.bind(t):"handleDOMEvents"==i&&(r=Mh(r,t,{})),n[i]=r}return n}var _h=function(){return x(function e(t){C(this,e),this.spec=t,this.props={},t.props&&Mh(t.props,this,this.props),this.key=t.key?t.key.key:Oh("plugin")},[{key:"getState",value:function(e){return e[this.key]}}])}(),Nh=Object.create(null);function Oh(e){return e in Nh?e+"$"+ ++Nh[e]:(Nh[e]=0,e+"$")}var Eh=function(){return x(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"key";C(this,e),this.key=Oh(t)},[{key:"get",value:function(e){return e.config.pluginsByKey[this.key]}},{key:"getState",value:function(e){return e[this.key]}}])}();function Ah(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}function Dh(e,t,n){for(var i=t.nodeBefore,r=t.pos-1;!i.isTextblock;r--){if(i.type.spec.isolating)return!1;var o=i.lastChild;if(!o)return!1;i=o}for(var a=t.nodeAfter,s=t.pos+1;!a.isTextblock;s++){if(a.type.spec.isolating)return!1;var c=a.firstChild;if(!c)return!1;a=c}var l=qd(e.doc,r,s,vu.empty);if(!l||l.from!=r||l instanceof Ad&&l.slice.size>=s-r)return!1;if(n){var u=e.tr.step(l);u.setSelection(hh.create(u.doc,r)),n(u.scrollIntoView())}return!0}function Ih(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e;i;i="start"==t?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(n&&1!=i.childCount)return!1}return!1}function Lh(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Rh(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}function zh(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){var n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function Ph(e){for(var t=0;t<e.edgeCount;t++){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Bh(e,t,n,i){var r,o,a=t.nodeBefore,s=t.nodeAfter,c=a.type.spec.isolating||s.type.spec.isolating;if(!c&&function(e,t,n){var i=t.nodeBefore,r=t.nodeAfter,o=t.index();return!(!(i&&r&&i.type.compatibleContent(r.type))||(!i.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-i.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(o,o+1)||!r.isTextblock&&!Vd(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;var l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(r=(o=a.contentMatchAt(a.childCount)).findWrapping(s.type))&&o.matchType(r[0]||s.type).validEnd){if(n){for(var u=t.pos+s.nodeSize,d=lu.empty,h=r.length-1;h>=0;h--)d=lu.from(r[h].create(null,d));d=lu.from(a.copy(d));var f=e.tr.step(new Dd(t.pos-1,u,t.pos,u,new vu(d,1,0),r.length,!0)),p=f.doc.resolve(u+2*r.length);p.nodeAfter&&p.nodeAfter.type==a.type&&Vd(f.doc,p.pos)&&f.join(p.pos),n(f.scrollIntoView())}return!0}var v=s.type.spec.isolating||i>0&&c?null:ch.findFrom(t,1),m=v&&v.$from.blockRange(v.$to),g=m&&zd(m);if(null!=g&&g>=t.depth)return n&&n(e.tr.lift(m,g).scrollIntoView()),!0;if(l&&Ih(s,"start",!0)&&Ih(a,"end")){for(var y=a,k=[];k.push(y),!y.isTextblock;)y=y.lastChild;for(var w=s,b=1;!w.isTextblock;w=w.firstChild)b++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(n){for(var C=lu.empty,S=k.length-1;S>=0;S--)C=lu.from(k[S].copy(C));n(e.tr.step(new Dd(t.pos-k.length,t.pos+s.nodeSize,t.pos+b,t.pos+s.nodeSize-b,new vu(C,k.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Fh(e){return function(t,n){for(var i=t.selection,r=e<0?i.$from:i.$to,o=r.depth;r.node(o).isInline;){if(!o)return!1;o--}return!!r.node(o).isTextblock&&(n&&n(t.tr.setSelection(hh.create(t.doc,e<0?r.start(o):r.end(o)))),!0)}}var Hh=Fh(-1),jh=Fh(1);function Vh(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,i){for(var r=!1,o=0;o<n.selection.ranges.length&&!r;o++){var a=n.selection.ranges[o],s=a.$from.pos,c=a.$to.pos;n.doc.nodesBetween(s,c,function(i,o){if(r)return!1;if(i.isTextblock&&!i.hasMarkup(e,t))if(i.type==e)r=!0;else{var a=n.doc.resolve(o),s=a.index();r=a.parent.canReplaceWith(s,s+1,e)}})}if(!r)return!1;if(i){for(var l=n.tr,u=0;u<n.selection.ranges.length;u++){var d=n.selection.ranges[u],h=d.$from.pos,f=d.$to.pos;l.setBlockType(h,f,e,t)}i(l.scrollIntoView())}return!0}}function Wh(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,i){var r=n.selection,o=r.$from,a=r.$to,s=o.blockRange(a);if(!s)return!1;var c=i?n.tr:null;return!!function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=!1,o=t,a=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;var s=a.resolve(t.start-2);o=new Au(s,s,t.depth),t.endIndex<t.parent.childCount&&(t=new Au(t.$from,a.resolve(t.$to.end(t.depth)),t.depth)),r=!0}var c=Pd(o,n,i,t);if(!c)return!1;e&&function(e,t,n,i,r){for(var o=lu.empty,a=n.length-1;a>=0;a--)o=lu.from(n[a].type.create(n[a].attrs,o));e.step(new Dd(t.start-(i?2:0),t.end,t.start,t.end,new vu(o,0,0),n.length,!0));for(var s=0,c=0;c<n.length;c++)n[c].type==r&&(s=c+1);for(var l=n.length-s,u=t.start+n.length-(i?2:0),d=t.parent,h=t.startIndex,f=t.endIndex,p=!0;h<f;h++,p=!1)!p&&jd(e.doc,u,l)&&(e.split(u,l),u+=2*l),u+=d.child(h).nodeSize}(e,t,c,r,n);return!0}(c,s,e,t)&&(i&&i(c.scrollIntoView()),!0)}}function $h(e){return function(t,n){var i=t.selection,r=i.$from,o=i.$to,a=r.blockRange(o,function(t){return t.childCount>0&&t.firstChild.type==e});return!!a&&(!n||(r.node(a.depth-1).type==e?function(e,t,n,i){var r=e.tr,o=i.end,a=i.$to.end(i.depth);o<a&&(r.step(new Dd(o-1,a,o,a,new vu(lu.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new Au(r.doc.resolve(i.$from.pos),r.doc.resolve(a),i.depth));var s=zd(i);if(null==s)return!1;r.lift(i,s);var c=r.doc.resolve(r.mapping.map(o,-1)-1);Vd(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos);return t(r.scrollIntoView()),!0}(t,n,e,a):function(e,t,n){for(var i=e.tr,r=n.parent,o=n.end,a=n.endIndex-1,s=n.startIndex;a>s;a--)o-=r.child(a).nodeSize,i.delete(o-1,o+1);var c=i.doc.resolve(n.start),l=c.nodeAfter;if(i.mapping.map(n.end)!=n.start+c.nodeAfter.nodeSize)return!1;var u=0==n.startIndex,d=n.endIndex==r.childCount,h=c.node(-1),f=c.index(-1);if(!h.canReplace(f+(u?0:1),f+1,l.content.append(d?lu.empty:lu.from(r))))return!1;var p=c.pos,v=p+l.nodeSize;return i.step(new Dd(p-(u?1:0),v+(d?1:0),p+1,v-1,new vu((u?lu.empty:lu.from(r.copy(lu.empty))).append(d?lu.empty:lu.from(r.copy(lu.empty))),u?0:1,d?0:1),u?0:1)),t(i.scrollIntoView()),!0}(t,n,a)))}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();var Uh=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},qh=function(e){var t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},Kh=null,Jh=function(e,t,n){var i=Kh||(Kh=document.createRange());return i.setEnd(e,null==n?e.nodeValue.length:n),i.setStart(e,t||0),i},Gh=function(e,t,n,i){return n&&(Xh(e,t,n,i,-1)||Xh(e,t,n,i,1))},Yh=/^(img|br|input|textarea|hr)$/i;function Xh(e,t,n,i,r){for(var o;;){if(e==n&&t==i)return!0;if(t==(r<0?0:Qh(e))){var a=e.parentNode;if(!a||1!=a.nodeType||Zh(e)||Yh.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Uh(e)+(r<0?0:1),e=a}else{if(1!=e.nodeType)return!1;var s=e.childNodes[t+(r<0?-1:0)];if(1==s.nodeType&&"false"==s.contentEditable){if(!(null===(o=s.pmViewDesc)||void 0===o?void 0:o.ignoreForSelection))return!1;t+=r}else e=s,t=r<0?Qh(e):0}}}function Qh(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Zh(e){for(var t,n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var ef=function(e){return e.focusNode&&Gh(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function tf(e,t){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}var nf="undefined"!=typeof navigator?navigator:null,rf="undefined"!=typeof document?document:null,of=nf&&nf.userAgent||"",af=/Edge\/(\d+)/.exec(of),sf=/MSIE \d/.exec(of),cf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(of),lf=!!(sf||cf||af),uf=sf?document.documentMode:cf?+cf[1]:af?+af[1]:0,df=!lf&&/gecko\/(\d+)/i.test(of);df&&(/Firefox\/(\d+)/.exec(of)||[0,0])[1];var hf=!lf&&/Chrome\/(\d+)/.exec(of),ff=!!hf,pf=hf?+hf[1]:0,vf=!lf&&!!nf&&/Apple Computer/.test(nf.vendor),mf=vf&&(/Mobile\/\w+/.test(of)||!!nf&&nf.maxTouchPoints>2),gf=mf||!!nf&&/Mac/.test(nf.platform),yf=!!nf&&/Win/.test(nf.platform),kf=/Android \d/.test(of),wf=!!rf&&"webkitFontSmoothing"in rf.documentElement.style,bf=wf?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Cf(e){var t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Sf(e,t){return"number"==typeof e?e:e[t]}function xf(e){var t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,i=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*i}}function Tf(e,t,n){for(var i=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument,a=n||e.dom;a;)if(1==a.nodeType){var s=a,c=s==o.body,l=c?Cf(o):xf(s),u=0,d=0;if(t.top<l.top+Sf(i,"top")?d=-(l.top-t.top+Sf(r,"top")):t.bottom>l.bottom-Sf(i,"bottom")&&(d=t.bottom-t.top>l.bottom-l.top?t.top+Sf(r,"top")-l.top:t.bottom-l.bottom+Sf(r,"bottom")),t.left<l.left+Sf(i,"left")?u=-(l.left-t.left+Sf(r,"left")):t.right>l.right-Sf(i,"right")&&(u=t.right-l.right+Sf(r,"right")),u||d)if(c)o.defaultView.scrollBy(u,d);else{var h=s.scrollLeft,f=s.scrollTop;d&&(s.scrollTop+=d),u&&(s.scrollLeft+=u);var p=s.scrollLeft-h,v=s.scrollTop-f;t={left:t.left-p,top:t.top-v,right:t.right-p,bottom:t.bottom-v}}var m=c?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(m))break;a="absolute"==m?a.offsetParent:qh(a)}else a=qh(a)}function Mf(e){for(var t=[],n=e.ownerDocument,i=e;i&&(t.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),e!=n);i=qh(i));return t}function _f(e,t){for(var n=0;n<e.length;n++){var i=e[n],r=i.dom,o=i.top,a=i.left;r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var Nf=null;function Of(e,t){for(var n,i,r,o,a=2e8,s=0,c=t.top,l=t.top,u=e.firstChild,d=0;u;u=u.nextSibling,d++){var h=void 0;if(1==u.nodeType)h=u.getClientRects();else{if(3!=u.nodeType)continue;h=Jh(u).getClientRects()}for(var f=0;f<h.length;f++){var p=h[f];if(p.top<=c&&p.bottom>=l){c=Math.max(p.bottom,c),l=Math.min(p.top,l);var v=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(v<a){n=u,a=v,i=v&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==u.nodeType&&v&&(s=d+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!r&&p.left<=t.left&&p.right>=t.left&&(r=u,o={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(s=d+1)}}return!n&&r&&(n=r,i=o,a=0),n&&3==n.nodeType?function(e,t){for(var n,i=e.nodeValue.length,r=document.createRange(),o=0;o<i;o++){r.setEnd(e,o+1),r.setStart(e,o);var a=Lf(r,1);if(a.top!=a.bottom&&Ef(t,a)){n={node:e,offset:o+(t.left>=(a.left+a.right)/2?1:0)};break}}return r.detach(),n||{node:e,offset:0}}(n,i):!n||a&&1==n.nodeType?{node:e,offset:s}:Of(n,i)}function Ef(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Af(e,t,n){var i=e.childNodes.length;if(i&&n.top<n.bottom)for(var r=Math.max(0,Math.min(i-1,Math.floor(i*(t.top-n.top)/(n.bottom-n.top))-2)),o=r;;){var a=e.childNodes[o];if(1==a.nodeType)for(var s=a.getClientRects(),c=0;c<s.length;c++){var l=s[c];if(Ef(t,l))return Af(a,t,l)}if((o=(o+1)%i)==r)break}return e}function Df(e,t){var n,i=e.dom.ownerDocument,r=0,o=function(e,t,n){if(e.caretPositionFromPoint)try{var i=e.caretPositionFromPoint(t,n);if(i)return{node:i.offsetNode,offset:Math.min(Qh(i.offsetNode),i.offset)}}catch(Ss){}if(e.caretRangeFromPoint){var r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Qh(r.startContainer),r.startOffset)}}}(i,t.left,t.top);o&&(n=o.node,r=o.offset);var a,s=(e.root.elementFromPoint?e.root:i).elementFromPoint(t.left,t.top);if(!s||!e.dom.contains(1!=s.nodeType?s.parentNode:s)){var c=e.dom.getBoundingClientRect();if(!Ef(t,c))return null;if(!(s=Af(e.dom,t,c)))return null}if(vf)for(var l=s;n&&l;l=qh(l))l.draggable&&(n=void 0);if(s=function(e,t){var n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(s,t),n){if(df&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length))<n.childNodes.length){var u,d=n.childNodes[r];"IMG"==d.nodeName&&(u=d.getBoundingClientRect()).right<=t.left&&u.bottom>t.top&&r++}var h;wf&&r&&1==n.nodeType&&1==(h=n.childNodes[r-1]).nodeType&&"false"==h.contentEditable&&h.getBoundingClientRect().top>=t.top&&r--,n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?a=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(a=function(e,t,n,i){for(var r=-1,o=t,a=!1;o!=e.dom;){var s=e.docView.nearestDesc(o,!0),c=void 0;if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((c=s.dom.getBoundingClientRect()).width||c.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!a&&c.left>i.left||c.top>i.top?r=s.posBefore:(!a&&c.right<i.left||c.bottom<i.top)&&(r=s.posAfter),a=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?i.top<(c.top+c.bottom)/2:i.left<(c.left+c.right)/2)?s.posBefore:s.posAfter;o=s.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,-1)}(e,n,r,t))}null==a&&(a=function(e,t,n){var i=Of(t,n),r=i.node,o=i.offset,a=-1;if(1==r.nodeType&&!r.firstChild){var s=r.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(r,o,a)}(e,s,t));var f=e.docView.nearestDesc(s,!0);return{pos:a,inside:f?f.posAtStart-f.border:-1}}function If(e){return e.top<e.bottom||e.left<e.right}function Lf(e,t){var n=e.getClientRects();if(n.length){var i=n[t<0?0:n.length-1];if(If(i))return i}return Array.prototype.find.call(n,If)||e.getBoundingClientRect()}var Rf=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function zf(e,t,n){var i=e.docView.domFromPos(t,n<0?-1:1),r=i.node,o=i.offset,a=i.atom,s=wf||df;if(3==r.nodeType){if(!s||!Rf.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){var c=o,l=o,u=n<0?1:-1;return n<0&&!o?(l++,u=-1):n>=0&&o==r.nodeValue.length?(c--,u=1):n<0?c--:l++,Pf(Lf(Jh(r,c,l),u),u<0)}var d=Lf(Jh(r,o,o),n);if(df&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){var h=Lf(Jh(r,o-1,o-1),-1);if(h.top==d.top){var f=Lf(Jh(r,o,o+1),-1);if(f.top!=d.top)return Pf(f,f.left<h.left)}}return d}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(null==a&&o&&(n<0||o==Qh(r))){var p=r.childNodes[o-1];if(1==p.nodeType)return Bf(p.getBoundingClientRect(),!1)}if(null==a&&o<Qh(r)){var v=r.childNodes[o];if(1==v.nodeType)return Bf(v.getBoundingClientRect(),!0)}return Bf(r.getBoundingClientRect(),n>=0)}if(null==a&&o&&(n<0||o==Qh(r))){var m=r.childNodes[o-1],g=3==m.nodeType?Jh(m,Qh(m)-(s?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(g)return Pf(Lf(g,1),!1)}if(null==a&&o<Qh(r)){for(var y=r.childNodes[o];y.pmViewDesc&&y.pmViewDesc.ignoreForCoords;)y=y.nextSibling;var k=y?3==y.nodeType?Jh(y,0,s?0:1):1==y.nodeType?y:null:null;if(k)return Pf(Lf(k,-1),!0)}return Pf(Lf(3==r.nodeType?Jh(r):r,-n),n>=0)}function Pf(e,t){if(0==e.width)return e;var n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Bf(e,t){if(0==e.height)return e;var n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Ff(e,t,n){var i=e.state,r=e.root.activeElement;i!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{i!=t&&e.updateState(i),r!=e.dom&&r&&r.focus()}}var Hf=/[\u0590-\u08ac]/;var jf=null,Vf=null,Wf=!1;function $f(e,t,n){return jf==t&&Vf==n?Wf:(jf=t,Vf=n,Wf="up"==n||"down"==n?function(e,t,n){var i=t.selection,r="up"==n?i.$from:i.$to;return Ff(e,t,function(){for(var t=e.docView.domFromPos(r.pos,"up"==n?-1:1).node;;){var i=e.docView.nearestDesc(t,!0);if(!i)break;if(i.node.isBlock){t=i.contentDOM||i.dom;break}t=i.dom.parentNode}for(var o=zf(e,r.pos,1),a=t.firstChild;a;a=a.nextSibling){var s=void 0;if(1==a.nodeType)s=a.getClientRects();else{if(3!=a.nodeType)continue;s=Jh(a,0,a.nodeValue.length).getClientRects()}for(var c=0;c<s.length;c++){var l=s[c];if(l.bottom>l.top+1&&("up"==n?o.top-l.top>2*(l.bottom-o.top):l.bottom-o.bottom>2*(o.bottom-l.top)))return!1}}return!0})}(e,t,n):function(e,t,n){var i=t.selection.$head;if(!i.parent.isTextblock)return!1;var r=i.parentOffset,o=!r,a=r==i.parent.content.size,s=e.domSelection();return s?Hf.test(i.parent.textContent)&&s.modify?Ff(e,t,function(){var t=e.domSelectionRange(),r=t.focusNode,o=t.focusOffset,a=t.anchorNode,c=t.anchorOffset,l=s.caretBidiLevel;s.modify("move",n,"character");var u=i.depth?e.docView.domAfterPos(i.before()):e.dom,d=e.domSelectionRange(),h=d.focusNode,f=d.focusOffset,p=h&&!u.contains(1==h.nodeType?h:h.parentNode)||r==h&&o==f;try{s.collapse(a,c),r&&(r!=a||o!=c)&&s.extend&&s.extend(r,o)}catch(Ss){}return null!=l&&(s.caretBidiLevel=l),p}):"left"==n||"backward"==n?o:a:i.pos==i.start()||i.pos==i.end()}(e,t,n))}var Uf=function(){return x(function e(t,n,i,r){C(this,e),this.parent=t,this.children=n,this.dom=i,this.contentDOM=r,this.dirty=0,i.pmViewDesc=this},[{key:"matchesWidget",value:function(e){return!1}},{key:"matchesMark",value:function(e){return!1}},{key:"matchesNode",value:function(e,t,n){return!1}},{key:"matchesHack",value:function(e){return!1}},{key:"parseRule",value:function(){return null}},{key:"stopEvent",value:function(e){return!1}},{key:"size",get:function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e}},{key:"border",get:function(){return 0}},{key:"destroy",value:function(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(var e=0;e<this.children.length;e++)this.children[e].destroy()}},{key:"posBeforeChild",value:function(e){for(var t=0,n=this.posAtStart;;t++){var i=this.children[t];if(i==e)return n;n+=i.size}}},{key:"posBefore",get:function(){return this.parent.posBeforeChild(this)}},{key:"posAtStart",get:function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}},{key:"posAfter",get:function(){return this.posBefore+this.size}},{key:"posAtEnd",get:function(){return this.posAtStart+this.size-2*this.border}},{key:"localPosFromDOM",value:function(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){var i,r;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&(!(r=i.pmViewDesc)||r.parent!=this);)i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}var o,a;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&(!(a=o.pmViewDesc)||a.parent!=this);)o=o.nextSibling;return o?this.posBeforeChild(a):this.posAtEnd}var s;if(e==this.dom&&this.contentDOM)s=t>Uh(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(var c=e;;c=c.parentNode){if(c==this.dom){s=!1;break}if(c.previousSibling)break}if(null==s&&t==e.childNodes.length)for(var l=e;;l=l.parentNode){if(l==this.dom){s=!0;break}if(l.nextSibling)break}}return(null==s?n>0:s)?this.posAtEnd:this.posAtStart}},{key:"nearestDesc",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!0,i=e;i;i=i.parentNode){var r=this.getDesc(i),o=void 0;if(r&&(!t||r.node)){if(!n||!(o=r.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return r;n=!1}}}},{key:"getDesc",value:function(e){for(var t=e.pmViewDesc,n=t;n;n=n.parent)if(n==this)return t}},{key:"posFromDOM",value:function(e,t,n){for(var i=e;i;i=i.parentNode){var r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,n)}return-1}},{key:"descAt",value:function(e){for(var t=0,n=0;t<this.children.length;t++){var i=this.children[t],r=n+i.size;if(n==e&&r!=n){for(;!i.border&&i.children.length;)for(var o=0;o<i.children.length;o++){var a=i.children[o];if(a.size){i=a;break}}return i}if(e<r)return i.descAt(e-n-i.border);n=r}}},{key:"domFromPos",value:function(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};for(var n,i=0,r=0,o=0;i<this.children.length;i++){var a=this.children[i],s=o+a.size;if(s>e||a instanceof Qf){r=e-o;break}o=s}if(r)return this.children[i].domFromPos(r-this.children[i].border,t);for(;i&&!(n=this.children[i-1]).size&&n instanceof qf&&n.side>=0;i--);if(t<=0){for(var c,l=!0;(c=i?this.children[i-1]:null)&&c.dom.parentNode!=this.contentDOM;i--,l=!1);return c&&t&&l&&!c.border&&!c.domAtom?c.domFromPos(c.size,t):{node:this.contentDOM,offset:c?Uh(c.dom)+1:0}}for(var u,d=!0;(u=i<this.children.length?this.children[i]:null)&&u.dom.parentNode!=this.contentDOM;i++,d=!1);return u&&d&&!u.border&&!u.domAtom?u.domFromPos(0,t):{node:this.contentDOM,offset:u?Uh(u.dom):this.contentDOM.childNodes.length}}},{key:"parseRange",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var i=-1,r=-1,o=n,a=0;;a++){var s=this.children[a],c=o+s.size;if(-1==i&&e<=c){var l=o+s.border;if(e>=l&&t<=c-s.border&&s.node&&s.contentDOM&&this.contentDOM.contains(s.contentDOM))return s.parseRange(e,t,l);e=o;for(var u=a;u>0;u--){var d=this.children[u-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=Uh(d.dom)+1;break}e-=d.size}-1==i&&(i=0)}if(i>-1&&(c>t||a==this.children.length-1)){t=c;for(var h=a+1;h<this.children.length;h++){var f=this.children[h];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){r=Uh(f.dom);break}t+=f.size}-1==r&&(r=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:r}}},{key:"emptyChildAt",value:function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}},{key:"domAfterPos",value:function(e){var t=this.domFromPos(e,0),n=t.node,i=t.offset;if(1!=n.nodeType||i==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[i]}},{key:"setSelection",value:function(e,t,n){for(var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=Math.min(e,t),o=Math.max(e,t),a=0,s=0;a<this.children.length;a++){var c=this.children[a],l=s+c.size;if(r>s&&o<l)return c.setSelection(e-s-c.border,t-s-c.border,n,i);s=l}var u=this.domFromPos(e,e?-1:1),d=t==e?u:this.domFromPos(t,t?-1:1),h=n.root.getSelection(),f=n.domSelectionRange(),p=!1;if((df||vf)&&e==t){var v=u,m=v.node,g=v.offset;if(3==m.nodeType){if((p=!(!g||"\n"!=m.nodeValue[g-1]))&&g==m.nodeValue.length)for(var y,k=m;k;k=k.parentNode){if(y=k.nextSibling){"BR"==y.nodeName&&(u=d={node:y.parentNode,offset:Uh(y)+1});break}var w=k.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{var b=m.childNodes[g-1];p=b&&("BR"==b.nodeName||"false"==b.contentEditable)}}if(df&&f.focusNode&&f.focusNode!=d.node&&1==f.focusNode.nodeType){var C=f.focusNode.childNodes[f.focusOffset];C&&"false"==C.contentEditable&&(i=!0)}if(i||p&&vf||!Gh(u.node,u.offset,f.anchorNode,f.anchorOffset)||!Gh(d.node,d.offset,f.focusNode,f.focusOffset)){var S=!1;if((h.extend||e==t)&&(!p||!df)){h.collapse(u.node,u.offset);try{e!=t&&h.extend(d.node,d.offset),S=!0}catch(Ss){}}if(!S){if(e>t){var x=u;u=d,d=x}var T=document.createRange();T.setEnd(d.node,d.offset),T.setStart(u.node,u.offset),h.removeAllRanges(),h.addRange(T)}}}},{key:"ignoreMutation",value:function(e){return!this.contentDOM&&"selection"!=e.type}},{key:"contentLost",get:function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}},{key:"markDirty",value:function(e,t){for(var n=0,i=0;i<this.children.length;i++){var r=this.children[i],o=n+r.size;if(n==o?e<=o&&t>=n:e<o&&t>n){var a=n+r.border,s=o-r.border;if(e>=a&&t<=s)return this.dirty=e==n||t==o?2:1,void(e!=a||t!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(e-a,t-a):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=o}this.dirty=2}},{key:"markParentsDirty",value:function(){for(var e=1,t=this.parent;t;t=t.parent,e++){var n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}},{key:"domAtom",get:function(){return!1}},{key:"ignoreForCoords",get:function(){return!1}},{key:"ignoreForSelection",get:function(){return!1}},{key:"isText",value:function(e){return!1}}])}(),qf=function(t){function r(e,t,i,o){var a;C(this,r);var s,c=t.type.toDOM;if("function"==typeof c&&(c=c(i,function(){return s?s.parent?s.parent.posBeforeChild(s):void 0:o})),!t.type.spec.raw){if(1!=c.nodeType){var l=document.createElement("span");l.appendChild(c),c=l}c.contentEditable="false",c.classList.add("ProseMirror-widget")}return(a=n(this,r,[e,[],c,null])).widget=t,a.widget=t,s=a,a}return i(r,t),x(r,[{key:"matchesWidget",value:function(e){return 0==this.dirty&&e.type.eq(this.widget.type)}},{key:"parseRule",value:function(){return{ignore:!0}}},{key:"stopEvent",value:function(e){var t=this.widget.spec.stopEvent;return!!t&&t(e)}},{key:"ignoreMutation",value:function(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}},{key:"destroy",value:function(){this.widget.type.destroy(this.dom),e(r,"destroy",this,3)([])}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForSelection",get:function(){return!!this.widget.type.spec.relaxedSide}},{key:"side",get:function(){return this.widget.type.side}}])}(Uf),Kf=function(e){function t(e,i,r,o){var a;return C(this,t),(a=n(this,t,[e,[],i,null])).textDOM=r,a.text=o,a}return i(t,e),x(t,[{key:"size",get:function(){return this.text.length}},{key:"localPosFromDOM",value:function(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}},{key:"domFromPos",value:function(e){return{node:this.textDOM,offset:e}}},{key:"ignoreMutation",value:function(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}])}(Uf),Jf=function(t){function r(e,t,i,o,a){var s;return C(this,r),(s=n(this,r,[e,[],i,o])).mark=t,s.spec=a,s}return i(r,t),x(r,[{key:"parseRule",value:function(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}},{key:"matchesMark",value:function(e){return 3!=this.dirty&&this.mark.eq(e)}},{key:"markDirty",value:function(t,n){if(e(r,"markDirty",this,3)([t,n]),0!=this.dirty){for(var i=this.parent;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=0}}},{key:"slice",value:function(e,t,n){var i=r.create(this.parent,this.mark,!0,n),o=this.children,a=this.size;t<a&&(o=dp(o,t,a,n)),e>0&&(o=dp(o,0,e,n));for(var s=0;s<o.length;s++)o[s].parent=i;return i.children=o,i}},{key:"ignoreMutation",value:function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e(r,"ignoreMutation",this,3)([t])}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),e(r,"destroy",this,3)([])}}],[{key:"create",value:function(e,t,n,i){var o=i.nodeViews[t.type.name],a=o&&o(t,i,n);return a&&a.dom||(a=dd.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new r(e,t,a.dom,a.contentDOM||a.dom,a)}}])}(Uf),Gf=function(e){function t(e,i,r,o,a,s,c,l,u){var d;return C(this,t),(d=n(this,t,[e,[],a,s])).node=i,d.outerDeco=r,d.innerDeco=o,d.nodeDOM=c,d}return i(t,e),x(t,[{key:"parseRule",value:function(){var e=this;if(this.node.type.spec.reparseInView)return null;var t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(var n=this.children.length-1;n>=0;n--){var i=this.children[n];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}t.contentElement||(t.getContent=function(){return lu.empty})}else t.contentElement=this.contentDOM;else t.getContent=function(){return e.node.content};return t}},{key:"matchesNode",value:function(e,t,n){return 0==this.dirty&&e.eq(this.node)&&sp(t,this.outerDeco)&&n.eq(this.innerDeco)}},{key:"size",get:function(){return this.node.nodeSize}},{key:"border",get:function(){return this.node.isLeaf?0:1}},{key:"updateChildren",value:function(e,t){var n=this,i=this.node.inlineContent,r=t,o=e.composing?this.localCompositionInfo(e,t):null,a=o&&o.pos>-1?o:null,s=o&&o.pos<0,c=new lp(this,a&&a.node,e);!function(e,t,n,i){var r=t.locals(e),o=0;if(0==r.length){for(var a=0;a<e.childCount;a++){var s=e.child(a);i(s,r,t.forChild(o,s),a),o+=s.nodeSize}return}for(var c=0,l=[],u=null,d=0;;){for(var h=void 0,f=void 0;c<r.length&&r[c].to==o;){var p=r[c++];p.widget&&(h?(f||(f=[h])).push(p):h=p)}if(h)if(f){f.sort(up);for(var v=0;v<f.length;v++)n(f[v],d,!!u)}else n(h,d,!!u);var m=void 0,g=void 0;if(u)g=-1,m=u,u=null;else{if(!(d<e.childCount))break;g=d,m=e.child(d++)}for(var y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;c<r.length&&r[c].from<=o&&r[c].to>o;)l.push(r[c++]);var k=o+m.nodeSize;if(m.isText){var w=k;c<r.length&&r[c].from<w&&(w=r[c].from);for(var b=0;b<l.length;b++)l[b].to<w&&(w=l[b].to);w<k&&(u=m.cut(w-o),m=m.cut(0,w-o),k=w,g=-1)}else for(;c<r.length&&r[c].to<k;)c++;var C=m.isInline&&!m.isLeaf?l.filter(function(e){return!e.inline}):l.slice();i(m,C,t.forChild(o,m),g),o=k}}(this.node,this.innerDeco,function(t,o,a){t.spec.marks?c.syncToMarks(t.spec.marks,i,e):t.type.side>=0&&!a&&c.syncToMarks(o==n.node.childCount?fu.none:n.node.child(o).marks,i,e),c.placeWidget(t,e,r)},function(t,n,a,l){var u;c.syncToMarks(t.marks,i,e),c.findNodeMatch(t,n,a,l)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=c.findIndexWithChild(o.node))>-1&&c.updateNodeAt(t,n,a,u,e)||c.updateNextNode(t,n,a,e,l,r)||c.addNode(t,n,a,e,r),r+=t.nodeSize}),c.syncToMarks([],i,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||2==this.dirty)&&(a&&this.protectLocalComposition(e,a),ep(this.contentDOM,this.children,e),mf&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){var t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}},{key:"localCompositionInfo",value:function(e,t){var n=e.state.selection,i=n.from,r=n.to;if(!(e.state.selection instanceof hh)||i<t||r>t+this.node.content.size)return null;var o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){var a=o.nodeValue,s=function(e,t,n,i){for(var r=0,o=0;r<e.childCount&&o<=i;){var a=e.child(r++),s=o;if(o+=a.nodeSize,a.isText){for(var c=a.text;r<e.childCount;){var l=e.child(r++);if(o+=l.nodeSize,!l.isText)break;c+=l.text}if(o>=n){if(o>=i&&c.slice(i-t.length-s,i-s)==t)return i-t.length;var u=s<i?c.lastIndexOf(t,i-s-1):-1;if(u>=0&&u+t.length+s>=n)return s+u;if(n==i&&c.length>=i+t.length-s&&c.slice(i-s,i-s+t.length)==t)return i}}}return-1}(this.node.content,a,i-t,r-t);return s<0?null:{node:o,pos:s,text:a}}return{node:o,pos:-1,text:""}}},{key:"protectLocalComposition",value:function(e,t){var n=t.node,i=t.pos,r=t.text;if(!this.getDesc(n)){for(var o=n;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}var a=new Kf(this,o,n,r);e.input.compositionNodes.push(a),this.children=dp(this.children,i,i+r.length,e,a)}}},{key:"update",value:function(e,t,n,i){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,i),!0)}},{key:"updateInner",value:function(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=0}},{key:"updateOuterDeco",value:function(e){if(!sp(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=rp(this.dom,this.nodeDOM,ip(this.outerDeco,this.node,t),ip(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}}},{key:"selectNode",value:function(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}},{key:"deselectNode",value:function(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}},{key:"domAtom",get:function(){return this.node.isAtom}}],[{key:"create",value:function(e,n,i,r,o,a){var s,c=o.nodeViews[n.type.name],l=c&&c(n,o,function(){return s?s.parent?s.parent.posBeforeChild(s):void 0:a},i,r),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText)if(u){if(3!=u.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else u=document.createTextNode(n.text);else if(!u){var h=dd.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);u=h.dom,d=h.contentDOM}d||n.isText||"BR"==u.nodeName||(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));var f=u;return u=ap(u,i,n),l?s=new Zf(e,n,i,r,u,d||null,f,l,o,a+1):n.isText?new Xf(e,n,i,r,u,f,o):new t(e,n,i,r,u,d||null,f,o,a+1)}}])}(Uf);function Yf(e,t,n,i,r){ap(i,t,e);var o=new Gf(void 0,e,t,n,i,i,i,r,0);return o.contentDOM&&o.updateChildren(r,0),o}var Xf=function(t){function r(e,t,i,o,a,s,c){return C(this,r),n(this,r,[e,t,i,o,a,null,s,c,0])}return i(r,t),x(r,[{key:"parseRule",value:function(){for(var e=this.nodeDOM.parentNode;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}},{key:"update",value:function(e,t,n,i){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=0,!0)}},{key:"inParent",value:function(){for(var e=this.parent.contentDOM,t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}},{key:"domFromPos",value:function(e){return{node:this.nodeDOM,offset:e}}},{key:"localPosFromDOM",value:function(t,n,i){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):e(r,"localPosFromDOM",this,3)([t,n,i])}},{key:"ignoreMutation",value:function(e){return"characterData"!=e.type&&"selection"!=e.type}},{key:"slice",value:function(e,t,n){var i=this.node.cut(e,t),o=document.createTextNode(i.text);return new r(this.parent,i,this.outerDeco,this.innerDeco,o,o,n)}},{key:"markDirty",value:function(t,n){e(r,"markDirty",this,3)([t,n]),this.dom==this.nodeDOM||0!=t&&n!=this.nodeDOM.nodeValue.length||(this.dirty=3)}},{key:"domAtom",get:function(){return!1}},{key:"isText",value:function(e){return this.node.text==e}}])}(Gf),Qf=function(e){function t(){return C(this,t),n(this,t,arguments)}return i(t,e),x(t,[{key:"parseRule",value:function(){return{ignore:!0}}},{key:"matchesHack",value:function(e){return 0==this.dirty&&this.dom.nodeName==e}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForCoords",get:function(){return"IMG"==this.dom.nodeName}}])}(Uf),Zf=function(t){function r(e,t,i,o,a,s,c,l,u,d){var h;return C(this,r),(h=n(this,r,[e,t,i,o,a,s,c,u,d])).spec=l,h}return i(r,t),x(r,[{key:"update",value:function(t,n,i,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){var a=this.spec.update(t,n,i);return a&&this.updateInner(t,n,i,o),a}return!(!this.contentDOM&&!t.isLeaf)&&e(r,"update",this,3)([t,n,i,o])}},{key:"selectNode",value:function(){this.spec.selectNode?this.spec.selectNode():e(r,"selectNode",this,3)([])}},{key:"deselectNode",value:function(){this.spec.deselectNode?this.spec.deselectNode():e(r,"deselectNode",this,3)([])}},{key:"setSelection",value:function(t,n,i,o){this.spec.setSelection?this.spec.setSelection(t,n,i.root):e(r,"setSelection",this,3)([t,n,i,o])}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),e(r,"destroy",this,3)([])}},{key:"stopEvent",value:function(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}},{key:"ignoreMutation",value:function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e(r,"ignoreMutation",this,3)([t])}}])}(Gf);function ep(e,t,n){for(var i=e.firstChild,r=!1,o=0;o<t.length;o++){var a=t[o],s=a.dom;if(s.parentNode==e){for(;s!=i;)i=cp(i),r=!0;i=i.nextSibling}else r=!0,e.insertBefore(s,i);if(a instanceof Jf){var c=i?i.previousSibling:e.lastChild;ep(a.contentDOM,a.children,n),i=c?c.nextSibling:e.firstChild}}for(;i;)i=cp(i),r=!0;r&&n.trackWrites==e&&(n.trackWrites=null)}var tp=function(e){e&&(this.nodeName=e)};tp.prototype=Object.create(null);var np=[new tp];function ip(e,t,n){if(0==e.length)return np;for(var i=n?np[0]:new tp,r=[i],o=0;o<e.length;o++){var a=e[o].type.attrs;if(a)for(var s in a.nodeName&&r.push(i=new tp(a.nodeName)),a){var c=a[s];null!=c&&(n&&1==r.length&&r.push(i=new tp(t.isInline?"span":"div")),"class"==s?i.class=(i.class?i.class+" ":"")+c:"style"==s?i.style=(i.style?i.style+";":"")+c:"nodeName"!=s&&(i[s]=c))}}return r}function rp(e,t,n,i){if(n==np&&i==np)return t;for(var r=t,o=0;o<i.length;o++){var a=i[o],s=n[o];if(o){var c=void 0;s&&s.nodeName==a.nodeName&&r!=e&&(c=r.parentNode)&&c.nodeName.toLowerCase()==a.nodeName||((c=document.createElement(a.nodeName)).pmIsDeco=!0,c.appendChild(r),s=np[0]),r=c}op(r,s||np[0],a)}return r}function op(e,t,n){for(var i in t)"class"==i||"style"==i||"nodeName"==i||i in n||e.removeAttribute(i);for(var r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){for(var o=t.class?t.class.split(" ").filter(Boolean):[],a=n.class?n.class.split(" ").filter(Boolean):[],s=0;s<o.length;s++)-1==a.indexOf(o[s])&&e.classList.remove(o[s]);for(var c=0;c<a.length;c++)-1==o.indexOf(a[c])&&e.classList.add(a[c]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style)for(var l,u=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;l=u.exec(t.style);)e.style.removeProperty(l[1]);n.style&&(e.style.cssText+=n.style)}}function ap(e,t,n){return rp(e,e,np,ip(t,n,1!=e.nodeType))}function sp(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function cp(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var lp=function(){return x(function e(t,n,i){C(this,e),this.lock=n,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(e,t){var n=t,i=n.children.length,r=e.childCount,o=new Map,a=[];e:for(;r>0;){for(var s=void 0;;)if(i){var c=n.children[i-1];if(!(c instanceof Jf)){s=c,i--;break}n=c,i=c.children.length}else{if(n==t)break e;i=n.parent.children.indexOf(n),n=n.parent}var l=s.node;if(l){if(l!=e.child(r-1))break;--r,o.set(s,r),a.push(s)}}return{index:r,matched:o,matches:a.reverse()}}(t.node.content,t)},[{key:"destroyBetween",value:function(e,t){if(e!=t){for(var n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}},{key:"destroyRest",value:function(){this.destroyBetween(this.index,this.top.children.length)}},{key:"syncToMarks",value:function(e,t,n){for(var i=0,r=this.stack.length>>1,o=Math.min(r,e.length);i<o&&(i==r-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);for(var a=-1,s=this.index;s<Math.min(this.index+3,this.top.children.length);s++){var c=this.top.children[s];if(c.matchesMark(e[r])&&!this.isLocked(c.dom)){a=s;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{var l=Jf.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,r++}}},{key:"findNodeMatch",value:function(e,t,n,i){var r,o=-1;if(i>=this.preMatch.index&&(r=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,n))o=this.top.children.indexOf(r,this.index);else for(var a=this.index,s=Math.min(this.top.children.length,a+5);a<s;a++){var c=this.top.children[a];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=a;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)}},{key:"updateNodeAt",value:function(e,t,n,i,r){var o=this.top.children[i];return 3==o.dirty&&o.dom==o.contentDOM&&(o.dirty=2),!!o.update(e,t,n,r)&&(this.destroyBetween(this.index,i),this.index++,!0)}},{key:"findIndexWithChild",value:function(e){for(;;){var t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){var n=e.pmViewDesc;if(n)for(var i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i;return-1}e=t}}},{key:"updateNextNode",value:function(e,t,n,i,r,o){for(var a=this.index;a<this.top.children.length;a++){var s=this.top.children[a];if(s instanceof Gf){var c=this.preMatch.matched.get(s);if(null!=c&&c!=r)return!1;var l=s.dom,u=void 0,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&3!=s.dirty&&sp(t,s.outerDeco));if(!d&&s.update(e,t,n,i))return this.destroyBetween(this.index,a),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,i,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=2,u.updateChildren(i,o+1),u.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}},{key:"recreateWrapper",value:function(e,t,n,i,r,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!sp(n,e.outerDeco)||!i.eq(e.innerDeco))return null;var a=Gf.create(this.top,t,n,i,r,o);if(a.contentDOM){a.children=e.children,e.children=[];var s,c=m(a.children);try{for(c.s();!(s=c.n()).done;){s.value.parent=a}}catch(l){c.e(l)}finally{c.f()}}return e.destroy(),a}},{key:"addNode",value:function(e,t,n,i,r){var o=Gf.create(this.top,e,t,n,i,r);o.contentDOM&&o.updateChildren(i,r+1),this.top.children.splice(this.index++,0,o),this.changed=!0}},{key:"placeWidget",value:function(e,t,n){var i=this.index<this.top.children.length?this.top.children[this.index]:null;if(!i||!i.matchesWidget(e)||e!=i.widget&&i.widget.type.toDOM.parentNode){var r=new qf(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}},{key:"addTextblockHacks",value:function(){for(var e=this.top.children[this.index-1],t=this.top;e instanceof Jf;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof Xf)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((vf||ff)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}},{key:"addHackNode",value:function(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{var n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");var i=new Qf(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}},{key:"isLocked",value:function(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}])}();function up(e,t){return e.type.side-t.type.side}function dp(e,t,n,i,r){for(var o=[],a=0,s=0;a<e.length;a++){var c=e[a],l=s,u=s+=c.size;l>=n||u<=t?o.push(c):(l<t&&o.push(c.slice(0,t-l,i)),r&&(o.push(r),r=void 0),u>n&&o.push(c.slice(n-l,c.size,i)))}return o}function hp(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e.domSelectionRange(),i=e.state.doc;if(!n.focusNode)return null;var r=e.docView.nearestDesc(n.focusNode),o=r&&0==r.size,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;var s,c,l=i.resolve(a);if(ef(n)){for(s=a;r&&!r.node;)r=r.parent;var u=r.node;if(r&&u.isAtom&&ph.isSelectable(u)&&r.parent&&(!u.isInline||!function(e,t,n){for(var i=0==t,r=t==Qh(e);i||r;){if(e==n)return!0;var o=Uh(e);if(!(e=e.parentNode))return!1;i=i&&0==o,r=r&&o==Qh(e)}}(n.focusNode,n.focusOffset,r.dom))){var d=r.posBefore;c=new ph(a==d?l:i.resolve(d))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){for(var h=a,f=a,p=0;p<n.rangeCount;p++){var v=n.getRangeAt(p);h=Math.min(h,e.docView.posFromDOM(v.startContainer,v.startOffset,1)),f=Math.max(f,e.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(h<0)return null;var m=g(f==e.state.selection.anchor?[f,h]:[h,f],2);s=m[0],a=m[1],l=i.resolve(a)}else s=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(s<0)return null}var y=i.resolve(s);c||(c=bp(e,y,l,"pointer"==t||e.state.selection.head<l.pos&&!o?1:-1));return c}function fp(e){return e.editable?e.hasFocus():Sp(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function pp(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.state.selection;if(kp(e,n),fp(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&ff){var i=e.domSelectionRange(),r=e.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&Gh(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){var t=e.domSelection();if(!t)return;var n=e.cursorWrapper.dom,i="IMG"==n.nodeName;i?t.collapse(n.parentNode,Uh(n)+1):t.collapse(n,0);!i&&!e.state.selection.visible&&lf&&uf<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{var o,a,s=n.anchor,c=n.head;!vp||n instanceof hh||(n.$from.parent.inlineContent||(o=mp(e,n.from)),n.empty||n.$from.parent.inlineContent||(a=mp(e,n.to))),e.docView.setSelection(s,c,e,t),vp&&(o&&yp(o),a&&yp(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);var n=e.domSelectionRange(),i=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=function(){n.anchorNode==i&&n.anchorOffset==r||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(function(){fp(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var vp=vf||ff&&pf<63;function mp(e,t){var n=e.docView.domFromPos(t,0),i=n.node,r=n.offset,o=r<i.childNodes.length?i.childNodes[r]:null,a=r?i.childNodes[r-1]:null;if(vf&&o&&"false"==o.contentEditable)return gp(o);if(!(o&&"false"!=o.contentEditable||a&&"false"!=a.contentEditable)){if(o)return gp(o);if(a)return gp(a)}}function gp(e){return e.contentEditable="true",vf&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function yp(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function kp(e,t){if(t instanceof ph){var n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(wp(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else wp(e)}function wp(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function bp(e,t,n,i){return e.someProp("createSelectionBetween",function(i){return i(e,t,n)})||hh.between(t,n,i)}function Cp(e){return!(e.editable&&!e.hasFocus())&&Sp(e)}function Sp(e){var t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(Ss){return!1}}function xp(e,t){var n=e.selection,i=n.$anchor,r=n.$head,o=t>0?i.max(r):i.min(r),a=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return a&&ch.findFrom(a,t)}function Tp(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Mp(e,t,n){var i=e.state.selection;if(!(i instanceof hh)){if(i instanceof ph&&i.node.isInline)return Tp(e,new hh(t>0?i.$to:i.$from));var r=xp(e.state,t);return!!r&&Tp(e,r)}if(n.indexOf("s")>-1){var o=i.$head,a=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;var s=e.state.doc.resolve(o.pos+a.nodeSize*(t<0?-1:1));return Tp(e,new hh(i.$anchor,s))}if(!i.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){var c=xp(e.state,t);return!!(c&&c instanceof ph)&&Tp(e,c)}if(!(gf&&n.indexOf("m")>-1)){var l,u=i.$head,d=u.textOffset?null:t<0?u.nodeBefore:u.nodeAfter;if(!d||d.isText)return!1;var h=t<0?u.pos-d.nodeSize:u.pos;return!!(d.isAtom||(l=e.docView.descAt(h))&&!l.contentDOM)&&(ph.isSelectable(d)?Tp(e,new ph(t<0?e.state.doc.resolve(u.pos-d.nodeSize):u)):!!wf&&Tp(e,new hh(e.state.doc.resolve(t<0?h:h+d.nodeSize))))}}function _p(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Np(e,t){var n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function Op(e,t){return t<0?function(e){var t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n)return;var r,o,a=!1;df&&1==n.nodeType&&i<_p(n)&&Np(n.childNodes[i],-1)&&(a=!0);for(;;)if(i>0){if(1!=n.nodeType)break;var s=n.childNodes[i-1];if(Np(s,-1))r=n,o=--i;else{if(3!=s.nodeType)break;i=(n=s).nodeValue.length}}else{if(Ep(n))break;for(var c=n.previousSibling;c&&Np(c,-1);)r=n.parentNode,o=Uh(c),c=c.previousSibling;if(c)i=_p(n=c);else{if((n=n.parentNode)==e.dom)break;i=0}}a?Ap(e,n,i):r&&Ap(e,r,o)}(e):function(e){var t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n)return;for(var r,o,a=_p(n);;)if(i<a){if(1!=n.nodeType)break;if(!Np(n.childNodes[i],1))break;r=n,o=++i}else{if(Ep(n))break;for(var s=n.nextSibling;s&&Np(s,1);)r=s.parentNode,o=Uh(s)+1,s=s.nextSibling;if(s)i=0,a=_p(n=s);else{if((n=n.parentNode)==e.dom)break;i=a=0}}r&&Ap(e,r,o)}(e)}function Ep(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ap(e,t,n){var i,r;3!=t.nodeType&&((r=function(e,t){for(;e&&t==e.childNodes.length&&!Zh(e);)t=Uh(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){var n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(i=function(e,t){for(;e&&!t&&!Zh(e);)t=Uh(e),e=e.parentNode;for(;e&&t;){var n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=i,n=i.nodeValue.length));var o=e.domSelection();if(o){if(ef(o)){var a=document.createRange();a.setEnd(t,n),a.setStart(t,n),o.removeAllRanges(),o.addRange(a)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();var s=e.state;setTimeout(function(){e.state==s&&pp(e)},50)}}function Dp(e,t){var n=e.state.doc.resolve(t);if(!ff&&!yf&&n.parent.inlineContent){var i=e.coordsAtPos(t);if(t>n.start()){var r=e.coordsAtPos(t-1),o=(r.top+r.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(r.left-i.left)>1)return r.left<i.left?"ltr":"rtl"}if(t<n.end()){var a=e.coordsAtPos(t+1),s=(a.top+a.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Ip(e,t,n){var i=e.state.selection;if(i instanceof hh&&!i.empty||n.indexOf("s")>-1)return!1;if(gf&&n.indexOf("m")>-1)return!1;var r=i.$from,o=i.$to;if(!r.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){var a=xp(e.state,t);if(a&&a instanceof ph)return Tp(e,a)}if(!r.parent.inlineContent){var s=t<0?r:o,c=i instanceof mh?ch.near(s,t):ch.findFrom(s,t);return!!c&&Tp(e,c)}return!1}function Lp(e,t){if(!(e.state.selection instanceof hh))return!0;var n=e.state.selection,i=n.$head,r=n.$anchor,o=n.empty;if(!i.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;var a=!i.textOffset&&(t<0?i.nodeBefore:i.nodeAfter);if(a&&!a.isText){var s=e.state.tr;return t<0?s.delete(i.pos-a.nodeSize,i.pos):s.delete(i.pos,i.pos+a.nodeSize),e.dispatch(s),!0}return!1}function Rp(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function zp(e,t){var n=t.keyCode,i=function(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||gf&&72==n&&"c"==i)return Lp(e,-1)||Op(e,-1);if(46==n&&!t.shiftKey||gf&&68==n&&"c"==i)return Lp(e,1)||Op(e,1);if(13==n||27==n)return!0;if(37==n||gf&&66==n&&"c"==i){var r=37==n?"ltr"==Dp(e,e.state.selection.from)?-1:1:-1;return Mp(e,r,i)||Op(e,r)}if(39==n||gf&&70==n&&"c"==i){var o=39==n?"ltr"==Dp(e,e.state.selection.from)?1:-1:1;return Mp(e,o,i)||Op(e,o)}return 38==n||gf&&80==n&&"c"==i?Ip(e,-1,i)||Op(e,-1):40==n||gf&&78==n&&"c"==i?function(e){if(!vf||e.state.selection.$head.parentOffset>0)return!1;var t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(n&&1==n.nodeType&&0==i&&n.firstChild&&"false"==n.firstChild.contentEditable){var r=n.firstChild;Rp(e,r,"true"),setTimeout(function(){return Rp(e,r,"false")},20)}return!1}(e)||Ip(e,1,i)||Op(e,1):i==(gf?"m":"c")&&(66==n||73==n||89==n||90==n)}function Pp(e,t){e.someProp("transformCopied",function(n){t=n(t,e)});for(var n=[],i=t,r=i.content,o=i.openStart,a=i.openEnd;o>1&&a>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,a--;var s=r.firstChild;n.push(s.type.name,s.attrs!=s.type.defaultAttrs?s.attrs:null),r=s.content}var c=e.someProp("clipboardSerializer")||dd.fromSchema(e.state.schema),l=Kp(),u=l.createElement("div");u.appendChild(c.serializeFragment(r,{document:l}));for(var d,h=u.firstChild,f=0;h&&1==h.nodeType&&(d=Up[h.nodeName.toLowerCase()]);){for(var p=d.length-1;p>=0;p--){for(var v=l.createElement(d[p]);u.firstChild;)v.appendChild(u.firstChild);u.appendChild(v),f++}h=u.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice","".concat(o," ").concat(a).concat(f?" -".concat(f):""," ").concat(JSON.stringify(n)));var m=e.someProp("clipboardTextSerializer",function(n){return n(t,e)})||t.content.textBetween(0,t.content.size,"\n\n");return{dom:u,text:m,slice:t}}function Bp(e,t,n,i,r){var o,a,s=r.parent.type.spec.code;if(!n&&!t)return null;var c=!!t&&(i||s||!n);if(c){if(e.someProp("transformPastedText",function(n){t=n(t,s||i,e)}),s)return a=new vu(lu.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",function(t){a=t(a,e,!0)}),a;var l=e.someProp("clipboardTextParser",function(n){return n(t,r,i,e)});if(l)a=l;else{var u=r.marks(),d=e.state.schema,h=dd.fromSchema(d);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(function(e){var t=o.appendChild(document.createElement("p"));e&&t.appendChild(h.serializeNode(d.text(e,u)))})}}else e.someProp("transformPastedHTML",function(t){n=t(n,e)}),o=function(e){var t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var n,i=Kp().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e);(n=r&&Up[r[1].toLowerCase()])&&(e=n.map(function(e){return"<"+e+">"}).join("")+e+n.map(function(e){return"</"+e+">"}).reverse().join(""));if(i.innerHTML=function(e){var t=window.trustedTypes;if(!t)return e;Jp||(Jp=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:function(e){return e}}));return Jp.createHTML(e)}(e),n)for(var o=0;o<n.length;o++)i=i.querySelector(n[o])||i;return i}(n),wf&&function(e){for(var t=e.querySelectorAll(ff?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<t.length;n++){var i=t[n];1==i.childNodes.length&&" "==i.textContent&&i.parentNode&&i.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),i)}}(o);var f=o&&o.querySelector("[data-pm-slice]"),p=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(p&&p[3])for(var v=+p[3];v>0;v--){for(var m=o.firstChild;m&&1!=m.nodeType;)m=m.nextSibling;if(!m)break;o=m}if(!a){var g=e.someProp("clipboardParser")||e.someProp("domParser")||td.fromSchema(e.state.schema);a=g.parseSlice(o,{preserveWhitespace:!(!c&&!p),context:r,ruleFromNode:function(e){return"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Fp.test(e.parentNode.nodeName)?null:{ignore:!0}}})}if(p)a=function(e,t){if(!e.size)return e;var n,i=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(vs){return e}for(var r=e.content,o=e.openStart,a=e.openEnd,s=n.length-2;s>=0;s-=2){var c=i.nodes[n[s]];if(!c||c.hasRequiredAttrs())break;r=lu.from(c.create(n[s+1],r)),o++,a++}return new vu(r,o,a)}($p(a,+p[1],+p[2]),p[4]);else if(a=vu.maxOpen(function(e,t){if(e.childCount<2)return e;for(var n,i=function(){var n,i=t.node(r).contentMatchAt(t.index(r)),o=[];if(e.forEach(function(e){if(o){var t,r=i.findWrapping(e.type);if(!r)return o=null;if(t=o.length&&n.length&&jp(r,n,e,o[o.length-1],0))o[o.length-1]=t;else{o.length&&(o[o.length-1]=Vp(o[o.length-1],n.length));var a=Hp(e,r);o.push(a),i=i.matchType(a.type),n=r}}}),o)return{v:lu.from(o)}},r=t.depth;r>=0;r--)if(n=i())return n.v;return e}(a.content,r),!0),a.openStart||a.openEnd){for(var y=0,k=0,w=a.content.firstChild;y<a.openStart&&!w.type.spec.isolating;y++,w=w.firstChild);for(var b=a.content.lastChild;k<a.openEnd&&!b.type.spec.isolating;k++,b=b.lastChild);a=$p(a,y,k)}return e.someProp("transformPasted",function(t){a=t(a,e,c)}),a}var Fp=/^(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 Hp(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=t.length-1;i>=n;i--)e=t[i].create(null,lu.from(e));return e}function jp(e,t,n,i,r){if(r<e.length&&r<t.length&&e[r]==t[r]){var o=jp(e,t,n,i.lastChild,r+1);if(o)return i.copy(i.content.replaceChild(i.childCount-1,o));if(i.contentMatchAt(i.childCount).matchType(r==e.length-1?n.type:e[r+1]))return i.copy(i.content.append(lu.from(Hp(n,e,r+1))))}}function Vp(e,t){if(0==t)return e;var n=e.content.replaceChild(e.childCount-1,Vp(e.lastChild,t-1)),i=e.contentMatchAt(e.childCount).fillBefore(lu.empty,!0);return e.copy(n.append(i))}function Wp(e,t,n,i,r,o){var a=t<0?e.firstChild:e.lastChild,s=a.content;return e.childCount>1&&(o=0),r<i-1&&(s=Wp(s,t,n,i,r+1,o)),r>=n&&(s=t<0?a.contentMatchAt(0).fillBefore(s,o<=r).append(s):s.append(a.contentMatchAt(a.childCount).fillBefore(lu.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(s))}function $p(e,t,n){return t<e.openStart&&(e=new vu(Wp(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new vu(Wp(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Up={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},qp=null;function Kp(){return qp||(qp=document.implementation.createHTMLDocument("title"))}var Jp=null;var Gp={},Yp={},Xp={touchstart:!0,touchmove:!0},Qp=x(function e(){C(this,e),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 Zp(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function ev(e){e.someProp("handleDOMEvents",function(t){for(var n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=function(t){return tv(e,t)})})}function tv(e,t){return e.someProp("handleDOMEvents",function(n){var i=n[t.type];return!!i&&(i(e,t)||t.defaultPrevented)})}function nv(e){return{left:e.clientX,top:e.clientY}}function iv(e,t,n,i,r){if(-1==i)return!1;for(var o,a=e.state.doc.resolve(i),s=function(i){if(e.someProp(t,function(t){return i>a.depth?t(e,n,a.nodeAfter,a.before(i),r,!0):t(e,n,a.node(i),a.before(i),r,!1)}))return{v:!0}},c=a.depth+1;c>0;c--)if(o=s(c))return o.v;return!1}function rv(e,t,n){if(e.focused||e.focus(),!e.state.selection.eq(t)){var i=e.state.tr.setSelection(t);"pointer"==n&&i.setMeta("pointer",!0),e.dispatch(i)}}function ov(e,t,n,i,r){return iv(e,"handleClickOn",t,n,i)||e.someProp("handleClick",function(n){return n(e,t,i)})||(r?function(e,t){if(-1==t)return!1;var n,i,r=e.state.selection;r instanceof ph&&(n=r.node);for(var o=e.state.doc.resolve(t),a=o.depth+1;a>0;a--){var s=a>o.depth?o.nodeAfter:o.node(a);if(ph.isSelectable(s)){i=n&&r.$from.depth>0&&a>=r.$from.depth&&o.before(r.$from.depth+1)==r.$from.pos?o.before(r.$from.depth):o.before(a);break}}return null!=i&&(rv(e,ph.create(e.state.doc,i),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;var n=e.state.doc.resolve(t),i=n.nodeAfter;return!!(i&&i.isAtom&&ph.isSelectable(i))&&(rv(e,new ph(n),"pointer"),!0)}(e,n))}function av(e,t,n,i){return iv(e,"handleDoubleClickOn",t,n,i)||e.someProp("handleDoubleClick",function(n){return n(e,t,i)})}function sv(e,t,n,i){return iv(e,"handleTripleClickOn",t,n,i)||e.someProp("handleTripleClick",function(n){return n(e,t,i)})||function(e,t,n){if(0!=n.button)return!1;var i=e.state.doc;if(-1==t)return!!i.inlineContent&&(rv(e,hh.create(i,0,i.content.size),"pointer"),!0);for(var r=i.resolve(t),o=r.depth+1;o>0;o--){var a=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(a.inlineContent)rv(e,hh.create(i,s+1,s+1+a.content.size),"pointer");else{if(!ph.isSelectable(a))continue;rv(e,ph.create(i,s),"pointer")}return!0}}(e,n,i)}function cv(e){return mv(e)}Yp.keydown=function(e,t){var n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!dv(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!kf||!ff||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!mf||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",function(t){return t(e,n)})||zp(e,n)?n.preventDefault():Zp(e,"key");else{var i=Date.now();e.input.lastIOSEnter=i,e.input.lastIOSEnterFallbackTimeout=setTimeout(function(){e.input.lastIOSEnter==i&&(e.someProp("handleKeyDown",function(t){return t(e,tf(13,"Enter"))}),e.input.lastIOSEnter=0)},200)}},Yp.keyup=function(e,t){16==t.keyCode&&(e.input.shiftKey=!1)},Yp.keypress=function(e,t){var n=t;if(!(dv(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||gf&&n.metaKey))if(e.someProp("handleKeyPress",function(t){return t(e,n)}))n.preventDefault();else{var i=e.state.selection;if(!(i instanceof hh&&i.$from.sameParent(i.$to))){var r=String.fromCharCode(n.charCode),o=function(){return e.state.tr.insertText(r).scrollIntoView()};/[\r\n]/.test(r)||e.someProp("handleTextInput",function(t){return t(e,i.$from.pos,i.$to.pos,r,o)})||e.dispatch(o()),n.preventDefault()}}};var lv=gf?"metaKey":"ctrlKey";Gp.mousedown=function(e,t){var n=t;e.input.shiftKey=n.shiftKey;var i=cv(e),r=Date.now(),o="singleClick";r-e.input.lastClick.time<500&&function(e,t){var n=t.x-e.clientX,i=t.y-e.clientY;return n*n+i*i<100}(n,e.input.lastClick)&&!n[lv]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?o="doubleClick":"doubleClick"==e.input.lastClick.type&&(o="tripleClick")),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:o,button:n.button};var a=e.posAtCoords(nv(n));a&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new uv(e,a,n,!!i)):("doubleClick"==o?av:sv)(e,a.pos,a.inside,n)?n.preventDefault():Zp(e,"pointer"))};var uv=function(){return x(function e(t,n,i,r){var o,a,s=this;if(C(this,e),this.view=t,this.pos=n,this.event=i,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!i[lv],this.allowDefault=i.shiftKey,n.inside>-1)o=t.state.doc.nodeAt(n.inside),a=n.inside;else{var c=t.state.doc.resolve(n.pos);o=c.parent,a=c.depth?c.before():0}var l=r?null:i.target,u=l?t.docView.nearestDesc(l,!0):null;this.target=u&&1==u.nodeDOM.nodeType?u.nodeDOM:null;var d=t.state.selection;(0==i.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||d instanceof ph&&d.from<=a&&d.to>a)&&(this.mightDrag={node:o,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!df||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(function(){s.view.input.mouseDown==s&&s.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Zp(t,"pointer")},[{key:"done",value:function(){var e=this;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(function(){return pp(e.view)}),this.view.input.mouseDown=null}},{key:"up",value:function(e){if(this.done(),this.view.dom.contains(e.target)){var t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(nv(e))),this.updateAllowDefault(e),this.allowDefault||!t?Zp(this.view,"pointer"):ov(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||vf&&this.mightDrag&&!this.mightDrag.node.isAtom||ff&&!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)?(rv(this.view,ch.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Zp(this.view,"pointer")}}},{key:"move",value:function(e){this.updateAllowDefault(e),Zp(this.view,"pointer"),0==e.buttons&&this.done()}},{key:"updateAllowDefault",value:function(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}])}();function dv(e,t){return!!e.composing||!!(vf&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Gp.touchstart=function(e){e.input.lastTouch=Date.now(),cv(e),Zp(e,"pointer")},Gp.touchmove=function(e){e.input.lastTouch=Date.now(),Zp(e,"pointer")},Gp.contextmenu=function(e){return cv(e)};var hv=kf?5e3:-1;function fv(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(function(){return mv(e)},t))}function pv(e){var t;for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function vv(e){var t=e.domSelectionRange();if(!t.focusNode)return null;var n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Qh(e=e.childNodes[t-1])}else{if(!e.parentNode||Zh(e))return null;t=Uh(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),i=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Zh(e))return null;t=Uh(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&i&&n!=i){var r=i.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||i==o)return o;if(!r||!r.isText(i.nodeValue))return i;if(e.input.compositionNode==i){var a=n.pmViewDesc;if(a&&a.isText(n.nodeValue))return i}}return n||i}function mv(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(kf&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),pv(e),t||e.docView&&e.docView.dirty){var n=hp(e),i=e.state.selection;return n&&!n.eq(i)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Yp.compositionstart=Yp.compositionupdate=function(e){if(!e.composing){e.domObserver.flush();var t=e.state,n=t.selection.$to;if(t.selection instanceof hh&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(function(e){return!1===e.type.spec.inclusive})||ff&&yf&&function(e){var t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n||1!=n.nodeType||i>=n.childNodes.length)return!1;var r=n.childNodes[i];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),mv(e,!0),e.markCursor=null;else if(mv(e,!t.selection.empty),df&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var i=e.domSelectionRange(),r=i.focusNode,o=i.focusOffset;r&&1==r.nodeType&&0!=o;){var a=o<0?r.lastChild:r.childNodes[o-1];if(!a)break;if(3==a.nodeType){var s=e.domSelection();s&&s.collapse(a,a.nodeValue.length);break}r=a,o=-1}e.input.composing=!0}fv(e,hv)},Yp.compositionend=function(e,t){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(function(){return e.domObserver.flush()}),e.input.compositionID++,fv(e,20))};var gv=lf&&uf<15||mf&&bf<604;function yv(e,t,n,i,r){var o=Bp(e,t,n,i,e.state.selection.$from);if(e.someProp("handlePaste",function(t){return t(e,r,o||vu.empty)}))return!0;if(!o)return!1;var a=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(o),s=a?e.state.tr.replaceSelectionWith(a,i):e.state.tr.replaceSelection(o);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function kv(e){var t=e.getData("text/plain")||e.getData("Text");if(t)return t;var n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Gp.copy=Yp.cut=function(e,t){var n=t,i=e.state.selection,r="cut"==n.type;if(!i.empty){var o=gv?null:n.clipboardData,a=Pp(e,i.content()),s=a.dom,c=a.text;o?(n.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",c)):function(e,t){if(e.dom.parentNode){var n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";var i=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(function(){n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}}(e,s),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},Yp.paste=function(e,t){var n=t;if(!e.composing||kf){var i=gv?null:n.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;i&&yv(e,kv(i),i.getData("text/html"),r,n)?n.preventDefault():function(e,t){if(e.dom.parentNode){var n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,i=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();var r=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(function(){e.focus(),i.parentNode&&i.parentNode.removeChild(i),n?yv(e,i.value,null,r,t):yv(e,i.textContent,i.innerHTML,r,t)},50)}}(e,n)}};var wv=x(function e(t,n,i){C(this,e),this.slice=t,this.move=n,this.node=i}),bv=gf?"altKey":"ctrlKey";function Cv(e,t){var n=e.someProp("dragCopies",function(e){return!e(t)});return null!=n?n:!t[bv]}for(var Sv in Gp.dragstart=function(e,t){var n=t,i=e.input.mouseDown;if(i&&i.done(),n.dataTransfer){var r,o=e.state.selection,a=o.empty?null:e.posAtCoords(nv(n));if(a&&a.pos>=o.from&&a.pos<=(o instanceof ph?o.to-1:o.to));else if(i&&i.mightDrag)r=ph.create(e.state.doc,i.mightDrag.pos);else if(n.target&&1==n.target.nodeType){var s=e.docView.nearestDesc(n.target,!0);s&&s.node.type.spec.draggable&&s!=e.docView&&(r=ph.create(e.state.doc,s.posBefore))}var c=Pp(e,(r||e.state.selection).content()),l=c.dom,u=c.text,d=c.slice;(!n.dataTransfer.files.length||!ff||pf>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(gv?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",gv||n.dataTransfer.setData("text/plain",u),e.dragging=new wv(d,Cv(e,n),r)}},Gp.dragend=function(e){var t=e.dragging;window.setTimeout(function(){e.dragging==t&&(e.dragging=null)},50)},Yp.dragover=Yp.dragenter=function(e,t){return t.preventDefault()},Yp.drop=function(e,t){try{!function(e,t,n){if(!t.dataTransfer)return;var i=e.posAtCoords(nv(t));if(!i)return;var r=e.state.doc.resolve(i.pos),o=n&&n.slice;o?e.someProp("transformPasted",function(t){o=t(o,e,!1)}):o=Bp(e,kv(t.dataTransfer),gv?null:t.dataTransfer.getData("text/html"),!1,r);var a=!(!n||!Cv(e,t));if(e.someProp("handleDrop",function(n){return n(e,t,o||vu.empty,a)}))return void t.preventDefault();if(!o)return;t.preventDefault();var s=o?Ud(e.state.doc,r.pos,o):r.pos;null==s&&(s=r.pos);var c=e.state.tr;if(a){var l=n.node;l?l.replace(c):c.deleteSelection()}var u=c.mapping.map(s),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,h=c.doc;d?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o);if(c.doc.eq(h))return;var f=c.doc.resolve(u);if(d&&ph.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new ph(f));else{var p=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach(function(e,t,n,i){return p=i}),c.setSelection(bp(e,f,c.doc.resolve(p)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Gp.focus=function(e){e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(function(){e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&pp(e)},20))},Gp.blur=function(e,t){var n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Gp.beforeinput=function(e,t){if(ff&&kf&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();var n=e.input.domChangeCount;setTimeout(function(){if(e.input.domChangeCount==n&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",function(t){return t(e,tf(8,"Backspace"))}))){var t=e.state.selection.$cursor;t&&t.pos>0&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView())}},50)}},Yp)Gp[Sv]=Yp[Sv];function xv(e,t){if(e==t)return!0;for(var n in e)if(e[n]!==t[n])return!1;for(var i in t)if(!(i in e))return!1;return!0}var Tv=function(){function e(t,n){C(this,e),this.toDOM=t,this.spec=n||Ev,this.side=this.spec.side||0}return x(e,[{key:"map",value:function(e,t,n,i){var r=e.mapResult(t.from+i,this.side<0?-1:1),o=r.pos;return r.deleted?null:new Nv(o-n,o-n,this)}},{key:"valid",value:function(){return!0}},{key:"eq",value:function(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&xv(this.spec,t.spec))}},{key:"destroy",value:function(e){this.spec.destroy&&this.spec.destroy(e)}}])}(),Mv=function(){function e(t,n){C(this,e),this.attrs=t,this.spec=n||Ev}return x(e,[{key:"map",value:function(e,t,n,i){var r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return r>=o?null:new Nv(r,o,this)}},{key:"valid",value:function(e,t){return t.from<t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&xv(this.attrs,t.attrs)&&xv(this.spec,t.spec)}},{key:"destroy",value:function(){}}],[{key:"is",value:function(t){return t.type instanceof e}}])}(),_v=function(){function e(t,n){C(this,e),this.attrs=t,this.spec=n||Ev}return x(e,[{key:"map",value:function(e,t,n,i){var r=e.mapResult(t.from+i,1);if(r.deleted)return null;var o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=r.pos?null:new Nv(r.pos-n,o.pos-n,this)}},{key:"valid",value:function(e,t){var n,i=e.content.findIndex(t.from),r=i.index,o=i.offset;return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&xv(this.attrs,t.attrs)&&xv(this.spec,t.spec)}},{key:"destroy",value:function(){}}])}(),Nv=function(){function e(t,n,i){C(this,e),this.from=t,this.to=n,this.type=i}return x(e,[{key:"copy",value:function(t,n){return new e(t,n,this.type)}},{key:"eq",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}},{key:"map",value:function(e,t,n){return this.type.map(e,this,t,n)}},{key:"spec",get:function(){return this.type.spec}},{key:"inline",get:function(){return this.type instanceof Mv}},{key:"widget",get:function(){return this.type instanceof Tv}}],[{key:"widget",value:function(t,n,i){return new e(t,t,new Tv(n,i))}},{key:"inline",value:function(t,n,i,r){return new e(t,n,new Mv(i,r))}},{key:"node",value:function(t,n,i,r){return new e(t,n,new _v(i,r))}}])}(),Ov=[],Ev={},Av=function(){function e(t,n){C(this,e),this.local=t.length?t:Ov,this.children=n.length?n:Ov}return x(e,[{key:"find",value:function(e,t,n){var i=[];return this.findInner(null==e?0:e,null==t?1e9:t,i,0,n),i}},{key:"findInner",value:function(e,t,n,i,r){for(var o=0;o<this.local.length;o++){var a=this.local[o];a.from<=t&&a.to>=e&&(!r||r(a.spec))&&n.push(a.copy(a.from+i,a.to+i))}for(var s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){var c=this.children[s]+1;this.children[s+2].findInner(e-c,t-c,n,i+c,r)}}},{key:"map",value:function(e,t,n){return this==Dv||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Ev)}},{key:"mapInner",value:function(t,n,i,r,o){for(var a,s=0;s<this.local.length;s++){var c=this.local[s].map(t,i,r);c&&c.type.valid(n,c)?(a||(a=[])).push(c):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?Lv(this.children,a||[],t,n,i,r,o):a?new e(a.sort(Fv),Ov):Dv}},{key:"add",value:function(t,n){return n.length?this==Dv?e.create(t,n):this.addInner(t,n,0):this}},{key:"addInner",value:function(t,n,i){var r,o=this,a=0;t.forEach(function(e,t){var s,c=t+i;if(s=zv(n,e,c)){for(r||(r=o.children.slice());a<r.length&&r[a]<t;)a+=3;r[a]==t?r[a+2]=r[a+2].addInner(e,s,c+1):r.splice(a,0,t,t+e.nodeSize,Bv(s,e,c+1,Ev)),a+=3}});for(var s=Rv(a?Pv(n):n,-i),c=0;c<s.length;c++)s[c].type.valid(t,s[c])||s.splice(c--,1);return new e(s.length?this.local.concat(s).sort(Fv):this.local,r||this.children)}},{key:"remove",value:function(e){return 0==e.length||this==Dv?this:this.removeInner(e,0)}},{key:"removeInner",value:function(t,n){for(var i=this.children,r=this.local,o=0;o<i.length;o+=3){for(var a,s=void 0,c=i[o]+n,l=i[o+1]+n,u=0;u<t.length;u++)(a=t[u])&&a.from>c&&a.to<l&&(t[u]=null,(s||(s=[])).push(a));if(s){i==this.children&&(i=this.children.slice());var d=i[o+2].removeInner(s,c+1);d!=Dv?i[o+2]=d:(i.splice(o,3),o-=3)}}if(r.length)for(var h,f=0;f<t.length;f++)if(h=t[f])for(var p=0;p<r.length;p++)r[p].eq(h,n)&&(r==this.local&&(r=this.local.slice()),r.splice(p--,1));return i==this.children&&r==this.local?this:r.length||i.length?new e(r,i):Dv}},{key:"forChild",value:function(t,n){if(this==Dv)return this;if(n.isLeaf)return e.empty;for(var i,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(i=this.children[o+2]);break}for(var a=t+1,s=a+n.content.size,c=0;c<this.local.length;c++){var l=this.local[c];if(l.from<s&&l.to>a&&l.type instanceof Mv){var u=Math.max(a,l.from)-a,d=Math.min(s,l.to)-a;u<d&&(r||(r=[])).push(l.copy(u,d))}}if(r){var h=new e(r.sort(Fv),Ov);return i?new Iv([h,i]):h}return i||Dv}},{key:"eq",value:function(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(var i=0;i<this.children.length;i+=3)if(this.children[i]!=t.children[i]||this.children[i+1]!=t.children[i+1]||!this.children[i+2].eq(t.children[i+2]))return!1;return!0}},{key:"locals",value:function(e){return Hv(this.localsInner(e))}},{key:"localsInner",value:function(e){if(this==Dv)return Ov;if(e.inlineContent||!this.local.some(Mv.is))return this.local;for(var t=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Mv||t.push(this.local[n]);return t}},{key:"forEachSet",value:function(e){e(this)}}],[{key:"create",value:function(e,t){return t.length?Bv(t,e,0,Ev):Dv}}])}();Av.empty=new Av([],[]),Av.removeOverlap=Hv;var Dv=Av.empty,Iv=function(){function e(t){C(this,e),this.members=t}return x(e,[{key:"map",value:function(t,n){var i=this.members.map(function(e){return e.map(t,n,Ev)});return e.from(i)}},{key:"forChild",value:function(t,n){if(n.isLeaf)return Av.empty;for(var i=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,n);o!=Dv&&(o instanceof e?i=i.concat(o.members):i.push(o))}return e.from(i)}},{key:"eq",value:function(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(var n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}},{key:"locals",value:function(e){for(var t,n=!0,i=0;i<this.members.length;i++){var r=this.members[i].localsInner(e);if(r.length)if(t){n&&(t=t.slice(),n=!1);for(var o=0;o<r.length;o++)t.push(r[o])}else t=r}return t?Hv(n?t:t.sort(Fv)):Ov}},{key:"forEachSet",value:function(e){for(var t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}],[{key:"from",value:function(t){switch(t.length){case 0:return Dv;case 1:return t[0];default:return new e(t.every(function(e){return e instanceof Av})?t:t.reduce(function(e,t){return e.concat(t instanceof Av?t:t.members)},[]))}}}])}();function Lv(e,t,n,i,r,o,a){for(var s=e.slice(),c=function(e){var t=0;n.maps[l].forEach(function(n,i,r,o){for(var a=o-r-(i-n),c=0;c<s.length;c+=3){var l=s[c+1];if(!(l<0||n>l+e-t)){var u=s[c]+e-t;i>=u?s[c+1]=n<=u?-2:-1:n>=e&&a&&(s[c]+=a,s[c+1]+=a)}}t+=a}),e=n.maps[l].map(e,-1),u=e},l=0,u=o;l<n.maps.length;l++)c(u);for(var d=!1,h=0;h<s.length;h+=3)if(s[h+1]<0){if(-2==s[h+1]){d=!0,s[h+1]=-1;continue}var f=n.map(e[h]+o),p=f-r;if(p<0||p>=i.content.size){d=!0;continue}var v=n.map(e[h+1]+o,-1)-r,m=i.content.findIndex(p),g=m.index,y=m.offset,k=i.maybeChild(g);if(k&&y==p&&y+k.nodeSize==v){var w=s[h+2].mapInner(n,k,f+1,e[h]+o+1,a);w!=Dv?(s[h]=p,s[h+1]=v,s[h+2]=w):(s[h+1]=-2,d=!0)}else d=!0}if(d){var b=function(e,t,n,i,r,o,a){function s(e,t){for(var o=0;o<e.local.length;o++){var c=e.local[o].map(i,r,t);c?n.push(c):a.onRemove&&a.onRemove(e.local[o].spec)}for(var l=0;l<e.children.length;l+=3)s(e.children[l+2],e.children[l]+t+1)}for(var c=0;c<e.length;c+=3)-1==e[c+1]&&s(e[c+2],t[c]+o+1);return n}(s,e,t,n,r,o,a),C=Bv(b,i,0,a);t=C.local;for(var S=0;S<s.length;S+=3)s[S+1]<0&&(s.splice(S,3),S-=3);for(var x=0,T=0;x<C.children.length;x+=3){for(var M=C.children[x];T<s.length&&s[T]<M;)T+=3;s.splice(T,0,C.children[x],C.children[x+1],C.children[x+2])}}return new Av(t.sort(Fv),s)}function Rv(e,t){if(!t||!e.length)return e;for(var n=[],i=0;i<e.length;i++){var r=e[i];n.push(new Nv(r.from+t,r.to+t,r.type))}return n}function zv(e,t,n){if(t.isLeaf)return null;for(var i,r=n+t.nodeSize,o=null,a=0;a<e.length;a++)(i=e[a])&&i.from>n&&i.to<r&&((o||(o=[])).push(i),e[a]=null);return o}function Pv(e){for(var t=[],n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Bv(e,t,n,i){var r=[],o=!1;t.forEach(function(t,a){var s=zv(e,t,a+n);if(s){o=!0;var c=Bv(s,t,n+a+1,i);c!=Dv&&r.push(a,a+t.nodeSize,c)}});for(var a=Rv(o?Pv(e):e,-n).sort(Fv),s=0;s<a.length;s++)a[s].type.valid(t,a[s])||(i.onRemove&&i.onRemove(a[s].spec),a.splice(s--,1));return a.length||r.length?new Av(a,r):Dv}function Fv(e,t){return e.from-t.from||e.to-t.to}function Hv(e){for(var t=e,n=0;n<t.length-1;n++){var i=t[n];if(i.from!=i.to)for(var r=n+1;r<t.length;r++){var o=t[r];if(o.from!=i.from){o.from<i.to&&(t==e&&(t=e.slice()),t[n]=i.copy(i.from,o.from),jv(t,r,i.copy(o.from,i.to)));break}o.to!=i.to&&(t==e&&(t=e.slice()),t[r]=o.copy(o.from,i.to),jv(t,r+1,o.copy(i.to,o.to)))}}return t}function jv(e,t,n){for(;t<e.length&&Fv(n,e[t])>0;)t++;e.splice(t,0,n)}function Vv(e){var t=[];return e.someProp("decorations",function(n){var i=n(e.state);i&&i!=Dv&&t.push(i)}),e.cursorWrapper&&t.push(Av.create(e.state.doc,[e.cursorWrapper.deco])),Iv.from(t)}var Wv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},$v=lf&&uf<=11,Uv=function(){return x(function e(){C(this,e),this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0},[{key:"set",value:function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}},{key:"clear",value:function(){this.anchorNode=this.focusNode=null}},{key:"eq",value:function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}])}(),qv=function(){return x(function e(t,n){var i=this;C(this,e),this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Uv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(function(e){for(var t=0;t<e.length;t++)i.queue.push(e[t]);lf&&uf<=11&&e.some(function(e){return"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length})?i.flushSoon():i.flush()}),$v&&(this.onCharData=function(e){i.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),i.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)},[{key:"flushSoon",value:function(){var e=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(function(){e.flushingSoon=-1,e.flush()},20))}},{key:"forceFlush",value:function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}},{key:"start",value:function(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Wv)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}},{key:"stop",value:function(){var e=this;if(this.observer){var t=this.observer.takeRecords();if(t.length){for(var n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout(function(){return e.flush()},20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}},{key:"connectSelection",value:function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}},{key:"disconnectSelection",value:function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"suppressSelectionUpdates",value:function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout(function(){return e.suppressingSelectionUpdates=!1},50)}},{key:"onSelectionChange",value:function(){if(Cp(this.view)){if(this.suppressingSelectionUpdates)return pp(this.view);if(lf&&uf<=11&&!this.view.state.selection.empty){var e=this.view.domSelectionRange();if(e.focusNode&&Gh(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}},{key:"setCurSelection",value:function(){this.currentSelection.set(this.view.domSelectionRange())}},{key:"ignoreSelectionChange",value:function(e){if(!e.focusNode)return!0;for(var t,n=new Set,i=e.focusNode;i;i=qh(i))n.add(i);for(var r=e.anchorNode;r;r=qh(r))if(n.has(r)){t=r;break}var o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}},{key:"pendingRecords",value:function(){if(this.observer){var e,t=m(this.observer.takeRecords());try{for(t.s();!(e=t.n()).done;){var n=e.value;this.queue.push(n)}}catch(i){t.e(i)}finally{t.f()}}return this.queue}},{key:"flush",value:function(){var e=this.view;if(e.docView&&!(this.flushingSoon>-1)){var t=this.pendingRecords();t.length&&(this.queue=[]);var n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Cp(e)&&!this.ignoreSelectionChange(n),r=-1,o=-1,a=!1,s=[];if(e.editable)for(var c=0;c<t.length;c++){var l=this.registerMutation(t[c],s);l&&(r=r<0?l.from:Math.min(l.from,r),o=o<0?l.to:Math.max(l.to,o),l.typeOver&&(a=!0))}if(df&&s.length){var u=s.filter(function(e){return"BR"==e.nodeName});if(2==u.length){var d=g(u,2),h=d[0],f=d[1];h.parentNode&&h.parentNode.parentNode==f.parentNode?f.remove():h.remove()}else{var p,v=this.currentSelection.focusNode,y=m(u);try{for(y.s();!(p=y.n()).done;){var k=p.value,w=k.parentNode;!w||"LI"!=w.nodeName||v&&Yv(e,v)==w||k.remove()}}catch(M){y.e(M)}finally{y.f()}}}else if((ff||vf)&&s.some(function(e){return"BR"==e.nodeName})&&(8==e.input.lastKeyCode||46==e.input.lastKeyCode)){var b,C=m(s);try{for(C.s();!(b=C.n()).done;){var S=b.value;if("BR"==S.nodeName&&S.parentNode){var x=S.nextSibling;x&&1==x.nodeType&&"false"==x.contentEditable&&S.parentNode.removeChild(S)}}}catch(M){C.e(M)}finally{C.f()}}var T=null;r<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ef(n)&&(T=hp(e))&&T.eq(ch.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,pp(e),this.currentSelection.set(n),e.scrollToSelection()):(r>-1||i)&&(r>-1&&(e.docView.markDirty(r,o),function(e){if(Kv.has(e))return;if(Kv.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=df,Jv)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."),Jv=!0}}(e)),this.handleDOMChange(r,o,a,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||pp(e),this.currentSelection.set(n))}}},{key:"registerMutation",value:function(e,t){if(t.indexOf(e.target)>-1)return null;var n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(var i=0;i<e.addedNodes.length;i++){var r=e.addedNodes[i];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};var o=e.previousSibling,a=e.nextSibling;if(lf&&uf<=11&&e.addedNodes.length)for(var s=0;s<e.addedNodes.length;s++){var c=e.addedNodes[s],l=c.previousSibling,u=c.nextSibling;(!l||Array.prototype.indexOf.call(e.addedNodes,l)<0)&&(o=l),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(a=u)}var d=o&&o.parentNode==e.target?Uh(o)+1:0,h=n.localPosFromDOM(e.target,d,-1),f=a&&a.parentNode==e.target?Uh(a):e.target.childNodes.length;return{from:h,to:n.localPosFromDOM(e.target,f,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}])}(),Kv=new WeakMap,Jv=!1;function Gv(e,t){var n=t.startContainer,i=t.startOffset,r=t.endContainer,o=t.endOffset,a=e.domAtPos(e.state.selection.anchor);if(Gh(a.node,a.offset,r,o)){var s=[r,o,n,i];n=s[0],i=s[1],r=s[2],o=s[3]}return{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}}function Yv(e,t){for(var n=t.parentNode;n&&n!=e.dom;n=n.parentNode){var i=e.docView.nearestDesc(n,!0);if(i&&i.node.isBlock)return n}return null}function Xv(e){var t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(vf&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(e.parentNode.lastChild==e||vf&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Qv=/^(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 Zv(e,t,n,i,r){var o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){var a=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,s=hp(e,a);if(s&&!e.state.selection.eq(s)){if(ff&&kf&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",function(t){return t(e,tf(13,"Enter"))}))return;var c=e.state.tr.setSelection(s);"pointer"==a?c.setMeta("pointer",!0):"key"==a&&c.scrollIntoView(),o&&c.setMeta("composition",o),e.dispatch(c)}}else{var l=e.state.doc.resolve(t),u=l.sharedDepth(n);t=l.before(u+1),n=e.state.doc.resolve(n).after(u+1);var d,h,f=e.state.selection,p=function(e,t,n){var i,r=e.docView.parseRange(t,n),o=r.node,a=r.fromOffset,s=r.toOffset,c=r.from,l=r.to,u=e.domSelectionRange(),d=u.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(i=[{node:d,offset:u.anchorOffset}],ef(u)||i.push({node:u.focusNode,offset:u.focusOffset})),ff&&8===e.input.lastKeyCode)for(var h=s;h>a;h--){var f=o.childNodes[h-1],p=f.pmViewDesc;if("BR"==f.nodeName&&!p){s=h;break}if(!p||p.size)break}var v=e.state.doc,m=e.someProp("domParser")||td.fromSchema(e.state.schema),g=v.resolve(c),y=null,k=m.parse(o,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:a,to:s,preserveWhitespace:"pre"!=g.parent.type.whitespace||"full",findPositions:i,ruleFromNode:Xv,context:g});if(i&&null!=i[0].pos){var w=i[0].pos,b=i[1]&&i[1].pos;null==b&&(b=w),y={anchor:w+c,head:b+c}}return{doc:k,sel:y,from:c,to:l}}(e,t,n),v=e.state.doc,m=v.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(d=e.state.selection.to,h="end"):(d=e.state.selection.from,h="start"),e.input.lastKeyCode=null;var g=function(e,t,n,i,r){var o=e.findDiffStart(t,n);if(null==o)return null;var a=e.findDiffEnd(t,n+e.size,n+t.size),s=a.a,c=a.b;if("end"==r){i-=s+Math.max(0,o-Math.min(s,c))-o}if(s<o&&e.size<t.size){var l=i<=o&&i>=s?o-i:0;(o-=l)&&o<t.size&&nm(t.textBetween(o-1,o+1))&&(o+=l?1:-1),c=o+(c-s),s=o}else if(c<o){var u=i<=o&&i>=c?o-i:0;(o-=u)&&o<e.size&&nm(e.textBetween(o-1,o+1))&&(o+=u?1:-1),s=o+(s-c),c=o}return{start:o,endA:s,endB:c}}(m.content,p.doc.content,p.from,d,h);if(g&&e.input.domChangeCount++,(mf&&e.input.lastIOSEnter>Date.now()-225||kf)&&r.some(function(e){return 1==e.nodeType&&!Qv.test(e.nodeName)})&&(!g||g.endA>=g.endB)&&e.someProp("handleKeyDown",function(t){return t(e,tf(13,"Enter"))}))e.input.lastIOSEnter=0;else{if(!g){if(!(i&&f instanceof hh&&!f.empty&&f.$head.sameParent(f.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){var y=em(e,e.state.doc,p.sel);if(y&&!y.eq(e.state.selection)){var k=e.state.tr.setSelection(y);o&&k.setMeta("composition",o),e.dispatch(k)}}return}g={start:f.from,endA:f.to,endB:f.to}}e.state.selection.from<e.state.selection.to&&g.start==g.endB&&e.state.selection instanceof hh&&(g.start>e.state.selection.from&&g.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?g.start=e.state.selection.from:g.endA<e.state.selection.to&&g.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(g.endB+=e.state.selection.to-g.endA,g.endA=e.state.selection.to)),lf&&uf<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>p.from&&"  "==p.doc.textBetween(g.start-p.from-1,g.start-p.from+1)&&(g.start--,g.endA--,g.endB--);var w=p.doc.resolveNoCache(g.start-p.from),b=p.doc.resolveNoCache(g.endB-p.from),C=v.resolve(g.start),S=w.sameParent(b)&&w.parent.inlineContent&&C.end()>=g.endA;if((mf&&e.input.lastIOSEnter>Date.now()-225&&(!S||r.some(function(e){return"DIV"==e.nodeName||"P"==e.nodeName}))||!S&&w.pos<p.doc.content.size&&(!w.sameParent(b)||!w.parent.inlineContent)&&w.pos<b.pos&&!/\S/.test(p.doc.textBetween(w.pos,b.pos,"","")))&&e.someProp("handleKeyDown",function(t){return t(e,tf(13,"Enter"))}))e.input.lastIOSEnter=0;else if(e.state.selection.anchor>g.start&&function(e,t,n,i,r){if(n-t<=r.pos-i.pos||tm(i,!0,!1)<r.pos)return!1;var o=e.resolve(t);if(!i.parent.isTextblock){var a=o.nodeAfter;return null!=a&&n==t+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;var s=e.resolve(tm(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||tm(s,!0,!1)<n)&&i.parent.content.cut(i.parentOffset).eq(s.parent.content)}(v,g.start,g.endA,w,b)&&e.someProp("handleKeyDown",function(t){return t(e,tf(8,"Backspace"))}))kf&&ff&&e.domObserver.suppressSelectionUpdates();else{ff&&g.endB==g.start&&(e.input.lastChromeDelete=Date.now()),kf&&!S&&w.start()!=b.start()&&0==b.parentOffset&&w.depth==b.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==g.endA&&(g.endB-=2,b=p.doc.resolveNoCache(g.endB-p.from),setTimeout(function(){e.someProp("handleKeyDown",function(t){return t(e,tf(13,"Enter"))})},20));var x,T=g.start,M=g.endA,_=function(t){var n=t||e.state.tr.replace(T,M,p.doc.slice(g.start-p.from,g.endB-p.from));if(p.sel){var i=em(e,n.doc,p.sel);i&&!(ff&&e.composing&&i.empty&&(g.start!=g.endB||e.input.lastChromeDelete<Date.now()-100)&&(i.head==T||i.head==n.mapping.map(M)-1)||lf&&i.empty&&i.head==T)&&n.setSelection(i)}return o&&n.setMeta("composition",o),n.scrollIntoView()};if(S)if(w.pos==b.pos){lf&&uf<=11&&0==w.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(function(){return pp(e)},20));var N=_(e.state.tr.delete(T,M)),O=v.resolve(g.start).marksAcross(v.resolve(g.endA));O&&N.ensureMarks(O),e.dispatch(N)}else if(g.endA==g.endB&&(x=function(e,t){for(var n,i,r,o=e.firstChild.marks,a=t.firstChild.marks,s=o,c=a,l=0;l<a.length;l++)s=a[l].removeFromSet(s);for(var u=0;u<o.length;u++)c=o[u].removeFromSet(c);if(1==s.length&&0==c.length)i=s[0],n="add",r=function(e){return e.mark(i.addToSet(e.marks))};else{if(0!=s.length||1!=c.length)return null;i=c[0],n="remove",r=function(e){return e.mark(i.removeFromSet(e.marks))}}for(var d=[],h=0;h<t.childCount;h++)d.push(r(t.child(h)));if(lu.from(d).eq(e))return{mark:i,type:n}}(w.parent.content.cut(w.parentOffset,b.parentOffset),C.parent.content.cut(C.parentOffset,g.endA-C.start())))){var E=_(e.state.tr);"add"==x.type?E.addMark(T,M,x.mark):E.removeMark(T,M,x.mark),e.dispatch(E)}else if(w.parent.child(w.index()).isText&&w.index()==b.index()-(b.textOffset?0:1)){var A=w.parent.textBetween(w.parentOffset,b.parentOffset),D=function(){return _(e.state.tr.insertText(A,T,M))};e.someProp("handleTextInput",function(t){return t(e,T,M,A,D)})||e.dispatch(D())}else e.dispatch(_());else e.dispatch(_())}}}}function em(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:bp(e,t.resolve(n.anchor),t.resolve(n.head))}function tm(e,t,n){for(var i=e.depth,r=t?e.end():e.pos;i>0&&(t||e.indexAfter(i)==e.node(i).childCount);)i--,r++,t=!1;if(n)for(var o=e.node(i).maybeChild(e.indexAfter(i));o&&!o.isLeaf;)o=o.firstChild,r++;return r}function nm(e){if(2!=e.length)return!1;var t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var im=function(){return x(function e(t,n){var i=this;C(this,e),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 Qp,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(cm),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=am(this),om(this),this.nodeViews=sm(this),this.docView=Yf(this.state.doc,rm(this),Vv(this),this.dom,this),this.domObserver=new qv(this,function(e,t,n,r){return Zv(i,e,t,n,r)}),this.domObserver.start(),function(e){var t=function(){var t=Gp[n];e.dom.addEventListener(n,e.input.eventHandlers[n]=function(n){!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,n)||tv(e,n)||!e.editable&&n.type in Yp||t(e,n)},Xp[n]?{passive:!0}:void 0)};for(var n in Gp)t();vf&&e.dom.addEventListener("input",function(){return null}),ev(e)}(this),this.updatePluginViews()},[{key:"composing",get:function(){return this.input.composing}},{key:"props",get:function(){if(this._props.state!=this.state){var e=this._props;for(var t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}},{key:"update",value:function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ev(this);var t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(cm),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}},{key:"setProps",value:function(e){var t={};for(var n in this._props)t[n]=this._props[n];for(var i in t.state=this.state,e)t[i]=e[i];this.update(t)}},{key:"updateState",value:function(e){this.updateStateInner(e,this._props)}},{key:"updateStateInner",value:function(e,t){var n,i=this.state,r=!1,o=!1;e.storedMarks&&this.composing&&(pv(this),o=!0),this.state=e;var a=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){var s=sm(this);(function(e,t){var n=0,i=0;for(var r in e){if(e[r]!=t[r])return!0;n++}for(var o in t)i++;return n!=i})(s,this.nodeViews)&&(this.nodeViews=s,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&ev(this),this.editable=am(this),om(this);var c=Vv(this),l=rm(this),u=i.plugins==e.plugins||i.doc.eq(e.doc)?e.scrollToSelection>i.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(e.doc,l,c);!d&&e.selection.eq(i.selection)||(o=!0);var h,f,p,v,m,g,y,k,w,b,C,S="preserve"==u&&o&&null==this.dom.style.overflowAnchor&&function(e){for(var t,n,i=e.dom.getBoundingClientRect(),r=Math.max(0,i.top),o=(i.left+i.right)/2,a=r+1;a<Math.min(innerHeight,i.bottom);a+=5){var s=e.root.elementFromPoint(o,a);if(s&&s!=e.dom&&e.dom.contains(s)){var c=s.getBoundingClientRect();if(c.top>=r-20){t=s,n=c.top;break}}}return{refDOM:t,refTop:n,stack:Mf(e.dom)}}(this);if(o){this.domObserver.stop();var x=d&&(lf||ff)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&(v=i.selection,m=e.selection,g=Math.min(v.$anchor.sharedDepth(v.head),m.$anchor.sharedDepth(m.head)),v.$anchor.start(g)!=m.$anchor.start(g));if(d){var T=ff?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=vv(this)),!r&&this.docView.update(e.doc,l,c,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=Yf(e.doc,l,c,this.dom,this)),T&&!this.trackWrites&&(x=!0)}x||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(h=this,f=h.docView.domFromPos(h.state.selection.anchor,0),p=h.domSelectionRange(),Gh(f.node,f.offset,p.anchorNode,p.anchorOffset)))?pp(this,x):(kp(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),"reset"==u?this.dom.scrollTop=0:"to selection"==u?this.scrollToSelection():S&&(k=(y=S).refDOM,w=y.refTop,b=y.stack,C=k?k.getBoundingClientRect().top:0,_f(b,0==C?0:C-w))}},{key:"scrollToSelection",value:function(){var e=this,t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",function(t){return t(e)}));else if(this.state.selection instanceof ph){var n=this.docView.domAfterPos(this.state.selection.from);1==n.nodeType&&Tf(this,n.getBoundingClientRect(),t)}else Tf(this,this.coordsAtPos(this.state.selection.head,1),t);else;}},{key:"destroyPluginViews",value:function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()}},{key:"updatePluginViews",value:function(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var t=0;t<this.pluginViews.length;t++){var n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(var i=0;i<this.directPlugins.length;i++){var r=this.directPlugins[i];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(var o=0;o<this.state.plugins.length;o++){var a=this.state.plugins[o];a.spec.view&&this.pluginViews.push(a.spec.view(this))}}}},{key:"updateDraggedNode",value:function(e,t){var n=e.node,i=-1;if(this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{var r=n.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&this.state.doc.nodeAt(r))==n.node&&(i=r)}this.dragging=new wv(e.slice,e.move,i<0?void 0:ph.create(this.state.doc,i))}},{key:"someProp",value:function(e,t){var n,i=this._props&&this._props[e];if(null!=i&&(n=t?t(i):i))return n;for(var r=0;r<this.directPlugins.length;r++){var o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}var a=this.state.plugins;if(a)for(var s=0;s<a.length;s++){var c=a[s].props[e];if(null!=c&&(n=t?t(c):c))return n}}},{key:"hasFocus",value:function(){if(lf){var 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("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}},{key:"focus",value:function(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Nf)return e.focus(Nf);var t=Mf(e);e.focus(null==Nf?{get preventScroll(){return Nf={preventScroll:!0},!0}}:void 0),Nf||(Nf=!1,_f(t,0))}(this.dom),pp(this),this.domObserver.start()}},{key:"root",get:function(){var e=this,t=this._root;if(null==t)for(var n,i=function(t){if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=function(){return t.ownerDocument.getSelection()}),{v:e._root=t}},r=this.dom.parentNode;r;r=r.parentNode)if(n=i(r))return n.v;return t||document}},{key:"updateRoot",value:function(){this._root=null}},{key:"posAtCoords",value:function(e){return Df(this,e)}},{key:"coordsAtPos",value:function(e){return zf(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)}},{key:"domAtPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.docView.domFromPos(e,t)}},{key:"nodeDOM",value:function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null}},{key:"posAtDOM",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=this.docView.posFromDOM(e,t,n);if(null==i)throw new RangeError("DOM position not inside the editor");return i}},{key:"endOfTextblock",value:function(e,t){return $f(this,t||this.state,e)}},{key:"pasteHTML",value:function(e,t){return yv(this,"",e,!1,t||new ClipboardEvent("paste"))}},{key:"pasteText",value:function(e,t){return yv(this,e,null,!0,t||new ClipboardEvent("paste"))}},{key:"serializeForClipboard",value:function(e){return Pp(this,e)}},{key:"destroy",value:function(){this.docView&&(!function(e){for(var t in e.domObserver.stop(),e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Vv(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Kh=null)}},{key:"isDestroyed",get:function(){return null==this.docView}},{key:"dispatchEvent",value:function(e){return function(e,t){tv(e,t)||!Gp[t.type]||!e.editable&&t.type in Yp||Gp[t.type](e,t)}(this,e)}},{key:"domSelectionRange",value:function(){var e=this.domSelection();return e?vf&&11===this.root.nodeType&&function(e){for(var t=e.activeElement;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){var n=t.getComposedRanges(e.root)[0];if(n)return Gv(e,n)}var i;function r(e){e.preventDefault(),e.stopImmediatePropagation(),i=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),i?Gv(e,i):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}},{key:"domSelection",value:function(){return this.root.getSelection()}}])}();function rm(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",function(n){if("function"==typeof n&&(n=n(e.state)),n)for(var i in n)"class"==i?t.class+=" "+n[i]:"style"==i?t.style=(t.style?t.style+";":"")+n[i]:t[i]||"contenteditable"==i||"nodeName"==i||(t[i]=String(n[i]))}),t.translate||(t.translate="no"),[Nv.node(0,e.state.doc.content.size,t)]}function om(e){if(e.markCursor){var t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Nv.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function am(e){return!e.someProp("editable",function(t){return!1===t(e.state)})}function sm(e){var t=Object.create(null);function n(e){for(var n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function cm(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}im.prototype.dispatch=function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var lm={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:"'"},um={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},dm="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),hm="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),fm=0;fm<10;fm++)lm[48+fm]=lm[96+fm]=String(fm);for(fm=1;fm<=24;fm++)lm[fm+111]="F"+fm;for(fm=65;fm<=90;fm++)lm[fm]=String.fromCharCode(fm+32),um[fm]=String.fromCharCode(fm);for(var pm in lm)um.hasOwnProperty(pm)||(um[pm]=lm[pm]);var vm="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),mm="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function gm(e){var t,n,i,r,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"==a&&(a=" ");for(var s=0;s<o.length-1;s++){var c=o[s];if(/^(cmd|meta|m)$/i.test(c))r=!0;else if(/^a(lt)?$/i.test(c))t=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))i=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: "+c);vm?r=!0:n=!0}}return t&&(a="Alt-"+a),n&&(a="Ctrl-"+a),r&&(a="Meta-"+a),i&&(a="Shift-"+a),a}function ym(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function km(e){var t=function(e){var t=Object.create(null);for(var n in e)t[gm(n)]=e[n];return t}(e);return function(e,n){var i,r=function(e){var t=!(dm&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||hm&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?um:lm)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),o=t[ym(r,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){var a=t[ym(r,n,!1)];if(a&&a(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(mm&&n.ctrlKey&&n.altKey)&&(i=lm[n.keyCode])&&i!=r){var s=t[ym(i,n)];if(s&&s(e.state,e.dispatch,e))return!0}}return!1}}var wm=Object.defineProperty,bm=function(e,t){for(var n in t)wm(e,n,{get:t[n],enumerable:!0})};function Cm(e){var t=e.state,n=e.transaction,i=n.selection,r=n.doc,o=n.storedMarks;return d(d({},t),{},{apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return i},get doc(){return r},get tr(){return i=n.selection,r=n.doc,o=n.storedMarks,n}})}var Sm=function(){return x(function e(t){C(this,e),this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state},[{key:"hasCustomState",get:function(){return!!this.customState}},{key:"state",get:function(){return this.customState||this.editor.state}},{key:"commands",get:function(){var e=this,t=this.rawCommands,n=this.editor,i=this.state,r=n.view,o=i.tr,a=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(function(t){var n=g(t,2),i=n[0],s=n[1];return[i,function(){var t=s.apply(void 0,arguments)(a);return o.getMeta("preventDispatch")||e.hasCustomState||r.dispatch(o),t}]}))}},{key:"chain",get:function(){var e=this;return function(){return e.createChain()}}},{key:"can",get:function(){var e=this;return function(){return e.createCan()}}},{key:"createChain",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.rawCommands,r=this.editor,o=this.state,a=r.view,s=[],c=!!e,l=e||o.tr,u=d(d({},Object.fromEntries(Object.entries(i).map(function(e){var i=g(e,2),r=i[0],o=i[1];return[r,function(){var e=t.buildProps(l,n),i=o.apply(void 0,arguments)(e);return s.push(i),u}]}))),{},{run:function(){return c||!n||l.getMeta("preventDispatch")||t.hasCustomState||a.dispatch(l),s.every(function(e){return!0===e})}});return u}},{key:"createCan",value:function(e){var t=this,n=this.rawCommands,i=this.state,r=!1,o=e||i.tr,a=this.buildProps(o,r),s=Object.fromEntries(Object.entries(n).map(function(e){var t=g(e,2),n=t[0],i=t[1];return[n,function(){return i.apply(void 0,arguments)(d(d({},a),{},{dispatch:void 0}))}]}));return d(d({},s),{},{chain:function(){return t.createChain(o,r)}})}},{key:"buildProps",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.rawCommands,r=this.editor,o=this.state,a=r.view,s={tr:e,editor:r,view:a,state:Cm({state:o,transaction:e}),dispatch:n?function(){}:void 0,chain:function(){return t.createChain(e,n)},can:function(){return t.createCan(e)},get commands(){return Object.fromEntries(Object.entries(i).map(function(e){var t=g(e,2),n=t[0],i=t[1];return[n,function(){return i.apply(void 0,arguments)(s)}]}))}};return s}}])}(),xm={};bm(xm,{blur:function(){return Tm},clearContent:function(){return Mm},clearNodes:function(){return _m},command:function(){return Nm},createParagraphNear:function(){return Om},cut:function(){return Em},deleteCurrentNode:function(){return Am},deleteNode:function(){return Im},deleteRange:function(){return Lm},deleteSelection:function(){return Rm},enter:function(){return zm},exitCode:function(){return Pm},extendMarkRange:function(){return $m},first:function(){return Um},focus:function(){return Ym},forEach:function(){return Xm},insertContent:function(){return Qm},insertContentAt:function(){return ng},joinBackward:function(){return og},joinDown:function(){return rg},joinForward:function(){return ag},joinItemBackward:function(){return sg},joinItemForward:function(){return cg},joinTextblockBackward:function(){return lg},joinTextblockForward:function(){return ug},joinUp:function(){return ig},keyboardShortcut:function(){return hg},lift:function(){return pg},liftEmptyBlock:function(){return vg},liftListItem:function(){return mg},newlineInCode:function(){return gg},resetAttributes:function(){return wg},scrollIntoView:function(){return bg},selectAll:function(){return Cg},selectNodeBackward:function(){return Sg},selectNodeForward:function(){return xg},selectParentNode:function(){return Tg},selectTextblockEnd:function(){return Mg},selectTextblockStart:function(){return _g},setContent:function(){return Og},setMark:function(){return oy},setMeta:function(){return ay},setNode:function(){return sy},setNodeSelection:function(){return cy},setTextDirection:function(){return ly},setTextSelection:function(){return uy},sinkListItem:function(){return dy},splitBlock:function(){return fy},splitListItem:function(){return py},toggleList:function(){return gy},toggleMark:function(){return yy},toggleNode:function(){return ky},toggleWrap:function(){return wy},undoInputRule:function(){return by},unsetAllMarks:function(){return Cy},unsetMark:function(){return Sy},unsetTextDirection:function(){return xy},updateAttributes:function(){return Ty},wrapIn:function(){return My},wrapInList:function(){return _y}});var Tm=function(){return function(e){var t=e.editor,n=e.view;return requestAnimationFrame(function(){var e;t.isDestroyed||(n.dom.blur(),null==(e=null==window?void 0:window.getSelection())||e.removeAllRanges())}),!0}},Mm=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return function(t){return t.commands.setContent("",{emitUpdate:e})}},_m=function(){return function(e){var t=e.state,n=e.tr,i=e.dispatch,r=n.selection.ranges;return!i||(r.forEach(function(e){var i=e.$from,r=e.$to;t.doc.nodesBetween(i.pos,r.pos,function(e,t){if(!e.type.isText){var i=n.doc,r=n.mapping,o=i.resolve(r.map(t)),a=i.resolve(r.map(t+e.nodeSize)),s=o.blockRange(a);if(s){var c=zd(s);if(e.type.isTextblock){var l=o.parent.contentMatchAt(o.index()).defaultType;n.setNodeMarkup(s.start,l)}(c||0===c)&&n.lift(s,c)}}})}),!0)}},Nm=function(e){return function(t){return e(t)}},Om=function(){return function(e){return function(e,t){var n=e.selection,i=n.$from,r=n.$to;if(n instanceof mh||i.parent.inlineContent||r.parent.inlineContent)return!1;var o=Ph(r.parent.contentMatchAt(r.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){var a=(!i.parentOffset&&r.index()<r.parent.childCount?i:r).pos,s=e.tr.insert(a,o.createAndFill());s.setSelection(hh.create(s.doc,a+1)),t(s.scrollIntoView())}return!0}(e.state,e.dispatch)}},Em=function(e,t){return function(n){var i=n.editor,r=n.tr,o=i.state.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);var a=r.mapping.map(t);return r.insert(a,o.content),r.setSelection(new hh(r.doc.resolve(Math.max(a-1,0)))),!0}},Am=function(){return function(e){var t=e.tr,n=e.dispatch,i=t.selection.$anchor.node();if(i.content.size>0)return!1;for(var r=t.selection.$anchor,o=r.depth;o>0;o-=1){if(r.node(o).type===i.type){if(n){var a=r.before(o),s=r.after(o);t.delete(a,s).scrollIntoView()}return!0}}return!1}};function Dm(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error("There is no node type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.nodes[e]}return e}var Im=function(e){return function(t){for(var n=t.tr,i=t.state,r=t.dispatch,o=Dm(e,i.schema),a=n.selection.$anchor,s=a.depth;s>0;s-=1){if(a.node(s).type===o){if(r){var c=a.before(s),l=a.after(s);n.delete(c,l).scrollIntoView()}return!0}}return!1}},Lm=function(e){return function(t){var n=t.tr,i=t.dispatch,r=e.from,o=e.to;return i&&n.delete(r,o),!0}},Rm=function(){return function(e){return function(e,t){return!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0)}(e.state,e.dispatch)}},zm=function(){return function(e){return e.commands.keyboardShortcut("Enter")}},Pm=function(){return function(e){return function(e,t){var n=e.selection,i=n.$head,r=n.$anchor;if(!i.parent.type.spec.code||!i.sameParent(r))return!1;var o=i.node(-1),a=i.indexAfter(-1),s=Ph(o.contentMatchAt(a));if(!s||!o.canReplaceWith(a,a,s))return!1;if(t){var c=i.after(),l=e.tr.replaceWith(c,c,s.createAndFill());l.setSelection(ch.near(l.doc.resolve(c),1)),t(l.scrollIntoView())}return!0}(e.state,e.dispatch)}};function Bm(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function Fm(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{strict:!0},i=Object.keys(t);return!i.length||i.every(function(i){return n.strict?t[i]===e[i]:Bm(t[i])?t[i].test(e[i]):t[i]===e[i]})}function Hm(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.find(function(e){return e.type===t&&Fm(Object.fromEntries(Object.keys(n).map(function(t){return[t,e.attrs[t]]})),n)})}function jm(e,t){return!!Hm(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function Vm(e,t,n){var i;if(e&&t){var r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(function(e){return e.type===t})||(r=e.parent.childBefore(e.parentOffset)),r.node&&r.node.marks.some(function(e){return e.type===t}))if(n=n||(null==(i=r.node.marks[0])?void 0:i.attrs),Hm(c(r.node.marks),t,n)){for(var o=r.index,a=e.start()+r.offset,s=o+1,l=a+r.node.nodeSize;o>0&&jm(c(e.parent.child(o-1).marks),t,n);)o-=1,a-=e.parent.child(o).nodeSize;for(;s<e.parent.childCount&&jm(c(e.parent.child(s).marks),t,n);)l+=e.parent.child(s).nodeSize,s+=1;return{from:a,to:l}}}}function Wm(e,t){if("string"==typeof e){if(!t.marks[e])throw Error("There is no mark type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.marks[e]}return e}var $m=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.tr,r=n.state,o=n.dispatch,a=Wm(e,r.schema),s=i.doc,c=i.selection,l=c.$from,u=c.from,d=c.to;if(o){var h=Vm(l,a,t);if(h&&h.from<=u&&h.to>=d){var f=hh.create(s,h.from,h.to);i.setSelection(f)}}return!0}},Um=function(e){return function(t){for(var n="function"==typeof e?e(t):e,i=0;i<n.length;i+=1)if(n[i](t))return!0;return!1}};function qm(e){return e instanceof hh}function Km(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Math.min(Math.max(e,t),n)}function Jm(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t)return null;var n=ch.atStart(e),i=ch.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return i;var r=n.from,o=i.to;return"all"===t?hh.create(e,Km(0,r,o),Km(e.content.size,r,o)):hh.create(e,Km(t,r,o),Km(t,r,o))}function Gm(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Ym=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.editor,r=n.view,o=n.tr,a=n.dispatch;t=d({scrollIntoView:!0},t);var s=function(){(Gm()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&r.dom.focus(),requestAnimationFrame(function(){i.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&i.commands.scrollIntoView())})};if(r.hasFocus()&&null===e||!1===e)return!0;if(a&&null===e&&!qm(i.state.selection))return s(),!0;var c=Jm(o.doc,e)||i.state.selection,l=i.state.selection.eq(c);return a&&(l||o.setSelection(c),l&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0}},Xm=function(e,t){return function(n){return e.every(function(e,i){return t(e,d(d({},n),{},{index:i}))})}},Qm=function(e,t){return function(n){var i=n.tr;return n.commands.insertContentAt({from:i.selection.from,to:i.selection.to},e,t)}},Zm=function(e){for(var t=e.childNodes,n=t.length-1;n>=0;n-=1){var i=t[n];3===i.nodeType&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)?e.removeChild(i):1===i.nodeType&&Zm(i)}return e};function eg(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");var t="<body>".concat(e,"</body>"),n=(new window.DOMParser).parseFromString(t,"text/html").body;return Zm(n)}function tg(e,t,n){if(e instanceof Iu||e instanceof lu)return e;n=d({slice:!0,parseOptions:{}},n);var i="string"==typeof e;if("object"===_(e)&&null!==e)try{if(Array.isArray(e)&&e.length>0)return lu.fromArray(e.map(function(e){return t.nodeFromJSON(e)}));var r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(l){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:l});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",l),tg("",t,n)}if(i){if(n.errorOnInvalidContent){var o=!1,a="",s=new Zu({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:function(e){return o=!0,a="string"==typeof e?e:e.outerHTML,null}}]}})});if(n.slice?td.fromSchema(s).parseSlice(eg(e),n.parseOptions):td.fromSchema(s).parse(eg(e),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error("Invalid element found: ".concat(a))})}var c=td.fromSchema(t);return n.slice?c.parseSlice(eg(e),n.parseOptions).content:c.parse(eg(e),n.parseOptions)}return tg("",t,n)}var ng=function(e,t,n){return function(i){var r,o=i.tr,a=i.dispatch,s=i.editor;if(a){var c;n=d({parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1},n);var l=function(e){s.emit("contentError",{editor:s,error:e,disableCollaboration:function(){"collaboration"in s.storage&&"object"===_(s.storage.collaboration)&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},u=d({preserveWhitespace:"full"},n.parseOptions);if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{tg(t,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(vs){l(vs)}try{c=tg(t,s.schema,{parseOptions:u,errorOnInvalidContent:null!=(r=n.errorOnInvalidContent)?r:s.options.enableContentCheck})}catch(vs){return l(vs),!1}var h,f="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},p=f.from,v=f.to,m=!0,g=!0;if(("type"in c?[c]:c).forEach(function(e){e.check(),m=!!m&&(e.isText&&0===e.marks.length),g=!!g&&e.isBlock}),p===v&&g){var y=o.doc.resolve(p).parent;y.isTextblock&&!y.type.spec.code&&!y.childCount&&(p-=1,v+=1)}if(m){if(Array.isArray(t))h=t.map(function(e){return e.text||""}).join("");else if(t instanceof lu){var k="";t.forEach(function(e){e.text&&(k+=e.text)}),h=k}else h="object"===_(t)&&t&&t.text?t.text:t;o.insertText(h,p,v)}else{h=c;var w=o.doc.resolve(p),b=w.node(),C=0===w.parentOffset,S=b.isText||b.isTextblock,x=b.content.size>0;C&&S&&x&&(p=Math.max(0,p-1)),o.replaceWith(p,v,h)}n.updateSelection&&function(e,t,n){var i=e.steps.length-1;if(!(i<t)){var r=e.steps[i];if(r instanceof Ad||r instanceof Dd){var o=e.mapping.maps[i],a=0;o.forEach(function(e,t,n,i){0===a&&(a=i)}),e.setSelection(ch.near(e.doc.resolve(a),n))}}}(o,o.steps.length-1,-1),n.applyInputRules&&o.setMeta("applyInputRules",{from:p,text:h}),n.applyPasteRules&&o.setMeta("applyPasteRules",{from:p,text:h})}return!0}},ig=function(){return function(e){return function(e,t){var n,i=e.selection,r=i instanceof ph;if(r){if(i.node.isTextblock||!Vd(e.doc,i.from))return!1;n=i.from}else if(null==(n=$d(e.doc,i.from,-1)))return!1;if(t){var o=e.tr.join(n);r&&o.setSelection(ph.create(o.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0}(e.state,e.dispatch)}},rg=function(){return function(e){return function(e,t){var n,i=e.selection;if(i instanceof ph){if(i.node.isTextblock||!Vd(e.doc,i.to))return!1;n=i.to}else if(null==(n=$d(e.doc,i.to,1)))return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0}(e.state,e.dispatch)}},og=function(){return function(e){return function(e,t,n){var i=Ah(e,n);if(!i)return!1;var r=Lh(i);if(!r){var o=i.blockRange(),a=o&&zd(o);return null!=a&&(t&&t(e.tr.lift(o,a).scrollIntoView()),!0)}var s=r.nodeBefore;if(Bh(e,r,t,-1))return!0;if(0==i.parent.content.size&&(Ih(s,"end")||ph.isSelectable(s)))for(var c=i.depth;;c--){var l=qd(e.doc,i.before(c),i.after(c),vu.empty);if(l&&l.slice.size<l.to-l.from){if(t){var u=e.tr.step(l);u.setSelection(Ih(s,"end")?ch.findFrom(u.doc.resolve(u.mapping.map(r.pos,-1)),-1):ph.create(u.doc,r.pos-s.nodeSize)),t(u.scrollIntoView())}return!0}if(1==c||i.node(c-1).childCount>1)break}return!(!s.isAtom||r.depth!=i.depth-1||(t&&t(e.tr.delete(r.pos-s.nodeSize,r.pos).scrollIntoView()),0))}(e.state,e.dispatch)}},ag=function(){return function(e){return function(e,t,n){var i=Rh(e,n);if(!i)return!1;var r=zh(i);if(!r)return!1;var o=r.nodeAfter;if(Bh(e,r,t,1))return!0;if(0==i.parent.content.size&&(Ih(o,"start")||ph.isSelectable(o))){var a=qd(e.doc,i.before(),i.after(),vu.empty);if(a&&a.slice.size<a.to-a.from){if(t){var s=e.tr.step(a);s.setSelection(Ih(o,"start")?ch.findFrom(s.doc.resolve(s.mapping.map(r.pos)),1):ph.create(s.doc,s.mapping.map(r.pos))),t(s.scrollIntoView())}return!0}}return!(!o.isAtom||r.depth!=i.depth-1||(t&&t(e.tr.delete(r.pos,r.pos+o.nodeSize).scrollIntoView()),0))}(e.state,e.dispatch)}},sg=function(){return function(e){var t=e.state,n=e.dispatch,i=e.tr;try{var r=$d(t.doc,t.selection.$from.pos,-1);return null!=r&&(i.join(r,2),n&&n(i),!0)}catch(o){return!1}}},cg=function(){return function(e){var t=e.state,n=e.dispatch,i=e.tr;try{var r=$d(t.doc,t.selection.$from.pos,1);return null!=r&&(i.join(r,2),n&&n(i),!0)}catch(o){return!1}}},lg=function(){return function(e){return function(e,t,n){var i=Ah(e,n);if(!i)return!1;var r=Lh(i);return!!r&&Dh(e,r,t)}(e.state,e.dispatch)}},ug=function(){return function(e){return function(e,t,n){var i=Rh(e,n);if(!i)return!1;var r=zh(i);return!!r&&Dh(e,r,t)}(e.state,e.dispatch)}};function dg(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var hg=function(e){return function(t){var n=t.editor,i=t.view,r=t.tr,o=t.dispatch,a=function(e){var t,n,i,r,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"===a&&(a=" ");for(var s=0;s<o.length-1;s+=1){var c=o[s];if(/^(cmd|meta|m)$/i.test(c))r=!0;else if(/^a(lt)?$/i.test(c))t=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))i=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: ".concat(c));Gm()||dg()?r=!0:n=!0}}return t&&(a="Alt-".concat(a)),n&&(a="Ctrl-".concat(a)),r&&(a="Meta-".concat(a)),i&&(a="Shift-".concat(a)),a}(e).split(/-(?!$)/),s=a.find(function(e){return!["Alt","Ctrl","Meta","Shift"].includes(e)}),c=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),l=n.captureTransaction(function(){i.someProp("handleKeyDown",function(e){return e(i,c)})});return null==l||l.steps.forEach(function(e){var t=e.map(r.mapping);t&&o&&r.maybeStep(t)}),!0}};function fg(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=e.selection,r=i.from,o=i.to,a=i.empty,s=t?Dm(t,e.schema):null,c=[];e.doc.nodesBetween(r,o,function(e,t){if(!e.isText){var n=Math.max(r,t),i=Math.min(o,t+e.nodeSize);c.push({node:e,from:n,to:i})}});var l=o-r,u=c.filter(function(e){return!s||s.name===e.node.type.name}).filter(function(e){return Fm(e.node.attrs,n,{strict:!1})});return a?!!u.length:u.reduce(function(e,t){return e+t.to-t.from},0)>=l}var pg=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.state,r=n.dispatch;return!!fg(i,Dm(e,i.schema),t)&&function(e,t){var n=e.selection,i=n.$from,r=n.$to,o=i.blockRange(r),a=o&&zd(o);return null!=a&&(t&&t(e.tr.lift(o,a).scrollIntoView()),!0)}(i,r)}},vg=function(){return function(e){return function(e,t){var n=e.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var i=n.before();if(jd(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}var r=n.blockRange(),o=r&&zd(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)}(e.state,e.dispatch)}},mg=function(e){return function(t){var n=t.state,i=t.dispatch;return $h(Dm(e,n.schema))(n,i)}},gg=function(){return function(e){return function(e,t){var n=e.selection,i=n.$head,r=n.$anchor;return!(!i.parent.type.spec.code||!i.sameParent(r)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))}(e.state,e.dispatch)}};function yg(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function kg(e,t){var n="string"==typeof t?[t]:t;return Object.keys(e).reduce(function(t,i){return n.includes(i)||(t[i]=e[i]),t},{})}var wg=function(e,t){return function(n){var i=n.tr,r=n.state,o=n.dispatch,a=null,s=null,c=yg("string"==typeof e?e:e.name,r.schema);if(!c)return!1;"node"===c&&(a=Dm(e,r.schema)),"mark"===c&&(s=Wm(e,r.schema));var l=!1;return i.selection.ranges.forEach(function(e){r.doc.nodesBetween(e.$from.pos,e.$to.pos,function(e,n){a&&a===e.type&&(l=!0,o&&i.setNodeMarkup(n,void 0,kg(e.attrs,t))),s&&e.marks.length&&e.marks.forEach(function(r){s===r.type&&(l=!0,o&&i.addMark(n,n+e.nodeSize,s.create(kg(r.attrs,t))))})})}),l}},bg=function(){return function(e){var t=e.tr;return e.dispatch&&t.scrollIntoView(),!0}},Cg=function(){return function(e){var t=e.tr;if(e.dispatch){var n=new mh(t.doc);t.setSelection(n)}return!0}},Sg=function(){return function(e){return function(e,t,n){var i=e.selection,r=i.$head,o=r;if(!i.empty)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=Lh(r)}var a=o&&o.nodeBefore;return!(!a||!ph.isSelectable(a)||(t&&t(e.tr.setSelection(ph.create(e.doc,o.pos-a.nodeSize)).scrollIntoView()),0))}(e.state,e.dispatch)}},xg=function(){return function(e){return function(e,t,n){var i=e.selection,r=i.$head,o=r;if(!i.empty)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=zh(r)}var a=o&&o.nodeAfter;return!(!a||!ph.isSelectable(a)||(t&&t(e.tr.setSelection(ph.create(e.doc,o.pos)).scrollIntoView()),0))}(e.state,e.dispatch)}},Tg=function(){return function(e){return function(e,t){var n,i=e.selection,r=i.$from,o=i.to,a=r.sharedDepth(o);return 0!=a&&(n=r.before(a),t&&t(e.tr.setSelection(ph.create(e.doc,n))),!0)}(e.state,e.dispatch)}},Mg=function(){return function(e){var t=e.state,n=e.dispatch;return jh(t,n)}},_g=function(){return function(e){var t=e.state,n=e.dispatch;return Hh(t,n)}};function Ng(e,t){return tg(e,t,{slice:!1,parseOptions:arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},errorOnInvalidContent:(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).errorOnInvalidContent})}var Og=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errorOnInvalidContent,i=t.emitUpdate,r=void 0===i||i,o=t.parseOptions,a=void 0===o?{}:o;return function(t){var i=t.editor,o=t.tr,s=t.dispatch,c=t.commands,l=o.doc;if("full"!==a.preserveWhitespace){var u=Ng(e,i.schema,a,{errorOnInvalidContent:null!=n?n:i.options.enableContentCheck});return s&&o.replaceWith(0,l.content.size,u).setMeta("preventUpdate",!r),!0}return s&&o.setMeta("preventUpdate",!r),c.insertContentAt({from:0,to:l.content.size},e,{parseOptions:a,errorOnInvalidContent:null!=n?n:i.options.enableContentCheck})}};function Eg(e,t){var n=Wm(t,e.schema),i=e.selection,r=i.from,o=i.to,a=i.empty,s=[];a?(e.storedMarks&&s.push.apply(s,c(e.storedMarks)),s.push.apply(s,c(e.selection.$head.marks()))):e.doc.nodesBetween(r,o,function(e){s.push.apply(s,c(e.marks))});var l=s.find(function(e){return e.type.name===n.name});return l?d({},l.attrs):{}}function Ag(e){return function(t){return function(e,t){for(var n=e.depth;n>0;n-=1){var i=e.node(n);if(t(i))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:i}}}(t.$from,e)}}function Dg(e,t,n){return void 0===e.config[t]&&e.parent?Dg(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind(d(d({},n),{},{parent:e.parent?Dg(e.parent,t,n):null})):e.config[t]}function Ig(e){return e.map(function(e){var t=Dg(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e].concat(c(Ig(t()))):e}).flat(10)}function Lg(e,t){var n=dd.fromSchema(t).serializeFragment(e),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Rg(e){return"function"==typeof e}function zg(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;if(Rg(e)){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return t?e.bind(t).apply(void 0,i):e.apply(void 0,i)}return e}function Pg(e){return{baseExtensions:e.filter(function(e){return"extension"===e.type}),nodeExtensions:e.filter(function(e){return"node"===e.type}),markExtensions:e.filter(function(e){return"mark"===e.type})}}function Bg(e){var t=[],n=Pg(e),i=n.nodeExtensions,r=n.markExtensions,o=[].concat(c(i),c(r)),a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(function(e){var n=Dg(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage,extensions:o});n&&n().forEach(function(e){e.types.forEach(function(n){Object.entries(e.attributes).forEach(function(e){var i=g(e,2),r=i[0],o=i[1];t.push({type:n,name:r,attribute:d(d({},a),o)})})})})}),o.forEach(function(e){var n={name:e.name,options:e.options,storage:e.storage},i=Dg(e,"addAttributes",n);if(i){var r=i();Object.entries(r).forEach(function(n){var i=g(n,2),r=i[0],o=i[1],s=d(d({},a),o);"function"==typeof(null==s?void 0:s.default)&&(s.default=s.default()),(null==s?void 0:s.isRequired)&&void 0===(null==s?void 0:s.default)&&delete s.default,t.push({type:e.name,name:r,attribute:s})})}}),t}function Fg(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter(function(e){return!!e}).reduce(function(e,t){var n=d({},e);return Object.entries(t).forEach(function(e){var t=g(e,2),i=t[0],r=t[1];if(n[i])if("class"===i){var o=r?String(r).split(" "):[],a=n[i]?n[i].split(" "):[],s=o.filter(function(e){return!a.includes(e)});n[i]=[].concat(c(a),c(s)).join(" ")}else if("style"===i){var l=r?r.split(";").map(function(e){return e.trim()}).filter(Boolean):[],u=n[i]?n[i].split(";").map(function(e){return e.trim()}).filter(Boolean):[],d=new Map;u.forEach(function(e){var t=g(e.split(":").map(function(e){return e.trim()}),2),n=t[0],i=t[1];d.set(n,i)}),l.forEach(function(e){var t=g(e.split(":").map(function(e){return e.trim()}),2),n=t[0],i=t[1];d.set(n,i)}),n[i]=Array.from(d.entries()).map(function(e){var t=g(e,2),n=t[0],i=t[1];return"".concat(n,": ").concat(i)}).join("; ")}else n[i]=r;else n[i]=r}),n},{})}function Hg(e,t){return t.filter(function(t){return t.type===e.type.name}).filter(function(e){return e.attribute.rendered}).map(function(t){return t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:T({},t.name,e.attrs[t.name])}).reduce(function(e,t){return Fg(e,t)},{})}function jg(e,t){return"style"in e?e:d(d({},e),{},{getAttrs:function(n){var i=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===i)return!1;var r=t.reduce(function(e,t){var i=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==i?e:d(d({},e),{},T({},t.name,i))},{});return d(d({},i),r)}})}function Vg(e){return Object.fromEntries(Object.entries(e).filter(function(e){var t=g(e,2),n=t[0],i=t[1];return("attrs"!==n||!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 0===Object.keys(e).length&&e.constructor===Object}(i))&&null!=i}))}function Wg(e){var t,n,i={};return!(null==(t=null==e?void 0:e.attribute)?void 0:t.isRequired)&&"default"in((null==e?void 0:e.attribute)||{})&&(i.default=e.attribute.default),void 0!==(null==(n=null==e?void 0:e.attribute)?void 0:n.validate)&&(i.validate=e.attribute.validate),[e.name,i]}function $g(e){return e.sort(function(e,t){var n=Dg(e,"priority")||100,i=Dg(t,"priority")||100;return n>i?-1:n<i?1:0})}function Ug(e){var t,n,i=$g(Ig(e)),r=(t=i.map(function(e){return e.name}),n=t.filter(function(e,n){return t.indexOf(e)!==n}),Array.from(new Set(n)));return r.length&&console.warn("[tiptap warn]: Duplicate extension names found: [".concat(r.map(function(e){return"'".concat(e,"'")}).join(", "),"]. This can lead to issues.")),i}function qg(e,t,n){var i=t.from,r=t.to,o=n||{},a=o.blockSeparator,s=void 0===a?"\n\n":a,c=o.textSerializers,l=void 0===c?{}:c,u="";return e.nodesBetween(i,r,function(e,n,o,a){var c;e.isBlock&&n>i&&(u+=s);var d=null==l?void 0:l[e.type.name];if(d)return o&&(u+=d({node:e,pos:n,parent:o,index:a,range:t})),!1;e.isText&&(u+=null==(c=null==e?void 0:e.text)?void 0:c.slice(Math.max(i,n)-n,r-n))}),u}function Kg(e){return Object.fromEntries(Object.entries(e.nodes).filter(function(e){return g(e,2)[1].spec.toText}).map(function(e){var t=g(e,2);return[t[0],t[1].spec.toText]}))}function Jg(e,t){var n=yg("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){var n=Dm(t,e.schema),i=e.selection,r=i.from,o=i.to,a=[];e.doc.nodesBetween(r,o,function(e){a.push(e)});var s=a.reverse().find(function(e){return e.type.name===n.name});return s?d({},s.attrs):{}}(e,t):"mark"===n?Eg(e,t):{}}function Gg(e){var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:JSON.stringify,n={};return e.filter(function(e){var i=t(e);return!Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=!0)})}(e);return 1===t.length?t:t.filter(function(e,n){var i=t.filter(function(e,t){return t!==n});return!i.some(function(t){return e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to})})}function Yg(e,t){return t.nodes[e]||t.marks[e]||null}function Xg(e,t,n){return Object.fromEntries(Object.entries(n).filter(function(n){var i=g(n,1)[0],r=e.find(function(e){return e.type===t&&e.name===i});return!!r&&r.attribute.keepOnSplit}))}function Qg(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=e.selection,r=i.empty,o=i.ranges,a=t?Wm(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(function(e){return!a||a.name===e.type.name}).find(function(e){return Fm(e.attrs,n,{strict:!1})});var s=0,l=[];if(o.forEach(function(t){var n=t.$from,i=t.$to,r=n.pos,o=i.pos;e.doc.nodesBetween(r,o,function(e,t){if(e.isText||e.marks.length){var n=Math.max(r,t),i=Math.min(o,t+e.nodeSize);s+=i-n,l.push.apply(l,c(e.marks.map(function(e){return{mark:e,from:n,to:i}})))}})}),0===s)return!1;var u=l.filter(function(e){return!a||a.name===e.mark.type.name}).filter(function(e){return Fm(e.mark.attrs,n,{strict:!1})}).reduce(function(e,t){return e+t.to-t.from},0),d=l.filter(function(e){return!a||e.mark.type!==a&&e.mark.type.excludes(a)}).reduce(function(e,t){return e+t.to-t.from},0);return(u>0?u+d:u)>=s}function Zg(e,t){return Array.isArray(t)?t.some(function(t){return("string"==typeof t?t:t.name)===e.name}):t}function ey(e,t){var n=Pg(t).nodeExtensions.find(function(t){return t.name===e});if(!n)return!1;var i=zg(Dg(n,"group",{name:n.name,options:n.options,storage:n.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function ty(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.checkChildren,r=void 0===i||i,o=n.ignoreWhitespace,a=void 0!==o&&o;if(a){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!=(t=e.text)?t:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(r){var s=!0;return e.content.forEach(function(e){!1!==s&&(ty(e,{ignoreWhitespace:a,checkChildren:r})||(s=!1))}),s}return!1}var ny=function(){function e(t){C(this,e),this.position=t}return x(e,[{key:"toJSON",value:function(){return{position:this.position}}}],[{key:"fromJSON",value:function(t){return new e(t.position)}}])}();function iy(e,t){var n=t.mapping.mapResult(e.position);return{position:new ny(n.pos),mapResult:n}}function ry(e){return new ny(e)}var oy=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.tr,r=n.state,o=n.dispatch,a=i.selection,s=a.empty,c=a.ranges,l=Wm(e,r.schema);if(o)if(s){var u=Eg(r,l);i.addStoredMark(l.create(d(d({},u),t)))}else c.forEach(function(e){var n=e.$from.pos,o=e.$to.pos;r.doc.nodesBetween(n,o,function(e,r){var a=Math.max(r,n),s=Math.min(r+e.nodeSize,o);e.marks.find(function(e){return e.type===l})?e.marks.forEach(function(e){l===e.type&&i.addMark(a,s,l.create(d(d({},e.attrs),t)))}):i.addMark(a,s,l.create(t))})});return function(e,t,n){var i,r=t.selection,o=null;if(qm(r)&&(o=r.$cursor),o){var a=null!=(i=e.storedMarks)?i:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(function(e){return e.type.excludes(n)}))}return r.ranges.some(function(t){var i=t.$from,r=t.$to,o=0===i.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(i.pos,r.pos,function(e,t,i){if(o)return!1;if(e.isInline){var r=!i||i.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(function(e){return e.type.excludes(n)});o=r&&a}return!o}),o})}(r,i,l)}},ay=function(e,t){return function(n){return n.tr.setMeta(e,t),!0}},sy=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i,r=n.state,o=n.dispatch,a=n.chain,s=Dm(e,r.schema);return r.selection.$anchor.sameParent(r.selection.$head)&&(i=r.selection.$anchor.parent.attrs),s.isTextblock?a().command(function(e){var n=e.commands;return!!Vh(s,d(d({},i),t))(r)||n.clearNodes()}).command(function(e){var n=e.state;return Vh(s,d(d({},i),t))(n,o)}).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)}},cy=function(e){return function(t){var n=t.tr;if(t.dispatch){var i=n.doc,r=Km(e,0,i.content.size),o=ph.create(i,r);n.setSelection(o)}return!0}},ly=function(e,t){return function(n){var i,r,o=n.tr,a=n.state,s=n.dispatch,c=a.selection;return"number"==typeof t?(i=t,r=t):t&&"from"in t&&"to"in t?(i=t.from,r=t.to):(i=c.from,r=c.to),s&&o.doc.nodesBetween(i,r,function(t,n){t.isText||o.setNodeMarkup(n,void 0,d(d({},t.attrs),{},{dir:e}))}),!0}},uy=function(e){return function(t){var n=t.tr;if(t.dispatch){var i=n.doc,r="number"==typeof e?{from:e,to:e}:e,o=r.from,a=r.to,s=hh.atStart(i).from,c=hh.atEnd(i).to,l=Km(o,s,c),u=Km(a,s,c),d=hh.create(i,l,u);n.setSelection(d)}return!0}},dy=function(e){return function(t){var n,i=t.state,r=t.dispatch,o=Dm(e,i.schema);return(n=o,function(e,t){var i=e.selection,r=i.$from,o=i.$to,a=r.blockRange(o,function(e){return e.childCount>0&&e.firstChild.type==n});if(!a)return!1;var s=a.startIndex;if(0==s)return!1;var c=a.parent,l=c.child(s-1);if(l.type!=n)return!1;if(t){var u=l.lastChild&&l.lastChild.type==c.type,d=lu.from(u?n.create():null),h=new vu(lu.from(n.create(null,lu.from(c.type.create(null,d)))),u?3:1,0),f=a.start,p=a.end;t(e.tr.step(new Dd(f-(u?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0})(i,r)}};function hy(e,t){var n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){var i=n.filter(function(e){return null==t?void 0:t.includes(e.type.name)});e.tr.ensureMarks(i)}}var fy=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).keepMarks,t=void 0===e||e;return function(e){var n=e.tr,i=e.state,r=e.dispatch,o=e.editor,a=n.selection,s=n.doc,c=a.$from,l=a.$to,u=Xg(o.extensionManager.attributes,c.node().type.name,c.node().attrs);if(a instanceof ph&&a.node.isBlock)return!(!c.parentOffset||!jd(s,c.pos))&&(r&&(t&&hy(i,o.extensionManager.splittableMarks),n.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;var d=l.parentOffset===l.parent.content.size,h=0===c.depth?void 0:function(e){for(var t=0;t<e.edgeCount;t+=1){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(c.node(-1).contentMatchAt(c.indexAfter(-1))),f=d&&h?[{type:h,attrs:u}]:void 0,p=jd(n.doc,n.mapping.map(c.pos),1,f);if(f||p||!jd(n.doc,n.mapping.map(c.pos),1,h?[{type:h}]:void 0)||(p=!0,f=h?[{type:h,attrs:u}]:void 0),r){if(p&&(a instanceof hh&&n.deleteSelection(),n.split(n.mapping.map(c.pos),1,f),h&&!d&&!c.parentOffset&&c.parent.type!==h)){var v=n.mapping.map(c.before()),m=n.doc.resolve(v);c.node(-1).canReplaceWith(m.index(),m.index()+1,h)&&n.setNodeMarkup(n.mapping.map(c.before()),h)}t&&hy(i,o.extensionManager.splittableMarks),n.scrollIntoView()}return p}},py=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i,r=n.tr,o=n.state,a=n.dispatch,s=n.editor,c=Dm(e,o.schema),l=o.selection,u=l.$from,h=l.$to,f=o.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(h))return!1;var p=u.node(-1);if(p.type!==c)return!1;var v=s.extensionManager.attributes;if(0===u.parent.content.size&&u.node(-1).childCount===u.indexAfter(-1)){if(2===u.depth||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(a){for(var m=lu.empty,g=u.index(-1)?1:u.index(-2)?2:3,y=u.depth-g;y>=u.depth-3;y-=1)m=lu.from(u.node(y).copy(m));var k=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,w=d(d({},Xg(v,u.node().type.name,u.node().attrs)),t),b=(null==(i=c.contentMatch.defaultType)?void 0:i.createAndFill(w))||void 0;m=m.append(lu.from(c.createAndFill(null,b)||void 0));var C=u.before(u.depth-(g-1));r.replace(C,u.after(-k),new vu(m,4-g,0));var S=-1;r.doc.nodesBetween(C,r.doc.content.size,function(e,t){if(S>-1)return!1;e.isTextblock&&0===e.content.size&&(S=t+1)}),S>-1&&r.setSelection(hh.near(r.doc.resolve(S))),r.scrollIntoView()}return!0}var x=h.pos===u.end()?p.contentMatchAt(0).defaultType:null,T=d(d({},Xg(v,p.type.name,p.attrs)),t),M=d(d({},Xg(v,u.node().type.name,u.node().attrs)),t);r.delete(u.pos,h.pos);var _=x?[{type:c,attrs:T},{type:x,attrs:M}]:[{type:c,attrs:T}];if(!jd(r.doc,u.pos,2))return!1;if(a){var N=o.selection,O=o.storedMarks,E=s.extensionManager.splittableMarks,A=O||N.$to.parentOffset&&N.$from.marks();if(r.split(u.pos,2,_).scrollIntoView(),!A||!a)return!0;var D=A.filter(function(e){return E.includes(e.type.name)});r.ensureMarks(D)}return!0}},vy=function(e,t){var n=Ag(function(e){return e.type===t})(e.selection);if(!n)return!0;var i=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===i)return!0;var r=e.doc.nodeAt(i);return n.node.type!==(null==r?void 0:r.type)||!Vd(e.doc,n.pos)||(e.join(n.pos),!0)},my=function(e,t){var n=Ag(function(e){return e.type===t})(e.selection);if(!n)return!0;var i=e.doc.resolve(n.start).after(n.depth);if(void 0===i)return!0;var r=e.doc.nodeAt(i);return n.node.type!==(null==r?void 0:r.type)||!Vd(e.doc,i)||(e.join(i),!0)},gy=function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return function(r){var o=r.editor,a=r.tr,s=r.state,c=r.dispatch,l=r.chain,u=r.commands,d=r.can,h=o.extensionManager,f=h.extensions,p=h.splittableMarks,v=Dm(e,s.schema),m=Dm(t,s.schema),g=s.selection,y=s.storedMarks,k=g.$from,w=g.$to,b=k.blockRange(w),C=y||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;var S=Ag(function(e){return ey(e.type.name,f)})(g);if(b.depth>=1&&S&&b.depth-S.depth<=1){if(S.node.type===v)return u.liftListItem(m);if(ey(S.node.type.name,f)&&v.validContent(S.node.content)&&c)return l().command(function(){return a.setNodeMarkup(S.pos,v),!0}).command(function(){return vy(a,v)}).command(function(){return my(a,v)}).run()}return n&&C&&c?l().command(function(){var e=d().wrapInList(v,i),t=C.filter(function(e){return p.includes(e.type.name)});return a.ensureMarks(t),!!e||u.clearNodes()}).wrapInList(v,i).command(function(){return vy(a,v)}).command(function(){return my(a,v)}).run():l().command(function(){return!!d().wrapInList(v,i)||u.clearNodes()}).wrapInList(v,i).command(function(){return vy(a,v)}).command(function(){return my(a,v)}).run()}},yy=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(i){var r=i.state,o=i.commands,a=n.extendEmptyMarkRange,s=void 0!==a&&a,c=Wm(e,r.schema);return Qg(r,c,t)?o.unsetMark(c,{extendEmptyMarkRange:s}):o.setMark(c,t)}},ky=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(i){var r,o=i.state,a=i.commands,s=Dm(e,o.schema),c=Dm(t,o.schema),l=fg(o,s,n);return o.selection.$anchor.sameParent(o.selection.$head)&&(r=o.selection.$anchor.parent.attrs),l?a.setNode(c,r):a.setNode(s,d(d({},r),n))}},wy=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.state,r=n.commands,o=Dm(e,i.schema);return fg(i,o,t)?r.lift(o):r.wrapIn(o,t)}},by=function(){return function(e){for(var t=e.state,n=e.dispatch,i=t.plugins,r=0;r<i.length;r+=1){var o=i[r],a=void 0;if(o.spec.isInputRules&&(a=o.getState(t))){if(n){for(var s=t.tr,c=a.transform,l=c.steps.length-1;l>=0;l-=1)s.step(c.steps[l].invert(c.docs[l]));if(a.text){var u=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,u))}else s.delete(a.from,a.to)}return!0}}return!1}},Cy=function(){return function(e){var t=e.tr,n=e.dispatch,i=t.selection,r=i.empty,o=i.ranges;return r||n&&o.forEach(function(e){t.removeMark(e.$from.pos,e.$to.pos)}),!0}},Sy=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i,r=n.tr,o=n.state,a=n.dispatch,s=t.extendEmptyMarkRange,c=void 0!==s&&s,l=r.selection,u=Wm(e,o.schema),d=l.$from,h=l.empty,f=l.ranges;if(!a)return!0;if(h&&c){var p=l.from,v=l.to,m=null==(i=d.marks().find(function(e){return e.type===u}))?void 0:i.attrs,g=Vm(d,u,m);g&&(p=g.from,v=g.to),r.removeMark(p,v,u)}else f.forEach(function(e){r.removeMark(e.$from.pos,e.$to.pos,u)});return r.removeStoredMark(u),!0}},xy=function(e){return function(t){var n,i,r=t.tr,o=t.state,a=t.dispatch,s=o.selection;return"number"==typeof e?(n=e,i=e):e&&"from"in e&&"to"in e?(n=e.from,i=e.to):(n=s.from,i=s.to),a&&r.doc.nodesBetween(n,i,function(e,t){if(!e.isText){var n=d({},e.attrs);delete n.dir,r.setNodeMarkup(t,void 0,n)}}),!0}},Ty=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.tr,r=n.state,o=n.dispatch,a=null,s=null,c=yg("string"==typeof e?e:e.name,r.schema);if(!c)return!1;"node"===c&&(a=Dm(e,r.schema)),"mark"===c&&(s=Wm(e,r.schema));var l=!1;return i.selection.ranges.forEach(function(e){var n,c,u,h,f=e.$from.pos,p=e.$to.pos;i.selection.empty?r.doc.nodesBetween(f,p,function(e,t){a&&a===e.type&&(l=!0,u=Math.max(t,f),h=Math.min(t+e.nodeSize,p),n=t,c=e)}):r.doc.nodesBetween(f,p,function(e,r){r<f&&a&&a===e.type&&(l=!0,u=Math.max(r,f),h=Math.min(r+e.nodeSize,p),n=r,c=e),r>=f&&r<=p&&(a&&a===e.type&&(l=!0,o&&i.setNodeMarkup(r,void 0,d(d({},e.attrs),t))),s&&e.marks.length&&e.marks.forEach(function(n){if(s===n.type&&(l=!0,o)){var a=Math.max(r,f),c=Math.min(r+e.nodeSize,p);i.addMark(a,c,s.create(d(d({},n.attrs),t)))}}))}),c&&(void 0!==n&&o&&i.setNodeMarkup(n,void 0,d(d({},c.attrs),t)),s&&c.marks.length&&c.marks.forEach(function(e){s===e.type&&o&&i.addMark(u,h,s.create(d(d({},e.attrs),t)))}))}),l}},My=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.state,r=n.dispatch;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,i){var r=n.selection,o=r.$from,a=r.$to,s=o.blockRange(a),c=s&&Pd(s,e,t);return!!c&&(i&&i(n.tr.wrap(s,c).scrollIntoView()),!0)}}(Dm(e,i.schema),t)(i,r)}},_y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.state,r=n.dispatch;return Wh(Dm(e,i.schema),t)(i,r)}},Ny=function(){return x(function e(){C(this,e),this.callbacks={}},[{key:"on",value:function(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}},{key:"emit",value:function(e){for(var t=this,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];var o=this.callbacks[e];return o&&o.forEach(function(e){return e.apply(t,i)}),this}},{key:"off",value:function(e,t){var n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(function(e){return e!==t}):delete this.callbacks[e]),this}},{key:"once",value:function(e,t){var n=this,i=function(){n.off(e,i);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];t.apply(n,o)};return this.on(e,i)}},{key:"removeAllListeners",value:function(){this.callbacks={}}}])}(),Oy=x(function e(t){var n;C(this,e),this.find=t.find,this.handler=t.handler,this.undoable=null==(n=t.undoable)||n});function Ey(e){var t,n=e.editor,i=e.from,r=e.to,o=e.text,a=e.rules,s=e.plugin,c=n.view;if(c.composing)return!1;var l=c.state.doc.resolve(i);if(l.parent.type.spec.code||(null==(t=l.nodeBefore||l.nodeAfter)?void 0:t.marks.find(function(e){return e.type.spec.code})))return!1;var u=!1,d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n="",i=e.parentOffset;return e.parent.nodesBetween(Math.max(0,i-t),i,function(e,t,r,o){var a,s,c=(null==(s=(a=e.type.spec).toText)?void 0:s.call(a,{node:e,pos:t,parent:r,index:o}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?c:c.slice(0,Math.max(0,i-t))}),n}(l)+o;return a.forEach(function(e){if(!u){var t=function(e,t){if(Bm(t))return t.exec(e);var n=t(e);if(!n)return null;var i=[n.text];return i.index=n.index,i.input=e,i.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(n.replaceWith)),i}(d,e.find);if(t){var a=c.state.tr,l=Cm({state:c.state,transaction:a}),h={from:i-(t[0].length-o.length),to:r},f=new Sm({editor:n,state:l}),p=f.commands,v=f.chain,m=f.can;null!==e.handler({state:l,range:h,match:t,commands:p,chain:v,can:m})&&a.steps.length&&(e.undoable&&a.setMeta(s,{transform:a,from:i,to:r,text:o}),c.dispatch(a),u=!0)}}}),u}function Ay(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function Dy(e,t){var n=d({},e);return Ay(e)&&Ay(t)&&Object.keys(t).forEach(function(i){Ay(t[i])&&Ay(e[i])?n[i]=Dy(e[i],t[i]):n[i]=t[i]}),n}var Iy=function(){return x(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};C(this,e),this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config=d(d({},this.config),t),this.name=this.config.name},[{key:"options",get:function(){return d({},zg(Dg(this,"addOptions",{name:this.name}))||{})}},{key:"storage",get:function(){return d({},zg(Dg(this,"addStorage",{name:this.name,options:this.options}))||{})}},{key:"configure",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.extend(d(d({},this.config),{},{addOptions:function(){return Dy(e.options,t)}}));return n.name=this.name,n.parent=this.parent,n}},{key:"extend",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new this.constructor(d(d({},this.config),e));return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}}])}(),Ly=function(t){function r(){var e;return C(this,r),(e=n(this,r,arguments)).type="mark",e}return i(r,t),x(r,[{key:"configure",value:function(t){return e(r,"configure",this,3)([t])}},{key:"extend",value:function(t){var n="function"==typeof t?t():t;return e(r,"extend",this,3)([n])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r("function"==typeof e?e():e)}},{key:"handleExit",value:function(e){var t=e.editor,n=e.mark,i=t.state.tr,r=t.state.selection.$from;if(r.pos===r.end()){var o=r.marks(),a=!!o.find(function(e){return(null==e?void 0:e.type.name)===n.name});if(!a)return!1;var s=o.find(function(e){return(null==e?void 0:e.type.name)===n.name});return s&&i.removeStoredMark(s),i.insertText(" ",r.pos),t.view.dispatch(i),!0}return!1}}])}(Iy);function Ry(e){var t=e.editor,n=e.state,i=e.from,r=e.to,o=e.rule,a=e.pasteEvent,s=e.dropEvent,l=new Sm({editor:t,state:n}),u=l.commands,d=l.chain,h=l.can,f=[];return n.doc.nodesBetween(i,r,function(e,t){var l,p,v,m,g;if(!(null==(p=null==(l=e.type)?void 0:l.spec)?void 0:p.code)&&(e.isText||e.isTextblock||e.isInline)){var y=null!=(g=null!=(m=null==(v=e.content)?void 0:v.size)?m:e.nodeSize)?g:0,k=Math.max(i,t),w=Math.min(r,t+y);if(!(k>=w))(function(e,t,n){if(Bm(t))return c(e.matchAll(t));var i=t(e,n);return i?i.map(function(t){var n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n}):[]})(e.isText?e.text||"":e.textBetween(k-t,w-t,void 0,""),o.find,a).forEach(function(e){if(void 0!==e.index){var t=k+e.index+1,i=t+e[0].length,r={from:n.tr.mapping.map(t),to:n.tr.mapping.map(i)},c=o.handler({state:n,range:r,match:e,commands:u,chain:d,can:h,pasteEvent:a,dropEvent:s});f.push(c)}})}}),f.every(function(e){return null!==e})}var zy=null;function Py(e){var t,n=e.editor,i=e.rules,r=null,o=!1,a=!1,s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(u){t=null}var c=function(e){var i=e.state,r=e.from,o=e.to,a=e.rule,c=e.pasteEvt,l=i.tr,u=Cm({state:i,transaction:l});if(Ry({editor:n,state:u,from:Math.max(r-1,0),to:o.b-1,rule:a,pasteEvent:c,dropEvent:t})&&l.steps.length){try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(d){t=null}return s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,l}},l=i.map(function(e){return new _h({view:function(e){var t=function(t){var i;(r=(null==(i=e.dom.parentElement)?void 0:i.contains(t.target))?e.dom.parentElement:null)&&(zy=n)},i=function(){zy&&(zy=null)};return window.addEventListener("dragstart",t),window.addEventListener("dragend",i),{destroy:function(){window.removeEventListener("dragstart",t),window.removeEventListener("dragend",i)}}},props:{handleDOMEvents:{drop:function(e,n){if(a=r===e.dom.parentElement,t=n,!a){var i=zy;(null==i?void 0:i.isEditable)&&setTimeout(function(){var e=i.state.selection;e&&i.commands.deleteRange({from:e.from,to:e.to})},10)}return!1},paste:function(e,t){var n,i=null==(n=t.clipboardData)?void 0:n.getData("text/html");return s=t,o=!!(null==i?void 0:i.includes("data-pm-slice")),!1}}},appendTransaction:function(t,n,i){var r=t[0],l="paste"===r.getMeta("uiEvent")&&!o,u="drop"===r.getMeta("uiEvent")&&!a,d=r.getMeta("applyPasteRules"),h=!!d;if(l||u||h){if(h){var f=d.text;"string"==typeof f||(f=Lg(lu.from(f),i.schema));var p=d.from,v=p+f.length,m=function(e){var t,n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(t=n.clipboardData)||t.setData("text/html",e),n}(f);return c({rule:e,state:i,from:p,to:{b:v},pasteEvt:m})}var g=n.doc.content.findDiffStart(i.doc.content),y=n.doc.content.findDiffEnd(i.doc.content);if("number"==typeof g&&y&&g!==y.b)return c({rule:e,state:i,from:g,to:y,pasteEvt:s})}}})});return l}var By=function(){return x(function e(t,n){C(this,e),this.splittableMarks=[],this.editor=n,this.baseExtensions=t,this.extensions=Ug(t),this.schema=function(e,t){var n,i=Bg(e),r=Pg(e),o=r.nodeExtensions,a=r.markExtensions,s=null==(n=o.find(function(e){return Dg(e,"topNode")}))?void 0:n.name,c=Object.fromEntries(o.map(function(n){var r=i.filter(function(e){return e.type===n.name}),o={name:n.name,options:n.options,storage:n.storage,editor:t},a=e.reduce(function(e,t){var i=Dg(t,"extendNodeSchema",o);return d(d({},e),i?i(n):{})},{}),s=Vg(d(d({},a),{},{content:zg(Dg(n,"content",o)),marks:zg(Dg(n,"marks",o)),group:zg(Dg(n,"group",o)),inline:zg(Dg(n,"inline",o)),atom:zg(Dg(n,"atom",o)),selectable:zg(Dg(n,"selectable",o)),draggable:zg(Dg(n,"draggable",o)),code:zg(Dg(n,"code",o)),whitespace:zg(Dg(n,"whitespace",o)),linebreakReplacement:zg(Dg(n,"linebreakReplacement",o)),defining:zg(Dg(n,"defining",o)),isolating:zg(Dg(n,"isolating",o)),attrs:Object.fromEntries(r.map(Wg))})),c=zg(Dg(n,"parseHTML",o));c&&(s.parseDOM=c.map(function(e){return jg(e,r)}));var l=Dg(n,"renderHTML",o);l&&(s.toDOM=function(e){return l({node:e,HTMLAttributes:Hg(e,r)})});var u=Dg(n,"renderText",o);return u&&(s.toText=u),[n.name,s]})),l=Object.fromEntries(a.map(function(n){var r=i.filter(function(e){return e.type===n.name}),o={name:n.name,options:n.options,storage:n.storage,editor:t},a=e.reduce(function(e,t){var i=Dg(t,"extendMarkSchema",o);return d(d({},e),i?i(n):{})},{}),s=Vg(d(d({},a),{},{inclusive:zg(Dg(n,"inclusive",o)),excludes:zg(Dg(n,"excludes",o)),group:zg(Dg(n,"group",o)),spanning:zg(Dg(n,"spanning",o)),code:zg(Dg(n,"code",o)),attrs:Object.fromEntries(r.map(Wg))})),c=zg(Dg(n,"parseHTML",o));c&&(s.parseDOM=c.map(function(e){return jg(e,r)}));var l=Dg(n,"renderHTML",o);return l&&(s.toDOM=function(e){return l({mark:e,HTMLAttributes:Hg(e,r)})}),[n.name,s]}));return new Zu({topNode:s,nodes:c,marks:l})}(this.extensions,n),this.setupExtensions()},[{key:"commands",get:function(){var e=this;return this.extensions.reduce(function(t,n){var i=Dg(n,"addCommands",{name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:e.editor,type:Yg(n.name,e.schema)});return i?d(d({},t),i()):t},{})}},{key:"plugins",get:function(){var e=this,t=this.editor;return $g(c(this.extensions).reverse()).flatMap(function(n){var i={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:Yg(n.name,e.schema)},r=[],o=Dg(n,"addKeyboardShortcuts",i),a={};if("mark"===n.type&&Dg(n,"exitable",i)&&(a.ArrowRight=function(){return Ly.handleExit({editor:t,mark:n})}),o){var s=Object.fromEntries(Object.entries(o()).map(function(e){var n=g(e,2),i=n[0],r=n[1];return[i,function(){return r({editor:t})}]}));a=d(d({},a),s)}var l=function(e){return new _h({props:{handleKeyDown:km(e)}})}(a);r.push(l);var u=Dg(n,"addInputRules",i);if(Zg(n,t.options.enableInputRules)&&u){var h=u();if(h&&h.length){var f=function(e){var t=e.editor,n=e.rules,i=new _h({state:{init:function(){return null},apply:function(e,r,o){var a=e.getMeta(i);if(a)return a;var s=e.getMeta("applyInputRules");return!!s&&setTimeout(function(){var e=s.text;"string"==typeof e||(e=Lg(lu.from(e),o.schema));var r=s.from,a=r+e.length;Ey({editor:t,from:r,to:a,text:e,rules:n,plugin:i})}),e.selectionSet||e.docChanged?null:r}},props:{handleTextInput:function(e,r,o,a){return Ey({editor:t,from:r,to:o,text:a,rules:n,plugin:i})},handleDOMEvents:{compositionend:function(e){return setTimeout(function(){var r=e.state.selection.$cursor;r&&Ey({editor:t,from:r.pos,to:r.pos,text:"",rules:n,plugin:i})}),!1}},handleKeyDown:function(e,r){if("Enter"!==r.key)return!1;var o=e.state.selection.$cursor;return!!o&&Ey({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:i})}},isInputRules:!0});return i}({editor:t,rules:h}),p=Array.isArray(f)?f:[f];r.push.apply(r,c(p))}}var v=Dg(n,"addPasteRules",i);if(Zg(n,t.options.enablePasteRules)&&v){var m=v();if(m&&m.length){var y=Py({editor:t,rules:m});r.push.apply(r,c(y))}}var k=Dg(n,"addProseMirrorPlugins",i);if(k){var w=k();r.push.apply(r,c(w))}return r})}},{key:"attributes",get:function(){return Bg(this.extensions)}},{key:"nodeViews",get:function(){var e=this,t=this.editor,n=Pg(this.extensions).nodeExtensions;return Object.fromEntries(n.filter(function(e){return!!Dg(e,"addNodeView")}).map(function(n){var i=e.attributes.filter(function(e){return e.type===n.name}),r={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:Dm(n.name,e.schema)},o=Dg(n,"addNodeView",r);if(!o)return[];var a=o();if(!a)return[];return[n.name,function(e,r,o,s,c){var l=Hg(e,i);return a({node:e,view:r,getPos:o,decorations:s,innerDecorations:c,editor:t,extension:n,HTMLAttributes:l})}]}))}},{key:"markViews",get:function(){var e=this,t=this.editor,n=Pg(this.extensions).markExtensions;return Object.fromEntries(n.filter(function(e){return!!Dg(e,"addMarkView")}).map(function(n){var i=e.attributes.filter(function(e){return e.type===n.name}),r={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:Wm(n.name,e.schema)},o=Dg(n,"addMarkView",r);if(!o)return[];return[n.name,function(e,r,a){var s=Hg(e,i);return o()({mark:e,view:r,inline:a,editor:t,extension:n,HTMLAttributes:s,updateAttributes:function(n){!function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.state,r=i.doc,o=i.tr,a=e;r.descendants(function(t,i){var r=o.mapping.map(i),s=o.mapping.map(i)+t.nodeSize,c=null;if(t.marks.forEach(function(e){if(e!==a)return!1;c=e}),c){var l=!1;if(Object.keys(n).forEach(function(e){n[e]!==c.attrs[e]&&(l=!0)}),l){var u=e.type.create(d(d({},e.attrs),n));o.removeMark(r,s,e.type),o.addMark(r,s,u)}}}),o.docChanged&&t.view.dispatch(o)}(e,t,n)}})}]}))}},{key:"setupExtensions",value:function(){var e=this,t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(function(e){return[e.name,e.storage]})),t.forEach(function(t){var n,i={name:t.name,options:t.options,storage:e.editor.extensionStorage[t.name],editor:e.editor,type:Yg(t.name,e.schema)};"mark"===t.type&&((null==(n=zg(Dg(t,"keepOnSplit",i)))||n)&&e.splittableMarks.push(t.name));var r=Dg(t,"onBeforeCreate",i),o=Dg(t,"onCreate",i),a=Dg(t,"onUpdate",i),s=Dg(t,"onSelectionUpdate",i),c=Dg(t,"onTransaction",i),l=Dg(t,"onFocus",i),u=Dg(t,"onBlur",i),d=Dg(t,"onDestroy",i);r&&e.editor.on("beforeCreate",r),o&&e.editor.on("create",o),a&&e.editor.on("update",a),s&&e.editor.on("selectionUpdate",s),c&&e.editor.on("transaction",c),l&&e.editor.on("focus",l),u&&e.editor.on("blur",u),d&&e.editor.on("destroy",d)})}}])}();By.resolve=Ug,By.sort=$g,By.flatten=Ig;bm({},{ClipboardTextSerializer:function(){return Hy},Commands:function(){return jy},Delete:function(){return Vy},Drop:function(){return Wy},Editable:function(){return $y},FocusEvents:function(){return qy},Keymap:function(){return Ky},Paste:function(){return Jy},Tabindex:function(){return Gy},TextDirection:function(){return Yy},focusEventsPluginKey:function(){return Uy}});var Fy=function(t){function r(){var e;return C(this,r),(e=n(this,r,arguments)).type="extension",e}return i(r,t),x(r,[{key:"configure",value:function(t){return e(r,"configure",this,3)([t])}},{key:"extend",value:function(t){var n="function"==typeof t?t():t;return e(r,"extend",this,3)([n])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r("function"==typeof e?e():e)}}])}(Iy),Hy=Fy.create({name:"clipboardTextSerializer",addOptions:function(){return{blockSeparator:void 0}},addProseMirrorPlugins:function(){var e=this;return[new _h({key:new Eh("clipboardTextSerializer"),props:{clipboardTextSerializer:function(){var t=e.editor,n=t.state,i=t.schema,r=n.doc,o=n.selection.ranges,a=Math.min.apply(Math,c(o.map(function(e){return e.$from.pos}))),s=Math.max.apply(Math,c(o.map(function(e){return e.$to.pos}))),l=Kg(i);return qg(r,{from:a,to:s},d(d({},void 0!==e.options.blockSeparator?{blockSeparator:e.options.blockSeparator}:{}),{},{textSerializers:l}))}}})]}}),jy=Fy.create({name:"commands",addCommands:function(){return d({},xm)}}),Vy=Fy.create({name:"delete",onUpdate:function(e){var t,n,i,r=this,o=e.transaction,a=e.appendedTransactions,s=function(){var e,t,n,i;if(!(null!=(i=null==(n=null==(t=null==(e=r.editor.options.coreExtensionOptions)?void 0:e.delete)?void 0:t.filterTransaction)?void 0:n.call(t,o))?i:o.getMeta("y-sync$"))){var s,l,u,d=(s=o.before,l=[o].concat(c(a)),u=new ah(s),l.forEach(function(e){e.steps.forEach(function(e){u.step(e)})}),u),h=function(e){var t=e.mapping,n=e.steps,i=[];return t.maps.forEach(function(e,r){var o=[];if(e.ranges.length)e.forEach(function(e,t){o.push({from:e,to:t})});else{var a=n[r],s=a.from,c=a.to;if(void 0===s||void 0===c)return;o.push({from:s,to:c})}o.forEach(function(e){var n=e.from,o=e.to,a=t.slice(r).map(n,-1),s=t.slice(r).map(o),c=t.invert().map(a,-1),l=t.invert().map(s);i.push({oldRange:{from:c,to:l},newRange:{from:a,to:s}})})}),Gg(i)}(d);h.forEach(function(e){d.mapping.mapResult(e.oldRange.from).deletedAfter&&d.mapping.mapResult(e.oldRange.to).deletedBefore&&d.before.nodesBetween(e.oldRange.from,e.oldRange.to,function(t,n){var i=n+t.nodeSize-2,a=e.oldRange.from<=n&&i<=e.oldRange.to;r.editor.emit("delete",{type:"node",node:t,from:n,to:i,newFrom:d.mapping.map(n),newTo:d.mapping.map(i),deletedRange:e.oldRange,newRange:e.newRange,partial:!a,editor:r.editor,transaction:o,combinedTransform:d})})});var f=d.mapping;d.steps.forEach(function(e,t){var n,i;if(e instanceof Nd){var a=f.slice(t).map(e.from,-1),s=f.slice(t).map(e.to),c=f.invert().map(a,-1),l=f.invert().map(s),u=null==(n=d.doc.nodeAt(a-1))?void 0:n.marks.some(function(t){return t.eq(e.mark)}),h=null==(i=d.doc.nodeAt(s))?void 0:i.marks.some(function(t){return t.eq(e.mark)});r.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:c,to:l},newRange:{from:a,to:s},partial:Boolean(h||u),editor:r.editor,transaction:o,combinedTransform:d})}})}};null==(i=null==(n=null==(t=this.editor.options.coreExtensionOptions)?void 0:t.delete)?void 0:n.async)||i?setTimeout(s,0):s()}}),Wy=Fy.create({name:"drop",addProseMirrorPlugins:function(){var e=this;return[new _h({key:new Eh("tiptapDrop"),props:{handleDrop:function(t,n,i,r){e.editor.emit("drop",{editor:e.editor,event:n,slice:i,moved:r})}}})]}}),$y=Fy.create({name:"editable",addProseMirrorPlugins:function(){var e=this;return[new _h({key:new Eh("editable"),props:{editable:function(){return e.editor.options.editable}}})]}}),Uy=new Eh("focusEvents"),qy=Fy.create({name:"focusEvents",addProseMirrorPlugins:function(){var e=this.editor;return[new _h({key:Uy,props:{handleDOMEvents:{focus:function(t,n){e.isFocused=!0;var i=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1},blur:function(t,n){e.isFocused=!1;var i=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1}}}})]}}),Ky=Fy.create({name:"keymap",addKeyboardShortcuts:function(){var e=this,t=function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.undoInputRule()},function(){return t.command(function(e){var n=e.tr,i=n.selection,r=n.doc,o=i.empty,a=i.$anchor,s=a.pos,c=a.parent,l=a.parent.isTextblock&&s>0?n.doc.resolve(s-1):a,u=l.parent.type.spec.isolating,d=a.pos-a.parentOffset,h=u&&1===l.parent.childCount?d===a.pos:ch.atStart(r).from===s;return!(!o||!c.type.isTextblock||c.textContent.length||!h||h&&"paragraph"===a.parent.type.name)&&t.clearNodes()})},function(){return t.deleteSelection()},function(){return t.joinBackward()},function(){return t.selectNodeBackward()}]})},n=function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.deleteSelection()},function(){return t.deleteCurrentNode()},function(){return t.joinForward()},function(){return t.selectNodeForward()}]})},i={Enter:function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.newlineInCode()},function(){return t.createParagraphNear()},function(){return t.liftEmptyBlock()},function(){return t.splitBlock()}]})},"Mod-Enter":function(){return e.editor.commands.exitCode()},Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:n,"Mod-Delete":n,"Mod-a":function(){return e.editor.commands.selectAll()}},r=d({},i),o=d(d({},i),{},{"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":n,"Ctrl-Alt-Backspace":n,"Alt-Delete":n,"Alt-d":n,"Ctrl-a":function(){return e.editor.commands.selectTextblockStart()},"Ctrl-e":function(){return e.editor.commands.selectTextblockEnd()}});return Gm()||dg()?o:r},addProseMirrorPlugins:function(){var e=this;return[new _h({key:new Eh("clearDocument"),appendTransaction:function(t,n,i){if(!t.some(function(e){return e.getMeta("composition")})){var r=t.some(function(e){return e.docChanged})&&!n.doc.eq(i.doc),o=t.some(function(e){return e.getMeta("preventClearDocument")});if(r&&!o){var a=n.selection,s=a.empty,c=a.from,l=a.to,u=ch.atStart(n.doc).from,d=ch.atEnd(n.doc).to;if(!s&&(c===u&&l===d))if(ty(i.doc)){var h=i.tr,f=Cm({state:i,transaction:h});if(new Sm({editor:e.editor,state:f}).commands.clearNodes(),h.steps.length)return h}}}}})]}}),Jy=Fy.create({name:"paste",addProseMirrorPlugins:function(){var e=this;return[new _h({key:new Eh("tiptapPaste"),props:{handlePaste:function(t,n,i){e.editor.emit("paste",{editor:e.editor,event:n,slice:i})}}})]}}),Gy=Fy.create({name:"tabindex",addProseMirrorPlugins:function(){var e=this;return[new _h({key:new Eh("tabindex"),props:{attributes:function(){return e.editor.isEditable?{tabindex:"0"}:{}}}})]}}),Yy=Fy.create({name:"textDirection",addOptions:function(){return{direction:void 0}},addGlobalAttributes:function(){var e=this;return this.options.direction?[{types:Pg(this.extensions).nodeExtensions.filter(function(e){return"text"!==e.name}).map(function(e){return e.name}),attributes:{dir:{default:this.options.direction,parseHTML:function(t){var n=t.getAttribute("dir");return!n||"ltr"!==n&&"rtl"!==n&&"auto"!==n?e.options.direction:n},renderHTML:function(e){return e.dir?{dir:e.dir}:{}}}}}]:[]},addProseMirrorPlugins:function(){var e=this;return[new _h({key:new Eh("textDirection"),props:{attributes:function(){var t=e.options.direction;return t?{dir:t}:{}}}})]}}),Xy=function(){function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;C(this,e),this.currentNode=null,this.actualDepth=null,this.isBlock=i,this.resolvedPos=t,this.editor=n,this.currentNode=r}return x(e,[{key:"name",get:function(){return this.node.type.name}},{key:"node",get:function(){return this.currentNode||this.resolvedPos.node()}},{key:"element",get:function(){return this.editor.view.domAtPos(this.pos).node}},{key:"depth",get:function(){var e;return null!=(e=this.actualDepth)?e:this.resolvedPos.depth}},{key:"pos",get:function(){return this.resolvedPos.pos}},{key:"content",get:function(){return this.node.content},set:function(e){var t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error("You can’t set content on a block node. Tried to set content on ".concat(this.name," at ").concat(this.pos));t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}},{key:"attributes",get:function(){return this.node.attrs}},{key:"textContent",get:function(){return this.node.textContent}},{key:"size",get:function(){return this.node.nodeSize}},{key:"from",get:function(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}},{key:"range",get:function(){return{from:this.from,to:this.to}}},{key:"to",get:function(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}},{key:"parent",get:function(){if(0===this.depth)return null;var t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}},{key:"before",get:function(){var t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}},{key:"after",get:function(){var t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}},{key:"children",get:function(){var t=this,n=[];return this.node.content.forEach(function(i,r){var o=i.isBlock&&!i.isTextblock,a=i.isAtom&&!i.isText,s=t.pos+r+(a?0:1);if(!(s<0||s>t.resolvedPos.doc.nodeSize-2)){var c=t.resolvedPos.doc.resolve(s);if(o||!(c.depth<=t.depth)){var l=new e(c,t.editor,o,o?i:null);o&&(l.actualDepth=t.depth+1),n.push(new e(c,t.editor,o,o?i:null))}}}),n}},{key:"firstChild",get:function(){return this.children[0]||null}},{key:"lastChild",get:function(){var e=this.children;return e[e.length-1]||null}},{key:"closest",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,i=this.parent;i&&!n;){if(i.node.type.name===e)if(Object.keys(t).length>0)for(var r=i.node.attrs,o=Object.keys(t),a=0;a<o.length;a+=1){var s=o[a];if(r[s]!==t[s])break}else n=i;i=i.parent}return n}},{key:"querySelector",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.querySelectorAll(e,t,!0)[0]||null}},{key:"querySelectorAll",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[];if(!this.children||0===this.children.length)return i;var r=Object.keys(t);return this.children.forEach(function(o){if(!(n&&i.length>0)){if(o.node.type.name===e)r.every(function(e){return t[e]===o.node.attrs[e]})&&i.push(o);n&&i.length>0||(i=i.concat(o.querySelectorAll(e,t,n)))}}),i}},{key:"setAttribute",value:function(e){var t=this.editor.state.tr;t.setNodeMarkup(this.from,void 0,d(d({},this.node.attrs),e)),this.editor.view.dispatch(t)}}])}();var Qy=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};C(this,t),(e=n(this,t)).css=null,e.className="tiptap",e.editorView=null,e.isFocused=!1,e.isInitialized=!1,e.extensionStorage={},e.instanceId=Math.random().toString(36).slice(2,9),e.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:function(){return null},onCreate:function(){return null},onMount:function(){return null},onUnmount:function(){return null},onUpdate:function(){return null},onSelectionUpdate:function(){return null},onTransaction:function(){return null},onFocus:function(){return null},onBlur:function(){return null},onDestroy:function(){return null},onContentError:function(e){throw e.error},onPaste:function(){return null},onDrop:function(){return null},onDelete:function(){return null}},e.isCapturingTransaction=!1,e.capturedTransaction=null,e.utils={getUpdatedPosition:iy,createMappablePosition:ry},e.setOptions(i),e.createExtensionManager(),e.createCommandManager(),e.createSchema(),e.on("beforeCreate",e.options.onBeforeCreate),e.emit("beforeCreate",{editor:e}),e.on("mount",e.options.onMount),e.on("unmount",e.options.onUnmount),e.on("contentError",e.options.onContentError),e.on("create",e.options.onCreate),e.on("update",e.options.onUpdate),e.on("selectionUpdate",e.options.onSelectionUpdate),e.on("transaction",e.options.onTransaction),e.on("focus",e.options.onFocus),e.on("blur",e.options.onBlur),e.on("destroy",e.options.onDestroy),e.on("drop",function(t){var n=t.event,i=t.slice,r=t.moved;return e.options.onDrop(n,i,r)}),e.on("paste",function(t){var n=t.event,i=t.slice;return e.options.onPaste(n,i)}),e.on("delete",e.options.onDelete);var r=e.createDoc(),o=Jm(r,e.options.autofocus);return e.editorState=Th.create({doc:r,schema:e.schema,selection:o||void 0}),e.options.element&&e.mount(e.options.element),e}return i(t,e),x(t,[{key:"mount",value:function(e){var t=this;if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(function(){t.isDestroyed||(!1!==t.options.autofocus&&null!==t.options.autofocus&&t.commands.focus(t.options.autofocus),t.emit("create",{editor:t}),t.isInitialized=!0)},0)}},{key:"unmount",value:function(){if(this.editorView){var e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(".".concat(this.className)).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}},{key:"storage",get:function(){return this.extensionStorage}},{key:"commands",get:function(){return this.commandManager.commands}},{key:"chain",value:function(){return this.commandManager.chain()}},{key:"can",value:function(){return this.commandManager.can()}},{key:"injectCSS",value:function(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=function(e,t,n){var i=document.querySelector("style[data-tiptap-style".concat(n?"-".concat(n):"","]"));if(null!==i)return i;var r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute("data-tiptap-style".concat(n?"-".concat(n):""),""),r.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(r),r}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}',this.options.injectNonce))}},{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=d(d({},this.options),e),this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}},{key:"setEditable",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}},{key:"isEditable",get:function(){return this.options.editable&&this.view&&this.view.editable}},{key:"view",get:function(){var e=this;return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:function(t){e.editorState=t},dispatch:function(t){e.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:function(t,n){if(e.editorView)return e.editorView[n];if("state"===n)return e.editorState;if(n in t)return Reflect.get(t,n);throw new Error("[tiptap error]: The editor view is not available. Cannot access view['".concat(n,"']. The editor may not be mounted yet."))}})}},{key:"state",get:function(){return this.editorView&&(this.editorState=this.view.state),this.editorState}},{key:"registerPlugin",value:function(e,t){var n=Rg(t)?t(e,c(this.state.plugins)):[].concat(c(this.state.plugins),[e]),i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}},{key:"unregisterPlugin",value:function(e){if(!this.isDestroyed){var t=this.state.plugins,n=t;if([].concat(e).forEach(function(e){var t="string"==typeof e?"".concat(e,"$"):e.key;n=n.filter(function(e){return!e.key.startsWith(t)})}),t.length!==n.length){var i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}}}},{key:"createExtensionManager",value:function(){var e,t,n=this,i=this.options.enableCoreExtensions?[$y,Hy.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),jy,qy,Ky,Gy,Wy,Jy,Vy,Yy.configure({direction:this.options.textDirection})].filter(function(e){return"object"!==_(n.options.enableCoreExtensions)||!1!==n.options.enableCoreExtensions[e.name]}):[],r=[].concat(c(i),c(this.options.extensions)).filter(function(e){return["extension","node","mark"].includes(null==e?void 0:e.type)});this.extensionManager=new By(r,this)}},{key:"createCommandManager",value:function(){this.commandManager=new Sm({editor:this})}},{key:"createSchema",value:function(){this.schema=this.extensionManager.schema}},{key:"createDoc",value:function(){var e,t=this;try{e=Ng(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(vs){if(!(vs instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(vs.message)))throw vs;this.emit("contentError",{editor:this,error:vs,disableCollaboration:function(){"collaboration"in t.storage&&"object"===_(t.storage.collaboration)&&t.storage.collaboration&&(t.storage.collaboration.isDisabled=!0),t.options.extensions=t.options.extensions.filter(function(e){return"collaboration"!==e.name}),t.createExtensionManager()}}),e=Ng(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}},{key:"createView",value:function(e){var t;this.editorView=new im(e,d(d({},this.options.editorProps),{},{attributes:d({role:"textbox"},null==(t=this.options.editorProps)?void 0:t.attributes),dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews}));var n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}},{key:"createNodeViews",value:function(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}},{key:"prependClass",value:function(){this.view.dom.className="".concat(this.className," ").concat(this.view.dom.className)}},{key:"captureTransaction",value:function(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;var t=this.capturedTransaction;return this.capturedTransaction=null,t}},{key:"dispatchTransaction",value:function(e){var t=this;if(!this.view.isDestroyed){if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach(function(e){var n;return null==(n=t.capturedTransaction)?void 0:n.step(e)}):void(this.capturedTransaction=e);var n=this.state.applyTransaction(e),i=n.state,r=n.transactions,o=!this.state.selection.eq(i.selection),a=r.includes(e),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:i}),a){this.view.updateState(i),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:r.slice(1)}),o&&this.emit("selectionUpdate",{editor:this,transaction:e});var c=r.findLast(function(e){return e.getMeta("focus")||e.getMeta("blur")}),l=null==c?void 0:c.getMeta("focus"),u=null==c?void 0:c.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:c}),u&&this.emit("blur",{editor:this,event:u.event,transaction:c}),e.getMeta("preventUpdate")||!r.some(function(e){return e.docChanged})||s.doc.eq(i.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:r.slice(1)})}}}},{key:"getAttributes",value:function(e){return Jg(this.state,e)}},{key:"isActive",value:function(e,t){var n="string"==typeof e?e:null,i="string"==typeof e?t:e;return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return fg(e,null,n)||Qg(e,null,n);var i=yg(t,e.schema);return"node"===i?fg(e,t,n):"mark"===i&&Qg(e,t,n)}(this.state,n,i)}},{key:"getJSON",value:function(){return this.state.doc.toJSON()}},{key:"getHTML",value:function(){return Lg(this.state.doc.content,this.schema)}},{key:"getText",value:function(e){var t=e||{},n=t.blockSeparator,i=void 0===n?"\n\n":n,r=t.textSerializers,o=void 0===r?{}:r;return function(e,t){return qg(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:i,textSerializers:d(d({},Kg(this.schema)),o)})}},{key:"isEmpty",get:function(){return ty(this.state.doc)}},{key:"destroy",value:function(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}},{key:"isDestroyed",get:function(){var e,t;return null==(t=null==(e=this.editorView)?void 0:e.isDestroyed)||t}},{key:"$node",value:function(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelector(e,t))||null}},{key:"$nodes",value:function(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(e,t))||null}},{key:"$pos",value:function(e){var t=this.state.doc.resolve(e);return new Xy(t,this)}},{key:"$doc",get:function(){return this.$pos(0)}}])}(Ny);var Zy=function(){return x(function e(t){var n,i,r,o,a,s=this;C(this,e),this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=function(e){if(s.isResizing&&s.activeHandle){var t=e.clientX-s.startX,n=e.clientY-s.startY;s.handleResize(t,n)}},this.handleTouchMove=function(e){if(s.isResizing&&s.activeHandle){var t=e.touches[0];if(t){var n=t.clientX-s.startX,i=t.clientY-s.startY;s.handleResize(n,i)}}},this.handleMouseUp=function(){if(s.isResizing){var e=s.element.offsetWidth,t=s.element.offsetHeight;s.onCommit(e,t),s.isResizing=!1,s.activeHandle=null,s.container.dataset.resizeState="false",s.classNames.resizing&&s.container.classList.remove(s.classNames.resizing),document.removeEventListener("mousemove",s.handleMouseMove),document.removeEventListener("mouseup",s.handleMouseUp),document.removeEventListener("keydown",s.handleKeyDown),document.removeEventListener("keyup",s.handleKeyUp)}},this.handleKeyDown=function(e){"Shift"===e.key&&(s.isShiftKeyPressed=!0)},this.handleKeyUp=function(e){"Shift"===e.key&&(s.isShiftKeyPressed=!1)},this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(null==(n=t.options)?void 0:n.min)&&(this.minSize=d(d({},this.minSize),t.options.min)),(null==(i=t.options)?void 0:i.max)&&(this.maxSize=t.options.max),(null==(r=null==t?void 0:t.options)?void 0:r.directions)&&(this.directions=t.options.directions),(null==(o=t.options)?void 0:o.preserveAspectRatio)&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(null==(a=t.options)?void 0:a.className)&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()},[{key:"dom",get:function(){return this.container}},{key:"contentDOM",get:function(){return this.contentElement}},{key:"update",value:function(e,t,n){return e.type===this.node.type&&(this.node=e,!this.onUpdate||this.onUpdate(e,t,n))}},{key:"destroy",value:function(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}},{key:"createContainer",value:function(){var e=document.createElement("div");return e.dataset.resizeContainer="",e.dataset.node=this.node.type.name,e.style.display="flex",e.style.justifyContent="flex-start",e.style.alignItems="flex-start",this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}},{key:"createWrapper",value:function(){var e=document.createElement("div");return e.style.position="relative",e.style.display="block",e.dataset.resizeWrapper="",this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}},{key:"createHandle",value:function(e){var t=document.createElement("div");return t.dataset.resizeHandle=e,t.style.position="absolute",this.classNames.handle&&(t.className=this.classNames.handle),t}},{key:"positionHandle",value:function(e,t){var n=t.includes("top"),i=t.includes("bottom"),r=t.includes("left"),o=t.includes("right");n&&(e.style.top="0"),i&&(e.style.bottom="0"),r&&(e.style.left="0"),o&&(e.style.right="0"),"top"!==t&&"bottom"!==t||(e.style.left="0",e.style.right="0"),"left"!==t&&"right"!==t||(e.style.top="0",e.style.bottom="0")}},{key:"attachHandles",value:function(){var e=this;this.directions.forEach(function(t){var n=e.createHandle(t);e.positionHandle(n,t),n.addEventListener("mousedown",function(n){return e.handleResizeStart(n,t)}),n.addEventListener("touchstart",function(n){return e.handleResizeStart(n,t)}),e.wrapper.appendChild(n)})}},{key:"applyInitialSize",value:function(){var e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width="".concat(e,"px"),this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height="".concat(t,"px"),this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}},{key:"handleResizeStart",value:function(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,!function(e){return"touches"in e}(e)?(this.startX=e.clientX,this.startY=e.clientY):(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}},{key:"handleResize",value:function(e,t){if(this.activeHandle){var n=this.preserveAspectRatio||this.isShiftKeyPressed,i=this.calculateNewDimensions(this.activeHandle,e,t),r=i.width,o=i.height,a=this.applyConstraints(r,o,n);this.element.style.width="".concat(a.width,"px"),this.element.style.height="".concat(a.height,"px"),this.onResize&&this.onResize(a.width,a.height)}}},{key:"calculateNewDimensions",value:function(e,t,n){var i=this.startWidth,r=this.startHeight,o=e.includes("right"),a=e.includes("left"),s=e.includes("bottom"),c=e.includes("top");return o?i=this.startWidth+t:a&&(i=this.startWidth-t),s?r=this.startHeight+n:c&&(r=this.startHeight-n),"right"!==e&&"left"!==e||(i=this.startWidth+(o?t:-t)),"top"!==e&&"bottom"!==e||(r=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(i,r,e):{width:i,height:r}}},{key:"applyConstraints",value:function(e,t,n){var i,r,o,a;if(!n){var s=Math.max(this.minSize.width,e),c=Math.max(this.minSize.height,t);return(null==(i=this.maxSize)?void 0:i.width)&&(s=Math.min(this.maxSize.width,s)),(null==(r=this.maxSize)?void 0:r.height)&&(c=Math.min(this.maxSize.height,c)),{width:s,height:c}}var l=e,u=t;return l<this.minSize.width&&(u=(l=this.minSize.width)/this.aspectRatio),u<this.minSize.height&&(l=(u=this.minSize.height)*this.aspectRatio),(null==(o=this.maxSize)?void 0:o.width)&&l>this.maxSize.width&&(u=(l=this.maxSize.width)/this.aspectRatio),(null==(a=this.maxSize)?void 0:a.height)&&u>this.maxSize.height&&(l=(u=this.maxSize.height)*this.aspectRatio),{width:l,height:u}}},{key:"applyAspectRatio",value:function(e,t,n){var i="top"===n||"bottom"===n;return"left"===n||"right"===n?{width:e,height:e/this.aspectRatio}:i?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}}])}();function ek(e){if(!(null==e?void 0:e.trim()))return{};var t={},n=[],i=e.replace(/["']([^"']*)["']/g,function(e){return n.push(e),"__QUOTED_".concat(n.length-1,"__")}),r=i.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(r){var o=r.map(function(e){return e.trim().slice(1)});t.class=o.join(" ")}var a=i.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(t.id=a[1]);Array.from(i.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(function(e){var i,r=g(e,3),o=r[1],a=r[2],s=parseInt((null==(i=a.match(/__QUOTED_(\d+)__/))?void 0:i[1])||"0",10),c=n[s];c&&(t[o]=c.slice(1,-1))});var s=i.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();s&&s.split(/\s+/).filter(Boolean).forEach(function(e){e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)});return t}function tk(e){if(!e||0===Object.keys(e).length)return"";var t=[];e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(function(e){return t.push(".".concat(e))});return e.id&&t.push("#".concat(e.id)),Object.entries(e).forEach(function(e){var n=g(e,2),i=n[0],r=n[1];"class"!==i&&"id"!==i&&(!0===r?t.push(i):!1!==r&&null!=r&&t.push("".concat(i,'="').concat(String(r),'"')))}),t.join(" ")}function nk(e){var t=e.nodeName,n=e.name,i=e.parseAttributes,r=void 0===i?ek:i,o=e.serializeAttributes,a=void 0===o?tk:o,s=e.defaultAttributes,c=void 0===s?{}:s,l=e.requiredAttributes,u=void 0===l?[]:l,h=e.allowedAttributes,f=n||t;return{parseMarkdown:function(e,n){var i=d(d({},c),e.attributes);return n.createNode(t,i,[])},markdownTokenizer:{name:t,level:"block",start:function(e){var t,n=new RegExp("^:::".concat(f,"(?:\\s|$)"),"m"),i=null==(t=e.match(n))?void 0:t.index;return void 0!==i?i:-1},tokenize:function(e,n,i){var o=new RegExp("^:::".concat(f,"(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)")),a=e.match(o);if(a){var s=a[1]||"",c=r(s);if(!u.find(function(e){return!(e in c)}))return{type:t,raw:a[0],attributes:c}}}},renderMarkdown:function(e){var t=function(e){if(!h)return e;var t={};return h.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),n=a(t),i=n?" {".concat(n,"}"):"";return":::".concat(f).concat(i," :::")}}}function ik(e){var t=e.nodeName,n=e.name,i=e.getContent,r=e.parseAttributes,o=void 0===r?ek:r,a=e.serializeAttributes,s=void 0===a?tk:a,c=e.defaultAttributes,l=void 0===c?{}:c,u=e.content,h=void 0===u?"block":u,f=e.allowedAttributes,p=n||t;return{parseMarkdown:function(e,n){var r;if(i){var o=i(e);r="string"==typeof o?[{type:"text",text:o}]:o}else r="block"===h?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);var a=d(d({},l),e.attributes);return n.createNode(t,a,r)},markdownTokenizer:{name:t,level:"block",start:function(e){var t,n=new RegExp("^:::".concat(p),"m"),i=null==(t=e.match(n))?void 0:t.index;return void 0!==i?i:-1},tokenize:function(e,n,i){var r,a=new RegExp("^:::".concat(p,"(?:\\s+\\{([^}]*)\\})?\\s*\\n")),s=e.match(a);if(s){var c=g(s,2),l=c[0],u=c[1],d=o(void 0===u?"":u),f=1,v=l.length,m="",y=/^:::([\w-]*)(\s.*)?/gm,k=e.slice(v);for(y.lastIndex=0;;){var w=y.exec(k);if(null===w)break;var b=w.index,C=w[1];if(!(null==(r=w[2])?void 0:r.endsWith(":::")))if(C)f+=1;else if(0===(f-=1)){var S=k.slice(0,b);m=S.trim();var x=e.slice(0,v+b+w[0].length),T=[];if(m)if("block"===h)for((T=i.blockTokens(S)).forEach(function(e){!e.text||e.tokens&&0!==e.tokens.length||(e.tokens=i.inlineTokens(e.text))});T.length>0;){var M=T[T.length-1];if("paragraph"!==M.type||M.text&&""!==M.text.trim())break;T.pop()}else T=i.inlineTokens(m);return{type:t,raw:x,attributes:d,content:m,tokens:T}}}}}},renderMarkdown:function(e,t){var n=function(e){if(!f)return e;var t={};return f.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),i=s(n),r=i?" {".concat(i,"}"):"",o=t.renderChildren(e.content||[],"\n\n");return":::".concat(p).concat(r,"\n\n").concat(o,"\n\n:::")}}}function rk(e){if(!e.trim())return{};for(var t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,i=n.exec(e);null!==i;){var r=g(i,4),o=r[1],a=r[2],s=r[3];t[o]=a||s,i=n.exec(e)}return t}function ok(e){return Object.entries(e).filter(function(e){var t=g(e,2)[1];return null!=t}).map(function(e){var t=g(e,2),n=t[0],i=t[1];return"".concat(n,'="').concat(i,'"')}).join(" ")}function ak(e){var t=e.nodeName,n=e.name,i=e.getContent,r=e.parseAttributes,o=void 0===r?rk:r,a=e.serializeAttributes,s=void 0===a?ok:a,c=e.defaultAttributes,l=void 0===c?{}:c,u=e.selfClosing,h=void 0!==u&&u,f=e.allowedAttributes,p=n||t,v=p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:function(e,n){var r=d(d({},l),e.attributes);if(h)return n.createNode(t,r);var o=i?i(e):e.content||"";return o?n.createNode(t,r,[n.createTextNode(o)]):n.createNode(t,r,[])},markdownTokenizer:{name:t,level:"inline",start:function(e){var t=h?new RegExp("\\[".concat(v,"\\s*[^\\]]*\\]")):new RegExp("\\[".concat(v,"\\s*[^\\]]*\\][\\s\\S]*?\\[\\/").concat(v,"\\]")),n=e.match(t),i=null==n?void 0:n.index;return void 0!==i?i:-1},tokenize:function(e,n,i){var r=h?new RegExp("^\\[".concat(v,"\\s*([^\\]]*)\\]")):new RegExp("^\\[".concat(v,"\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/").concat(v,"\\]")),a=e.match(r);if(a){var s="",c="";if(h){c=g(a,2)[1]}else{var l=g(a,3);c=l[1],s=l[2]||""}var u=o(c.trim());return{type:t,raw:a[0],content:s.trim(),attributes:u}}}},renderMarkdown:function(e){var t="";i?t=i(e):e.content&&e.content.length>0&&(t=e.content.filter(function(e){return"text"===e.type}).map(function(e){return e.text}).join(""));var n=function(e){if(!f)return e;var t={};return f.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),r=s(n),o=r?" ".concat(r):"";return h?"[".concat(p).concat(o,"]"):"[".concat(p).concat(o,"]").concat(t,"[/").concat(p,"]")}}}function sk(e,t,n){for(var i,r,o,a,s,c=e.split("\n"),l=[],u="",d=0,h=t.baseIndentSize||2,f=function(){var e=c[d],s=e.match(t.itemPattern);if(!s)return l.length>0?0:""===e.trim()?(d+=1,u="".concat(u).concat(e,"\n"),1):{v:void 0};var f=t.extractItemData(s),p=f.indentLevel,v=f.mainContent;u="".concat(u).concat(e,"\n");var m,g=[v];for(d+=1;d<c.length;){var y=c[d];if(""===y.trim()){var k=c.slice(d+1).findIndex(function(e){return""!==e.trim()});if(-1===k)break;var w=c[d+1+k];if(((null==(r=null==(i=w.match(/^(\s*)/))?void 0:i[1])?void 0:r.length)||0)>p){g.push(y),u="".concat(u).concat(y,"\n"),d+=1;continue}break}if(!(((null==(a=null==(o=y.match(/^(\s*)/))?void 0:o[1])?void 0:a.length)||0)>p))break;g.push(y),u="".concat(u).concat(y,"\n"),d+=1}var b=g.slice(1);if(b.length>0){var C=b.map(function(e){return e.slice(p+h)}).join("\n");C.trim()&&(m=t.customNestedParser?t.customNestedParser(C):n.blockTokens(C))}var S=t.createToken(f,m);l.push(S)};d<c.length&&0!==(s=f());)if(1!==s&&s)return s.v;if(0!==l.length)return{items:l,raw:u}}function ck(e,t,n,i){if(!e||!Array.isArray(e.content))return"";var r="function"==typeof n?n(i):n,o=function(e){return b(e)||l(e)||k(e)||y()}(e.content),a=o[0],s=o.slice(1),c=t.renderChildren([a]),u=["".concat(r).concat(c)];return s&&s.length>0&&s.forEach(function(e){var n=t.renderChildren([e]);if(n){var i=n.split("\n").map(function(e){return e?t.indent(e):""}).join("\n");u.push(i)}}),u.join("\n")}bm({},{createAtomBlockMarkdownSpec:function(){return nk},createBlockMarkdownSpec:function(){return ik},createInlineMarkdownSpec:function(){return ak},parseAttributes:function(){return ek},parseIndentedBlocks:function(){return sk},renderNestedMarkdownContent:function(){return ck},serializeAttributes:function(){return tk}});var lk=function(t){function r(){var e;return C(this,r),(e=n(this,r,arguments)).type="node",e}return i(r,t),x(r,[{key:"configure",value:function(t){return e(r,"configure",this,3)([t])}},{key:"extend",value:function(t){var n="function"==typeof t?t():t;return e(r,"extend",this,3)([n])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r("function"==typeof e?e():e)}}])}(Iy),uk=lk.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:function(e,t){return e.content?t.renderChildren(e.content,"\n\n"):""}}),dk=uk;function hk(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new _h({view:function(t){return new fk(t,e)}})}var fk=function(){return x(function e(t,n){var i,r=this;C(this,e),this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(i=n.width)&&void 0!==i?i:1,this.color=!1===n.color?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(function(e){var n=function(t){r[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}})},[{key:"destroy",value:function(){var e=this;this.handlers.forEach(function(t){var n=t.name,i=t.handler;return e.editorView.dom.removeEventListener(n,i)})}},{key:"update",value:function(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}},{key:"setCursor",value:function(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}},{key:"updateOverlay",value:function(){var e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,i=this.editorView.dom,r=i.getBoundingClientRect(),o=r.width/i.offsetWidth,a=r.height/i.offsetHeight;if(n){var s=t.nodeBefore,c=t.nodeAfter;if(s||c){var l=this.editorView.nodeDOM(this.cursorPos-(s?s.nodeSize:0));if(l){var u=l.getBoundingClientRect(),d=s?u.bottom:u.top;s&&c&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);var h=this.width/2*a;e={left:u.left,right:u.right,top:d-h,bottom:d+h}}}}if(!e){var f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;e={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}var v,m,g=this.editorView.dom.offsetParent;if(this.element||(this.element=g.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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!g||g==document.body&&"static"==getComputedStyle(g).position)v=-pageXOffset,m=-pageYOffset;else{var y=g.getBoundingClientRect(),k=y.width/g.offsetWidth,w=y.height/g.offsetHeight;v=y.left-g.scrollLeft*k,m=y.top-g.scrollTop*w}this.element.style.left=(e.left-v)/o+"px",this.element.style.top=(e.top-m)/a+"px",this.element.style.width=(e.right-e.left)/o+"px",this.element.style.height=(e.bottom-e.top)/a+"px"}},{key:"scheduleRemoval",value:function(e){var t=this;clearTimeout(this.timeout),this.timeout=setTimeout(function(){return t.setCursor(null)},e)}},{key:"dragover",value:function(e){if(this.editorView.editable){var t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,r="function"==typeof i?i(this.editorView,t,e):i;if(t&&!r){var o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){var a=Ud(this.editorView.state.doc,o,this.editorView.dragging.slice);null!=a&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}}},{key:"dragend",value:function(){this.scheduleRemoval(20)}},{key:"drop",value:function(){this.scheduleRemoval(20)}},{key:"dragleave",value:function(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}])}(),pk=function(e){function t(e){return C(this,t),n(this,t,[e,e])}return i(t,e),x(t,[{key:"map",value:function(e,n){var i=e.resolve(n.map(this.head));return t.valid(i)?new t(i):ch.near(i)}},{key:"content",value:function(){return vu.empty}},{key:"eq",value:function(e){return e instanceof t&&e.head==this.head}},{key:"toJSON",value:function(){return{type:"gapcursor",pos:this.head}}},{key:"getBookmark",value:function(){return new vk(this.anchor)}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}},{key:"valid",value:function(e){var t=e.parent;if(t.isTextblock||!function(e){for(var t=e.depth;t>=0;t--){var n=e.index(t),i=e.node(t);if(0!=n)for(var r=i.child(n-1);;r=r.lastChild){if(0==r.childCount&&!r.inlineContent||mk(r.type))return!0;if(r.inlineContent)return!1}else if(i.type.spec.isolating)return!0}return!0}(e)||!function(e){for(var t=e.depth;t>=0;t--){var n=e.indexAfter(t),i=e.node(t);if(n!=i.childCount)for(var r=i.child(n);;r=r.firstChild){if(0==r.childCount&&!r.inlineContent||mk(r.type))return!0;if(r.inlineContent)return!1}else if(i.type.spec.isolating)return!0}return!0}(e))return!1;var n=t.type.spec.allowGapCursor;if(null!=n)return n;var i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}},{key:"findGapCursorFrom",value:function(e,n){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e:for(;;){if(!i&&t.valid(e))return e;for(var r=e.pos,o=null,a=e.depth;;a--){var s=e.node(a);if(n>0?e.indexAfter(a)<s.childCount:e.index(a)>0){o=s.child(n>0?e.indexAfter(a):e.index(a)-1);break}if(0==a)return null;r+=n;var c=e.doc.resolve(r);if(t.valid(c))return c}for(;;){var l=n>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!ph.isSelectable(o)){e=e.doc.resolve(r+o.nodeSize*n),i=!1;continue e}break}o=l,r+=n;var u=e.doc.resolve(r);if(t.valid(u))return u}return null}}}])}(ch);pk.prototype.visible=!1,pk.findFrom=pk.findGapCursorFrom,ch.jsonID("gapcursor",pk);var vk=function(){function e(t){C(this,e),this.pos=t}return x(e,[{key:"map",value:function(t){return new e(t.map(this.pos))}},{key:"resolve",value:function(e){var t=e.resolve(this.pos);return pk.valid(t)?new pk(t):ch.near(t)}}])}();function mk(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}var gk=km({ArrowLeft:yk("horiz",-1),ArrowRight:yk("horiz",1),ArrowUp:yk("vert",-1),ArrowDown:yk("vert",1)});function yk(e,t){var n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,i,r){var o=e.selection,a=t>0?o.$to:o.$from,s=o.empty;if(o instanceof hh){if(!r.endOfTextblock(n)||0==a.depth)return!1;s=!1,a=e.doc.resolve(t>0?a.after():a.before())}var c=pk.findGapCursorFrom(a,t,s);return!!c&&(i&&i(e.tr.setSelection(new pk(c))),!0)}}function kk(e,t,n){if(!e||!e.editable)return!1;var i=e.state.doc.resolve(t);if(!pk.valid(i))return!1;var r=e.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&ph.isSelectable(e.state.doc.nodeAt(r.inside)))&&(e.dispatch(e.state.tr.setSelection(new pk(i))),!0)}function wk(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof pk))return!1;var n=e.state.selection.$from,i=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!i)return!1;for(var r=lu.empty,o=i.length-1;o>=0;o--)r=lu.from(i[o].createAndFill(null,r));var a=e.state.tr.replace(n.pos,n.pos,new vu(r,0,0));return a.setSelection(hh.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function bk(e){if(!(e.selection instanceof pk))return null;var t=document.createElement("div");return t.className="ProseMirror-gapcursor",Av.create(e.doc,[Nv.widget(e.selection.head,t,{key:"gapcursor"})])}var Ck=200,Sk=function(){};Sk.prototype.append=function(e){return e.length?(e=Sk.from(e),!this.length&&e||e.length<Ck&&this.leafAppend(e)||this.length<Ck&&e.leafPrepend(this)||this.appendInner(e)):this},Sk.prototype.prepend=function(e){return e.length?Sk.from(e).append(this):this},Sk.prototype.appendInner=function(e){return new Tk(this,e)},Sk.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Sk.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Sk.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Sk.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Sk.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var i=[];return this.forEach(function(t,n){return i.push(e(t,n))},t,n),i},Sk.from=function(e){return e instanceof Sk?e:e&&e.length?new xk(e):Sk.empty};var xk=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,i){for(var r=t;r<n;r++)if(!1===e(this.values[r],i+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,i){for(var r=t-1;r>=n;r--)if(!1===e(this.values[r],i+r))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Ck)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Ck)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Sk);Sk.empty=new xk([]);var Tk=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,i){var r=this.left.length;return!(t<r&&!1===this.left.forEachInner(e,t,Math.min(n,r),i))&&(!(n>r&&!1===this.right.forEachInner(e,Math.max(t-r,0),Math.min(this.length,n)-r,i+r))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,i){var r=this.left.length;return!(t>r&&!1===this.right.forEachInvertedInner(e,t-r,Math.max(n,r)-r,i+r))&&(!(n<r&&!1===this.left.forEachInvertedInner(e,Math.min(t,r),n,i))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Sk),Mk=function(){function e(t,n){C(this,e),this.items=t,this.eventCount=n}return x(e,[{key:"popEvent",value:function(t,n){var i=this;if(0==this.eventCount)return null;for(var r,o,a=this.items.length;;a--){if(this.items.get(a-1).selection){--a;break}}n&&(r=this.remapping(a,this.items.length),o=r.maps.length);var s,c,l=t.tr,u=[],d=[];return this.items.forEach(function(t,n){if(!t.step)return r||(r=i.remapping(a,n+1),o=r.maps.length),o--,void d.push(t);if(r){d.push(new _k(t.map));var h,f=t.step.map(r.slice(o));f&&l.maybeStep(f).doc&&(h=l.mapping.maps[l.mapping.maps.length-1],u.push(new _k(h,void 0,void 0,u.length+d.length))),o--,h&&r.appendMap(h,o)}else l.maybeStep(t.step);return t.selection?(s=r?t.selection.map(r.slice(o)):t.selection,c=new e(i.items.slice(0,a).append(d.reverse().concat(u)),i.eventCount-1),!1):void 0},this.items.length,0),{remaining:c,transform:l,selection:s}}},{key:"addTransform",value:function(t,n,i,r){for(var o=[],a=this.eventCount,s=this.items,c=!r&&s.length?s.get(s.length-1):null,l=0;l<t.steps.length;l++){var u,d=t.steps[l].invert(t.docs[l]),h=new _k(t.mapping.maps[l],d,n);(u=c&&c.merge(h))&&(h=u,l?o.pop():s=s.slice(0,s.length-1)),o.push(h),n&&(a++,n=void 0),r||(c=h)}var f=a-i.depth;return f>Ok&&(s=function(e,t){var n;return e.forEach(function(e,i){if(e.selection&&0==t--)return n=i,!1}),e.slice(n)}(s,f),a-=f),new e(s.append(o),a)}},{key:"remapping",value:function(e,t){var n=new Cd;return this.items.forEach(function(t,i){var r=null!=t.mirrorOffset&&i-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,r)},e,t),n}},{key:"addMaps",value:function(t){return 0==this.eventCount?this:new e(this.items.append(t.map(function(e){return new _k(e)})),this.eventCount)}},{key:"rebased",value:function(t,n){if(!this.eventCount)return this;var i=[],r=Math.max(0,this.items.length-n),o=t.mapping,a=t.steps.length,s=this.eventCount;this.items.forEach(function(e){e.selection&&s--},r);var c=n;this.items.forEach(function(e){var n=o.getMirror(--c);if(null!=n){a=Math.min(a,n);var r=o.maps[n];if(e.step){var l=t.steps[n].invert(t.docs[n]),u=e.selection&&e.selection.map(o.slice(c+1,n));u&&s++,i.push(new _k(r,l,u))}else i.push(new _k(r))}},r);for(var l=[],u=n;u<a;u++)l.push(new _k(o.maps[u]));var d=new e(this.items.slice(0,r).append(l).append(i),s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-i.length)),d}},{key:"emptyItemCount",value:function(){var e=0;return this.items.forEach(function(t){t.step||e++}),e}},{key:"compress",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items.length,n=this.remapping(0,t),i=n.maps.length,r=[],o=0;return this.items.forEach(function(e,a){if(a>=t)r.push(e),e.selection&&o++;else if(e.step){var s=e.step.map(n.slice(i)),c=s&&s.getMap();if(i--,c&&n.appendMap(c,i),s){var l=e.selection&&e.selection.map(n.slice(i));l&&o++;var u,d=new _k(c.invert(),s,l),h=r.length-1;(u=r.length&&r[h].merge(d))?r[h]=u:r.push(d)}}else e.map&&i--},this.items.length,0),new e(Sk.from(r.reverse()),o)}}])}();Mk.empty=new Mk(Sk.empty,0);var _k=function(){function e(t,n,i,r){C(this,e),this.map=t,this.step=n,this.selection=i,this.mirrorOffset=r}return x(e,[{key:"merge",value:function(t){if(this.step&&t.step&&!t.selection){var n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}}])}(),Nk=x(function e(t,n,i,r,o){C(this,e),this.done=t,this.undone=n,this.prevRanges=i,this.prevTime=r,this.prevComposition=o}),Ok=20;function Ek(e){for(var t=[],n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(function(e,n,i,r){return t.push(i,r)});return t}function Ak(e,t){if(!e)return null;for(var n=[],i=0;i<e.length;i+=2){var r=t.map(e[i],1),o=t.map(e[i+1],-1);r<=o&&n.push(r,o)}return n}var Dk=!1,Ik=null;function Lk(e){var t=e.plugins;if(Ik!=t){Dk=!1,Ik=t;for(var n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Dk=!0;break}}return Dk}var Rk=new Eh("history"),zk=new Eh("closeHistory");function Pk(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new _h({key:Rk,state:{init:function(){return new Nk(Mk.empty,Mk.empty,null,0,-1)},apply:function(t,n,i){return function(e,t,n,i){var r,o=n.getMeta(Rk);if(o)return o.historyState;n.getMeta(zk)&&(e=new Nk(e.done,e.undone,null,0,-1));var a=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(a&&a.getMeta(Rk))return a.getMeta(Rk).redo?new Nk(e.done.addTransform(n,void 0,i,Lk(t)),e.undone,Ek(n.mapping.maps),e.prevTime,e.prevComposition):new Nk(e.done,e.undone.addTransform(n,void 0,i,Lk(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||a&&!1===a.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new Nk(e.done.rebased(n,r),e.undone.rebased(n,r),Ak(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Nk(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ak(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);var s=n.getMeta("composition"),c=0==e.prevTime||!a&&e.prevComposition!=s&&(e.prevTime<(n.time||0)-i.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;var n=!1;return e.mapping.maps[0].forEach(function(e,i){for(var r=0;r<t.length;r+=2)e<=t[r+1]&&i>=t[r]&&(n=!0)}),n}(n,e.prevRanges)),l=a?Ak(e.prevRanges,n.mapping):Ek(n.mapping.maps);return new Nk(e.done.addTransform(n,c?t.selection.getBookmark():void 0,i,Lk(t)),Mk.empty,l,n.time,null==s?e.prevComposition:s)}(n,i,t,e)}},config:e,props:{handleDOMEvents:{beforeinput:function(e,t){var n=t.inputType,i="historyUndo"==n?Fk:"historyRedo"==n?Hk:null;return!(!i||!e.editable)&&(t.preventDefault(),i(e.state,e.dispatch))}}}})}function Bk(e,t){return function(n,i){var r=Rk.getState(n);if(!r||0==(e?r.undone:r.done).eventCount)return!1;if(i){var o=function(e,t,n){var i=Lk(t),r=Rk.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,i);if(!o)return null;var a=o.selection.resolve(o.transform.doc),s=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),r,i),c=new Nk(n?s:o.remaining,n?o.remaining:s,null,0,-1);return o.transform.setSelection(a).setMeta(Rk,{redo:n,historyState:c})}(r,n,e);o&&i(t?o.scrollIntoView():o)}return!0}}var Fk=Bk(!1,!0),Hk=Bk(!0,!0);Fy.create({name:"characterCount",addOptions:function(){return{limit:null,mode:"textSize",textCounter:function(e){return e.length},wordCounter:function(e){return e.split(" ").filter(function(e){return""!==e}).length}}},addStorage:function(){return{characters:function(){return 0},words:function(){return 0}}},onBeforeCreate:function(){var e=this;this.storage.characters=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc;if("textSize"===((null==t?void 0:t.mode)||e.options.mode)){var i=n.textBetween(0,n.content.size,void 0," ");return e.options.textCounter(i)}return n.nodeSize},this.storage.words=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc,i=n.textBetween(0,n.content.size," "," ");return e.options.wordCounter(i)}},addProseMirrorPlugins:function(){var e=this,t=!1;return[new _h({key:new Eh("characterCount"),appendTransaction:function(n,i,r){if(!t){var o=e.options.limit;if(null!=o&&0!==o){var a=e.storage.characters({node:r.doc});if(a>o){var s=a-o;console.warn("[CharacterCount] Initial content exceeded limit of ".concat(o," characters. Content was automatically trimmed."));var c=r.tr.deleteRange(0,s);return t=!0,c}t=!0}else t=!0}},filterTransaction:function(t,n){var i=e.options.limit;if(!t.docChanged||0===i||null==i)return!0;var r=e.storage.characters({node:n.doc}),o=e.storage.characters({node:t.doc});if(o<=i)return!0;if(r>i&&o>i&&o<=r)return!0;if(r>i&&o>i&&o>r)return!1;if(!t.getMeta("paste"))return!1;var a=t.selection.$head.pos,s=a-(o-i),c=a;return t.deleteRange(s,c),!(e.storage.characters({node:t.doc})>i)}})]}}),Fy.create({name:"dropCursor",addOptions:function(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins:function(){return[hk(this.options)]}}),Fy.create({name:"focus",addOptions:function(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins:function(){var e=this;return[new _h({key:new Eh("focus"),props:{decorations:function(t){var n=t.doc,i=t.selection,r=e.editor,o=r.isEditable,a=r.isFocused,s=i.anchor,c=[];if(!o||!a)return Av.create(n,[]);var l=0;"deepest"===e.options.mode&&n.descendants(function(e,t){if(!e.isText){if(!(s>=t&&s<=t+e.nodeSize-1))return!1;l+=1}});var u=0;return n.descendants(function(t,n){return!t.isText&&(s>=n&&s<=n+t.nodeSize-1&&(u+=1,"deepest"===e.options.mode&&l-u>0||"shallowest"===e.options.mode&&u>1?"deepest"===e.options.mode:void c.push(Nv.node(n,n+t.nodeSize,{class:e.options.className}))))}),Av.create(n,c)}}})]}}),Fy.create({name:"gapCursor",addProseMirrorPlugins:function(){return[new _h({props:{decorations:bk,createSelectionBetween:function(e,t,n){return t.pos==n.pos&&pk.valid(n)?new pk(n):null},handleClick:kk,handleKeyDown:gk,handleDOMEvents:{beforeinput:wk}}})]},extendNodeSchema:function(e){var t;return{allowGapCursor:null!=(t=zg(Dg(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))?t:null}}});var jk=Fy.create({name:"placeholder",addOptions:function(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins:function(){var e=this;return[new _h({key:new Eh("placeholder"),props:{decorations:function(t){var n=t.doc,i=t.selection,r=e.editor.isEditable||!e.options.showOnlyWhenEditable,o=i.anchor,a=[];if(!r)return null;var s=e.editor.isEmpty;return n.descendants(function(t,n){var i=o>=n&&o<=n+t.nodeSize,r=!t.isLeaf&&ty(t);if((i||!e.options.showOnlyCurrent)&&r){var c=[e.options.emptyNodeClass];s&&c.push(e.options.emptyEditorClass);var l=Nv.node(n,n+t.nodeSize,{class:c.join(" "),"data-placeholder":"function"==typeof e.options.placeholder?e.options.placeholder({editor:e.editor,node:t,pos:n,hasAnchor:i}):e.options.placeholder});a.push(l)}return e.options.includeChildren}),Av.create(n,a)}}})]}});function Vk(e){var t=e.types,n=e.node;return n&&Array.isArray(t)&&t.includes(n.type)||(null==n?void 0:n.type)===t}Fy.create({name:"selection",addOptions:function(){return{className:"selection"}},addProseMirrorPlugins:function(){var e=this.editor,t=this.options;return[new _h({key:new Eh("selection"),props:{decorations:function(n){return n.selection.empty||e.isFocused||!e.isEditable||n.selection instanceof ph||e.view.dragging?null:Av.create(n.doc,[Nv.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}}),Fy.create({name:"trailingNode",addOptions:function(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins:function(){var e,t=this,n=new Eh(this.name),i=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(function(e){return g(e,2)[1]}).filter(function(e){return(t.options.notAfter||[]).concat(i).includes(e.name)});return[new _h({key:n,appendTransaction:function(e,t,r){var o=r.doc,a=r.tr,s=r.schema,c=n.getState(r),l=o.content.size,u=s.nodes[i];if(c)return a.insert(l,u.create())},state:{init:function(e,t){return!Vk({node:t.tr.doc.lastChild,types:r})},apply:function(e,t){return e.docChanged?e.getMeta("__uniqueIDTransaction")?t:!Vk({node:e.doc.lastChild,types:r}):t}}})]}});var Wk=Fy.create({name:"undoRedo",addOptions:function(){return{depth:100,newGroupDelay:500}},addCommands:function(){return{undo:function(){return function(e){var t=e.state,n=e.dispatch;return Fk(t,n)}},redo:function(){return function(e){var t=e.state,n=e.dispatch;return Hk(t,n)}}}},addProseMirrorPlugins:function(){return[Pk(this.options)]},addKeyboardShortcuts:function(){var e=this;return{"Mod-z":function(){return e.editor.commands.undo()},"Shift-Mod-z":function(){return e.editor.commands.redo()},"Mod-y":function(){return e.editor.commands.redo()},"Mod-я":function(){return e.editor.commands.undo()},"Shift-Mod-я":function(){return e.editor.commands.redo()}}}}),$k=jk,Uk=lk.create({name:"text",group:"inline",parseMarkdown:function(e){return{type:"text",text:e.text||""}},renderMarkdown:function(e){return e.text||""}}),qk=lk.create({name:"paragraph",priority:1e3,addOptions:function(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML:function(){return[{tag:"p"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["p",Fg(this.options.HTMLAttributes,t),0]},parseMarkdown:function(e,t){var n=e.tokens||[];return 1===n.length&&"image"===n[0].type?t.parseChildren([n[0]]):t.createNode("paragraph",void 0,t.parseInline(n))},renderMarkdown:function(e,t){return e&&Array.isArray(e.content)?t.renderChildren(e.content):""},addCommands:function(){var e=this;return{setParagraph:function(){return function(t){return t.commands.setNode(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Alt-0":function(){return e.editor.commands.setParagraph()}}}}),Kk=qk,Jk=lk.create({name:"hardBreak",markdownTokenName:"br",addOptions:function(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:function(){return[{tag:"br"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["br",Fg(this.options.HTMLAttributes,t)]},renderText:function(){return"\n"},renderMarkdown:function(){return" \n"},parseMarkdown:function(){return{type:"hardBreak"}},addCommands:function(){var e=this;return{setHardBreak:function(){return function(t){var n=t.commands,i=t.chain,r=t.state,o=t.editor;return n.first([function(){return n.exitCode()},function(){return n.command(function(){var t=r.selection,n=r.storedMarks;if(t.$from.parent.type.spec.isolating)return!1;var a=e.options.keepMarks,s=o.extensionManager.splittableMarks,c=n||t.$to.parentOffset&&t.$from.marks();return i().insertContent({type:e.name}).command(function(e){var t=e.tr;if(e.dispatch&&c&&a){var n=c.filter(function(e){return s.includes(e.type.name)});t.ensureMarks(n)}return!0}).run()})}])}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Enter":function(){return e.editor.commands.setHardBreak()},"Shift-Enter":function(){return e.editor.commands.setHardBreak()}}}}),Gk=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Yk=lk.create({name:"image",addOptions:function(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline:function(){return this.options.inline},group:function(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:function(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML:function(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML:function(e){var t=e.HTMLAttributes;return["img",Fg(this.options.HTMLAttributes,t)]},parseMarkdown:function(e,t){return t.createNode("image",{src:e.href,title:e.title,alt:e.text})},renderMarkdown:function(e){var t,n,i,r,o,a,s=null!=(n=null==(t=e.attrs)?void 0:t.src)?n:"",c=null!=(r=null==(i=e.attrs)?void 0:i.alt)?r:"",l=null!=(a=null==(o=e.attrs)?void 0:o.title)?a:"";return l?"![".concat(c,"](").concat(s,' "').concat(l,'")'):"![".concat(c,"](").concat(s,")")},addNodeView:function(){var e=this;if(!this.options.resize||!this.options.resize.enabled||"undefined"==typeof document||!this.editor.isEditable)return null;var t=this.options.resize,n=t.directions,i=t.minWidth,r=t.minHeight,o=t.alwaysPreserveAspectRatio;return function(t){var a=t.node,s=t.getPos,c=t.HTMLAttributes,l=document.createElement("img");Object.entries(c).forEach(function(e){var t=g(e,2),n=t[0],i=t[1];if(null!=i)switch(n){case"width":case"height":break;default:l.setAttribute(n,i)}}),l.src=c.src;var u=new Zy({element:l,node:a,getPos:s,onResize:function(e,t){l.style.width="".concat(e,"px"),l.style.height="".concat(t,"px")},onCommit:function(t,n){var i=s();void 0!==i&&e.editor.chain().setNodeSelection(i).updateAttributes(e.name,{width:t,height:n}).run()},onUpdate:function(e,t,n){return e.type===a.type},options:{directions:n,min:{width:i,height:r},preserveAspectRatio:!0===o}}),d=u.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",l.onload=function(){d.style.visibility="",d.style.pointerEvents=""},u}},addCommands:function(){var e=this;return{setImage:function(t){return function(n){return n.commands.insertContent({type:e.name,attrs:t})}}}},addInputRules:function(){return[(e={find:Gk,type:this.type,getAttributes:function(e){var t=g(e,5),n=t[2];return{src:t[3],alt:n,title:t[4]}}},new Oy({find:e.find,handler:function(t){var n=t.state,i=t.range,r=t.match,o=zg(e.getAttributes,void 0,r)||{},a=n.tr,s=i.from,c=i.to,l=e.type.create(o);if(r[1]){var u=s+r[0].lastIndexOf(r[1]);u>c?u=c:c=u+r[1].length;var d=r[0][r[0].length-1];a.insertText(d,s+r[0].length-1),a.replaceWith(u,c,l)}else if(r[0]){var h=e.type.isInline?s:s-1;a.insert(h,e.type.create(o)).delete(a.mapping.map(s),a.mapping.map(c))}a.scrollIntoView()},undoable:e.undoable}))];var e}}),Xk=Yk,Qk=Fy.create({name:"fileHandler",addOptions:function(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins:function(){return[(e={key:new Eh(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste},t=e.key,n=e.editor,i=e.onPaste,r=e.onDrop,o=e.allowedMimeTypes,new _h({key:t||new Eh("fileHandler"),props:{handleDrop:function(e,t){var i;if(!r)return!1;if(!(null==(i=t.dataTransfer)?void 0:i.files.length))return!1;var a=e.posAtCoords({left:t.clientX,top:t.clientY}),s=Array.from(t.dataTransfer.files);return o&&(s=s.filter(function(e){return o.includes(e.type)})),0!==s.length&&(t.preventDefault(),t.stopPropagation(),r(n,s,(null==a?void 0:a.pos)||0),!0)},handlePaste:function(e,t){var r;if(!i)return!1;if(!(null==(r=t.clipboardData)?void 0:r.files.length))return!1;var a=Array.from(t.clipboardData.files),s=t.clipboardData.getData("text/html");return o&&(a=a.filter(function(e){return o.includes(e.type)})),0!==a.length&&(t.preventDefault(),t.stopPropagation(),i(n,a,s),!(s.length>0))}}}))];var e,t,n,i,r,o}}),Zk=new ra("chat-editor"),ew=fl(function(e,t){var n=e.c,i=e.value,r=e.disabled,o=e.placeholder,a=e.onChange,s=e.onKeyDown,c=e.onCreate,l=qa(null),u=qa(null),d=Ds(!1),f=function(){n.inputExpand.value||requestAnimationFrame(function(){if(l.current){var e=l.current.view.dom;d.value=e.scrollHeight>e.clientHeight}})},p=function(e){n.inputExpand.value=e,e||f()};return $a(function(){var e=function(e){var t;null===(t=l.current)||void 0===t||t.commands.setContent(e)};return n.evt.on("onSetInput",e),function(){n.evt.off("onSetInput",e)}},[]),$a(function(){if(u.current){var e,t,r=function(){var e=v(h().m(function e(t){var i,r;return h().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n.opts.uploader.onUpload(t,function(){},{context:n.context,params:n.params});case 1:if(i=e.v){e.n=2;break}return e.a(2,{name:"",url:""});case 2:return r=n.opts.uploader.getDownLoadUrl(i,{context:n.context,params:n.params}),e.a(2,{name:i.name,url:r})}},e)}));return function(t){return e.apply(this,arguments)}}(),d=new Qy({element:u.current,extensions:[dk,Uk.extend({addKeyboardShortcuts:function(){return{"Mod-Enter":function(){var e,t;return null===(e=l.current)||void 0===e||e.commands.enter(),null===(t=l.current)||void 0===t||t.commands.scrollIntoView(),!0},"Shift-Enter":function(){var e,t;return null===(e=l.current)||void 0===e||e.commands.setHardBreak(),null===(t=l.current)||void 0===t||t.commands.scrollIntoView(),!0}}}}),Kk,Jk,Wk,$k.configure({placeholder:o,showOnlyWhenEditable:!0,showOnlyCurrent:!1}),Xk.configure({inline:!0,allowBase64:!0,HTMLAttributes:{draggable:"false"}}).extend({draggable:!1}),Qk.configure({onDrop:(t=v(h().m(function e(t,n){var i;return h().w(function(e){for(;;)switch(e.n){case 0:if((n=n.filter(function(e){return e.type.startsWith("image/")})).length){e.n=1;break}return e.a(2);case 1:return e.n=2,Promise.all(n.map(function(e){return r(e)}));case 2:if(i=e.v,!t.isDestroyed){e.n=3;break}return e.a(2);case 3:t.chain().deleteSelection().insertContentAt(t.state.selection.from,i.map(function(e){return{type:"image",attrs:{src:e.url,alt:e.name}}})).focus().scrollIntoView().run();case 4:return e.a(2)}},e)})),function(e,n){return t.apply(this,arguments)}),onPaste:(e=v(h().m(function e(t,n){var i;return h().w(function(e){for(;;)switch(e.n){case 0:if((n=n.filter(function(e){return e.type.startsWith("image/")})).length){e.n=1;break}return e.a(2);case 1:return e.n=2,Promise.all(n.map(function(e){return r(e)}));case 2:if(i=e.v,!t.isDestroyed){e.n=3;break}return e.a(2);case 3:t.chain().deleteSelection().insertContentAt(t.state.selection.from,i.map(function(e){return{type:"image",attrs:{src:e.url,alt:e.name}}})).focus().scrollIntoView().run();case 4:return e.a(2)}},e)})),function(t,n){return e.apply(this,arguments)})})],content:i||"",editorProps:{handleKeyDown:function(e,t){return s(t)}},onUpdate:function(){!function(e){a(e),f()}(d.getHTML())},onCreate:function(){c(d)}});return l.current=d,function(){l.current&&(l.current.destroy(),l.current=null)}}},[]),Ka(t,function(){return{toggleCollapse:p}}),na("div",{className:"".concat(Zk.b()," ").concat(r?Zk.m("disabled"):""," ").concat(Zk.is("has-scrollbar",d.value)),children:[na("div",{ref:u,className:Zk.e("content")}),n.inputExpand.value?na("div",{title:Uc.t.value("exitFullscreen"),className:Zk.e("collapse"),onClick:function(){return p(!1)},children:na(js,{})}):na("div",{title:Uc.t.value("fullscreen"),className:Zk.e("collapse"),onClick:function(){return p(!0)},children:na(Hs,{})})]})}),tw=new ra("user-message-question"),nw=function(e){var t=Ds(null),n=Ds(135),i=Ds(!0),r=Ds(!1),o=qa(null),a=Ja(function(){return ba.parseMixedContent(e.message.content)},[e.message.content]),c=Ds({resources:[],remainingText:"",hasResources:!1});c.value=a;var l=g(Wa(!1),2),u=l[0];(0,l[1])(!0===e.message.reeditstate),u&&t.value&&(t.value.destroy(),t.value=null);var d=qa(null);$a(function(){!function(){if(!t.value&&!u){var e=Na.protect(c.value.remainingText||"");t.value=new s({el:o.current,value:e,editor:{defaultModel:"previewOnly",codemirror:{autofocus:!1}},previewer:{enablePreviewerBubble:!1},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}}})}}()},[c.value.remainingText,u]),$a(function(){if(o.current&&window.ResizeObserver){var e=new ResizeObserver(function(){var e,i=null===(e=t.value)||void 0===e?void 0:e.previewer.options.previewerDom;i&&(r.value=i.scrollHeight>n.value)});return e.observe(o.current),function(){e.disconnect()}}},[o.current]);return na("div",{className:tw.b(),children:[na("div",{className:tw.e("user-header"),children:[e.children,na("div",{className:tw.e("user"),children:Uc.t.value("me")})]}),na("div",{className:tw.e("content"),children:[40===e.message.state&&na("div",{className:tw.em("content","warning-container"),onClick:function(t){e.message&&e.controller&&e.controller.refreshMessage(e.message,!0)},children:na("div",{className:tw.em("content","warning"),children:[na("div",{className:"warning-icon",title:Uc.t.value("retry"),children:na(mc,{})}),na("div",{className:"refresh-icon",title:Uc.t.value("retry"),children:na(Bs,{})})]})}),na("div",!0===u?{className:tw.em("content","re-edit-body"),children:[na(ew,{c:e.controller,value:e.controller.reEditContent.value,disabled:e.controller.isLoading.value,onCreate:function(e){d.current=e,e.commands.focus("end")},onChange:function(t){!function(t){e.controller.reEditContent.value=t,e.controller.reEditContentChanged.value=!0}(t)},onKeyDown:function(t){return function(t){return"Escape"===t.code&&"Escape"===t.key&&!0===e.message.reeditstate?(t.stopPropagation(),e.controller.reEditCancel(e.message),!0):"Enter"===t.code&&"Enter"===t.key&&!1===t.shiftKey?(e.controller.reEditContentChanged.value&&setTimeout(function(){e.controller.reEditSubmit(e.message)},0),t.stopPropagation(),!0):void 0}(t)}}),na("div",{className:tw.em("content","re-edit-btns"),children:[na("div",{className:"".concat(tw.em("content","re-edit-btn")," ").concat(tw.em("content","cancel-btn")),onClick:function(t){!function(t){t.stopPropagation(),e.controller.reEditCancel(e.message)}(t)},children:Uc.t.value("cancel")}),na("div",{className:"".concat(tw.em("content","re-edit-btn")," ").concat(tw.em("content","send-btn")," ").concat(tw.is("disabled ",!e.controller.reEditContentChanged.value)),onClick:function(t){!function(t){e.controller.reEditContentChanged.value&&(t.stopPropagation(),e.controller.reEditSubmit(e.message))}(t)},children:Uc.t.value("send")})]})]}:{className:tw.em("content","body"),children:[c.value.hasResources&&na("div",{className:tw.em("content","material"),children:c.value.resources.map(function(t){return na(iu,{material:t,disabled:!0,controller:e.controller},t.id)})}),na("div",{className:"pre-wrap-container",children:[na("div",{className:"".concat(tw.e("text-content")," ").concat(tw.is("collapse",i.value)),ref:o,style:{maxHeight:i.value?"".concat(n.value,"px"):""}}),na("div",{className:"".concat(tw.e("collapse-btn")," ").concat(tw.is("visible",r.value)),title:i.value?Uc.t.value("expand"):Uc.t.value("foldUp"),onClick:function(){i.value=!i.value},children:i.value?na("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",children:na("path",{fill:"currentColor",d:"M104.704 338.752a64 64 0 0 1 90.496 0l316.8 316.8 316.8-316.8a64 64 0 0 1 90.496 90.496L557.248 791.296a64 64 0 0 1-90.496 0L104.704 429.248a64 64 0 0 1 0-90.496"})}):na("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",children:na("path",{fill:"currentColor",d:"M104.704 685.248a64 64 0 0 0 90.496 0l316.8-316.8 316.8 316.8a64 64 0 0 0 90.496-90.496L557.248 232.704a64 64 0 0 0-90.496 0L104.704 594.752a64 64 0 0 0 0 90.496"})})})]})]})]})]})},iw=new ra("error-message"),rw=function(e){var t=e.message,n=e.size,i=g(Wa(!0),2),r=i[0],o=i[1],a=Ds(la()),c=Ds(null),l=Ds({resources:[],remainingText:"",hasResources:!1}),u=function(e){var t=ba.parseMixedContent(e),n=t.resources,i=t.remainingText,r=t.hasResources,o=t.error;l.value={resources:n,remainingText:i,hasResources:r,error:o}};t.think||(t.think={title:"",description:"",collapse:!0});var h=function(e,n){t.think=d(d({},t.think),{},{title:e?Uc.t.value("thinkThrough"):!0===t.completed?Uc.t.value("stopThinking"):Uc.t.value("thinking"),description:n||"",done:e||!0===t.completed}),t.think.done||(t.think.beginTime||(t.think.beginTime=Date.now()),t.think.endTime=void 0),t.think.done&&!t.think.endTime&&(t.think.endTime=Date.now(),t.think.collapse=!0)},f=function(e){var t=e.indexOf("<think>"),n=e.indexOf("</think>"),i="",r="",o=!1;return-1===n?(o=!1,i=e.slice(t+7),r=""):(o=!0,i=e.slice(t+7,n),r=e.slice(n+8)),{isThoughtCompleted:o,thoughtContent:i,answerContent:r}},p=function(t){var n=t.target,i=null==n?void 0:n.closest('a[href^="chunkview://"], a[href^="view://"], a[href^="action://"]');if(i){t.preventDefault();var r=i.getAttribute("href");if(r){var o="";switch(r.startsWith("chunkview://")?o="chunkview":r.startsWith("view://")?o="view":r.startsWith("action://")&&(o="action"),o){case"chunkview":case"view":case"action":e.controller.handlePredefinedClick(o,r,e.message,t);break;default:console.error(Uc.t.value("protocol",{protocol:o}))}}return!1}};$a(function(){if(n>=0&&c.value){if(t.content&&-1!==t.content.indexOf("<think>")){var e=f(t.content),i=e.isThoughtCompleted,r=e.thoughtContent,o=e.answerContent;h(i,r),u(o)}else u(t.content);c.value.setMarkdown(l.value.remainingText||"")}},[t,n]),$a(function(){var e;if(t.content&&-1!==t.content.indexOf("<think>")){var n=f(t.content),i=n.isThoughtCompleted,r=n.thoughtContent,o=n.answerContent;h(i,r),o&&u(o)}else u(t.content);e=l.value.remainingText,c.value=new s({id:a,value:e||"",editor:{defaultModel:"previewOnly",codemirror:{autofocus:!1}},themeSettings:{mainTheme:"dark",codeBlockTheme:"dark"},previewer:{enablePreviewerBubble:!1},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}},callback:{onClickPreview:p}})},[]);var v=Ja(function(){return t.errorText||Uc.t.value("unknownError")},[t.errorText]);return na("div",{className:iw.b(),children:[na("div",{className:iw.b("header"),children:[na("div",{className:iw.be("header","caption"),children:"AI "}),e.children]}),na("div",{className:"".concat(iw.b("content")," pre-wrap-container"),children:[l.value.hasResources&&na("div",{className:"content-material-container",children:l.value.resources.map(function(t){return na(iu,{material:t,disabled:!0,controller:e.controller},t.id)})}),t.chatsteps&&t.chatsteps.length>0&&na(Xl,{items:t.chatsteps||[],controller:e.controller,onLinkClick:p}),na(Zc,{toolcallCompleted:!!t.toolcallcompleted,items:t.toolcalls||[],controller:e.controller,onLinkClick:p}),na(qc,{item:t.think,controller:e.controller}),na("div",{id:a})]}),r&&v&&na("div",{className:"".concat(iw.b("footer")),children:[na("div",{className:"".concat(iw.be("footer","close")),onClick:function(){o(!1)},children:na(Ls,{})}),na("div",{className:"".concat(iw.be("footer","text")),children:v})]})]})},ow=new ra("unknown-message"),aw=function(e){return na("div",{className:ow.b(),children:na("div",{className:"".concat(ow.e("content")," pre-wrap-container"),children:Uc.t.value("unsupportedMessageType",{type:e.message.type})})})},sw=new ra("chat-message-item"),cw=function(e){var t=e.message,n=e.size,i=null;switch(t.type){case"DEFAULT":i="ASSISTANT"===t.role?ou:nw;break;case"ERROR":i=rw;break;default:i=aw}return na("div",{className:sw.b(),children:Eo(i,{size:n,message:t,controller:e.controller,children:e.children})})},lw=function(){return x(function e(t){C(this,e),T(this,"toolcallcompleted",!0),T(this,"toolcalls",[]),T(this,"chatsteps",[]),T(this,"chatuiactions",[]),T(this,"think",void 0),T(this,"usage",void 0),T(this,"reeditstate",!1),T(this,"allcontent",""),this.msg=t,this.toolcalls=t.toolcalls||[],this.chatsteps=t.chatsteps||[],this.chatuiactions=t.chatuiactions||[],this.allcontent=t.content,this.usage=t.usage,this.think=t.think||void 0},[{key:"messageid",get:function(){return this.msg.messageid}},{key:"state",get:function(){return this.msg.state}},{key:"role",get:function(){return this.msg.role}},{key:"type",get:function(){return this.msg.type}},{key:"status",get:function(){return this.msg.status}},{key:"realcontent",get:function(){var e=this.msg.content;if(-1!==e.indexOf("<think>")&&-1===e.indexOf("</think>"))return"";if(-1!==(e=e.replace(/<think>[^]*?<\/think>/g,"").trim()).indexOf("<chatstep>")&&-1===e.indexOf("</chatstep>"))return"";if(-1!==(e=e.replace(/<chatstep>[^]*?<\/chatstep>/g,"").trim()).indexOf("<tool_call>")&&-1===e.indexOf("</tool_call>"))return"";if(-1!==(e=e.replace(/<tool_call>[^]*?<\/tool_call>/g,"").trim()).indexOf("<resources>")&&-1===e.indexOf("</resources>"))return"";var t=(e=e.replace(/<resources>[^]*?<\/resources>/g,"").trim()).indexOf("<suggestions>");-1!==t&&(e=e.substring(0,t).trim());var n=e.indexOf("<chatuiaction>");return-1!==n&&(e=e.substring(0,n).trim()),e}},{key:"errorText",get:function(){return this.msg.errorText}},{key:"content",get:function(){return this.msg.content}},{key:"completed",get:function(){return this.msg.completed}},{key:"suggestions",get:function(){return this.msg.suggestions}},{key:"_origin",get:function(){return this.msg}},{key:"islike",get:function(){return this.msg.islike}},{key:"isdislike",get:function(){return this.msg.isdislike}},{key:"feedbackcontent",get:function(){return this.msg.feedbackcontent}},{key:"realmessageid",get:function(){return this.msg.realmessageid}},{key:"metadata",get:function(){return this.msg.metadata}},{key:"agent_tag",get:function(){return this.msg.agent_tag}},{key:"create_time",get:function(){return this.msg.create_time},set:function(e){this.msg.create_time=e}},{key:"update",value:function(e){var t="USER"===e.role;if(e.content||(e.content=""),this.allcontent+=e.content,e.content&&-1!==e.content.indexOf("<think>")&&this.msg.content&&!t&&(this.msg.content=""),this.msg.content+=e.content,!t){-1===this.msg.content.indexOf("<tool_call>")&&-1===this.msg.content.indexOf("</tool_call>")||(this.msg.content=""),this.computeToolCalls();var n=this.msg.content.indexOf("<chatstep>"),i=this.msg.content.indexOf("</chatstep>");-1===n&&-1===i||(this.msg.content=-1!==n&&-1!==i?this.msg.content.replace(/<chatstep>[^]*?<\/chatstep>/g,""):""),this.computeChatSteps();var r=this.msg.content.indexOf("<chatuiaction>"),o=this.msg.content.indexOf("</chatuiaction>");-1===r&&-1===o||(this.msg.content=-1!==r&&-1!==o?this.msg.content.replace(/<chatuiaction>[^]*?<\/chatuiaction>/g,""):""),this.computeChatUIActions()}}},{key:"replace",value:function(e){this.msg=e}},{key:"updateCompleted",value:function(e){this.msg.completed=e,this.toolcallcompleted=e}},{key:"computeToolCalls",value:function(){var e=Ta.parse(this.allcontent),t=e.completed,n=e.toolCalls;this.toolcallcompleted=t,this.toolcalls=n}},{key:"computeChatSteps",value:function(){this.chatsteps=Ma.parse(this.allcontent)}},{key:"computeChatUIActions",value:function(){this.chatuiactions=_a.parse(this.allcontent)}}])}(),uw=function(){return x(function e(t){C(this,e),this.data=t},[{key:"appid",get:function(){return this.data.appid}},{key:"id",get:function(){return this.data.id}},{key:"type",get:function(){return this.data.type}},{key:"caption",get:function(){return this.data.caption}},{key:"sourceCaption",get:function(){return this.data.sourceCaption}},{key:"url",get:function(){return this.data.url}},{key:"aiChat",get:function(){return this.data.aiChat}},{key:"captionMode",get:function(){return this.data.captionMode}},{key:"realid",get:function(){return this.data.realid}},{key:"sequence",get:function(){return this.data.sequence}},{key:"isTop",get:function(){return this.data.isTop}},{key:"isShow",get:function(){var e;return null===(e=this.data.isShow)||void 0===e||e}},{key:"disableStorage",get:function(){return this.data.disableStorage||!1}},{key:"captionComputed",get:function(){return this.data.captionComputed||!1}},{key:"scope",get:function(){return this.data.scope}},{key:"groupid",get:function(){return this.data.groupid}}])}(),dw=function(){return x(function e(t){C(this,e),this.material=t},[{key:"id",get:function(){return this.material.id}},{key:"type",get:function(){return this.material.type}},{key:"metadata",get:function(){return this.material.metadata}},{key:"data",get:function(){return this.material.data}}])}(),hw=function(){return x(function e(t,n){C(this,e),this.agent=t,this.defaultConfig=n},[{key:"id",get:function(){return this.agent.id}},{key:"caption",get:function(){return this.agent.caption}},{key:"default",get:function(){return this.agent.default}},{key:"order",get:function(){return this.agent.order}},{key:"value",get:function(){return this.agent.id}},{key:"label",get:function(){return this.agent.caption}},{key:"knowledge_bases",get:function(){return this.agent.knowledge_bases}},{key:"allow_any_knowledge_base",get:function(){return this.agent.allow_any_knowledge_base}},{key:"rerank",get:function(){return this.agent.rerank||this.defaultConfig.chunkrerank}},{key:"maxchunks",get:function(){return this.agent.maxchunks||this.defaultConfig.maxchunks}},{key:"chunkthreshold",get:function(){return this.agent.chunkthreshold||this.defaultConfig.chunkthreshold}},{key:"chunkpageindex",get:function(){return this.agent.chunkpageindex||this.defaultConfig.chunkpageindex}}])}(),fw=function(){return x(function e(t){C(this,e),this.knowledgeBase=t},[{key:"id",get:function(){return this.knowledgeBase.id}},{key:"name",get:function(){return this.knowledgeBase.name}},{key:"value",get:function(){return this.knowledgeBase.id}},{key:"label",get:function(){return this.knowledgeBase.name}}])}(),pw=new ra("chat-toolbar-item"),vw=function(e){var t,n,i,r=e.model,o=e.data,a=e.className,s=e.disabled,c=void 0!==s&&s,l=e.buttonType,u=void 0===l?"default":l,d=e.onClick,h=g(Wa(!1),2),f=h[0],p=h[1],v=qa(null),m=function(e){return"function"==typeof e.hidden?e.hidden(o):!0===e.hidden};if(m(r))return na(Do,{});var y=function(e){return!!c||("function"==typeof e.disabled?e.disabled(o):!0===e.disabled)},k=function(e){var t,n,i,r;return"function"==typeof e.icon?e.icon():null!==(t=e.icon)&&void 0!==t&&t.showIcon&&null!==(n=e.icon)&&void 0!==n&&n.cssClass?na("i",{className:e.icon.cssClass}):null!==(i=e.icon)&&void 0!==i&&i.showIcon&&null!==(r=e.icon)&&void 0!==r&&r.imagePath?ha(e.icon.imagePath)?na("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):na("img",{src:e.icon.imagePath}):void 0},w=function(e,t){y(t)||(p(!1),d(e,t))};return $a(function(){var e=function(e){v.current&&v.current.contains(e.target)||p(!1)};return f&&document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[f]),na("div",{className:"".concat(pw.b()," ").concat(pw.b(u)," ").concat(r.customClass||""," ").concat(a||""," ").concat(pw.is("disabled",y(r))," ").concat(pw.is("more",!(null===(t=r.children)||void 0===t||!t.length))),children:[na("div",{title:r.title,className:pw.e("content"),onClick:function(e){return w(e,r)},children:[na("div",{className:pw.em("content","icon"),children:k(r)}),na("div",{className:pw.em("content","label"),children:r.label})]}),(null===(n=r.children)||void 0===n?void 0:n.length)&&na("div",{title:Uc.t.value("more"),className:pw.e("more"),onClick:function(e){y(r)||p(!0)},children:na("i",{"aria-hidden":"true",className:"fa fa-angle-down ".concat(pw.em("more","icon"))})}),f&&na("div",{ref:v,className:pw.b("dropdown"),children:null===(i=r.children)||void 0===i?void 0:i.map(function(e,t){if(!m(e))return na("div",{title:e.title,onClick:function(t){return w(t,e)},className:"".concat(pw.be("dropdown","item")," ").concat(e.customClass||""," ").concat(pw.is("disabled",y(e))),children:[na("div",{className:pw.bem("dropdown","item","icon"),children:k(e)}),na("div",{className:pw.bem("dropdown","item","label"),children:e.label})]},t)})})]})},mw=new ra("chat-toolbar"),gw=function(e){var t=e.controller,n=e.items,i=void 0===n?[]:n,r=e.data,o=e.type,a=e.className,s=e.style,l=Ya(ab),u=[],h=[{label:Uc.t.value("resetConversation"),title:Uc.t.value("resetConversation"),icon:function(){return na(oc,{})},onClick:function(){t.resetTopicMessage()},children:[{label:Uc.t.value("clearConversation"),title:Uc.t.value("clearConversation"),icon:function(){return na(rc,{})},onClick:function(){t.clearTopicMessage()}}]}],f=[{label:Uc.t.value("refresh"),title:Uc.t.value("refresh"),icon:function(){return na(Bs,{})},onClick:function(){t.refreshMessage(r)}},{label:Uc.t.value("delete"),title:Uc.t.value("delete"),hidden:function(){return!r.realmessageid},icon:function(){return na(Ps,{})},onClick:function(){t.deleteMessage(r)}}];l.enableBackFill&&f.unshift.apply(f,[{label:Uc.t.value("backfill"),title:Uc.t.value("backfill"),icon:function(){return na(Rs,{})},onClick:function(){t.backfill(r)}}]);var p=[{label:Uc.t.value("refresh"),title:Uc.t.value("refresh"),icon:function(){return na(Bs,{})},hidden:function(){return!!t.reEditContent.value},onClick:function(){t.refreshMessage(r,!0)}},{label:Uc.t.value("reedit"),title:Uc.t.value("reedit"),icon:function(){return na(Ac,{})},hidden:function(){return!!t.reEditContent.value||r.messageid!==t.lastUserMsgID.value||!!t.isLoading.value},onClick:function(){t.reEditEnter(r)}}];if("content"===o)switch(r.type){case"DEFAULT":u="ASSISTANT"===r.role?[].concat(f,c(i)):[].concat(p);break;case"ERROR":u=[].concat(f,c(i))}else u=[].concat(h,c(i));var v=function(n,i){var o=d({},r);if(r instanceof lw?(Object.assign(o,{topic:t.topic}),o.msg.realcontent=r.realcontent):(o.data||(o.data={}),Object.assign(o.data,{messages:t.messages.value})),i.onClick&&"function"==typeof i.onClick)i.onClick(n,i,t.context,t.params,o);else{var a=e.controller.opts.extendToolbarClick;a&&"function"==typeof a&&a(n,i,t.context,t.params,o)}},m=Ja(function(){return"content"===o&&("ASSISTANT"===(null==r?void 0:r.role)?20===(null==r?void 0:r.state)&&!0!==(null==r?void 0:r.completed)||t.isLoading.value:"USER"===(null==r?void 0:r.role)&&t.isLoading.value)},[null==r?void 0:r.state,null==r?void 0:r.completed,null==r?void 0:r.role,t.isLoading.value]);return na("div",{className:"".concat(mw.b()," ").concat(a||""),style:s,children:u.map(function(e,t){return na(vw,{data:r,model:e,disabled:m,buttonType:"content"===o?"circle":"default",onClick:v.bind(void 0)},t)})})},yw=function(e){var t=Ds(!1),n=Ds({}),i=new ra("chat-back-bottom"),r=Ds(null),o=function(){if(r.value){var n=e.visibilityHeight||200,i=r.value.scrollHeight-r.value.scrollTop-r.value.offsetHeight;t.value=i>=n}},a=function(e,t){var n=null;return function(){for(var i=this,r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];n||(n=setTimeout(function(){e.apply(i,o),n=null},t))}}(o,300);return Ja(function(){n.value={right:"".concat(e.right,"px"),bottom:"".concat(e.bottom,"px")}},[e.right,e.bottom]),$a(function(){if(e.target){var t,n=null!==(t=document.querySelector(e.target))&&void 0!==t?t:void 0;n&&(r.value=n,n.addEventListener("scroll",a),o())}},[]),na("div",{className:"".concat(i.b()," ").concat(i.is("visible",t.value)),style:n.value,onClick:function(){var t;r.value&&(r.value.scrollTo({top:r.value.scrollHeight,behavior:"smooth"}),null===(t=e.onClick)||void 0===t||t.call(e))},children:na(ic,{className:i.e("icon")})})},kw=new ra("chat-messages"),ww=function(e){var t,n=e.controller.messages,i=e.controller.isLoadingHistory,r=g(Wa(!0),2),o=r[0],a=r[1],s=qa(!1),c=qa(null),l=qa(n.value),u=qa(n.value.length),d=qa(null===(t=n.value[0])||void 0===t?void 0:t.messageid),h=function(e){var t=e.count,n=e.getItemKey,i=e.estimateSize,r=e.overscan,o=void 0===r?5:r,a=qa(null),s=Ds(Number.MAX_SAFE_INTEGER),c=Ds(0),l=Ds(0),u=qa(new Map),d=qa(new Map),h=qa(new Map),f=s.value,p=c.value,v=l.value;$a(function(){var e=a.current;if(e){var t=function(){s.value=e.scrollTop};e.addEventListener("scroll",t,{passive:!0}),s.value=e.scrollTop,c.value=e.clientHeight;var n="undefined"!=typeof ResizeObserver?new ResizeObserver(function(){c.value=e.clientHeight}):null;return null==n||n.observe(e),function(){e.removeEventListener("scroll",t),null==n||n.disconnect()}}},[]);var m=function(e){var t=h.current.get(e);return t||(t=function(t){var n=d.current.get(e);if(n&&(n.disconnect(),d.current.delete(e)),t&&"undefined"!=typeof ResizeObserver){var i=new ResizeObserver(function(){var n=Math.round(t.offsetHeight);n>0&&u.current.get(e)!==n&&(u.current.set(e,n),l.value+=1)});i.observe(t),d.current.set(e,i)}},h.current.set(e,t)),t},g=Ja(function(){var e=new Array(t+1);e[0]=0;for(var r=0;r<t;r+=1){var a=u.current.get(n(r));e[r+1]=e[r]+(null!=a?a:i(r))}for(var s=e[t]||0,c=f+p,l=0,d=0,h=t-1;d<=h;){var v=Math.floor((d+h)/2);e[v]<=f?(l=v,d=v+1):h=v-1}for(var g=l=Math.max(0,l-o);g<t&&e[g]<c;)g+=1;g=Math.min(t,g+o);for(var y=[],k=l;k<g;k+=1){var w=n(k);y.push({index:k,key:w,start:e[k],size:e[k+1]-e[k],measureRef:m(w)})}return{offsets:e,totalSize:s,virtualItems:y}},[t,f,p,v]),y=qa(t),k=qa(t>0?n(0):void 0),w=t>0?n(0):void 0;return Ua(function(){var e,i=a.current,r=y.current,o=k.current,c=t>r&&void 0!==o&&o!==w;if(y.current=t,k.current=w,i&&c){for(var l=-1,u=0;u<t;u+=1)if(n(u)===o){l=u;break}if(!(l<=0)){var d=null!==(e=g.offsets[l])&&void 0!==e?e:0;if(d>0){var h=i.scrollTop+d;s.value=h,i.scrollTop=h}}}},[t,w]),{containerRef:a,virtualItems:g.virtualItems,totalSize:g.totalSize,offsets:g.offsets,getOffset:function(e){var t;return null!==(t=g.offsets[e])&&void 0!==t?t:0},restoreScrollPosition:function(){var e=a.current;e&&(e.scrollTop=s.value)}}}({count:n.value.length,getItemKey:function(e){var t;return(null===(t=n.value[e])||void 0===t?void 0:t.messageid)||String(e)},estimateSize:function(e){var t=n.value[e];if(!t||"SYSTEM"===t.role)return 0;var i=t.content||"";return Math.max(200,Math.min(550,200+i.length/20*43))},overscan:3}),f=h.containerRef,p=h.virtualItems,v=h.totalSize,m=h.offsets,y=h.restoreScrollPosition,k=function(){var e=f.current;e&&(s.current=!0,e.scrollTo({top:Number.MAX_SAFE_INTEGER,behavior:"auto"}),setTimeout(function(){s.current=!1},500))};$a(function(){return e.controller.evt.on("onActivated",y),function(){e.controller.evt.off("onActivated",y)}},[]),Ua(function(){var e,t=f.current;if(t){var i=n.value.length,r=u.current,s=null===(e=n.value[0])||void 0===e?void 0:e.messageid,h=i>r&&s===d.current,p=i>r&&s!==d.current,v=l.current!==n.value;if(u.current=i,d.current=s,l.current=n.value,h)return a(!0),void k();if(o)k();else if(v&&!p&&c.current){var g,y=c.current,w=y.messageid,b=y.offsetWithin,C=n.value.findIndex(function(e){return e.messageid===w});if(C>=0)t.scrollTop=(null!==(g=m[C])&&void 0!==g?g:0)+b}}},[n.value,v,o]);return na("div",{className:kw.e("wrap"),children:[na("div",{ref:f,className:kw.b(),onScroll:function(){if(!s.current){var t=f.current;if(t){var n=t.scrollTop,i=t.scrollHeight-(n+t.clientHeight)<50;if(a(i),n<1&&e.controller.hasMoreHistory.value&&!e.controller.isLoadingHistory.value&&e.controller.loadHistoryMore(),i)c.current=null;else{var r=p[0];r&&(c.current={messageid:r.key,offsetWithin:n-r.start})}}}},children:[na("div",{style:{position:"relative",height:"".concat(v,"px")},children:[p.map(function(t){var i,r=n.value[t.index];if(!r||"SYSTEM"===r.role)return null;var o=(null===(i=r.content)||void 0===i?void 0:i.length)||0;return na("div",{ref:t.measureRef,style:{position:"absolute",top:0,left:0,width:"100%",transform:"translateY(".concat(t.start,"px)")},children:na(cw,{size:o,message:r,controller:e.controller,children:na(gw,{type:"content",mode:"DEFAULT",hideTopicSidebar:!1,data:r,items:e.toolbarItems,controller:e.controller})})},t.key)}),i.value&&na("div",{className:kw.e("history-loading"),children:na(il,{size:20})})]}),na(yw,{right:20,bottom:14,target:".".concat(kw.b()),onClick:function(){s.current=!0,a(!0)}})]}),e.children?na("div",{className:kw.e("footer-toolbar"),children:e.children}):null]})},bw=new ra("chat-splitter"),Cw=function(e){var t=e.direction,n=e.onDragStart,i=e.onMove,r=e.onDragEnd,o=e.className,a=void 0===o?"":o,s=Ds(!1),c=qa({x:0,y:0}),l=qa(i),u=qa(r);l.current=i,u.current=r;return na("div",{className:"".concat(bw.b()," ").concat(bw.is(t,!0)," ").concat(bw.is("dragging",s.value)," ").concat(a),onMouseDown:function(e){e.preventDefault(),s.value=!0,document.body.style.userSelect="none",c.current={x:e.clientX,y:e.clientY},null==n||n();var i=function(e){var n,i="vertical"===t?e.clientX-c.current.x:e.clientY-c.current.y;null===(n=l.current)||void 0===n||n.call(l,i)},r=function(){var e;s.value=!1,document.body.style.userSelect="",window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",r),null===(e=u.current)||void 0===e||e.call(u)};window.addEventListener("mousemove",i),window.addEventListener("mouseup",r)},children:na("div",{className:bw.e("line")})})},Sw=function(e){return e.STYLE_CACHE="ai-chat-style-cache",e.MINIMIZE_STYLY_CHCHE="ai-chat-minimize-style-cache",e.TOPIC_SIDEBAR_WIDTH="ai-chat-topic-sidebar-width",e.INPUT_HEIGHT="ai-chat-input-height",e.DATA_BASE_NAME="ibiz-chat",e.DATA_TABLE_NAME="history-message",e.DATA_TABLE_KEY_NAME="id",e}(Sw||{}),xw=function(e){return e.NONE_SCOPE_ID="__NONE__",e.NONE_SCOPE_KEY="scope:__NONE__",e}(xw||{});function Tw(e){switch(e){case"user":default:return"USER";case"agent":return"ASSISTANT";case"system":return"SYSTEM"}}function Mw(e){switch(e){case"pending":return 20;case"sent":case"canceled":default:return 30;case"failed":return 40}}function _w(e){switch(e){case"pending":case"sent":case"canceled":default:return"DEFAULT";case"failed":return"ERROR"}}function Nw(e){var t;if(e.metadata)try{t=JSON.parse(e.metadata)}catch(vs){console.warn("解析消息 metadata 失败,已做容错处理",{value:e.metadata,error:vs})}return{messageid:e.id,state:Mw(e.status),type:_w(e.status),role:Tw(e.sender_type),content:e.content,completed:!0,islike:e.is_like,isdislike:e.is_dislike,feedbackcontent:e.feedback_content,realmessageid:e.id,status:e.status,metadata:t,agent_tag:e.agent_tag,create_time:e.create_time}}var Ow=function(){return x(function e(t,n,i){C(this,e),T(this,"evt",new p),T(this,"messages",gs([])),T(this,"isLoadingHistory",gs(!1)),T(this,"hasMoreHistory",gs(!1)),T(this,"loadedHistoryCount",0),T(this,"nextHistoryPage",0),T(this,"materials",gs([])),T(this,"input",gs("")),T(this,"inputExpand",gs(!1)),T(this,"reEditContent",gs("")),T(this,"reEditContentChanged",gs(!1)),T(this,"lastUserMsgID",gs(void 0)),T(this,"isLoading",gs(!1)),T(this,"enableKnowledgeBaseSelect",gs(!1)),T(this,"enableRecallConfigSetting",gs(!1)),T(this,"enableAIAgentChange",!0),T(this,"activeAIAgentID",void 0),T(this,"agentList",gs([])),T(this,"context",void 0),T(this,"params",void 0),T(this,"appDataEntityId",void 0),T(this,"topicId",void 0),T(this,"topic",void 0),T(this,"aiTopic",void 0),T(this,"chatSessionid",""),T(this,"chatMode",void 0),T(this,"chatScope",void 0),T(this,"isDigestProcessed",!1),T(this,"needUpdateMetaData",!0),T(this,"knowledgeBasesList",[]),T(this,"selectionKnowledgeBases",gs([])),T(this,"selectionProject",void 0),T(this,"knowledgeBases",gs([])),T(this,"placeholder",gs("")),T(this,"reCallConfig",gs({chunkrerank:2,maxchunks:void 0,chunkthreshold:void 0,chunkpageindex:void 0})),T(this,"streamingMsgID",void 0),T(this,"inited",gs(!1)),T(this,"steerQuesCfg",gs({enable:!1,message:""})),T(this,"activeAsyncacitonid",""),this.opts=t,this.resourceOptions=n,this.topicOptions=i,this.context=t.context,this.params=t.params,this.appDataEntityId=t.appDataEntityId,this.aiTopic=t.aiTopic,this.topicId=t.topicId,this.topic=t.topic,this.activeAIAgentID=t.activeAIAgentID,this.enableAIAgentChange=!!t.enableAIAgentChange,this.chatMode=t.srfMode,this.chatScope=t.srfScope,this.chatSessionid=t.sessionid,this.enableKnowledgeBaseSelect.value=!!t.enableKnowledgeBaseSelect,this.enableRecallConfigSetting.value=!!t.enableRecallConfigSetting,this.placeholder.value=t.placeholder||Uc.t.value("chatInputPlaceholder"),this.initAIChat()},[{key:"resourceMode",get:function(){var e;return(null===(e=this.resourceOptions)||void 0===e?void 0:e.resourceMode)||"LOCAL"}},{key:"currentTopicDisableStorage",get:function(){if(this.topicId&&this.aiTopic){var e=this.aiTopic.getCurrentTopicByID(this.topicId);if(e&&e.disableStorage)return!0}return!1}},{key:"sessionCaptionMode",get:function(){if(this.aiTopic&&this.topicId){var e=this.aiTopic.getCurrentTopicByID(this.topicId);if(e&&e.captionMode)return e.captionMode}return this.topicOptions&&this.topicOptions.captionMode?this.topicOptions.captionMode:"default"}},{key:"sessionDefaultCaption",get:function(){if(this.aiTopic&&this.topicId){var e=this.aiTopic.getCurrentTopicByID(this.topicId);if(e&&e.caption)return e.caption}return this.opts.caption||Uc.t.value("newConversation")}},{key:"sessionMeta",get:function(){if(this.aiTopic&&this.topicId){var e=this.aiTopic.getCurrentTopicByID(this.topicId);if(e&&!e.disableStorage)return{appid:e.appid,id:e.id,type:e.type,captionMode:e.captionMode,captionComputed:!!e.captionComputed,caption:e.caption||e.sourceCaption,sourceCaption:e.sourceCaption,url:e.url,aiChat:e.aiChat?d(d({},e.aiChat),{},{activeAIAgentID:this.activeAIAgentID,selectAIKnowledgeBaseId:this.getQueryKnowledgeBases()}):e.aiChat,isTop:e.isTop,sequence:e.sequence,scope:e.scope,groupid:e.groupid}}}},{key:"updateAIChat",value:function(e){this.streamingMsgID||(this.opts=e,this.initAIChat())}},{key:"initAIChat",value:(U=v(h().m(function e(){return h().w(function(e){for(;;)switch(e.n){case 0:return this.inited.value=!1,this.messages.value=[],this.needUpdateMetaData=!0,e.n=1,this.initAIChatAgent();case 1:return e.n=2,this.initAIChatKnowledge();case 2:return e.n=3,this.fecthHistory();case 3:return e.a(2)}},e,this)})),function(){return U.apply(this,arguments)})},{key:"initAIChatAgent",value:($=v(h().m(function e(){var t,n=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.opts.aiAgentlist&&this.opts.aiAgentlist.length>0&&this.opts.aiAgentlist.forEach(function(e){n.agentList.value=[].concat(c(n.agentList.value),[new hw(e,{chunkrerank:n.opts.reRankDefaultValue,maxchunks:n.opts.maxChunksDefaultValue,chunkthreshold:n.opts.chunkThresholdDefaultValue,chunkpageindex:n.opts.chunkPageIndexDefaultValue})])}),this.enableRecallConfigSetting.value){e.n=1;break}return e.a(2);case 1:t=this.agentList.value.find(function(e){return e.id===n.activeAIAgentID}),t&&(this.reCallConfig.value={chunkrerank:t.rerank,maxchunks:t.maxchunks,chunkthreshold:t.chunkthreshold,chunkpageindex:t.chunkpageindex});case 2:return e.a(2)}},e,this)})),function(){return $.apply(this,arguments)})},{key:"initAIChatKnowledge",value:(W=v(h().m(function e(){var t;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.enableKnowledgeBaseSelect.value){e.n=1;break}return e.a(2);case 1:null!==(t=this.opts.aiknowledgeBasesList)&&void 0!==t&&t.length&&(this.knowledgeBasesList=this.opts.aiknowledgeBasesList.map(function(e){return new fw(e)})),this.computeSelectedKnowledge();case 2:return e.a(2)}},e,this)})),function(){return W.apply(this,arguments)})},{key:"computeSelectedKnowledge",value:function(){var e,t=this;if(this.enableKnowledgeBaseSelect.value){var n=this.agentList.value.find(function(e){return e.id===t.activeAIAgentID});if(this.knowledgeBases.value=!n||n.allow_any_knowledge_base?c(this.knowledgeBasesList):(null===(e=n.knowledge_bases)||void 0===e?void 0:e.map(function(e){return new fw({id:e.ai_knowledge_base_id,name:e.ai_knowledge_base_name})}))||[],this.opts.selectAIKnowledgeBaseId)this.selectionKnowledgeBases.value=this.knowledgeBases.value.filter(function(e){var n;return null===(n=t.opts.selectAIKnowledgeBaseId)||void 0===n?void 0:n.includes(e.id)}).map(function(e){return e.id});else if(n){var i;this.selectionKnowledgeBases.value=(null===(i=n.knowledge_bases)||void 0===i?void 0:i.map(function(e){return e.ai_knowledge_base_id}))||[]}}}},{key:"knowledgeRemoteSearch",value:(V=v(h().m(function e(t){var n,i,r,o=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.enableKnowledgeBaseSelect.value){e.n=1;break}return e.a(2,[]);case 1:if(n=this.agentList.value.find(function(e){return e.id===o.activeAIAgentID}),n&&!n.allow_any_knowledge_base){e.n=4;break}if(!this.opts.fetchKnowledgeBaseList){e.n=3;break}return e.n=2,this.opts.fetchKnowledgeBaseList({query:t,knowledgebases:this.getQueryKnowledgeBases()});case 2:if(!((i=e.v)&&i.length>0)){e.n=3;break}return r=new Map(i.map(function(e){return[e.id,e]})),e.a(2,Array.from(r.values()).map(function(e){return{value:e.id,label:e.name}}));case 3:e.n=5;break;case 4:if(!(n&&n.knowledge_bases&&n.knowledge_bases.length>0)){e.n=5;break}return e.a(2,n.knowledge_bases.map(function(e){return{value:e.ai_knowledge_base_id,label:e.ai_knowledge_base_name}}).filter(function(e){return e.label.toLowerCase().includes(t.toLowerCase())}));case 5:return e.a(2,[])}},e,this)})),function(e){return V.apply(this,arguments)})},{key:"getHistoryStoreKey",value:function(e){return"".concat(e)}},{key:"getQueryKnowledgeBases",value:function(){return this.enableKnowledgeBaseSelect.value?this.selectionKnowledgeBases.value.join(","):void 0}},{key:"getQueryRecallConfig",value:function(){return this.enableRecallConfigSetting.value?this.reCallConfig.value:void 0}},{key:"fecthHistory",value:(j=v(h().m(function e(){var t,n,i,r=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(!this.opts.isSimple){e.n=1;break}return this.inited.value=!0,e.a(2,!0);case 1:if(this.hasMoreHistory.value=!1,!this.topicId){e.n=8;break}if(t={},!this.currentTopicDisableStorage){e.n=2;break}t.data=[],e.n=6;break;case 2:if("LOCAL"!==this.resourceMode){e.n=4;break}return e.n=3,ka.getData(Sw.DATA_BASE_NAME,Sw.DATA_TABLE_NAME,this.getHistoryStoreKey(this.topicId));case 3:t=e.v,e.n=6;break;case 4:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=6;break}return e.n=5,this.fetchRemoteHistoryPage(!0);case 5:(n=e.v)&&n.length>0&&(t.data=n);case 6:if(!(t&&t.data&&t.data.length>0)){e.n=8;break}return i=t.data.map(function(e){return r.addMessage(r.buildHistoryMessage(e),!0)}),this.onMessageChange("historymsg",i),e.n=7,this.afterFecthHistory();case 7:return e.a(2,!0);case 8:return e.n=9,this.opts.history(this.context,this.params,{appDataEntityId:this.appDataEntityId,appendCurData:this.opts.appendCurData,sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,srfmode:this.chatMode,srfscope:this.chatScope});case 9:if(!e.v){e.n=10;break}return e.n=10,this.afterFecthHistory();case 10:return e.a(2,!0)}},e,this)})),function(){return j.apply(this,arguments)})},{key:"fetchRemoteHistoryPage",value:(H=v(h().m(function e(t){var n,i,r,o,a;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.resourceOptions){e.n=1;break}return e.a(2,[]);case 1:return t&&(this.nextHistoryPage=0,this.loadedHistoryCount=0),e.n=2,this.resourceOptions.getMessages({n_session_id_eq:this.chatSessionid,page:this.nextHistoryPage,size:this.opts.chatMessagePageSize||100});case 2:if(i=e.v,r=i.data||[],o=null!==(n=i.total)&&void 0!==n?n:0,0!==(a=r.map(function(e){return Nw(e)})).length){e.n=3;break}return this.hasMoreHistory.value=!1,e.a(2,a);case 3:return this.loadedHistoryCount+=a.length,this.hasMoreHistory.value=this.loadedHistoryCount<o,this.hasMoreHistory.value&&(this.nextHistoryPage+=1),e.a(2,a)}},e,this)})),function(e){return H.apply(this,arguments)})},{key:"buildHistoryMessage",value:function(e){return{messageid:e.messageid,state:e.state,type:e.type,role:e.role,islike:e.islike,isdislike:e.isdislike,metadata:e.metadata,feedbackcontent:e.feedbackcontent,content:e.content,suggestions:e.suggestions,completed:!0,toolcalls:e.toolcalls,realmessageid:e.realmessageid,status:e.status,chatsteps:e.chatsteps,chatuiactions:e.chatuiactions,agent_tag:e.agent_tag,create_time:e.create_time}}},{key:"loadHistoryMore",value:(F=v(h().m(function e(){var t,n,i=this;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this.isLoadingHistory.value&&this.hasMoreHistory.value){e.n=1;break}return e.a(2);case 1:if("REMOTE"===this.resourceMode&&this.resourceOptions){e.n=2;break}return e.a(2);case 2:if(!this.currentTopicDisableStorage){e.n=3;break}return e.a(2);case 3:return this.isLoadingHistory.value=!0,e.p=4,e.n=5,this.fetchRemoteHistoryPage(!1);case 5:if(0!==(t=e.v).length){e.n=6;break}return e.a(2);case 6:n=t.map(function(e){var t=i.buildHistoryMessage(e);i.attachMessageAgentID(t);var n=new lw(t);return n.update(d(d({},t),{},{content:""})),n}),this.messages.value=[].concat(c(n),c(this.messages.value)),this.onMessageChange("historymsg",n);case 7:return e.p=7,this.isLoadingHistory.value=!1,e.f(7);case 8:return e.a(2)}},e,this,[[4,,7,8]])})),function(){return F.apply(this,arguments)})},{key:"afterFecthHistory",value:(B=v(h().m(function e(){var t,n,i,r,o,a,s,l,u,f=this;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.inited.value=!0,!this.opts.appendCurContent){e.n=1;break}return this.addMessage({state:30,messageid:la(),role:"USER",type:"DEFAULT",content:this.opts.appendCurContent,completed:!0,status:"sent"}),e.n=1,this.markLastUserMessage();case 1:if(this.opts.appendCurResource&&(t=ba.parseMixedContent(this.opts.appendCurResource),n=t.hasResources,i=t.resources,n&&i&&i.length>0&&i.forEach(function(e){f.replaceMaterial(e.id,e)})),!1===this.opts.autoQuestion){e.n=6;break}if(r=this.messages.value.length-1,!(o=this.messages.value[r])||"USER"!==o.role){e.n=6;break}return(a=this.stringlyMaterialResource(!1))&&(s=a+o.content,l=d(d({},o._origin),{},{messageid:la(),content:s}),u=new lw(l),this.messages.value[r]=u,this.messages.value=c(this.messages.value),this.onMessageChange("updatemsg",u)),e.p=2,this.isLoading.value=!0,e.n=3,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode,this.chatScope,this.getQueryKnowledgeBases(),this.getQueryRecallConfig(),this.opts.appendCurData,this.opts.srfMcpservers,this.sessionMeta,this.selectionProject);case 3:if(!this.opts.action){e.n=4;break}return e.n=4,this.opts.action("question",o.content);case 4:return e.p=4,this.isLoading.value=!1,this.resetSteerQuesCfg(),e.f(4);case 5:return e.n=6,this.updateTopic("history"===this.opts.captionComputedMode);case 6:return e.n=7,this.markLastUserMessage();case 7:return e.a(2)}},e,this,[[2,,4,5]])})),function(){return B.apply(this,arguments)})},{key:"asyncToIndexDB",value:(P=v(h().m(function e(){var t;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.topicId&&"LOCAL"===this.resourceMode){e.n=1;break}return e.a(2);case 1:if(!this.currentTopicDisableStorage){e.n=2;break}return e.a(2);case 2:return t={id:this.getHistoryStoreKey(this.topicId),data:this.messages.value.map(function(e){return d(d({},e._origin),{},{toolcalls:e.toolcalls,chatsteps:e.chatsteps,chatuiactions:e.chatuiactions})}),timestamp:(new Date).getTime()},e.n=3,ka.updateData(Sw.DATA_BASE_NAME,Sw.DATA_TABLE_NAME,t);case 3:return e.a(2)}},e,this)})),function(){return P.apply(this,arguments)})},{key:"setInput",value:function(e){this.evt.emit("onSetInput",e||"")}},{key:"attachMessageAgentID",value:function(e){"ASSISTANT"===e.role&&!e.hasOwnProperty("agent_tag")&&this.activeAIAgentID&&(e.agent_tag=this.activeAIAgentID)}},{key:"addMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.attachMessageAgentID(e),20===e.state&&"pending"===e.status&&e.messageid&&(this.streamingMsgID=e.messageid);var n=this.messages.value.find(function(t){return t.messageid===e.messageid}),i=n?"updatemsg":"createmsg";return n?(n.update(e),this.messages.value=c(this.messages.value)):((n=new lw(e)).update(d(d({},e),{},{content:""})),this.messages.value=[].concat(c(this.messages.value),[n])),t||this.onMessageChange(i,n),this.asyncToIndexDB(),n}},{key:"completeMessage",value:(z=v(h().m(function e(t,n){var i,r;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.streamingMsgID===t&&n&&(this.streamingMsgID=void 0),!(i=this.messages.value.find(function(e){return e.messageid===t}))){e.n=1;break}return i.updateCompleted(n),this.messages.value=c(this.messages.value),this.onMessageChange("updatemsg",i),e.n=1,this.asyncToIndexDB();case 1:!0===this.opts.autoFill&&"ASSISTANT"===(r=i||this.messages.value[this.messages.value.length-1]).role&&30===r.state&&this.backfill(r),this.evt.emit("onCompleteMessage",{messageid:t,completed:n});case 2:return e.a(2)}},e,this)})),function(e,t){return z.apply(this,arguments)})},{key:"replaceMessage",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.attachMessageAgentID(e);var i=[];if(e.content){var r=e.content,o=r.indexOf("<chatuiaction>"),a=r.indexOf("</chatuiaction>");-1!==o&&-1!==a&&o<a&&(e.content=r.replace(/<chatuiaction>[^]*?<\/chatuiaction>/g,""));var s=r.indexOf("<chatstep>"),l=r.indexOf("</chatstep>");-1!==s&&-1!==l&&s<l&&(i=Ma.parse(e.content),e.content=r.replace(/<chatstep>[^]*?<\/chatstep>/g,""))}var u=d({},e),h=this.messages.value.findIndex(function(t){return t.messageid===e.messageid});if(-1!==h){if("ERROR"===e.type){var f=this.messages.value[h].content;try{var p=JSON.parse(f);p&&p.choices&&p.choices.length>0&&(f=p.choices[0].content||f)}catch(vs){console.warn("解析错误消息内容失败,已做容错处理",{value:f,error:vs})}finally{e.content=f}}var v;if(i.length>0)null===(v=this.messages.value[h].chatsteps)||void 0===v||v.push.apply(v,c(i));u.toolcalls=this.messages.value[h].toolcalls,u.chatsteps=this.messages.value[h].chatsteps,u.chatuiactions=this.messages.value[h].chatuiactions,u.think=this.messages.value[h].think,u.usage=this.messages.value[h].usage,this.messages.value[h].replace(e),this.messages.value=c(this.messages.value),this.onMessageChange("updatemsg",this.messages.value[h])}else{var m;if(i.length>0)e.chatsteps||(e.chatsteps=[]),(m=e.chatsteps).push.apply(m,c(i));var g=new lw(e);this.messages.value=[].concat(c(this.messages.value),[g]),this.onMessageChange("updatemsg",g)}this.asyncToIndexDB(),"DEFAULT"===e.type&&this.opts.recommendPrompt&&n&&this.opts.recommendPrompt(this.context,this.params,{appDataEntityId:this.appDataEntityId,message:{messages:[d(d({},e),{},{content:e.content.replace(/<think>[^]*?<\/think>/g,"")})],sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID}}).then(function(e){e&&e.content&&t.updateRecommendPrompt(u,e.content)})}},{key:"updateMsgUsage",value:function(e,t){var n=this.messages.value.findIndex(function(t){return t.messageid===e});-1!==n&&(this.messages.value[n].usage=t,this.messages.value=c(this.messages.value),this.onMessageChange("updatemsg",this.messages.value[n]))}},{key:"stopMessage",value:(R=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:return this.attachMessageAgentID(t),n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}),t.content=t.content||Uc.t.value("userInterrupt"),-1!==n?(delete this.messages.value[n].think,this.messages.value[n].replace(t),this.messages.value=c(this.messages.value),this.onMessageChange("updatemsg",this.messages.value[n])):(i=new lw(t),this.messages.value=[].concat(c(this.messages.value),[i]),this.onMessageChange("createmsg",i)),e.n=1,this.markLastUserMessage();case 1:return e.n=2,this.asyncToIndexDB();case 2:return e.a(2)}},e,this)})),function(e){return R.apply(this,arguments)})},{key:"stringlyMaterialResource",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t="",n=[];return this.materials.value&&this.materials.value.length>0&&(this.materials.value.forEach(function(e){if("ossfile"===e.type){var t=e.metadata;t.state&&"successed"===t.state&&n.push(e)}else n.push(e)}),e&&(this.materials.value=[])),n&&n.length>0&&(t=ba.stringify(n)),t}},{key:"cloneMessage",value:function(e){var t=new lw(e._origin);return delete t.think,t}},{key:"getMessages",value:function(){var e=this.messages.value.filter(function(e){return"ERROR"!==e.type&&"canceled"!==e.status}).map(function(e){return f(e._origin)});return e.forEach(function(e){"ASSISTANT"===e.role&&(e.content=e.content.replace(/<tool_call>[^]*?<\/tool_call>/g,"").replace(/<think>[^]*?<\/think>/g,"").trim(),delete e.toolcalls,delete e.chatsteps,delete e.chatuiactions,delete e.think,delete e.metadata,delete e.agent_tag)}),e}},{key:"getAllMessages",value:function(){return this.messages.value.map(function(e){return e._origin})}},{key:"question",value:(L=v(h().m(function e(t){var n,i=this;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,this.isLoading.value=!0,this.reEditExit(),this.messages.value.forEach(function(e,t){var n=e._origin;n.suggestions&&(n.suggestions=void 0,i.messages.value[t].replace(n))}),this.messages.value=c(this.messages.value),this.asyncToIndexDB(),(n=this.stringlyMaterialResource(!0))?n+="\n".concat(t):n=t,this.addMessage({state:30,messageid:la(),role:"USER",type:"DEFAULT",content:n,status:"sent"}),e.n=1,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode,this.chatScope,this.getQueryKnowledgeBases(),this.getQueryRecallConfig(),this.opts.appendCurData,this.opts.srfMcpservers,this.sessionMeta,this.selectionProject);case 1:return this.opts.action&&this.opts.action("question",t),this.isLoading.value=!1,this.resetSteerQuesCfg(),e.n=2,this.markLastUserMessage();case 2:return e.n=3,this.updateTopic(!(!this.opts.captionComputedMode||"history"!==this.opts.captionComputedMode&&"question"!==this.opts.captionComputedMode));case 3:e.n=5;break;case 4:e.p=4,e.v,this.isLoading.value=!1,this.resetSteerQuesCfg();case 5:return e.a(2)}},e,this,[[0,4]])})),function(e){return L.apply(this,arguments)})},{key:"abortQuestion",value:(I=v(h().m(function e(){return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this.opts.abortQuestion(this,this.context,this.params,{appDataEntityId:this.appDataEntityId,sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,srfmode:this.chatMode,srfscope:this.chatScope,srfproject:this.selectionProject});case 1:return e.p=1,this.isLoading.value=!1,this.resetSteerQuesCfg(),e.f(1);case 2:return e.a(2)}},e,this,[[0,,1,2]])})),function(){return I.apply(this,arguments)})},{key:"supplementQuestion",value:(D=v(h().m(function e(){var t;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.steerQuesCfg.value.message){e.n=1;break}return e.a(2);case 1:return e.p=1,t={state:30,messageid:la(),role:"USER",type:"DEFAULT",content:this.steerQuesCfg.value.message,status:"sent"},e.n=2,this.opts.supplementQuestion(this,this.context,this.params,{appDataEntityId:this.appDataEntityId,sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,srfmode:this.chatMode,srfscope:this.chatScope,srfproject:this.selectionProject,messages:[t]});case 2:return e.p=2,this.resetSteerQuesCfg(),e.f(2);case 3:return e.a(2)}},e,this,[[1,,2,3]])})),function(){return D.apply(this,arguments)})},{key:"setSteerQuesCfg",value:function(e){this.steerQuesCfg.value={enable:!0,message:e}}},{key:"resetSteerQuesCfg",value:function(){this.steerQuesCfg.value={enable:!1,message:""}}},{key:"backfill",value:function(e){if(this.opts.action){var t=this.cloneMessage(e);this.opts.action("backfill",t)}}},{key:"deleteMessage",value:(A=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:if(-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&(this.messages.value.splice(n,1),this.messages.value=c(this.messages.value)),this.asyncToIndexDB(),"REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=1;break}if(!t.realmessageid){e.n=1;break}return e.n=1,this.resourceOptions.deleteMessage(t.realmessageid);case 1:i=this.cloneMessage(t),this.onMessageChange("deletemsg",i);case 2:return e.a(2)}},e,this)})),function(e){return A.apply(this,arguments)})},{key:"refreshMessage",value:(E=v(h().m(function e(t){var n,i,r,o,a,s,l,u,f=arguments;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=f.length>1&&void 0!==f[1]&&f[1],this.isLoading.value=!0,e.p=1,i=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}),r=[],!n){e.n=3;break}return 40===t.state&&(a=d(d({},t._origin),{},{state:30}),this.replaceMessage(a,!1)),o=this.messages.value[i],r=this.messages.value.splice(i,this.messages.value.length-i),this.addMessage(d(d({},o._origin),{},{messageid:la()})),e.n=2,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode,this.chatScope,this.getQueryKnowledgeBases(),this.getQueryRecallConfig(),this.opts.appendCurData,this.opts.srfMcpservers,this.sessionMeta,this.selectionProject);case 2:e.n=6;break;case 3:if(i!==this.messages.value.length-1){e.n=5;break}return(s=this.messages.value.pop())&&r.push(s),(o=this.messages.value[this.messages.value.length-1])&&(r.push(o),this.messages.value.pop(),this.addMessage(d(d({},o._origin),{},{messageid:la()}))),this.messages.value=c(this.messages.value),e.n=4,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode,this.chatScope,this.getQueryKnowledgeBases(),this.getQueryRecallConfig(),this.opts.appendCurData,this.opts.srfMcpservers,this.sessionMeta,this.selectionProject);case 4:e.n=6;break;case 5:return i>=1&&(i-=1,o=this.messages.value[i]),r=this.messages.value.splice(i,this.messages.value.length-i),o&&this.addMessage(d(d({},o._origin),{},{messageid:la()})),e.n=6,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode,this.chatScope,this.getQueryKnowledgeBases(),this.getQueryRecallConfig(),this.opts.appendCurData,this.opts.srfMcpservers,this.sessionMeta,this.selectionProject);case 6:if(this.asyncToIndexDB(),!("REMOTE"===this.resourceMode&&this.resourceOptions&&r&&r.length>0)){e.n=7;break}if(!(l=r.filter(function(e){return e.realmessageid}).map(function(e){return e.realmessageid}).join(","))){e.n=7;break}return e.n=7,this.resourceOptions.deleteMessage(l);case 7:this.opts.action&&(u=this.cloneMessage(t),this.opts.action("refreshmsg",u));case 8:return e.p=8,this.isLoading.value=!1,this.resetSteerQuesCfg(),e.n=9,this.markLastUserMessage();case 9:return e.f(8);case 10:return e.a(2)}},e,this,[[1,,8,10]])})),function(e){return E.apply(this,arguments)})},{key:"copyMessage",value:function(e,t){var n;if(ya.copy(e),null===(n=this.opts.utils)||void 0===n||n.message.success(Uc.t.value("copied")),this.opts.action){var i=this.cloneMessage(t);this.opts.action("copymsg",i)}}},{key:"reEditEnter",value:(O=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&(this.messages.value[n].reeditstate=!0,this.reEditContent.value=ma(t.content),this.messages.value=c(this.messages.value));case 1:return e.a(2)}},e,this)})),function(e){return O.apply(this,arguments)})},{key:"reEditExit",value:(N=v(h().m(function e(){var t;return h().w(function(e){for(;;)switch(e.n){case 0:-1!==(t=this.messages.value.findIndex(function(e){return!0===e.reeditstate}))&&(this.messages.value[t].reeditstate=!1,this.reEditContent.value="",this.reEditContentChanged.value=!1,this.messages.value=c(this.messages.value));case 1:return e.a(2)}},e,this)})),function(){return N.apply(this,arguments)})},{key:"reEditSubmit",value:(_=v(h().m(function e(t){var n,i,r;return h().w(function(e){for(;;)switch(e.n){case 0:if(-1===(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))){e.n=1;break}return i=va(this.reEditContent.value),r=d(d({},t._origin),{},{content:i,realcontent:i}),this.replaceMessage(r,!1),this.messages.value[n].reeditstate=!1,this.reEditContent.value="",this.reEditContentChanged.value=!1,e.n=1,this.refreshMessage(t,!0);case 1:return e.a(2)}},e,this)})),function(e){return _.apply(this,arguments)})},{key:"reEditCancel",value:(M=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&(this.messages.value[n].reeditstate=!1,this.reEditContent.value="",this.reEditContentChanged.value=!1,this.messages.value=c(this.messages.value));case 1:return e.a(2)}},e,this)})),function(e){return M.apply(this,arguments)})},{key:"markLastUserMessage",value:(S=v(h().m(function e(){var t,n;return h().w(function(e){for(;;)switch(e.n){case 0:if(0!==this.messages.value.length){e.n=1;break}return e.a(2);case 1:t=c(this.messages.value).reverse(),n=t.find(function(e){return"USER"===e.role}),this.lastUserMsgID.value=null==n?void 0:n.messageid;case 2:return e.a(2)}},e,this)})),function(){return S.apply(this,arguments)})},{key:"resetTopicMessage",value:(b=v(h().m(function e(){var t,n;return h().w(function(e){for(;;)switch(e.n){case 0:if(null===(t=this.opts.utils)||void 0===t||!t.confirm){e.n=2;break}return e.n=1,this.opts.utils.confirm.warning({title:Uc.t.value("resetConversation"),desc:Uc.t.value("resetTopicConfirmTip")});case 1:if(e.v){e.n=2;break}return e.a(2,!1);case 2:return n=!0,e.n=3,this.clearTopicMessage(!1);case 3:if(n=e.v){e.n=4;break}return e.a(2,n);case 4:return e.n=5,this.fecthHistory();case 5:return e.a(2,n)}},e,this)})),function(){return b.apply(this,arguments)})},{key:"clearTopicMessage",value:(w=v(h().m(function e(){var t,n,i,r,o=arguments;return h().w(function(e){for(;;)switch(e.n){case 0:if(o.length>0&&void 0!==o[0]&&!o[0]||null===(t=this.opts.utils)||void 0===t||!t.confirm){e.n=2;break}return e.n=1,this.opts.utils.confirm.warning({title:Uc.t.value("clearConversation"),desc:Uc.t.value("clearTopicConfirmTip")});case 1:if(e.v){e.n=2;break}return e.a(2,!1);case 2:return n=!0,e.n=3,this.abortQuestion();case 3:if(!this.topicId){e.n=10;break}if(!this.topicId||!this.aiTopic){e.n=9;break}if(!this.currentTopicDisableStorage){e.n=4;break}n=!0,e.n=9;break;case 4:if("LOCAL"!==this.resourceMode){e.n=6;break}return e.n=5,ka.deleteData(Sw.DATA_BASE_NAME,Sw.DATA_TABLE_NAME,this.getHistoryStoreKey(this.topicId));case 5:n=e.v,e.n=9;break;case 6:if("REMOTE"!==this.resourceMode){e.n=9;break}if(!this.resourceOptions){e.n=9;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:this.chatSessionid});case 7:if(!((i=e.v)&&i.length>0)){e.n=9;break}return e.n=8,this.resourceOptions.clearAllMessageBySessionId(i[0].realid);case 8:n=e.v;case 9:e.n=13;break;case 10:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=13;break}return e.n=11,this.resourceOptions.getSessionList({n_session_id_eq:this.chatSessionid});case 11:if(!((r=e.v)&&r.length>0)){e.n=13;break}return e.n=12,this.resourceOptions.clearAllMessageBySessionId(r[0].realid);case 12:n=e.v;case 13:if(n){e.n=14;break}return e.a(2,n);case 14:return this.messages.value=[],e.a(2,n)}},e,this)})),function(){return w.apply(this,arguments)})},{key:"addMaterial",value:function(e){var t=this.materials.value.find(function(t){return t.id===e.id});this.materials.value=t?c(this.materials.value):[].concat(c(this.materials.value),[new dw(e)])}},{key:"replaceMaterial",value:function(e,t){var n=this.materials.value.findIndex(function(t){return t.id===e});-1!==n?(this.materials.value[n]=new dw(t),this.materials.value=c(this.materials.value)):this.materials.value=[].concat(c(this.materials.value),[new dw(t)])}},{key:"deleteMaterial",value:function(e){var t=this.materials.value.findIndex(function(t){return t.id===e.id});-1!==t&&(this.materials.value.splice(t,1),this.materials.value=c(this.materials.value))}},{key:"updateRecommendPrompt",value:function(e,t){if(t){var n=this.messages.value.findIndex(function(t){return t.messageid===e.messageid}),i=Ca.parseMixedContent(t).suggestions;if(i&&i.length>0){e.suggestions=i;var r=new lw(e);-1!==n?(this.messages.value[n]=r,this.messages.value=c(this.messages.value)):this.messages.value=[].concat(c(this.messages.value),[r]),this.onMessageChange("updatemsg",r),this.asyncToIndexDB()}}}},{key:"clearUIActions",value:(k=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&((i=this.messages.value[n]._origin).suggestions=void 0,this.messages.value[n].replace(i),this.messages.value=c(this.messages.value)),this.asyncToIndexDB();case 1:return e.a(2)}},e,this)})),function(e){return k.apply(this,arguments)})},{key:"handleSuggestionClick",value:(y=v(h().m(function e(t,n,i){var r,o,a,s,c,l,u,f,p,v,m,y;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.n=1,this.clearUIActions(t);case 1:r=n.type,o=n.metadata,y=r,e.n="action"===y?2:"raw"===y?9:11;break;case 2:if(!this.opts.extendToolbarClick){e.n=8;break}if(s=n.data.actionid,c=n.data.appid,s){e.n=3;break}throw new Error(Uc.t.value("actionIdCannotEmpty"));case 3:if(this.addMessage({messageid:la(),state:30,type:"DEFAULT",role:"USER",content:o.content_name,status:"sent"}),l=this.cloneMessage(t),Object.assign(l,{topic:this.topic}),l.msg.realcontent=t.realcontent,u=d({},this.context),!o.action_context){e.n=6;break}e.p=4,f=o.action_context.split(";"),(p=f.reduce(function(e,t){if(t.trim()){var n=g(t.split(":"),2),i=n[0],r=n[1];i&&r&&(e[i.trim()]=r.trim())}return e},{}))&&Object.keys(p).length>0&&Object.assign(u,d({},p)),e.n=6;break;case 5:throw e.p=5,e.v,new Error(Uc.t.value("actionExContext"));case 6:return e.n=7,this.opts.extendToolbarClick(i,{id:s,isPluginApp:!!c,appId:c||this.context.srfappid},u,this.params,l);case 7:v=e.v,(m=null==v||null===(a=v.data)||void 0===a?void 0:a[0])&&m.content&&this.addMessage({messageid:la(),state:30,type:m.type||"DEFAULT",role:m.role||"ASSISTANT",content:m.content,status:"sent"});case 8:return e.a(3,12);case 9:return e.n=10,this.question(n.data.content);case 10:return e.a(3,12);case 11:throw new Error(Uc.t.value("notSupportingType",{type:r}));case 12:return e.a(2)}},e,this,[[4,5]])})),function(e,t,n){return y.apply(this,arguments)})},{key:"handleUIActionClick",value:(m=v(h().m(function e(t,n,i){var r,o,a,s,c,l,u,f,p,v,m,y,k;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.n=1,this.clearUIActions(t);case 1:r=n.type,o=n.data,a=n.metadata,k=r,e.n="action"===k?2:"raw"===k?9:11;break;case 2:if(!this.opts.extendToolbarClick){e.n=8;break}if(c=o.actionid,l=o.appid,c){e.n=3;break}throw new Error(Uc.t.value("actionIdCannotEmpty"));case 3:if(u=this.cloneMessage(t),Object.assign(u,{topic:this.topic}),u.msg.realcontent=t.realcontent,f=d({},this.context),!a.action_context){e.n=6;break}e.p=4,p=a.action_context.split(";"),(v=p.reduce(function(e,t){if(t.trim()){var n=g(t.split(":"),2),i=n[0],r=n[1];i&&r&&(e[i.trim()]=r.trim())}return e},{}))&&Object.keys(v).length>0&&Object.assign(f,d({},v)),e.n=6;break;case 5:throw e.p=5,e.v,new Error(Uc.t.value("actionExContext"));case 6:return e.n=7,this.opts.extendToolbarClick(i,{id:c,isPluginApp:!!l,appId:l||this.context.srfappid},f,this.params,u);case 7:m=e.v,(y=null==m||null===(s=m.data)||void 0===s?void 0:s[0])&&y.content&&this.addMessage({messageid:la(),state:30,type:y.type||"DEFAULT",role:y.role||"ASSISTANT",content:y.content,status:"sent"});case 8:return e.a(3,12);case 9:return e.n=10,this.question(o.content);case 10:return e.a(3,12);case 11:throw new Error(Uc.t.value("notSupportingType",{type:r}));case 12:return e.a(2)}},e,this,[[4,5]])})),function(e,t,n){return m.apply(this,arguments)})},{key:"setActiveAIAgentID",value:(u=v(h().m(function e(t){var n,i=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.activeAIAgentID!==t){e.n=1;break}return e.a(2);case 1:this.activeAIAgentID=t,this.topicId&&this.aiTopic&&this.aiTopic.updateTopicChatByID(this.topicId,{activeAIAgentID:t}),this.enableRecallConfigSetting.value&&(n=this.agentList.value.find(function(e){return e.id===i.activeAIAgentID}),n&&(this.reCallConfig.value={chunkrerank:n.rerank,maxchunks:n.maxchunks,chunkthreshold:n.chunkthreshold,chunkpageindex:n.chunkpageindex})),this.enableKnowledgeBaseSelect.value&&this.computeSelectedKnowledge();case 2:return e.a(2)}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"setAIAgentConfig",value:function(e){this.reCallConfig.value=d(d({},this.reCallConfig.value),e)}},{key:"searchAIAgent",value:(l=v(h().m(function e(t){var n,i,r=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(n=[],!this.opts.fetchAgentList){e.n=3;break}return e.n=1,this.opts.fetchAgentList({query:t,agentid:this.activeAIAgentID||this.opts.activeAIAgentID});case 1:if(i=e.v){e.n=2;break}i=[];case 2:n=i.map(function(e){return new hw(e,{chunkrerank:r.opts.reRankDefaultValue,maxchunks:r.opts.maxChunksDefaultValue,chunkthreshold:r.opts.chunkThresholdDefaultValue,chunkpageindex:r.opts.chunkPageIndexDefaultValue})}),e.n=4;break;case 3:n=this.agentList.value;case 4:return e.a(2,n)}},e,this)})),function(e){return l.apply(this,arguments)})},{key:"searchProject",value:(s=v(h().m(function e(){var t,n,i,r,o=arguments;return h().w(function(e){for(;;)switch(e.n){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:"",n=o.length>1&&void 0!==o[1]?o[1]:"",i=[],!this.opts.fetchProject){e.n=2;break}return e.n=1,this.opts.fetchProject(this.context,d(d({},this.params),{},{appDataEntityId:this.appDataEntityId}),{file_path:t,pattern:n,srfaiagent:this.activeAIAgentID||"",sessionid:this.chatSessionid,max_depth:1});case 1:r=e.v,i=r.map(function(e){return{id:e.name,label:e.name,isLeaf:"dir"!==e.type}});case 2:return e.a(2,i)}},e,this)})),function(){return s.apply(this,arguments)})},{key:"setSelectionKnowledge",value:function(e){this.selectionKnowledgeBases.value=c(e);var t=this.getQueryKnowledgeBases();this.topicId&&this.aiTopic&&t&&this.aiTopic.updateTopicChatByID(this.topicId,{selectAIKnowledgeBaseId:t})}},{key:"updateTopic",value:(a=v(h().m(function e(){var t,n,i,r,o,a,s,c,l,u,f,p,v,m,g,y,k=arguments;return h().w(function(e){for(;;)switch(e.n){case 0:if(t=!(k.length>0&&void 0!==k[0])||k[0],!this.chatSessionid||!this.chatSessionid.startsWith("temp")){e.n=1;break}return e.a(2);case 1:if((n=t)&&this.topicId&&this.aiTopic&&(i=this.aiTopic.getCurrentTopicByID(this.topicId))&&i.captionComputed&&(n=!1),n&&!0===this.isDigestProcessed&&(n=!1),r="",o=!1,!n){e.n=6;break}if(!(a=this.messages.value.find(function(e){return"USER"===e.role}))){e.n=6;break}if(o=!0,!this.sessionCaptionMode){e.n=6;break}y=this.sessionCaptionMode,e.n="snippet"===y?2:"summary"===y?3:5;break;case 2:return s=a.content,c=ba.parseMixedContent(s),l=c.remainingText,r=l.substring(0,15),e.a(3,6);case 3:return e.n=4,this.opts.chatDigest(this.context,this.params,{appDataEntityId:this.appDataEntityId,message:{messages:this.getMessages(),sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,mode:"title",maxtokens:this.opts.summaryMaxTokens||30}});case 4:return(u=e.v)&&u.content&&(r=u.content),e.a(3,6);case 5:return r=this.sessionDefaultCaption,e.a(3,6);case 6:if(f={},!o||"REMOTE"!==this.resourceMode||!this.resourceOptions||this.currentTopicDisableStorage){e.n=8;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:this.chatSessionid});case 7:if(!((p=e.v)&&p.length>0)){e.n=8;break}if(v=p[0],m={},v.ui_meta&&(m=ga(v.ui_meta)),!r||!v||v.caption===r||!0===m.captionComputed){e.n=8;break}if(f.caption=r,f.ui_meta=d(d({},this.sessionMeta),{},{captionComputed:!0}),!(Object.keys(f).length>0)){e.n=8;break}return e.n=8,this.resourceOptions.updateSession(p[0].realid,f);case 8:if(!this.topicId||!this.aiTopic){e.n=11;break}if(g=this.needUpdateMetaData?this.sessionMeta:void 0,!o||!r){e.n=10;break}return e.n=9,this.aiTopic.updateTopicCaption(this.topicId,r);case 9:this.isDigestProcessed=!0,e.n=11;break;case 10:if(!g||!this.aiTopic.backupOptions){e.n=11;break}return e.n=11,this.aiTopic.updateTopicConfig(this.aiTopic.backupOptions);case 11:this.needUpdateMetaData=!1;case 12:return e.a(2)}},e,this)})),function(){return a.apply(this,arguments)})},{key:"messageLike",value:(o=v(h().m(function e(t){var n,i,r;return h().w(function(e){for(;;)switch(e.n){case 0:if(n="1"===t.islike,(i=t.realmessageid)&&this.resourceOptions){e.n=1;break}return e.a(2);case 1:if(!n){e.n=3;break}return e.n=2,this.resourceOptions.cancelFeedback(i);case 2:r=e.v,e.n=5;break;case 3:return e.n=4,this.resourceOptions.likeMessage(i);case 4:r=e.v;case 5:r&&(t.islike=n?"0":"1",n||"1"!==t.isdislike||(t.isdislike="0"),this.replaceMessage(t,!1));case 6:return e.a(2)}},e,this)})),function(e){return o.apply(this,arguments)})},{key:"messageDisLike",value:(r=v(h().m(function e(t){var n,i,r,o;return h().w(function(e){for(;;)switch(e.n){case 0:if(n="1"===t.isdislike,i=t.realmessageid,r=t.feedbackcontent,i&&this.resourceOptions){e.n=1;break}return e.a(2);case 1:if(!n){e.n=3;break}return e.n=2,this.resourceOptions.cancelFeedback(i);case 2:o=e.v,e.n=5;break;case 3:return e.n=4,this.resourceOptions.dislikeMessage(i,r);case 4:o=e.v;case 5:o&&(t.isdislike=n?"0":"1",n||"1"!==t.islike||(t.islike="0"),this.replaceMessage(t,!1));case 6:return e.a(2)}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"handlePredefinedClick",value:(i=v(h().m(function e(t,n,i,r){var o,a,s;return h().w(function(e){for(;;)switch(e.n){case 0:s=t,e.n="chunkview"===s?1:"view"===s?5:"action"===s?7:9;break;case 1:if(o=n.replace("chunkview://",""),this.opts.chunkView){e.n=2;break}return console.error(Uc.t.value("chunkView")),e.a(2);case 2:if(this.opts.chunkEntity){e.n=3;break}return console.error(Uc.t.value("chunkEntity")),e.a(2);case 3:return a="view://".concat(this.opts.chunkView,'?srfnavctx={"').concat(this.opts.chunkEntity,'":"').concat(o,'"}'),e.n=4,this.handlePredefViewClick(a,i,r);case 4:case 6:case 8:return e.a(3,9);case 5:return e.n=6,this.handlePredefViewClick(n,i,r);case 7:return e.n=8,this.handlePredefActionClick(n,i,r);case 9:return e.a(2)}},e,this)})),function(e,t,n,r){return i.apply(this,arguments)})},{key:"handlePredefViewClick",value:(n=v(h().m(function e(t,n,i){return h().w(function(e){for(;;)switch(e.n){case 0:if(this.opts.openLinkView){e.n=1;break}return e.a(2);case 1:return e.n=2,this.opts.openLinkView(t,n,i);case 2:return e.a(2)}},e,this)})),function(e,t,i){return n.apply(this,arguments)})},{key:"handlePredefActionClick",value:(t=v(h().m(function e(t,n,i){var r,o,a,s,c,l,u,f,p,v,m,g;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.opts.extendToolbarClick){e.n=1;break}return e.a(2);case 1:if(o=pa(t),a=o.typeId,s=o.context,c=o.params,l=a,u=s.appid,l){e.n=2;break}throw new Error(Uc.t.value("actionIdCannotEmpty"));case 2:return f=this.cloneMessage(n),Object.assign(f,{topic:this.topic}),f.msg.realcontent=n.realcontent,p=d({},this.context),s&&Object.keys(s).length>0&&Object.assign(p,d({},s)),v=d({},this.params),c&&Object.keys(c).length>0&&Object.assign(v,d({},c)),e.n=3,this.opts.extendToolbarClick(i,{id:l,isPluginApp:!!u,appId:u||this.context.srfappid},p,v,f);case 3:m=e.v,(g=null==m||null===(r=m.data)||void 0===r?void 0:r[0])&&g.content&&this.addMessage({messageid:la(),state:30,type:g.type||"DEFAULT",role:g.role||"ASSISTANT",content:g.content,status:"sent"});case 4:return e.a(2)}},e,this)})),function(e,n,i){return t.apply(this,arguments)})},{key:"onMessageChange",value:function(e,t){var n,i;null===(n=(i=this.opts).action)||void 0===n||n.call(i,e,t)}},{key:"destroyed",value:(e=v(h().m(function e(){return h().w(function(e){for(;;)switch(e.n){case 0:this.evt.reset();case 1:return e.a(2)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"setActiveAsyncacitonId",value:function(e){this.activeAsyncacitonid=e}},{key:"getActiveAsyncacitonId",value:function(){return this.activeAsyncacitonid}}]);var e,t,n,i,r,o,a,s,l,u,m,y,k,w,b,S,M,_,N,O,E,A,D,I,L,R,z,P,B,F,H,j,V,W,$,U}(),Ew=function(){return x(function e(t){C(this,e),T(this,"topics",gs([])),T(this,"activedTopic",gs(void 0)),T(this,"topicSidebarCollapse",gs(!1)),T(this,"topicSidebarWidth",gs(0)),T(this,"isTempChat",gs(!1)),T(this,"isSelectMode",gs(!1)),T(this,"selectedTopicIds",gs(new Set)),T(this,"backupOptions",void 0),T(this,"preActivedTopic",void 0),T(this,"remoteSessionList",[]),T(this,"resourceMode","LOCAL"),T(this,"resourceOptions",void 0),T(this,"configList",[]),T(this,"storageMode","DEFAULT"),T(this,"compWrapperId","DEFAULT"),T(this,"workMode","DEFAULT"),T(this,"scopeList",[]),T(this,"groups",gs([])),T(this,"groupConfig",void 0),this.chat=t},[{key:"isTopicGenerating",value:function(e){var t,n;return null!==(t=null===(n=this.chat.getAiChatControllerByTopicId(e))||void 0===n?void 0:n.isLoading.value)&&void 0!==t&&t}},{key:"setActivedTopic",value:function(e){this.preActivedTopic=this.activedTopic.value,this.activedTopic.value=e,this.handleAction("active",e)}},{key:"injectBasicResources",value:function(e,t,n){this.compWrapperId=e||"DEFAULT",this.workMode=t,this.scopeList=null!=n?n:[],this.computeTopicSidebarWidth()}},{key:"injectResourceOptions",value:function(e){this.resourceMode=(null==e?void 0:e.resourceMode)||"LOCAL",this.resourceOptions=e}},{key:"fetchHistory",value:(I=v(h().m(function e(t){var n,i,r,o,a=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.topics.value=[],this.storageMode=t.storageMode||"DEFAULT","WORKSPACE"!==this.workMode){e.n=1;break}return e.n=1,this.fetchGroups(t);case 1:if("REMOTESESSION"!==this.storageMode){e.n=3;break}if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=3;break}return e.n=2,this.resourceOptions.getSessionList();case 2:return this.remoteSessionList=e.v,e.n=3,this.asyncRemoteSession();case 3:if("DEFAULT"!==this.storageMode){e.n=8;break}return i=t.configService(t.appid,"aitopics",t.type),e.n=4,i.load();case 4:if(r=e.v,this.configList=Array.isArray(r)?r:[],!(this.configList&&this.configList.length>0)){e.n=8;break}if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=7;break}return e.n=5,this.resourceOptions.getSessionList();case 5:return this.remoteSessionList=e.v,e.n=6,this.asyncRemoteSession();case 6:e.n=8;break;case 7:o=1,this.configList.forEach(function(e,t){e.captionComputed||(e.caption=Uc.t.value("historySession",{count:o}),o+=1),Object.prototype.hasOwnProperty.call(e,"sequence")||(e.sequence=t),Object.prototype.hasOwnProperty.call(e,"isTop")||(e.isTop=0),a.topics.value=[].concat(c(a.topics.value),[new uw(e)])});case 8:null===(n=t.action)||void 0===n||n.call(t,"history",{topics:this.topics.value});case 9:return e.a(2)}},e,this)})),function(e){return I.apply(this,arguments)})},{key:"asyncRemoteSession",value:(D=v(h().m(function e(){var t,n=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.remoteSessionList&&0!==this.remoteSessionList.length&&("DEFAULT"!==this.storageMode||0!==this.configList.length)){e.n=1;break}return e.a(2);case 1:t=1,this.remoteSessionList.forEach(function(e){var i;if("DEFAULT"===n.storageMode&&(i=n.configList.find(function(t){var n;return(null===(n=t.aiChat)||void 0===n?void 0:n.sessionid)===e.session_id})),"REMOTESESSION"===n.storageMode&&e.ui_meta&&(i=ga(e.ui_meta)),i&&!i.captionComputed&&(i.caption=Uc.t.value("historySession",{count:t}),t+=1),i&&i.id){i.realid=e.realid,i.sequence=e.sequence,i.isTop=e.is_top?e.is_top:0,e.caption&&(i.caption=e.caption),e.scope&&(i.scope=e.scope);var r=n.topics.value.findIndex(function(t){var n;return(null===(n=t.aiChat)||void 0===n?void 0:n.sessionid)===e.session_id});-1===r?n.topics.value=[].concat(c(n.topics.value),[new uw(i)]):(n.topics.value.splice(r,1,new uw(i)),n.topics.value=c(n.topics.value))}});case 2:return e.a(2)}},e,this)})),function(){return D.apply(this,arguments)})},{key:"asyncTopic",value:(A=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:this.backupOptions=t,n=this.topics.value.findIndex(function(e){return e.id===t.id}),i=new uw(t),-1!==n?this.topics.value.splice(n,1,i):this.topics.value=[].concat(c(this.topics.value),[i]),this.setActivedTopic(i);case 1:return e.a(2)}},e,this)})),function(e){return A.apply(this,arguments)})},{key:"getCurrentTopicByID",value:function(e){var t=this.topics.value.find(function(t){return t.id===e});return t&&t.data?new uw(d({},t.data)):void 0}},{key:"updateTopicChatByID",value:(E=v(h().m(function e(t,n){var i,r,o,a;return h().w(function(e){for(;;)switch(e.n){case 0:if(t&&n&&this.backupOptions){e.n=1;break}return e.a(2);case 1:if(-1!==(i=this.topics.value.findIndex(function(e){return e.id===t}))&&this.topics.value[i].data.aiChat){e.n=2;break}return e.a(2);case 2:if(r=this.topics.value[i]){e.n=3;break}return e.a(2);case 3:if(r.data.aiChat=d(d({},r.data.aiChat),n),!1!==r.captionComputed){e.n=4;break}return e.a(2);case 4:if("REMOTESESSION"!==this.storageMode||!this.resourceOptions){e.n=8;break}if(o={ui_meta:this.buildTopicUiMeta(r,n)},!r.realid){e.n=6;break}return e.n=5,this.resourceOptions.updateSession(r.realid,o);case 5:e.n=8;break;case 6:if(!r.aiChat||!r.aiChat.sessionid){e.n=8;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:r.aiChat.sessionid});case 7:if(!((a=e.v)&&a.length>0)){e.n=8;break}return e.n=8,this.resourceOptions.updateSession(a[0].realid,o);case 8:if("DEFAULT"!==this.storageMode){e.n=9;break}return e.n=9,this.updateTopicConfig(this.backupOptions);case 9:this.handleAction("update",r);case 10:return e.a(2)}},e,this)})),function(e,t){return E.apply(this,arguments)})},{key:"buildTopicUiMeta",value:function(e,t){return{appid:e.appid,id:e.id,type:e.type,captionMode:e.captionMode,captionComputed:!!e.captionComputed,caption:e.caption||e.sourceCaption,sourceCaption:e.sourceCaption,url:e.url,aiChat:d(d({},e.aiChat),t),isTop:e.isTop,sequence:e.sequence,scope:e.scope,groupid:e.groupid}}},{key:"updateTopicRemoteMeta",value:(O=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:if("REMOTESESSION"===this.storageMode||"DEFAULT"===this.storageMode&&"REMOTE"===this.resourceMode){e.n=1;break}return e.a(2);case 1:if(this.resourceOptions){e.n=2;break}return e.a(2);case 2:if(n={ui_meta:this.buildTopicUiMeta(t)},(t.scope||void 0===t.scope)&&Object.assign(n,{scope:t.scope||null}),!t.realid){e.n=4;break}return e.n=3,this.resourceOptions.updateSession(t.realid,n);case 3:e.n=6;break;case 4:if(!t.aiChat||!t.aiChat.sessionid){e.n=6;break}return e.n=5,this.resourceOptions.getSessionList({n_session_id_eq:t.aiChat.sessionid});case 5:if(!((i=e.v)&&i.length>0)){e.n=6;break}return e.n=6,this.resourceOptions.updateSession(i[0].realid,n);case 6:return e.a(2)}},e,this)})),function(e){return O.apply(this,arguments)})},{key:"removeTopic",value:(N=v(h().m(function e(t,n,i,r,o){var a,s,l,u,d;return h().w(function(e){for(;;)switch(e.n){case 0:if(s=!0,!t.beforeDelete){e.n=2;break}return e.n=1,t.beforeDelete(Uc.t.value("deleteConversation"),Uc.t.value("deleteConversationConfirmTip"));case 1:s=e.v;case 2:if(s){e.n=3;break}return e.a(2);case 3:if(l=!1,!r||!r.disableStorage){e.n=4;break}l=!0,e.n=11;break;case 4:if("DEFAULT"!==this.storageMode){e.n=9;break}if("LOCAL"!==this.resourceMode){e.n=6;break}return e.n=5,ka.deleteData(Sw.DATA_BASE_NAME,Sw.DATA_TABLE_NAME,r.id);case 5:l=e.v,e.n=8;break;case 6:return e.n=7,this.deleteRemoteSession(r);case 7:l=e.v;case 8:e.n=11;break;case 9:if("REMOTESESSION"!==this.storageMode){e.n=11;break}return e.n=10,this.deleteRemoteSession(r);case 10:l=e.v;case 11:if(l){e.n=12;break}return e.a(2);case 12:return-1!==(u=this.topics.value.findIndex(function(e){return e.id===r.id}))&&(this.topics.value.splice(u,1),this.topics.value=c(this.topics.value)),"DEFAULT"===this.storageMode&&-1!==(d=this.configList.findIndex(function(e){return e.id===r.id}))&&this.configList.splice(d,1),e.n=13,this.updateTopicConfig(t);case 13:this.handleAction("remove",r),this.topics.value.length>0&&r.id===(null===(a=this.activedTopic.value)||void 0===a?void 0:a.id)&&this.handleTopicChange(this.topics.value[0]);case 14:return e.a(2)}},e,this)})),function(e,t,n,i,r){return N.apply(this,arguments)})},{key:"deleteRemoteSession",value:(_=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:if("REMOTE"===this.resourceMode&&this.resourceOptions){e.n=1;break}return e.a(2,!1);case 1:if(!t.realid){e.n=2;break}return e.a(2,this.resourceOptions.deleteSession(t.realid));case 2:if(null===(n=t.aiChat)||void 0===n||!n.sessionid){e.n=5;break}return e.n=3,this.resourceOptions.getSessionList({n_session_id_eq:t.aiChat.sessionid});case 3:if(!((i=e.v)&&i.length>0)){e.n=4;break}return e.a(2,this.resourceOptions.deleteSession(i[0].realid));case 4:return e.a(2,!0);case 5:return e.a(2,!1)}},e,this)})),function(e){return _.apply(this,arguments)})},{key:"handleTopicChange",value:function(e){var t;(null===(t=this.activedTopic.value)||void 0===t?void 0:t.id)!==e.id&&(this.setActivedTopic(e),this.chat.switchAiChatController(e))}},{key:"handleTopicAction",value:(M=v(h().m(function e(t,n,i){var r,o,a,s,l,u;return h().w(function(e){for(;;)switch(e.n){case 0:if(r=this.topics.value.find(function(e){return e.id===n.id}),!(this.backupOptions&&r&&r.aiChat)){e.n=10;break}o=r.aiChat,a=o.context,s=o.params,u=t,e.n="DELETE"===u?1:"RENAME"===u||"PINNED"===u?3:9;break;case 1:return e.n=2,this.removeTopic(this.backupOptions,a,s,r,i);case 2:return e.a(3,9);case 3:if("PINNED"===t&&(n.data.isTop=0===n.data.isTop?1:0,this.topics.value=c(this.topics.value)),!n||n.disableStorage){e.n=8;break}if(!n||"REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=7;break}if(!n.realid){e.n=5;break}return e.n=4,this.resourceOptions.updateSession(n.realid,{caption:n.caption,is_top:n.isTop});case 4:e.n=7;break;case 5:if(!n.aiChat||!n.aiChat.sessionid){e.n=7;break}return e.n=6,this.resourceOptions.getSessionList({n_session_id_eq:n.aiChat.sessionid});case 6:if(!((l=e.v)&&l.length>0)){e.n=7;break}return e.n=7,this.resourceOptions.updateSession(l[0].realid,{caption:n.caption,is_top:n.isTop});case 7:if("DEFAULT"!==this.storageMode){e.n=8;break}return e.n=8,this.updateTopicConfig(this.backupOptions);case 8:return e.a(3,9);case 9:this.handleAction(t,n);case 10:return e.a(2)}},e,this)})),function(e,t,n){return M.apply(this,arguments)})},{key:"newTopic",value:(S=v(h().m(function e(t,n,i){var r,o,a,s,l,u,f,p;return h().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:if(r=this.getCurrentTopicByID(t)){e.n=2;break}return e.a(2);case 2:o=ua(r.id),a="".concat(o,"@").concat(Date.now()),s=fa("TOPIC",a),n&&r.aiChat&&(r.data.aiChat=d(d(d({},r.aiChat),n),{},{sessionid:s})),l=Uc.t.value("newConversation"),u=Math.max.apply(Math,c(this.topics.value.map(function(e){return e.sequence}))),f=d({appid:r.appid,id:a,type:r.type,captionMode:r.captionMode,caption:l,sourceCaption:r.sourceCaption,url:r.url,aiChat:r.aiChat,sequence:u+1,isTop:0,disableStorage:r.disableStorage},i),p=new uw(f),this.topics.value=[p].concat(c(this.topics.value)),this.handleAction("create",p),this.handleTopicChange(p);case 3:return e.a(2)}},e,this)})),function(e,t,n){return S.apply(this,arguments)})},{key:"clearTopic",value:(b=v(h().m(function e(){var t,n,i,r=this,o=arguments;return h().w(function(e){for(;;)switch(e.n){case 0:if(t=o.length>0&&void 0!==o[0]&&o[0],n=this.topics.value.find(function(e){var t;return e.id===(null===(t=r.activedTopic.value)||void 0===t?void 0:t.id)}),this.backupOptions&&n){e.n=1;break}return e.a(2);case 1:if(!this.backupOptions.beforeDelete){e.n=3;break}return e.n=2,this.backupOptions.beforeDelete(Uc.t.value("clearSession"),Uc.t.value(t?"clearSessionWithGroupConfirmTip":"clearSessionConfirmTip"));case 2:if(e.v){e.n=3;break}return e.a(2);case 3:if(i=!1,"DEFAULT"!==this.storageMode){e.n=8;break}if("LOCAL"!==this.resourceMode){e.n=5;break}return e.n=4,Promise.all(this.topics.value.filter(function(e){return e.id!==n.id&&!e.disableStorage}).map(function(e){return ka.deleteData(Sw.DATA_BASE_NAME,Sw.DATA_TABLE_NAME,e.id)}));case 4:i=!0,e.n=7;break;case 5:return e.n=6,this.clearRemoteSession(n);case 6:i=e.v;case 7:e.n=10;break;case 8:if("REMOTESESSION"!==this.storageMode){e.n=10;break}return e.n=9,this.clearRemoteSession(n);case 9:i=e.v;case 10:if(i){e.n=11;break}return e.a(2);case 11:return"DEFAULT"===this.storageMode&&(this.configList=[]),this.handleAction("clear",n),this.topics.value=n?[n]:[],e.n=12,this.updateTopicConfig(this.backupOptions);case 12:if(!t){e.n=13;break}return this.groups.value=[],e.n=13,this.saveGroups();case 13:return e.a(2)}},e,this)})),function(){return b.apply(this,arguments)})},{key:"clearRemoteSession",value:(w=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.resourceOptions){e.n=1;break}return e.a(2,!0);case 1:if(i=null===(n=t.aiChat)||void 0===n?void 0:n.sessionid){e.n=2;break}return e.a(2,!0);case 2:return e.a(2,this.resourceOptions.clearAllSession(i))}},e,this)})),function(e){return w.apply(this,arguments)})},{key:"enterSelectMode",value:function(e){this.isSelectMode.value=!0,e&&(this.selectedTopicIds.value=new Set([e]))}},{key:"exitSelectMode",value:function(){this.isSelectMode.value=!1,this.selectedTopicIds.value=new Set}},{key:"toggleTopicSelected",value:function(e){var t=new Set(this.selectedTopicIds.value);t.has(e)?t.delete(e):t.add(e),this.selectedTopicIds.value=t}},{key:"getSelectedTopics",value:function(){var e=this;return this.topics.value.filter(function(t){return e.selectedTopicIds.value.has(t.id)})}},{key:"updateTopicCaption",value:(k=v(h().m(function e(t,n){var i;return h().w(function(e){for(;;)switch(e.n){case 0:if(!(i=this.topics.value.find(function(e){return e.id===t}))||i.caption===n){e.n=1;break}if(i.data.caption=n,i.data.captionComputed=!0,this.topics.value=c(this.topics.value),this.handleAction("update",i),!this.backupOptions){e.n=1;break}return e.n=1,this.updateTopicConfig(this.backupOptions);case 1:return e.a(2)}},e,this)})),function(e,t){return k.apply(this,arguments)})},{key:"updateTopicConfig",value:(y=v(h().m(function e(t){var n,i,r;return h().w(function(e){for(;;)switch(e.n){case 0:if(t&&"DEFAULT"===this.storageMode&&!0!==this.isTempChat.value){e.n=1;break}return e.a(2);case 1:return n=[],i=new Set,this.topics.value.forEach(function(e){i.add(e.id),!e.disableStorage&&e.captionComputed&&n.push({appid:e.appid,id:e.id,type:e.type,captionMode:e.captionMode,captionComputed:!!e.captionComputed,caption:e.caption||e.sourceCaption,sourceCaption:e.sourceCaption,url:e.url,aiChat:e.aiChat,isTop:e.isTop,sequence:e.sequence,scope:e.scope,groupid:e.groupid})}),this.configList.forEach(function(e){i.has(e.id)||n.push({appid:e.appid,id:e.id,type:e.type,captionMode:e.captionMode,captionComputed:!!e.captionComputed,caption:e.caption,sourceCaption:e.sourceCaption,url:e.url,aiChat:e.aiChat,isTop:e.isTop,sequence:e.sequence,scope:e.scope,groupid:e.groupid})}),r=t.configService(t.appid,"aitopics",t.type),e.n=2,null==r?void 0:r.save(n);case 2:return e.a(2)}},e,this)})),function(e){return y.apply(this,arguments)})},{key:"computeTopicSidebarWidth",value:function(){var e;this.topicSidebarWidth.value=!0===this.topicSidebarCollapse.value?42:null!==(e=this.getTopicSidebarWidthCache())&&void 0!==e?e:200}},{key:"getTopicSidebarWidthCacheKey",value:function(){return"".concat(this.compWrapperId,"__").concat(Sw.TOPIC_SIDEBAR_WIDTH)}},{key:"getTopicSidebarWidthCache",value:function(){var e=this.getTopicSidebarWidthCacheKey(),t=localStorage.getItem(e);if(null!==t){var n=Number(t);return Number.isFinite(n)&&n>0?n:void 0}}},{key:"updateTopicSidebarWidth",value:function(){var e=this.getTopicSidebarWidthCacheKey();localStorage.setItem(e,String(this.topicSidebarWidth.value))}},{key:"switchTopicSidebarCollapse",value:function(){this.topicSidebarCollapse.value=!this.topicSidebarCollapse.value,this.computeTopicSidebarWidth()}},{key:"globalNewTopic",value:function(e,t){if(this.activedTopic.value)if(this.isTempChat.value){if(!this.backupOptions)return;this.exitTempChat();var n=this.backupOptions.aiChat;this.newTopic(this.backupOptions.id,{activeAIAgentID:n.activeAIAgentID},{scope:e,groupid:t})}else{var i=this.activedTopic.value.aiChat;this.newTopic(this.activedTopic.value.id,{activeAIAgentID:i.activeAIAgentID},{scope:e,groupid:t})}}},{key:"enterTempChat",value:function(){if(this.isTempChat.value=!0,this.backupOptions){var e=ua(this.backupOptions.id),t=fa("TEMP"),n=Math.max.apply(Math,c(this.topics.value.map(function(e){return e.sequence}))),i=d(d({},this.backupOptions.aiChat),{},{sessionid:t}),r={appid:this.backupOptions.appid,id:"".concat(e,"@").concat(Date.now()),type:this.backupOptions.type,captionMode:this.backupOptions.captionMode,caption:Uc.t.value("temporarySession"),sourceCaption:Uc.t.value("temporarySession"),url:this.backupOptions.url,aiChat:i,sequence:n+1,isTop:0,disableStorage:!0,isShow:!1},o=new uw(r);this.topics.value=[].concat(c(this.topics.value),[o]),this.handleAction("createTemp",o),this.handleTopicChange(o)}else console.error(Uc.t.value("temporarySessionFailed"))}},{key:"exitTempChat",value:function(){this.isTempChat.value=!1;var e=this.topics.value.findIndex(function(e){return!0===e.disableStorage&&!1===e.isShow});if(-1!==e){var t=this.topics.value[e];this.topics.value.splice(e,1),this.topics.value=c(this.topics.value),this.handleAction("removeTemp",t)}}},{key:"handleAction",value:function(e,t){var n,i,r,o;null===(n=this.backupOptions)||void 0===n||null===(i=n.action)||void 0===i||i.call(n,e,{topic:t,params:null==t||null===(r=t.aiChat)||void 0===r?void 0:r.params,context:null==t||null===(o=t.aiChat)||void 0===o?void 0:o.context,topics:this.topics.value})}},{key:"resolveTopicRealIds",value:(g=v(h().m(function e(t){var n,i=this;return h().w(function(e){for(;;)switch(e.n){case 0:return n=[],e.n=1,Promise.all(t.map(function(){var e=v(h().m(function e(t){var r,o;return h().w(function(e){for(;;)switch(e.n){case 0:if(!t.realid){e.n=1;break}return n.push(t.realid),e.a(2);case 1:if(null===(r=t.aiChat)||void 0===r||!r.sessionid){e.n=3;break}return e.n=2,i.resourceOptions.getSessionList({n_session_id_eq:t.aiChat.sessionid});case 2:(o=e.v)&&o.length>0&&n.push(o[0].realid);case 3:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}()));case 1:return e.a(2,n)}},e)})),function(e){return g.apply(this,arguments)})},{key:"batchDeleteRemoteSession",value:(m=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.resourceOptions&&0!==t.length){e.n=1;break}return e.a(2,!0);case 1:return e.n=2,this.resolveTopicRealIds(t);case 2:if(0!==(n=e.v).length){e.n=3;break}return e.a(2,!0);case 3:return e.a(2,this.resourceOptions.batchDeleteSession(n))}},e,this)})),function(e){return m.apply(this,arguments)})},{key:"batchPinTop",value:(p=v(h().m(function e(){var t,n;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.backupOptions){e.n=1;break}return e.a(2);case 1:if(0!==(t=this.getSelectedTopics()).length){e.n=2;break}return e.a(2);case 2:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=5;break}return e.n=3,this.resolveTopicRealIds(t);case 3:if(!((n=e.v).length>0)){e.n=5;break}return e.n=4,this.resourceOptions.batchTopSession(n);case 4:if(e.v){e.n=5;break}return e.a(2);case 5:if(t.forEach(function(e){e.data.isTop=1}),this.topics.value=c(this.topics.value),"DEFAULT"!==this.storageMode){e.n=6;break}return e.n=6,this.updateTopicConfig(this.backupOptions);case 6:this.exitSelectMode();case 7:return e.a(2)}},e,this)})),function(){return p.apply(this,arguments)})},{key:"batchUnPinTop",value:(f=v(h().m(function e(){var t,n;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.backupOptions){e.n=1;break}return e.a(2);case 1:if(0!==(t=this.getSelectedTopics()).length){e.n=2;break}return e.a(2);case 2:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=5;break}return e.n=3,this.resolveTopicRealIds(t);case 3:if(!((n=e.v).length>0)){e.n=5;break}return e.n=4,this.resourceOptions.batchUnTopSession(n);case 4:if(e.v){e.n=5;break}return e.a(2);case 5:if(t.forEach(function(e){e.data.isTop=0}),this.topics.value=c(this.topics.value),"DEFAULT"!==this.storageMode){e.n=6;break}return e.n=6,this.updateTopicConfig(this.backupOptions);case 6:this.exitSelectMode();case 7:return e.a(2)}},e,this)})),function(){return f.apply(this,arguments)})},{key:"batchDeleteTopics",value:(u=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.backupOptions){e.n=1;break}return e.a(2);case 1:if(!(n=this.getSelectedTopics())||0!==n.length){e.n=2;break}return e.a(2);case 2:return e.n=3,this.deleteTopicsCore(n);case 3:this.exitSelectMode();case 4:return e.a(2)}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"deleteTopicsCore",value:(l=v(h().m(function e(t,n,i){var r,o;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.backupOptions){e.n=1;break}return e.a(2,!1);case 1:if(!this.backupOptions.beforeDelete){e.n=3;break}return e.n=2,this.backupOptions.beforeDelete(null!=n?n:0===t.length?Uc.t.value("batchDeleteSession"):Uc.t.value("batchDeleteConversation",{count:t.length}),null!=i?i:Uc.t.value("batchDeleteConversationConfirmTip"));case 2:if(e.v){e.n=3;break}return e.a(2,!1);case 3:if(t&&0!==t.length){e.n=4;break}return e.a(2,!0);case 4:if(r=!1,"DEFAULT"!==this.storageMode){e.n=9;break}if("LOCAL"!==this.resourceMode){e.n=6;break}return e.n=5,Promise.all(t.filter(function(e){return!e.disableStorage}).map(function(e){return ka.deleteData(Sw.DATA_BASE_NAME,Sw.DATA_TABLE_NAME,e.id)}));case 5:r=!0,e.n=8;break;case 6:return e.n=7,this.batchDeleteRemoteSession(t);case 7:r=e.v;case 8:e.n=11;break;case 9:if("REMOTESESSION"!==this.storageMode){e.n=11;break}return e.n=10,this.batchDeleteRemoteSession(t);case 10:r=e.v;case 11:if(r){e.n=12;break}return e.a(2,!1);case 12:return o=new Set(t.map(function(e){return e.id})),this.topics.value=this.topics.value.filter(function(e){return!o.has(e.id)}),"DEFAULT"===this.storageMode&&(this.configList=this.configList.filter(function(e){return!o.has(e.id)})),e.n=13,this.updateTopicConfig(this.backupOptions);case 13:return this.activedTopic.value&&o.has(this.activedTopic.value.id)&&this.topics.value.length>0&&this.handleTopicChange(this.topics.value[0]),e.a(2,!0)}},e,this)})),function(e,t,n){return l.apply(this,arguments)})},{key:"getGroupConfig",value:function(e){return this.groupConfig||(this.groupConfig=e.configService(e.appid,"aigroups",e.type)),this.groupConfig}},{key:"fetchGroups",value:(s=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:return n=this.getGroupConfig(t),e.n=1,n.load();case 1:i=e.v,this.groups.value=Array.isArray(i)?i:[];case 2:return e.a(2)}},e,this)})),function(e){return s.apply(this,arguments)})},{key:"saveGroups",value:(a=v(h().m(function e(){var t;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.backupOptions){e.n=1;break}return e.a(2);case 1:return t=this.getGroupConfig(this.backupOptions),e.n=2,null==t?void 0:t.save(this.groups.value);case 2:return e.a(2)}},e,this)})),function(){return a.apply(this,arguments)})},{key:"computeGroupTree",value:function(e){var t=this,n=null==e?void 0:e.trim().toLowerCase(),i=c(this.topics.value).sort(function(e,t){return e.isTop!==t.isTop?t.isTop?1:-1:t.sequence-e.sequence}).filter(function(e){var t,i;return!1!==e.isShow&&(!n||null!==(t=null===(i=e.caption)||void 0===i?void 0:i.toLowerCase().includes(n))&&void 0!==t&&t)}),r=[];this.scopeList.forEach(function(e){var n=i.filter(function(t){return String(t.scope)===String(e.id)});if(0!==n.length){var o=t.groups.value.filter(function(t){return String(t.scopeid)===String(e.id)}),a=new Set(o.map(function(e){return e.id}));r.push({key:"scope:".concat(String(e.id)),scopeid:e.id,text:e.text,groups:o.map(function(e){return{id:e.id,text:e.text,collapsed:e.collapsed,topics:n.filter(function(t){return t.groupid===e.id})}}),ungroupedTopics:n.filter(function(e){return!e.groupid||!a.has(e.groupid)})})}});var o=i.filter(function(e){return t.isUnclassifiedTopic(e)}),a=this.groups.value.filter(function(e){return e.scopeid===xw.NONE_SCOPE_ID});if(o.length>0){var s=new Set(a.map(function(e){return e.id}));r.push({key:xw.NONE_SCOPE_KEY,scopeid:void 0,text:Uc.t.value("unclassifiedTopic"),groups:a.map(function(e){return{id:e.id,text:e.text,collapsed:e.collapsed,topics:o.filter(function(t){return t.groupid===e.id})}}),ungroupedTopics:o.filter(function(e){return!e.groupid||!s.has(e.groupid)})})}return r}},{key:"isUnclassifiedTopic",value:function(e){return!e.scope||!this.scopeList.some(function(t){return String(t.id)===String(e.scope)})}},{key:"addGroup",value:(o=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return n={id:"group_".concat(Date.now(),"_").concat(Math.random().toString(36).slice(2,8)),text:Uc.t.value("newGroup"),scopeid:null!=t?t:xw.NONE_SCOPE_ID,collapsed:!0},this.groups.value=[].concat(c(this.groups.value),[n]),e.p=1,e.n=2,this.saveGroups();case 2:return e.a(2,n);case 3:return e.p=3,i=e.v,this.groups.value=this.groups.value.filter(function(e){return e.id!==n.id}),this.groups.value=c(this.groups.value),console.error("[AiTopicController] addGroup 持久化失败",i),e.a(2,void 0)}},e,this,[[1,3]])})),function(e){return o.apply(this,arguments)})},{key:"renameGroup",value:(r=v(h().m(function e(t,n){var i,r,o;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if((i=this.groups.value.find(function(e){return e.id===t}))&&n&&i.text!==n){e.n=1;break}return e.a(2,void 0);case 1:return r=i.text,i.text=n,this.groups.value=c(this.groups.value),e.p=2,e.n=3,this.saveGroups();case 3:return e.a(2,i);case 4:return e.p=4,o=e.v,i.text=r,this.groups.value=c(this.groups.value),console.error("[AiTopicController] renameGroup 持久化失败",o),e.a(2,void 0)}},e,this,[[2,4]])})),function(e,t){return r.apply(this,arguments)})},{key:"toggleGroupCollapse",value:(i=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:if(n=this.groups.value.find(function(e){return e.id===t})){e.n=1;break}return e.a(2);case 1:return n.collapsed=!0!==n.collapsed,this.groups.value=c(this.groups.value),e.n=2,this.saveGroups();case 2:return e.a(2)}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"removeScope",value:(n=v(h().m(function e(t){var n,i,r,o=this;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(void 0!==t){e.n=1;break}n=this.topics.value.filter(function(e){return o.isUnclassifiedTopic(e)}),e.n=3;break;case 1:if(this.scopeList.some(function(e){return String(e.id)===String(t)})){e.n=2;break}return e.a(2,!1);case 2:n=this.topics.value.filter(function(e){return String(e.scope)===String(t)});case 3:return e.n=4,this.deleteTopicsCore(n,Uc.t.value("deleteScope"),Uc.t.value("deleteScopeConfirmTip"));case 4:if(e.v){e.n=5;break}return e.a(2,!1);case 5:return i=this.groups.value,this.groups.value=this.groups.value.filter(function(e){return String(e.scopeid)!==String(void 0===t?xw.NONE_SCOPE_ID:t)}),e.p=6,e.n=7,this.saveGroups();case 7:return e.a(2,!0);case 8:return e.p=8,r=e.v,this.groups.value=i,console.error("[AiTopicController] removeScope 持久化失败",r),e.a(2,!1)}},e,this,[[6,8]])})),function(e){return n.apply(this,arguments)})},{key:"removeGroup",value:(t=v(h().m(function e(t){var n,i,r;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.groups.value.some(function(e){return e.id===t})){e.n=1;break}return e.a(2,!1);case 1:return n=this.topics.value.filter(function(e){return e.groupid===t}),e.n=2,this.deleteTopicsCore(n,Uc.t.value("deleteGroup"),Uc.t.value("deleteGroupConfirmTip"));case 2:if(e.v){e.n=3;break}return e.a(2,!1);case 3:return i=this.groups.value,this.groups.value=this.groups.value.filter(function(e){return e.id!==t}),e.p=4,e.n=5,this.saveGroups();case 5:return e.a(2,!0);case 6:return e.p=6,r=e.v,this.groups.value=i,console.error("[AiTopicController] removeGroup 持久化失败",r),e.a(2,!1)}},e,this,[[4,6]])})),function(e){return t.apply(this,arguments)})},{key:"moveTopic",value:(e=v(h().m(function e(t,n,i){var r,o,a,s,l;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if((r=this.topics.value.find(function(e){return e.id===t}))&&this.backupOptions){e.n=1;break}return e.a(2,!1);case 1:if(o=r.data.scope,a=r.data.groupid,s=void 0===n?void 0:this.getOriginScopeId(n),(void 0===o?void 0:String(o))!==(void 0===s?void 0:String(s))||a!==i){e.n=2;break}return e.a(2,!0);case 2:if(r.data.scope=s,r.data.groupid=i,this.topics.value=c(this.topics.value),this.handleAction("update",r),e.p=3,"DEFAULT"!==this.storageMode){e.n=4;break}return e.n=4,this.updateTopicConfig(this.backupOptions);case 4:return e.n=5,this.updateTopicRemoteMeta(r);case 5:e.n=7;break;case 6:return e.p=6,l=e.v,r.data.scope=o,r.data.groupid=a,this.topics.value=c(this.topics.value),this.handleAction("update",r),console.error("[AiTopicController] moveTopic 持久化失败,已还原归属",l),e.a(2,!1);case 7:return e.a(2,!0)}},e,this,[[3,6]])})),function(t,n,i){return e.apply(this,arguments)})},{key:"getOriginScopeId",value:function(e){var t=this.scopeList.find(function(t){return String(t.id)===String(e)});return t?t.id:e}},{key:"getAiChat",value:function(){return this.chat.aiChat}}]);var e,t,n,i,r,o,a,s,l,u,f,p,m,g,y,k,w,b,S,M,_,N,O,E,A,D,I}(),Aw=x(function e(t){C(this,e),this.aiChat=t}),Dw=function(e){function t(){return C(this,t),n(this,t,arguments)}return i(t,e),x(t,[{key:"excuteAction",value:(r=v(h().m(function e(t,n){var i,r,o=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(!n||!n.onClick||"function"!=typeof n.onClick){e.n=2;break}return e.n=1,n.onClick(t,n,this.aiChat.context,this.aiChat.params);case 1:i=e.v,e.n=5;break;case 2:if(!(r=this.aiChat.opts.extendToolbarClick)){e.n=4;break}return e.n=3,r(t,n,this.aiChat.context,this.aiChat.params,{});case 3:i=e.v,e.n=5;break;case 4:console.error(Uc.t.value("extensionToolbarClick"));case 5:i&&i.data&&i.data.length>0&&i.data.forEach(function(e){var t={id:e.id,type:e.type,data:e.data||{},metadata:e.metadata||{}};n.id&&Object.assign(t.metadata,{actionId:n.id}),o.aiChat.addMaterial(t)});case 6:return e.a(2)}},e,this)})),function(e,t){return r.apply(this,arguments)})}]);var r}(Aw),Iw=function(e){function t(){return C(this,t),n(this,t,arguments)}return i(t,e),x(t,[{key:"excuteAction",value:(r=v(h().m(function e(t,n){var i,r,o,a,s,c,l,u,d,f,p,m,g,y,k=this;return h().w(function(e){for(;;)switch(e.n){case 0:i=this.aiChat.opts.uploader,r=i.folder,o=i.accept,a=i.maxSize,s=i.multiple,c=i.onError,l=i.onSelect,u=i.onUpload,d=i.onSuccess,f=i.onDownLoad,p=i.getDownLoadUrl,m=i.onProgress,g=i.globalDownloadPrifix,y={folder:r,globalDownloadPrifix:g,multiple:s||!0,accept:o||"*/*",maxSize:a||5242880,onSelect:function(e){null==l||l(e),e.length>0&&e.forEach(function(e){var t=k.buildMaterialObject(r,e);Object.assign(t.metadata,{state:"uploading"}),k.aiChat.addMaterial(t)})},onUpload:function(){var e=v(h().m(function e(t,n){return h().w(function(e){for(;;)if(0===e.n)return e.a(2,u(t,n,{context:k.aiChat.context,params:k.aiChat.params}))},e)}));return function(t,n){return e.apply(this,arguments)}}(),onDownLoad:f,getDownLoadUrl:p,onSuccess:function(e,t){var n={id:e.id,type:"ossfile",data:{id:e.id,name:e.name,folder:r},metadata:{ext:e.ext,fileext:e.fileext,fileid:e.fileid,filename:e.filename,size:e.size,filesize:e.filesize,state:"successed",folder:r}};k.aiChat.replaceMaterial(t.name,n),null==d||d(e,t)},onError:function(e,t){var n=k.buildMaterialObject(r,t);Object.assign(n.metadata,{state:"failed"}),k.aiChat.replaceMaterial(t.name,n),null==c||c(e,t)},onProgress:function(e,t){null==m||m(e,t)}},new wa(y).openFilePicker();case 1:return e.a(2)}},e,this)})),function(e,t){return r.apply(this,arguments)})},{key:"buildMaterialObject",value:function(e,t){return{id:t.name,type:"ossfile",data:{name:t.name,id:t.name,folder:e},metadata:{size:t.size,type:t.type,lastModified:t.lastModified,folder:e}}}}]);var r}(Aw),Lw=function(){return x(function e(){C(this,e)},null,[{key:"getMaterialHelper",value:function(e,t){return"ossfile"===e?new Iw(t):new Dw(t)}}])}(),Rw=function(){return x(function e(){C(this,e),T(this,"mode","DEFAULT"),T(this,"backupChatOptions",void 0),T(this,"resourceOptions",void 0),T(this,"aiTopic",void 0),T(this,"aiTopicMap",new Map),this.aiTopic=new Ew(this)},[{key:"aiChat",get:function(){var e,t=this.aiTopicMap.get("".concat(null===(e=this.aiTopic.activedTopic.value)||void 0===e?void 0:e.id));if(!t&&this.backupChatOptions&&this.backupChatOptions.topicOptions&&this.backupChatOptions.topicOptions.ingnoreAsyncTopic){var n=this.aiTopicMap.entries().next().value;t=n?n[1]:void 0}return t}},{key:"getAiChatControllerByTopicId",value:function(e){return this.aiTopicMap.get("".concat(e))}},{key:"initIndexDB",value:(t=v(h().m(function e(){return h().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ka.checkTableExists(Sw.DATA_BASE_NAME,Sw.DATA_TABLE_NAME);case 1:if(e.v){e.n=2;break}return e.n=2,ka.createTable(Sw.DATA_BASE_NAME,Sw.DATA_TABLE_NAME,Sw.DATA_TABLE_KEY_NAME,!1);case 2:return e.a(2)}},e)})),function(){return t.apply(this,arguments)})},{key:"create",value:(e=v(h().m(function e(t){var n,i,r,o,a,s,c,l,u;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.aiTopic.injectBasicResources((null===(n=t.containerOptions)||void 0===n?void 0:n.compWrapperId)||"DEFAULT",(null===(i=t.topicOptions)||void 0===i?void 0:i.workMode)||"DEFAULT",null===(r=t.topicOptions)||void 0===r?void 0:r.scopeList),t.chatOptions.language&&Uc.setLanguage(t.chatOptions.language),t.chatOptions.locale&&Uc.setLocale(t.chatOptions.locale),this.resourceOptions=t.resourceOptions,"LOCAL"!==((null===(o=t.resourceOptions)||void 0===o?void 0:o.resourceMode)||"LOCAL")){e.n=1;break}return e.n=1,this.initIndexDB();case 1:if(this.backupChatOptions=t,c=t.chatOptions,this.setupContainer(t,c),c.aiAgentlist||!c.fetchAgentList){e.n=3;break}return e.n=2,c.fetchAgentList({agentid:c.activeAIAgentID});case 2:c.aiAgentlist=e.v;case 3:if(c.aiknowledgeBasesList||!c.fetchKnowledgeBaseList||!c.enableKnowledgeBaseSelect){e.n=5;break}return e.n=4,c.fetchKnowledgeBaseList();case 4:c.aiknowledgeBasesList=e.v,e.n=6;break;case 5:c.aiknowledgeBasesList=[];case 6:if(t.chatOptions.isSimple||!t.mode||"TOPIC"!==t.mode){e.n=11;break}return this.aiTopic.injectResourceOptions(t.resourceOptions),l=t.topicOptions,Object.assign(l,{aiChat:{caption:c.caption,context:c.context,params:c.params,appDataEntityId:c.appDataEntityId,sessionid:c.sessionid,contentToolbarItems:c.contentToolbarItems,footerToolbarItems:c.footerToolbarItems,questionToolbarItems:c.questionToolbarItems,otherToolbarItems:c.otherToolbarItems,appendCurData:c.appendCurData,appendCurContent:c.appendCurContent,enableAIAgentChange:c.enableAIAgentChange,activeAIAgentID:c.activeAIAgentID,selectAIKnowledgeBaseId:c.selectAIKnowledgeBaseId,srfMode:c.srfMode,srfScope:c.srfScope,appendCurResource:c.appendCurResource}}),e.n=7,this.aiTopic.fetchHistory(l);case 7:if(l.ingnoreAsyncTopic){e.n=9;break}return this.syncHistoryOptions(l,c,t.resourceOptions),e.n=8,this.aiTopic.asyncTopic(l);case 8:e.n=10;break;case 9:this.aiTopic.setActivedTopic(void 0);case 10:e.n=12;break;case 11:this.aiTopic.setActivedTopic(void 0);case 12:return Object.assign(c,{topicId:null===(a=l)||void 0===a?void 0:a.id,topic:l,aiTopic:this.aiTopic}),u=new Ow(c,this.resourceOptions,t.topicOptions),this.aiTopicMap.set("".concat(null===(s=l)||void 0===s?void 0:s.id),u),t.mode&&"TOPIC"===t.mode&&this.aiTopic.isTempChat.value?this.aiTopic.enterTempChat():this.renderChatContent(t,c,u),e.a(2,u)}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"syncHistoryOptions",value:function(e,t,n){if(e.disableStorage){var i=fa("TEMP");return t.sessionid=i,e.aiChat.sessionid=i,e.caption=Uc.t.value("temporarySession"),void(e.sourceCaption=Uc.t.value("temporarySession"))}var r=this.aiTopic.getCurrentTopicByID(e.id);if(r&&(e.sequence=r.sequence,e.isTop=r.isTop,e.scope=r.scope,e.groupid=r.groupid),!t.activeAIAgentID)if(r&&r.aiChat&&r.aiChat.activeAIAgentID)t.activeAIAgentID=r.aiChat.activeAIAgentID,e.aiChat.activeAIAgentID=r.aiChat.activeAIAgentID;else if(t.aiAgentlist&&t.aiAgentlist.length>0&&!t.activeAIAgentID){var o=t.aiAgentlist.find(function(e){return 1===e.default});o?(t.activeAIAgentID=o.id,e.aiChat.activeAIAgentID=o.id):(t.activeAIAgentID=t.aiAgentlist[0].id,e.aiChat.activeAIAgentID=t.aiAgentlist[0].id)}t.selectAIKnowledgeBaseId||r&&r.aiChat&&r.aiChat.selectAIKnowledgeBaseId&&(t.selectAIKnowledgeBaseId=r.aiChat.selectAIKnowledgeBaseId,e.aiChat.selectAIKnowledgeBaseId=r.aiChat.selectAIKnowledgeBaseId),r&&r.aiChat&&r.aiChat.sessionid&&(t.sessionid=r.aiChat.sessionid,e.aiChat.sessionid=r.aiChat.sessionid);var a=n.resourceMode;"LOCAL"===a?"default"!==e.captionMode?(e.sourceCaption=Uc.t.value("newConversation"),r&&r.caption?e.caption=r.caption:e.caption=Uc.t.value("newConversation")):e.sourceCaption=e.caption:"REMOTE"===a&&(e.sourceCaption=e.caption,r&&r.caption&&(e.caption=r.caption)),r&&(e.captionComputed=!!r.captionComputed),"REMOTE"===a&&r&&r.realid&&(e.realid=r.realid)}},{key:"switchAiChatController",value:function(e){var t,n,i,r=d({},this.backupChatOptions.chatOptions);e.aiChat&&Object.assign(r,{caption:e.aiChat.caption,context:e.aiChat.context,params:e.aiChat.params,sessionid:e.aiChat.sessionid,contentToolbarItems:e.aiChat.contentToolbarItems,footerToolbarItems:e.aiChat.footerToolbarItems,questionToolbarItems:e.aiChat.questionToolbarItems,otherToolbarItems:e.aiChat.otherToolbarItems,appendCurData:e.aiChat.appendCurData,appendCurContent:void 0,activeAIAgentID:e.aiChat.activeAIAgentID,enableAIAgentChange:e.aiChat.enableAIAgentChange,selectAIKnowledgeBaseId:e.aiChat.selectAIKnowledgeBaseId,srfMode:e.aiChat.srfMode,srfScope:null!==(t=e.scope)&&void 0!==t?t:e.aiChat.srfScope,appendCurResource:e.aiChat.appendCurResource,appDataEntityId:e.aiChat.appDataEntityId,topicId:e.id,topic:e,aiTopic:this.aiTopic,extendToolbarClick:this.backupChatOptions.chatOptions.extendToolbarClick,recommendPrompt:this.backupChatOptions.chatOptions.recommendPrompt,chatDigest:this.backupChatOptions.chatOptions.chatDigest,openLinkView:this.backupChatOptions.chatOptions.openLinkView});this.aiTopicMap.has("".concat(e.id))?(n=this.aiTopicMap.get("".concat(e.id))).updateAIChat(r):(n=new Ow(r,this.resourceOptions,null===(i=this.backupChatOptions)||void 0===i?void 0:i.topicOptions),this.aiTopicMap.set("".concat(e.id),n));this.renderSwitchedContent(r,n)}},{key:"close",value:function(){this.aiTopicMap.forEach(function(e){e.destroyed()})}},{key:"onDeactivated",value:function(){var e;null===(e=this.aiChat)||void 0===e||e.evt.emit("onDeactivated")}},{key:"onActivated",value:function(){var e;null===(e=this.aiChat)||void 0===e||e.evt.emit("onActivated")}}]);var e,t}(),zw=function(t){function r(){var e;C(this,r);for(var t=arguments.length,i=new Array(t),o=0;o<t;o++)i[o]=arguments[o];return T(e=n(this,r,[].concat(i)),"container",void 0),T(e,"minimize",void 0),e}return i(r,t),x(r,[{key:"create",value:(o=v(h().m(function t(n){var i,o,a,s;return h().w(function(t){for(;;)if(0===t.n)return o=(null===(i=n.containerOptions)||void 0===i?void 0:i.minimizeOptions)||{},a=o.enable,s=o.openMode,this.minimize=a&&("minimize"===s||"autoexpand"===s),t.a(2,e(r,"create",this,3)([n]))},t,this)})),function(e){return o.apply(this,arguments)})},{key:"setupContainer",value:function(e,t){var n,i,r,o=this;this.close(),this.container=document.createElement("div"),this.container.classList.add("ibiz-ai-chat"),document.body.appendChild(this.container),Zo(Eo(sb,{mode:e.mode?e.mode:"DEFAULT",containerOptions:e.containerOptions,caption:t.caption,autoClose:null===(n=e.containerOptions)||void 0===n?void 0:n.autoClose,compWrapperId:(null===(i=e.containerOptions)||void 0===i?void 0:i.compWrapperId)||"DEFAULT",hideTopicSidebar:(null===(r=e.topicOptions)||void 0===r?void 0:r.hideTopicSidebar)||!1,close:function(){o.close(),t&&t.closed&&t.closed(t.context,t.params,[])},fullscreen:function(e){t&&t.fullscreen&&t.fullscreen(e,t.context,t.params)},minimize:function(e){o.minimize=e,t&&t.minimize&&t.minimize(e,t.context,t.params)},isLoading:!0}),this.container)}},{key:"renderChatContent",value:function(e,t,n){var i,r,o,a,s=this;Zo(Eo(sb,{aiChat:n,aiTopic:this.aiTopic,mode:e.mode?e.mode:"DEFAULT",containerOptions:e.containerOptions,caption:t.caption,enableBackFill:null===(i=e.containerOptions)||void 0===i?void 0:i.enableBackFill,compWrapperId:(null===(r=e.containerOptions)||void 0===r?void 0:r.compWrapperId)||"DEFAULT",contentToolbarItems:t.contentToolbarItems,footerToolbarItems:t.footerToolbarItems,questionToolbarItems:t.questionToolbarItems,autoClose:null===(o=e.containerOptions)||void 0===o?void 0:o.autoClose,hideTopicSidebar:(null===(a=e.topicOptions)||void 0===a?void 0:a.hideTopicSidebar)||!1,close:function(){s.close(),t.closed&&t.closed(t.context,t.params,n.getAllMessages())},fullscreen:function(e){t.fullscreen&&t.fullscreen(e,t.context,t.params)},minimize:function(e){s.minimize=e,t.minimize&&t.minimize(e,t.context,t.params)},isLoading:!1}),this.container)}},{key:"renderSwitchedContent",value:function(e,t){var n,i,r,o,a,s,c=this;this.container&&Zo(Eo(sb,{aiChat:t,aiTopic:this.aiTopic,mode:null!==(n=this.backupChatOptions)&&void 0!==n&&n.mode?this.backupChatOptions.mode:"DEFAULT",containerOptions:null===(i=this.backupChatOptions)||void 0===i?void 0:i.containerOptions,caption:e.caption,enableBackFill:null===(r=this.backupChatOptions)||void 0===r||null===(r=r.containerOptions)||void 0===r?void 0:r.enableBackFill,compWrapperId:(null===(o=this.backupChatOptions)||void 0===o||null===(o=o.containerOptions)||void 0===o?void 0:o.compWrapperId)||"DEFAULT",contentToolbarItems:e.contentToolbarItems,footerToolbarItems:e.footerToolbarItems,questionToolbarItems:e.questionToolbarItems,autoClose:null===(a=this.backupChatOptions)||void 0===a||null===(a=a.containerOptions)||void 0===a?void 0:a.autoClose,hideTopicSidebar:(null===(s=this.backupChatOptions)||void 0===s||null===(s=s.topicOptions)||void 0===s?void 0:s.hideTopicSidebar)||!1,close:function(){c.close(),e.closed&&e.closed(e.context,e.params,t.getAllMessages())},fullscreen:function(t){e.fullscreen&&e.fullscreen(t,e.context,e.params)},minimize:function(t){c.minimize=t,e.minimize&&e.minimize(t,e.context,e.params)},isLoading:!1}),this.container)}},{key:"hidden",value:function(){this.container&&(this.container.style.display="none")}},{key:"show",value:function(){this.container&&(this.container.style.display="flex")}},{key:"close",value:function(){e(r,"close",this,3)([]),this.container&&(Zo(null,this.container),this.container.remove(),this.container=void 0)}},{key:"onMinimizeChange",value:function(e){var t;null===(t=this.aiChat)||void 0===t||t.evt.emit("onMinimizeChange",e)}}]);var o}(Rw),Pw=(t("chat",new zw),function(t){function r(){var e;C(this,r);for(var t=arguments.length,i=new Array(t),o=0;o<t;o++)i[o]=arguments[o];return T(e=n(this,r,[].concat(i)),"container",void 0),e}return i(r,t),x(r,[{key:"create",value:(o=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:if(this.container=null===(i=n.containerOptions)||void 0===i?void 0:i.container,this.container){t.n=1;break}throw new Error("container is required");case 1:return n.chatOptions.isSimple&&(n.chatOptions.autoQuestion=!1),t.a(2,e(r,"create",this,3)([n]))}},t,this)})),function(e){return o.apply(this,arguments)})},{key:"setupContainer",value:function(e,t){var n,i,r;if(e.chatOptions.isSimple)return Zo(Eo(fb,{isLoading:!0}),this.container);Zo(Eo(lb,{mode:e.mode?e.mode:"DEFAULT",caption:t.caption,extension:e.extensionOptions,enableBackFill:null===(n=e.containerOptions)||void 0===n?void 0:n.enableBackFill,compWrapperId:(null===(i=e.containerOptions)||void 0===i?void 0:i.compWrapperId)||"DEFAULT",hideTopicSidebar:(null===(r=e.topicOptions)||void 0===r?void 0:r.hideTopicSidebar)||!1,isLoading:!0}),this.container)}},{key:"renderChatContent",value:function(e,t,n){var i,r,o;if(e.chatOptions.isSimple)return Zo(Eo(fb,{aiChat:n,isLoading:!1,questionToolbarItems:t.questionToolbarItems}),this.container);Zo(Eo(lb,{aiChat:n,aiTopic:this.aiTopic,mode:e.mode?e.mode:"DEFAULT",caption:t.caption,extension:e.extensionOptions,enableBackFill:null===(i=e.containerOptions)||void 0===i?void 0:i.enableBackFill,compWrapperId:(null===(r=e.containerOptions)||void 0===r?void 0:r.compWrapperId)||"DEFAULT",contentToolbarItems:t.contentToolbarItems,footerToolbarItems:t.footerToolbarItems,questionToolbarItems:t.questionToolbarItems,hideTopicSidebar:(null===(o=e.topicOptions)||void 0===o?void 0:o.hideTopicSidebar)||!1,isLoading:!1}),this.container)}},{key:"renderSwitchedContent",value:function(e,t){var n,i,r,o;this.container&&Zo(Eo(lb,{aiChat:t,aiTopic:this.aiTopic,mode:null!==(n=this.backupChatOptions)&&void 0!==n&&n.mode?this.backupChatOptions.mode:"DEFAULT",caption:e.caption,enableBackFill:null===(i=this.backupChatOptions)||void 0===i||null===(i=i.containerOptions)||void 0===i?void 0:i.enableBackFill,compWrapperId:(null===(r=this.backupChatOptions)||void 0===r||null===(r=r.containerOptions)||void 0===r?void 0:r.compWrapperId)||"DEFAULT",contentToolbarItems:e.contentToolbarItems,footerToolbarItems:e.footerToolbarItems,questionToolbarItems:e.questionToolbarItems,hideTopicSidebar:(null===(o=this.backupChatOptions)||void 0===o||null===(o=o.topicOptions)||void 0===o?void 0:o.hideTopicSidebar)||!1,extension:e.extensionOptions,isLoading:!1}),this.container)}},{key:"close",value:function(){e(r,"close",this,3)([]),this.container&&Zo(null,this.container)}}]);var o}(Rw));var Bw=new ra("chat-input-material"),Fw=function(e){var t=e.controller.materials;return na("div",{className:Bw.b(),children:t.value.map(function(t){return na(iu,{material:t,disabled:!1,controller:e.controller},t.id)})})},Hw=new ra("chat-agent-setting"),jw=function(e){var t=e.controller,n=[{label:Uc.t.value("disabled"),value:0},{label:Uc.t.value("enable"),value:1},{label:Uc.t.value("automatic"),value:2}],i=[{label:Uc.t.value("chunkRerank"),value:"chunkrerank"},{label:Uc.t.value("chunkPageIndex"),value:"chunkpageindex"},{label:Uc.t.value("maxChunks"),value:"maxchunks"},{label:Uc.t.value("chunkThreshold"),value:"chunkthreshold"}],r=Ds({chunkrerank:!1,maxchunks:!1,chunkthreshold:!1,chunkpageindex:!1});$a(function(){var e=t.reCallConfig.value;r.value={chunkrerank:2!==e.chunkrerank,maxchunks:void 0!==e.maxchunks,chunkthreshold:void 0!==e.chunkthreshold,chunkpageindex:void 0!==e.chunkpageindex}},[t.activeAIAgentID]);var o=qa(null),a=qa(null),s=g(Wa(!1),2),c=s[0],l=s[1];$a(function(){var e=function(e){var t,n;e.target&&null!==(t=a.current)&&void 0!==t&&t.contains(e.target)||(null!==(n=o.current)&&void 0!==n&&n.contains(e.target)?l(function(e){return!e}):l(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var u=function(e,n){t.setAIAgentConfig(T({},e,n))},h=function(e){switch(e){case"chunkrerank":return na(ol,{popperStyle:{width:"100%",bottom:"inherit",top:"calc(100% + 4px)"},options:n,className:Hw.e("select"),value:t.reCallConfig.value[e],onChange:function(t){return u(e,t)}});case"chunkpageindex":return na(Kl,{showText:!0,className:Hw.e("switch"),value:t.reCallConfig.value[e],onChange:function(t){return u(e,t)}});case"maxchunks":return na(Ul,{min:0,max:20,step:1,showText:!0,onChange:function(t){return u(e,t)},value:t.reCallConfig.value[e]});case"chunkthreshold":return na(Ul,{min:0,max:1,step:.01,showText:!0,onChange:function(t){return u(e,t)},value:t.reCallConfig.value[e]})}},f=function(e){return na("li",{className:"".concat(Hw.em("dropdown","item")),children:[na("div",{className:Hw.em("dropdown","label"),children:[na("div",{className:Hw.em("dropdown","label-left"),children:e.label}),na("div",{className:Hw.em("dropdown","label-right"),onClick:function(){return t=e.value,n=!r.value[t],r.value=d(d({},r.value),{},T({},t,n)),void(n?["maxchunks","chunkthreshold"].includes(t)&&u(t,0):u(t,"chunkrerank"===t?2:void 0));var t,n},children:r.value[e.value]?Uc.t.value("customize"):Uc.t.value("default")})]}),r.value[e.value]?na("div",{className:Hw.em("dropdown","config"),children:h(e.value)}):void 0]})};return na("div",{className:"".concat(Hw.b()," ").concat(e.className?e.className:""),children:[na("div",{className:Hw.e("button"),ref:o,children:na("span",{title:Uc.t.value("recallSettings"),className:"".concat(Hw.em("button","icon")," ").concat(Hw.em("button","prefix")),children:na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",children:[na("path",{d:"M512 721.67619c-117.028571 0-209.67619-92.647619-209.67619-209.67619s92.647619-209.67619 209.67619-209.67619 209.67619 92.647619 209.67619 209.67619-92.647619 209.67619-209.67619 209.67619z m0-321.828571c-63.390476 0-112.152381 48.761905-112.152381 112.152381 0 63.390476 48.761905 112.152381 112.152381 112.152381s112.152381-48.761905 112.152381-112.152381c0-63.390476-48.761905-112.152381-112.152381-112.152381z"}),na("path",{d:"M604.647619 1009.371429l-14.628571-48.761905c-9.752381-34.133333-43.885714-58.514286-78.019048-58.514286s-68.266667 24.380952-78.019048 58.514286l-14.628571 48.761905-48.761905-14.628572C292.571429 975.238095 219.428571 931.352381 160.914286 877.714286l-34.133334-34.133334 34.133334-34.133333c24.380952-29.257143 29.257143-68.266667 9.752381-97.523809-19.504762-34.133333-53.638095-48.761905-92.647619-39.009524l-48.761905 9.752381-9.752381-48.761905c-9.752381-39.009524-14.628571-82.895238-14.628572-121.904762S9.752381 429.104762 19.504762 390.095238l9.752381-48.761905 48.761905 9.752381c34.133333 9.752381 73.142857-4.87619 92.647619-39.009524 19.504762-34.133333 14.628571-73.142857-9.752381-97.523809l-34.133334-34.133333 34.133334-34.133334C219.428571 92.647619 292.571429 48.761905 370.590476 24.380952l48.761905-14.628571 14.628571 43.885714c9.752381 34.133333 43.885714 58.514286 78.019048 58.514286s68.266667-24.380952 78.019048-58.514286l14.628571-43.885714 48.761905 14.628571C731.428571 48.761905 804.571429 92.647619 863.085714 146.285714l34.133334 34.133334-34.133334 34.133333c-24.380952 29.257143-29.257143 68.266667-9.752381 97.523809 19.504762 34.133333 53.638095 48.761905 92.647619 39.009524l48.761905-9.752381 9.752381 48.761905c9.752381 39.009524 14.628571 82.895238 14.628572 121.904762s-4.87619 82.895238-14.628572 121.904762l-9.752381 48.761905-48.761905-9.752381c-34.133333-9.752381-73.142857 4.87619-92.647619 39.009524-19.504762 34.133333-14.628571 73.142857 9.752381 97.523809l34.133334 34.133333-34.133334 34.133334c-58.514286 58.514286-131.657143 97.52381-209.67619 121.904762l-48.761905 9.752381z m-346.209524-175.542858c34.133333 24.380952 68.266667 43.885714 102.4 58.514286 34.133333-48.761905 87.771429-82.895238 151.161905-82.895238s117.028571 34.133333 151.161905 82.895238c34.133333-14.628571 68.266667-34.133333 102.4-58.514286-29.257143-53.638095-29.257143-117.028571 4.87619-170.666666 29.257143-53.638095 87.771429-87.771429 146.285715-87.771429 4.87619-19.504762 4.87619-39.009524 4.87619-58.514286s0-39.009524-4.87619-58.514285c-58.514286-4.87619-117.028571-34.133333-146.285715-87.771429-29.257143-53.638095-34.133333-117.028571-4.87619-170.666666-34.133333-34.133333-68.266667-53.638095-102.4-68.266667-34.133333 48.761905-87.771429 82.895238-151.161905 82.895238s-117.028571-29.257143-151.161905-82.895238c-34.133333 14.628571-68.266667 34.133333-102.4 58.514286 29.257143 53.638095 29.257143 117.028571-4.87619 175.542857-29.257143 53.638095-87.771429 87.771429-146.285715 87.771428-4.87619 19.504762-4.87619 39.009524-4.87619 58.514286s0 39.009524 4.87619 58.514286c58.514286 4.87619 117.028571 34.133333 146.285715 87.771428s34.133333 121.904762 4.87619 175.542857z"})]})})}),c?na("div",{className:Hw.e("dropdown"),ref:a,children:na("ul",{className:Hw.em("dropdown","list"),children:i.map(function(e){return f(e)})})}):null]})},Vw=function(){return na("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"icon-2xs text-text-tertiary/70",children:na("path",{d:"M2.66797 11V3.33301C2.66797 2.96574 2.96574 2.66797 3.33301 2.66797C3.70028 2.66797 3.99805 2.96574 3.99805 3.33301V11C3.99805 11.7109 3.99894 12.2044 4.03027 12.5879C4.06098 12.9634 4.11776 13.175 4.19824 13.333L4.26856 13.459C4.44487 13.7465 4.69781 13.9808 5 14.1348L5.12988 14.1904C5.27366 14.2419 5.46311 14.2797 5.74512 14.3027C6.12864 14.3341 6.62197 14.335 7.33301 14.335H15L15.0674 14.3418L14.1123 13.3867L14.0273 13.2822C13.8571 13.0242 13.8854 12.6735 14.1123 12.4463C14.3397 12.2189 14.6911 12.1906 14.9492 12.3613L15.0537 12.4463L17.1367 14.5293C17.3964 14.7889 17.3963 15.21 17.1367 15.4697L15.0537 17.5537C14.794 17.8134 14.372 17.8134 14.1123 17.5537C13.8526 17.294 13.8526 16.872 14.1123 16.6123L15.0664 15.6582L15 15.665H7.33301C6.64392 15.665 6.08696 15.6647 5.63672 15.6279C5.23614 15.5952 4.87531 15.5309 4.53906 15.3867L4.39649 15.3193C3.87528 15.0538 3.43887 14.6502 3.13477 14.1543L3.0127 13.9365C2.82084 13.5599 2.74153 13.1541 2.7041 12.6963C2.66732 12.2461 2.66797 11.6889 2.66797 11ZM15.665 15C15.665 15.0226 15.6594 15.0444 15.6572 15.0664L15.7256 14.999L15.6572 14.9316C15.6595 14.9541 15.665 14.9769 15.665 15ZM11.666 8.91797L11.8008 8.93164C12.1036 8.99381 12.3311 9.2618 12.3311 9.58301C12.3311 9.90422 12.1036 10.1722 11.8008 10.2344L11.666 10.248H7.5C7.13273 10.248 6.83496 9.95028 6.83496 9.58301C6.83496 9.21574 7.13273 8.91797 7.5 8.91797H11.666ZM14.166 4.33496L14.3008 4.34863C14.6036 4.41083 14.8311 4.67881 14.8311 5C14.8309 5.32109 14.6035 5.58924 14.3008 5.65137L14.166 5.66504H7.5C7.13284 5.66504 6.83514 5.36712 6.83496 5C6.83496 4.63273 7.13273 4.33496 7.5 4.33496H14.166Z",fill:"currentColor"})})},Ww=function(){return na("svg",{width:"21",height:"21",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"icon-2xs shrink-0",children:na("path",{d:"M13.1293 7.34753C13.3565 7.12027 13.7081 7.09207 13.9662 7.26257L14.0707 7.34753L18.0707 11.3475C18.3304 11.6072 18.3304 12.0292 18.0707 12.2889L14.0707 16.2889C13.811 16.5486 13.389 16.5486 13.1293 16.2889C12.8696 16.0292 12.8696 15.6072 13.1293 15.3475L15.9935 12.4833H6.59998C4.57585 12.4833 2.93494 10.8424 2.93494 8.81824V5.31824C2.93494 4.95097 3.23271 4.6532 3.59998 4.6532C3.96724 4.6532 4.26501 4.95097 4.26501 5.31824V8.81824C4.26501 10.1078 5.31039 11.1532 6.59998 11.1532H15.9935L13.1293 8.28894L13.0443 8.18445C12.8738 7.92632 12.902 7.5748 13.1293 7.34753Z",fill:"currentColor"})})},$w=new ra("lazy-tree"),Uw=function(e){var t=e.nodes,n=e.lazyLoad,i=e.onNodeClick,r=e.onNodeExpand,o=e.onNodeCheck,a=e.separator,s=void 0===a?"/":a,l=e.defaultCheckedKeys,u=e.showSearch,f=void 0!==u&&u,p=e.highlight,g=void 0===p||p,y=e.expandOnClickNode,k=void 0===y||y,w=Ds(c(t)),b=Ds(),C=Ds(l||[]),S=Cs(function(){var e,t=new Set,n=m(C.value);try{for(n.s();!(e=n.n()).done;)for(var i=e.value.split(s),r=1;r<i.length;r++)t.add(i.slice(0,r).join("\0"))}catch(o){n.e(o)}finally{n.f()}return t}),x=function(e){return S.value.has(e.id.split(s).join("\0"))};$a(function(){w.value=c(t)},[t]);var T,M,_=function(e,t){if(!t)return e;var n,i=t.toLowerCase().trim(),r=[],o=m(e);try{for(o.s();!(n=o.n()).done;){var a=n.value,s=a.label.toLowerCase().includes(i),c=[];if(a.children&&a.children.length>0&&(c=_(a.children,t)),s||c.length>0){var l=d(d({},a),{},{expanded:c.length>0&&!a.isLeaf||a.expanded,children:c});r.push(l)}}}catch(u){o.e(u)}finally{o.f()}return r},N=function(){var e=v(h().m(function e(t){var i,o;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!t.loading){e.n=1;break}return e.a(2);case 1:if(!t.expanded){e.n=2;break}return t.expanded=!1,w.value=c(w.value),null==r||r(t,!1),e.a(2);case 2:if(t.expanded=!0,t.loaded||t.isLeaf||!n){e.n=8;break}return t.loading=!0,w.value=c(w.value),e.p=3,e.n=4,n(t);case 4:i=e.v,t.children=i,t.loaded=!0,t.children.forEach(function(e){var n,i="".concat(t.id).concat(s);(s&&!e.id.startsWith(i)&&(e.id="".concat(i).concat(e.id)),e.parentId||(e.parentId=t.id),void 0===e.depth)&&(e.depth=(null!==(n=t.depth)&&void 0!==n?n:0)+1)}),e.n=6;break;case 5:e.p=5,o=e.v,console.error("加载子节点失败",o);case 6:return e.p=6,t.loading=!1,w.value=c(w.value),null==r||r(t,!0),e.f(6);case 7:e.n=9;break;case 8:w.value=c(w.value),null==r||r(t,!0);case 9:return e.a(2)}},e,null,[[3,5,6,7]])}));return function(t){return e.apply(this,arguments)}}(),O=function(e){e.isLeaf||N(e)},E=function(e,t){!function(e){var t=C.value.findIndex(function(t){return t===e.id});C.value=-1===t?[e.id]:[],null==o||o(e,-1===t)}(e),null==i||i(e,t),k&&O(e)},A=function(e){var t,n,i,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=e.id,s=null!==(t=e.expanded)&&void 0!==t&&t,c=null!==(n=e.loading)&&void 0!==n&&n,l=null!==(i=e.isLeaf)&&void 0!==i&&i;return na("div",{className:"".concat($w.e("node")," ").concat($w.is("active",g&&C.value.includes(e.id))," ").concat($w.is("check",g&&x(e))),"data-node-id":a,children:[na("div",{className:"".concat($w.e("node-content")," ").concat($w.is("expanded",s)),onClick:function(t){return E(e,t)},children:[na("span",{className:"".concat($w.e("node-toggle")," ").concat($w.is("loading",c)),onClick:function(t){k||(t.stopPropagation(),O(e))},children:l?na("span",{className:$w.e("node-toggle-placeholder")}):na("i",c?{className:"fa fa-spinner fa-pulse"}:{className:"fa fa-chevron-right ".concat(s?"rotate-90":"")})}),na("span",{className:$w.e("node-icon"),children:e.icon?na("i",{className:e.icon}):na("i",l?{className:"fa fa-file-text-o"}:{className:"fa ".concat(s?"fa-folder-open":"fa-folder")})}),na("span",{className:$w.e("node-label"),title:e.label,children:e.label})]}),s&&!l&&na("div",{className:$w.e("node-children"),children:c?na("div",{className:$w.e("node-loading"),children:[na("i",{className:"fa fa-spinner fa-pulse",style:{marginRight:"6px"}}),Uc.t.value("loading")]}):e.children&&e.children.length>0?e.children.map(function(e){return A(e,o+1)}):e.loaded&&0===(null===(r=e.children)||void 0===r?void 0:r.length)?na("div",{className:$w.e("node-empty"),children:Uc.t.value("noData")}):null})]},a)};return na("div",{className:$w.b(),children:[f&&na("div",{className:$w.e("search"),children:na(tl,{autoFocus:!0,value:b.value,onChange:function(e){b.value=e},placeholder:Uc.t.value("search")})}),na("div",{className:$w.e("main"),children:(M=(T=b.value)?_(w.value,T):w.value,M&&0!==M.length?M.map(function(e){return A(e,0)}):na("div",{className:$w.e("empty"),children:[na("i",{className:"fa fa-folder-open",style:{marginRight:"8px"}}),Uc.t.value("noData")]}))})]})},qw=new ra("chat-project"),Kw=function(e){var t=e.controller,n=qa(null),i=qa(null),r=Ds(""),o=g(Wa([]),2),a=o[0],s=o[1],c=g(Wa(!1),2),l=c[0],u=c[1],d=g(Wa(!1),2),f=d[0],p=d[1],m=Ds(Uc.t.value("projectPlaceholder")),y=function(){var e=v(h().m(function e(n){var i;return h().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.searchProject(n.id,r.value);case 1:return i=e.v,e.a(2,i)}},e)}));return function(t){return e.apply(this,arguments)}}(),k=function(){var e=v(h().m(function e(){var n;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,p(!0),e.n=1,t.searchProject("",r.value);case 1:n=e.v,s(n),e.n=3;break;case 2:e.p=2,e.v,s([]);case 3:return e.p=3,p(!1),e.f(3);case 4:return e.a(2)}},e,null,[[0,2,3,4]])}));return function(){return e.apply(this,arguments)}}();$a(function(){!1===l?(r.value="",s([])):k()},[l]),$a(function(){var e=function(e){var t,r;null!==(t=i.current)&&void 0!==t&&t.contains(e.target)||(null!==(r=n.current)&&void 0!==r&&r.contains(e.target)?u(function(e){return!e}):u(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);return na("div",{className:"".concat(qw.b()),children:[na("div",{ref:n,className:qw.e("button"),children:[na("span",{className:"".concat(qw.em("button","icon")," ").concat(qw.em("button","prefix")),children:na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M95.085714 292.571429L512 504.685714 928.914286 292.571429 512 87.771429 95.085714 292.571429z m58.514286 329.142857L65.828571 577.828571C36.571429 563.2 21.942857 541.257143 21.942857 512s14.628571-51.2 43.885714-65.828571l87.771429-43.885715-87.771429-43.885714C29.257143 343.771429 14.628571 299.885714 29.257143 263.314286c7.314286-14.628571 21.942857-29.257143 29.257143-29.257143L475.428571 29.257143c21.942857-7.314286 43.885714-7.314286 65.828572 0l416.914286 204.8c36.571429 14.628571 51.2 58.514286 29.257142 95.085714-7.314286 14.628571-21.942857 29.257143-29.257142 29.257143l-87.771429 43.885714L950.857143 438.857143c36.571429 14.628571 51.2 36.571429 51.2 73.142857 0 29.257143-14.628571 58.514286-51.2 73.142857l-80.457143 36.571429L950.857143 658.285714c36.571429 14.628571 51.2 36.571429 51.2 73.142857 0 29.257143-14.628571 58.514286-51.2 73.142858l-402.285714 197.485714c-7.314286 7.314286-21.942857 7.314286-36.571429 7.314286s-21.942857 0-36.571429-7.314286L58.514286 797.257143c-29.257143-14.628571-36.571429-36.571429-36.571429-65.828572s14.628571-51.2 43.885714-65.828571l87.771429-43.885714z m80.457143 43.885714l-138.971429 65.828571L512 943.542857l416.914286-204.8-138.971429-65.828571-241.371428 117.028571c-7.314286 7.314286-21.942857 7.314286-36.571429 7.314286s-21.942857 0-36.571429-7.314286L234.057143 665.6z m555.885714-219.428571L548.571429 563.2c-21.942857 7.314286-43.885714 7.314286-65.828572 0L234.057143 446.171429 95.085714 512 512 724.114286 928.914286 512l-138.971429-65.828571z"})})}),na("span",{title:m,className:qw.em("button","caption"),children:m}),na("span",{className:"".concat(qw.em("button","icon")," ").concat(qw.em("button","suffix")),children:l?Oc():uc()})]}),l?na("div",{className:qw.e("popup"),ref:i,children:[na("div",{className:qw.em("popup","search"),children:na(tl,{placeholder:Uc.t.value("search"),autoFocus:!0,value:r.value,onEnter:function(e){r.value=e,k()}})}),na("div",{className:qw.em("popup","tree"),children:f?na(il,{}):na(Uw,{nodes:a,lazyLoad:y,expandOnClickNode:!1,onNodeCheck:function(e,n){n?(m.value=e.label,t.selectionProject=e.id):(m.value=Uc.t.value("projectPlaceholder"),t.selectionProject=void 0)},defaultCheckedKeys:[t.selectionProject||""]})})]}):null]})},Jw=new ra("chat-input"),Gw=window.SpeechRecognition||window.webkitSpeechRecognition,Yw=function(e){var t,n=g(Wa(!1),2),i=n[0],r=n[1];Ya(ab);var o=e.controller.input,a=Ds(!1),s=qa(),c=qa(null),l=qa(null);$a(function(){var t=e.controller.opts.speechRecognition;if(!t&&Gw&&(t=new Gw),t)return t.onstart=function(){a.value=!0},t.onend=function(){a.value=!1},t.onresult=function(e){var t,n,i=null===(t=e.results)||void 0===t||null===(t=t[0])||void 0===t||null===(t=t[0])||void 0===t?void 0:t.transcript;i&&(null===(n=c.current)||void 0===n||n.commands.insertContent(i))},s.current=t,function(){try{t.stop(),t.abort()}catch(e){}t.onstart=null,t.onend=null,t.onresult=null,s.current=void 0,a.value=!1}},[]);var u=Is(function(){return va(o.value).length>0}),d=Ga(v(h().m(function t(){var n,i,r,a;return h().w(function(t){for(;;)switch(t.p=t.n){case 0:if(t.p=0,r=va(o.value)){t.n=1;break}return t.a(2);case 1:if(o.value="",null===(n=c.current)||void 0===n||n.chain().clearContent().run(),null===(i=l.current)||void 0===i||i.toggleCollapse(!1),!e.controller.isLoading.value){t.n=2;break}e.controller.setSteerQuesCfg(r),t.n=3;break;case 2:return t.n=3,e.controller.question(r);case 3:t.n=5;break;case 4:t.p=4,a=t.v,console.error(a);case 5:return t.p=5,setTimeout(function(){c.current&&!c.current.isDestroyed&&c.current.chain().focus().run()},100),t.f(5);case 6:return t.a(2)}},t,null,[[0,4,5,6]])})),[o]),f=Ga(v(h().m(function t(){return h().w(function(t){for(;;)switch(t.n){case 0:try{e.controller.abortQuestion()}catch(n){console.error(n)}case 1:return t.a(2)}},t)})),[o]),p=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return i=Lw.getMaterialHelper("ossfile",e.controller),t.n=1,i.excuteAction(n);case 1:r(!1);case 2:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),m=function(){var t=v(h().m(function t(n,i){var o;return h().w(function(t){for(;;)switch(t.n){case 0:return o=Lw.getMaterialHelper("common",e.controller),t.n=1,o.excuteAction(n,i);case 1:r(!1);case 2:return t.a(2)}},t)}));return function(e,n){return t.apply(this,arguments)}}(),y=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.controller.knowledgeRemoteSearch(n);case 1:return i=t.v,t.a(2,i)}},t)}));return function(e){return t.apply(this,arguments)}}(),k=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.controller.searchAIAgent(n);case 1:return i=t.v,t.a(2,i)}},t)}));return function(e){return t.apply(this,arguments)}}();return na("div",{className:"".concat(Jw.b("wrapper")," ").concat(Jw.is("expand",e.controller.inputExpand.value)),children:[na("div",{className:"".concat(Jw.b("steer-wrapper")," ").concat(Jw.is("enable",e.controller.steerQuesCfg.value.enable)),children:[na("div",{className:"".concat(Jw.b("left-steer-wrapper")," ").concat(Jw.b("flex-both-center")),children:[na(Vw,{}),na("div",{className:Jw.be("left-steer-wrapper","quesition"),children:e.controller.steerQuesCfg.value.message})]}),na("div",{className:"".concat(Jw.b("right-steer-wrapper")," ").concat(Jw.b("flex-both-center")),children:[na("div",{className:"".concat(Jw.be("right-steer-wrapper","steer")," ").concat(Jw.b("cursor-with-pointer")),onClick:function(){e.controller.supplementQuestion()},title:Uc.t.value("instantSteerTip"),children:[na(Ww,{}),na("span",{children:Uc.t.value("instantSteer")})]}),na("div",{className:"".concat(Jw.be("right-steer-wrapper","remove")," ").concat(Jw.b("cursor-with-pointer")),onClick:function(){e.controller.resetSteerQuesCfg()},children:na(Gs,{})})]})]}),na("div",{className:Jw.b("material-wrapper"),children:na(Fw,{controller:e.controller})}),na("div",{className:Jw.b("main-wrapper"),children:[na(ew,{ref:l,c:e.controller,value:o.value,disabled:!1,placeholder:e.controller.placeholder.value,onCreate:function(e){c.current=e},onChange:function(e){o.value=e},onKeyDown:function(t){if(!1===t.shiftKey&&"Enter"===t.code&&"Enter"===t.key)return e.controller.steerQuesCfg.value.enable?(e.controller.supplementQuestion(),!0):(d(),!0)}}),na("div",{className:Jw.b("action-wrapper"),children:[na("div",{className:Jw.b("left-action-wrapper"),children:[na(ol,{showBorder:!1,enableSearch:!0,placeholder:"Auto",className:Jw.b("agent-select"),popperStyle:{height:"220px"},value:e.controller.activeAIAgentID,options:e.controller.agentList.value,icon:function(){return na("div",{title:Uc.t.value("agent"),children:lc()})},disabled:!e.controller.enableAIAgentChange,onSearch:k,onChange:function(t){return n=t,void e.controller.setActiveAIAgentID(n);var n}}),e.controller.enableKnowledgeBaseSelect.value&&na(sl,{className:"".concat(Jw.b("setting-wrapper")," ").concat(Jw.is("disabled",!e.controller.selectionKnowledgeBases.value.length)),enableSearch:!0,popperStyle:{height:"220px"},options:e.controller.knowledgeBases.value,icon:function(){return na("div",{title:Uc.t.value("knowledge"),children:bc})},placeholder:Uc.t.value("knowledgeSearch"),value:e.controller.selectionKnowledgeBases.value,onSearch:function(e){return y(e)},onChange:function(t){e.controller.setSelectionKnowledge(t)}}),e.controller.opts.enableAIProject&&na(Kw,{controller:e.controller}),e.controller.enableRecallConfigSetting.value&&e.controller.agentList.value.length>0?na(jw,{controller:e.controller}):null]}),na("div",{className:Jw.b("right-action-wrapper"),children:[na("div",{className:"".concat(Jw.be("right-action-wrapper","action-item")," ").concat(Jw.is("disabled",e.controller.isLoading.value)),title:Uc.t.value("uploadDocument"),children:na(Fl,{triggerMode:"hover",content:na("div",{className:Jw.b("pop-actions"),children:[na("div",{className:Jw.b("pop-action-item"),onClick:function(e){p(e)},children:[na("span",{className:Jw.b("pop-action-item-icon"),children:na(Zs,{})}),na("span",{className:Jw.b("pop-action-item-title"),children:Uc.t.value("documentation")})]}),null===(t=e.questionToolbarItems)||void 0===t?void 0:t.map(function(e){var t,n,i;return na("div",{className:Jw.b("pop-action-item"),onClick:function(t){m(t,e)},children:[na("span",{className:Jw.b("pop-action-item-icon"),children:"function"==typeof e.icon?e.icon():(null===(t=e.icon)||void 0===t?void 0:t.showIcon)&&na(Do,{children:null!==(n=e.icon)&&void 0!==n&&n.cssClass?na("i",{className:e.icon.cssClass}):null!==(i=e.icon)&&void 0!==i&&i.imagePath?ha(e.icon.imagePath)?na("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):na("img",{src:e.icon.imagePath}):null})}),na("span",{className:Jw.b("pop-action-item-title"),children:e.label})]},e.id)})]}),position:"top-left",isOpen:i,onToggleOpen:r,children:na(Qs,{})})}),na("div",{title:a.value?Uc.t.value("voiceInputProgress"):Uc.t.value("voiceInput"),className:"".concat(Jw.be("right-action-wrapper","action-item")," ").concat(Jw.is("disabled",e.controller.isLoading.value)),onClick:function(){s.current&&(a.value?s.current.stop():s.current.start())},children:a.value?na(qs,{}):na(Us,{})}),u.value?na("div",{title:Uc.t.value("sendMessage"),className:"".concat(Jw.be("right-action-wrapper","action-item")," ").concat(Jw.is("send",!0)),onClick:d,children:na(zs,{className:Jw.e("send-icon")})}):e.controller.isLoading.value?na("div",{title:Uc.t.value("stopGenerating"),className:"".concat(Jw.be("right-action-wrapper","action-item")," ").concat(Jw.is("send",!0)),onClick:f,children:na(nc,{})}):na("div",{title:Uc.t.value("sendMessage"),className:"".concat(Jw.be("right-action-wrapper","action-item")," ").concat(Jw.is("disabled",!0)," ").concat(Jw.is("send",!0)),children:na(zs,{className:Jw.e("send-icon")})})]})]})]})]})},Xw=new ra("chat-topic-item"),Qw="",Zw=fl(function(e,t){var n,i=e.hasMoreThanOne,r=e.controller,o=e.topic,a=e.isSelectMode,s=e.isSelected,c=e.onClick,l=e.onAction,u=qa(null),d=qa(!1),h=Is(function(){var e;return(null===(e=r.activedTopic.value)||void 0===e?void 0:e.id)===o.id}),f=Is(function(){return!!r.activedTopic.value&&r.isTopicGenerating(o.id)}),p=Math.min(16,Math.max(6,Math.round(.35*((null===(n=o.caption)||void 0===n?void 0:n.length)||0)))),v=g(Wa(!1),2),m=v[0],y=v[1],k=Ds([]);k.value=i?[{id:"RENAME",caption:Uc.t.value("rename"),icon:na(ac,{})},{id:"PINNED",caption:o.isTop?Uc.t.value("unpin"):Uc.t.value("pinTop"),icon:o.isTop?na(pc,{}):na(fc,{})},{id:"MULTISELECT",caption:Uc.t.value("multiSelect"),icon:na(Pc,{})},{id:"DELETE",caption:Uc.t.value("delete"),icon:na(Gs,{})}]:[{id:"RENAME",caption:Uc.t.value("rename"),icon:na(ac,{})},{id:"PINNED",caption:o.isTop?Uc.t.value("unpin"):Uc.t.value("pinTop"),icon:o.isTop?na(pc,{}):na(fc,{})}];var w=Ds(!1),b=function(){w.value||(Qw=o.caption||Uc.t.value("newConversation"),d.current=!1,w.value=!0,setTimeout(function(){var e;null===(e=u.current)||void 0===e||e.focus()},100))};Ka(t,function(){return{enterEditMode:b}});return na("div",{className:"".concat(Xw.b()," ").concat(Xw.is("show-popup",m)," ").concat(Xw.is("active",h.value)," ").concat(Xw.is("edit",w.value)," ").concat(Xw.is("marquee",f.value)," ").concat(Xw.is("select-mode",a)),onClick:function(){a?r.toggleTopicSelected(o.id):c()}.bind(void 0),children:[na("input",{type:"checkbox",className:Xw.e("checkbox"),readOnly:!0,checked:!!a&&!!s}),na("div",{className:Xw.e("caption"),title:o.caption,children:w.value?na("input",{ref:u,value:o.caption,onBlur:function(e){e.stopPropagation(),w.value=!1,d.current?d.current=!1:l("RENAME",e)},onKeyDown:function(e){e.stopPropagation(),"Enter"===e.key?w.value=!1:"Escape"===e.key&&(d.current=!0,o.data.caption=Qw,w.value=!1)},onClick:function(e){return e.stopPropagation()},onChange:function(e){return(t=e).stopPropagation(),void(o.data.caption=null===(n=t.target)||void 0===n?void 0:n.value);var t,n},className:Xw.em("caption","editor")}):na("div",{className:Xw.em("caption","readonly"),children:[na("span",{className:Xw.em("caption","text"),children:f.value?na("span",{className:Xw.em("caption","marquee"),style:{animationDuration:"".concat(p,"s")},children:[na("span",{children:o.caption}),na("span",{"aria-hidden":"true",children:o.caption})]}):o.caption}),o.isTop?na("span",{className:Xw.em("caption","icon"),children:na(fc,{})}):null]})}),!w.value&&!a&&na("div",{className:Xw.e("icon"),children:[na("span",{title:Uc.t.value("jumpMainView"),className:Xw.em("icon","item"),onClick:function(e){e.stopPropagation(),l("LINK",e)}.bind(void 0),children:na(Js,{className:Xw.b("link-icon")})}),na(Fl,{triggerMode:"click",actions:k.value,position:"bottom",isOpen:m,onToggleOpen:y,onAction:function(e,t){"RENAME"===e?b():l(e,t),y(!1)}.bind(void 0),children:na("span",{className:Xw.em("icon","item"),title:Uc.t.value("more"),children:na(Ks,{className:Xw.e("more-icon")})})})]})]})}),eb=new ra("chat-topics"),tb=function(e){var t=e.controller.topics.value.filter(function(t){return e.controller.selectedTopicIds.value.has(t.id)}),n=t.length>0&&t.every(function(e){return 1===e.isTop}),i=qa(null),r=qa({}),o=Ds(void 0),a=Ds([]),s=Ds(0);$a(function(){var t=c(e.controller.topics.value).sort(function(e,t){return e.isTop!==t.isTop?t.isTop?1:-1:t.sequence-e.sequence});a.value=t.filter(function(e){var t,n;return null===(t=e.caption)||void 0===t?void 0:t.toLowerCase().includes((null===(n=o.value)||void 0===n?void 0:n.trim().toLowerCase())||"")})},[e.controller.topics.value]),$a(function(){var t=function(t){var n;if("F2"===t.key){var i=t.target;if(!(i&&("INPUT"===i.tagName||"TEXTAREA"===i.tagName||i.isContentEditable)||e.controller.topicSidebarCollapse.value||e.controller.isTempChat.value||e.controller.isSelectMode.value)){var o=e.controller.activedTopic.value;o&&(t.preventDefault(),t.stopPropagation(),null===(n=r.current[o.id])||void 0===n||n.enterEditMode())}}};return window.addEventListener("keydown",t),function(){window.removeEventListener("keydown",t)}},[]);var l=Is(function(){return a.value.length>1});$a(function(){var e=i.current;if(e){var t=function(){s.value=e.scrollTop};return e.addEventListener("scroll",t,{passive:!0}),function(){e.removeEventListener("scroll",t)}}},[]);var u=function(){var e=i.current;e&&0!==s.value&&(e.scrollTop=s.value)};$a(function(){var t=i.current;if(t){var n=setTimeout(function(){var e=t.querySelector(".ibiz-chat-topic-item.is-active");null==e||e.scrollIntoView({behavior:"smooth",block:"nearest"})},0),r=e.controller.getAiChat();return r&&r.evt.on("onActivated",u),function(){clearTimeout(n),r&&r.evt.off("onActivated",u)}}},[e.controller.activedTopic.value,a.value]);var d=function(){e.controller.switchTopicSidebarCollapse()},h=function(t){if(t)e.controller.enterTempChat();else{e.controller.exitTempChat();var n=e.controller.preActivedTopic;if(n||(n=e.controller.topics.value[0]),!n)return;e.controller.handleTopicChange(n)}};return na("div",{className:"".concat(eb.b()," ").concat(eb.is("collapsed",!0===e.controller.topicSidebarCollapse.value)),children:!0===e.controller.topicSidebarCollapse.value?na("div",{className:eb.e("collapse-container"),children:[na("div",{className:eb.e("icon-item"),title:Uc.t.value("openSidebar"),onClick:function(){return d()},children:na(Mc,{})}),!1===e.controller.isSelectMode.value&&(!1===e.controller.isTempChat.value?na("div",{className:eb.e("icon-item"),title:Uc.t.value("enterSession"),onClick:function(){return h(!0)},children:na(_c,{})}):na("div",{className:eb.e("icon-item"),title:Uc.t.value("exitSession"),onClick:function(){return h(!1)},children:na(Nc,{})}))]}):na(Do,{children:[na("div",{className:eb.e("header"),children:[na("div",{className:eb.e("icon-container"),children:[na("div",{className:eb.e("icon-item"),title:Uc.t.value("collapseSidebar"),onClick:function(){return d()},children:na(Mc,{})}),!1===e.controller.isSelectMode.value&&na(Do,{children:[na("div",{className:eb.e("icon-item"),title:Uc.t.value("newCreateConversation"),onClick:function(){e.controller.globalNewTopic()},children:na($s,{})}),!1===e.controller.isTempChat.value?na("div",{className:eb.e("icon-item"),title:Uc.t.value("enterSession"),onClick:function(){return h(!0)},children:na(_c,{})}):na("div",{className:eb.e("icon-item"),title:Uc.t.value("exitSession"),onClick:function(){return h(!1)},children:na(Nc,{})})]})]}),e.controller.isSelectMode.value?na("div",{className:eb.e("select-bar"),children:[na("span",{className:eb.e("select-info"),children:Uc.t.value("selectedCount",{count:e.controller.selectedTopicIds.value.size})}),na("div",{className:"".concat(eb.e("cancel-select")),title:Uc.t.value("cancelMultiSelect"),onClick:function(){return e.controller.exitSelectMode()},children:na(Ls,{})})]}):na(tl,{value:o.value,placeholder:Uc.t.value("searchTopics"),onChange:function(t){o.value=t,a.value=e.controller.topics.value.filter(function(e){var t,n;return null===(t=e.caption)||void 0===t?void 0:t.toLowerCase().includes((null===(n=o.value)||void 0===n?void 0:n.trim().toLowerCase())||"")})}.bind(void 0)})]}),na("div",{ref:i,className:eb.e("main"),children:a.value&&a.value.length>0?a.value.map(function(t){return!1===t.isShow?null:na(Zw,{ref:function(e){r.current[t.id]=e},hasMoreThanOne:l.value,topic:t,controller:e.controller,isSelectMode:e.controller.isSelectMode.value,isSelected:e.controller.selectedTopicIds.value.has(t.id),onClick:function(){return function(t){e.controller.isTempChat.value&&e.controller.exitTempChat(),e.controller.handleTopicChange(t)}(t)},onAction:function(n,i){return function(t,n,i){"MULTISELECT"!==t?e.controller.handleTopicAction(t,n,i):e.controller.enterSelectMode(n.id)}(n,t,i)}},t.id)}):na("div",{className:eb.e("empty"),children:Uc.t.value("noTopic")})}),e.controller.isSelectMode.value?na("div",{className:"".concat(eb.e("footer")," ").concat(eb.is("select-mode",e.controller.isSelectMode.value)),children:[na("div",{title:Uc.t.value(n?"unpin":"pinTop"),className:"".concat(eb.e("action")," ").concat(eb.is("disabled",0===e.controller.selectedTopicIds.value.size)),onClick:function(){return n?e.controller.batchUnPinTop():e.controller.batchPinTop()},children:[na(n?Bc:fc,{}),na("span",{children:Uc.t.value(n?"unpin":"pinTop")})]}),na("div",{title:Uc.t.value("delete"),className:"".concat(eb.e("action")," ").concat(eb.is("disabled",0===e.controller.selectedTopicIds.value.size)),onClick:function(t){return e.controller.batchDeleteTopics(t)},children:[na(Gs,{}),na("span",{children:Uc.t.value("delete")})]})]}):!0===l.value&&na("div",{className:eb.e("footer"),children:na("div",{title:Uc.t.value("clearSession"),className:eb.e("action"),onClick:function(){return e.controller.clearTopic()},children:[na(Gs,{}),na("span",{children:Uc.t.value("clearSession")})]})})]})})},nb=new ra("chat-group-topics"),ib=function(e){var t,n,i,r,o,a=e.controller.topics.value.filter(function(t){return e.controller.selectedTopicIds.value.has(t.id)}),s=a.length>0&&a.every(function(e){return 1===e.isTop}),c=qa(null),l=qa({}),u=Ds(void 0),d=Is(function(){return e.controller.computeGroupTree(u.value)}),f=Is(function(){return e.controller.topics.value.length>1}),p=Ds(new Set),m=qa(!1),g=qa(void 0),y=Ds(void 0),k=Ds(void 0),w=Ds(void 0),b=qa(null),C=qa(!1),S=Ds(!1),x=Ds(void 0),T=Ds(""),M=Ds(!1),_=Ds(void 0),N=qa(null),O=Ya(ab),E="number"==typeof(null==O?void 0:O.zIndex)?O.zIndex+10:999,A=function(){return e.controller.isSelectMode.value},D=function(e){var t=new Set(p.value);t.has(e)?t.delete(e):t.add(e),p.value=t};$a(function(){var t=function(t){if(t){var n=t.scope;return n&&e.controller.scopeList.some(function(e){return String(e.id)===String(n)})?"scope:".concat(String(n)):xw.NONE_SCOPE_KEY}}(e.controller.activedTopic.value);if(g.current!==t)if(g.current=t,m.current){if(t&&p.value.has(t)){var n=new Set(p.value);n.delete(t),p.value=n}}else{if(0===e.controller.topics.value.length)return;if(m.current=!0,!t)return;p.value=new Set(d.value.map(function(e){return e.key}).filter(function(e){return e!==t}))}},[e.controller.activedTopic.value,d.value]),$a(function(){var t=function(t){var n;if("F2"===t.key){var i=t.target;if(!(i&&("INPUT"===i.tagName||"TEXTAREA"===i.tagName||i.isContentEditable)||e.controller.topicSidebarCollapse.value||e.controller.isTempChat.value||e.controller.isSelectMode.value)){var r=e.controller.activedTopic.value;r&&(t.preventDefault(),t.stopPropagation(),null===(n=l.current[r.id])||void 0===n||n.enterEditMode())}}};return window.addEventListener("keydown",t),function(){window.removeEventListener("keydown",t)}},[]),$a(function(){if(w.value){C.current=!1;var e=setTimeout(function(){var e=b.current;if(e){e.focus();var t=e.value.length;e.setSelectionRange(t,t)}},0);return function(){return clearTimeout(e)}}},[w.value]);$a(function(){var e=c.current;if(e){var t=setTimeout(function(){var t=e.querySelector(".ibiz-chat-topic-item.is-active");null==t||t.scrollIntoView({behavior:"smooth",block:"nearest"})},0);return function(){return clearTimeout(t)}}},[e.controller.activedTopic.value,e.controller.topics.value]);var I=function(){e.controller.switchTopicSidebarCollapse()},L=function(t){if(t)e.controller.enterTempChat();else{e.controller.exitTempChat();var n=e.controller.preActivedTopic;if(n||(n=e.controller.topics.value[0]),!n)return;e.controller.handleTopicChange(n)}},R=function(){S.value=!1,M.value=!1,T.value=""},z=Is(function(){var t=T.value.trim().toLowerCase();return t?e.controller.scopeList.filter(function(e){var n;return String(null!==(n=e.text)&&void 0!==n?n:"").toLowerCase().includes(t)}):e.controller.scopeList}),P=Is(function(){if(x.value){var t=e.controller.scopeList.find(function(e){return String(e.id)===String(x.value)});return null==t?void 0:t.text}}),B=function(t){return!1===t.isShow?null:na("div",{draggable:!A(),onDragStart:function(){y.value=t.id},onDragEnd:function(){y.value=void 0,k.value=void 0},children:na(Zw,{ref:function(e){l.current[t.id]=e},hasMoreThanOne:f.value,topic:t,controller:e.controller,isSelectMode:e.controller.isSelectMode.value,isSelected:e.controller.selectedTopicIds.value.has(t.id),onClick:function(){return function(t){e.controller.isTempChat.value&&e.controller.exitTempChat(),e.controller.handleTopicChange(t)}(t)},onAction:function(n,i){return function(t,n,i){"MULTISELECT"!==t?e.controller.handleTopicAction(t,n,i):e.controller.enterSelectMode(n.id)}(n,t,i)}})},t.id)},F=function(e,t){t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),k.value=e},H=function(){var t=v(h().m(function t(n,i){return h().w(function(t){for(;;)switch(t.n){case 0:if(!y.value){t.n=1;break}return t.n=1,e.controller.moveTopic(y.value,n,i);case 1:y.value=void 0,k.value=void 0;case 2:return t.a(2)}},t)}));return function(e,n){return t.apply(this,arguments)}}(),j=function(t){var n,i=t.key===xw.NONE_SCOPE_KEY,r=p.value.has(t.key);return na("div",{className:nb.e("scope-node"),children:[na("div",{className:"".concat(nb.em("scope-node","header")," ").concat(nb.is("none",i)," ").concat(nb.is("dragover",k.value===t.key)),onDragOver:function(e){return F(t.key,e)},onDragLeave:function(){k.value===t.key&&(k.value=void 0)},onDrop:function(){return H(t.scopeid)},children:[na("span",{className:"".concat(nb.em("scope-node","arrow")," ").concat(nb.is("collapsed",r)),onClick:function(e){e.stopPropagation(),D(t.key)},children:na(Hc,{})}),na("span",{className:nb.em("scope-node","text"),title:t.text,children:t.text}),!A()&&na("div",{className:nb.em("scope-node","icons"),children:[na("span",{className:nb.em("scope-node","icon-item"),title:Uc.t.value("newGroup"),onClick:(n=v(h().m(function n(r){var o;return h().w(function(n){for(;;)switch(n.n){case 0:return r.stopPropagation(),p.value.has(t.key)&&D(t.key),n.n=1,e.controller.addGroup(i?void 0:t.scopeid);case 1:if(o=n.v){n.n=2;break}return n.a(2);case 2:w.value=o.id;case 3:return n.a(2)}},n)})),function(e){return n.apply(this,arguments)}),children:na(Fc,{})}),na("span",{className:"".concat(nb.em("scope-node","icon-item")," ").concat(nb.is("danger",!0)),title:Uc.t.value("deleteScope"),onClick:function(n){n.stopPropagation(),e.controller.removeScope(i?void 0:t.scopeid)},children:na(Gs,{})})]})]}),!r&&na("div",{className:nb.em("scope-node","children"),children:[t.groups.map(function(n){return function(t,n,i){var r=!0===n.collapsed,o=w.value===n.id;return na("div",{className:nb.e("group-node"),children:[na("div",{className:"".concat(nb.em("group-node","header")," ").concat(nb.is("renaming",o)," ").concat(nb.is("dragover",k.value==="".concat(i,">group:").concat(n.id))),onDragOver:function(e){return F("".concat(i,">group:").concat(n.id),e)},onDragLeave:function(){k.value==="".concat(i,">group:").concat(n.id)&&(k.value=void 0)},onDrop:function(){return H(t,n.id)},children:[!o&&na("span",{className:"".concat(nb.em("group-node","arrow")," ").concat(nb.is("collapsed",r)),onClick:function(t){t.stopPropagation(),e.controller.toggleGroupCollapse(n.id)},children:na(Hc,{})}),o?na("input",{ref:b,className:nb.em("group-node","editor"),defaultValue:n.text,onClick:function(e){return e.stopPropagation()},onKeyDown:function(t){t.stopPropagation(),"Enter"===t.key?(e.controller.renameGroup(n.id,t.target.value.trim()),w.value=void 0):"Escape"===t.key&&(C.current=!0,w.value=void 0)},onBlur:function(t){if(C.current)return C.current=!1,void(w.value=void 0);e.controller.renameGroup(n.id,t.target.value.trim()),w.value=void 0}}):na("span",{className:nb.em("group-node","text"),title:n.text,children:n.text}),!A()&&!o&&na("div",{className:nb.em("group-node","icons"),children:[na("span",{className:nb.em("group-node","icon-item"),title:Uc.t.value("newCreateConversation"),onClick:function(i){i.stopPropagation(),!0===n.collapsed&&e.controller.toggleGroupCollapse(n.id),e.controller.globalNewTopic(t,n.id)},children:na(Fc,{})}),na("span",{className:nb.em("group-node","icon-item"),title:Uc.t.value("rename"),onClick:function(e){e.stopPropagation(),w.value=n.id},children:na(ac,{})}),na("span",{className:"".concat(nb.em("group-node","icon-item")," ").concat(nb.is("danger",!0)),title:Uc.t.value("deleteGroup"),onClick:function(t){t.stopPropagation(),e.controller.removeGroup(n.id)},children:na(Gs,{})})]})]}),!r&&na("div",{className:nb.em("group-node","topics"),children:n.topics.some(function(e){return!1!==e.isShow})?n.topics.map(function(e){return B(e)}):na("div",{className:nb.em("group-node","empty"),children:Uc.t.value("noData")})})]},n.id)}(t.scopeid,n,t.key)}),t.ungroupedTopics.map(function(e){return B(e)})]})]},t.key)};return na("div",{className:"".concat(nb.b()," ").concat(nb.is("collapsed",!0===e.controller.topicSidebarCollapse.value)),children:[!0===e.controller.topicSidebarCollapse.value?na("div",{className:nb.e("collapse-container"),children:[na("div",{className:nb.e("icon-item"),title:Uc.t.value("openSidebar"),onClick:function(){return I()},children:na(Mc,{})}),!1===e.controller.isSelectMode.value&&(!1===e.controller.isTempChat.value?na("div",{className:nb.e("icon-item"),title:Uc.t.value("enterSession"),onClick:function(){return L(!0)},children:na(_c,{})}):na("div",{className:nb.e("icon-item"),title:Uc.t.value("exitSession"),onClick:function(){return L(!1)},children:na(Nc,{})}))]}):na(Do,{children:[na("div",{className:nb.e("header"),children:[na("div",{className:nb.e("icon-container"),children:[na("div",{className:nb.e("icon-item"),title:Uc.t.value("collapseSidebar"),onClick:function(){return I()},children:na(Mc,{})}),!1===e.controller.isSelectMode.value&&na(Do,{children:[na("div",{ref:N,className:nb.e("icon-item"),title:Uc.t.value("newCreateConversation"),onClick:function(){return function(){var t,n,i=null===(t=N.current)||void 0===t?void 0:t.getBoundingClientRect();if(i){var r=Math.min(i.right,window.innerWidth-400-8);_.value={left:Math.max(8,r),top:i.bottom+4}}var o=null===(n=e.controller.activedTopic.value)||void 0===n?void 0:n.scope,a=null!=o&&""!==o&&e.controller.scopeList.some(function(e){return String(e.id)===String(o)});x.value=a?o:void 0,T.value="",M.value=!1,S.value=!0}()},children:na($s,{})}),!1===e.controller.isTempChat.value?na("div",{className:nb.e("icon-item"),title:Uc.t.value("enterSession"),onClick:function(){return L(!0)},children:na(_c,{})}):na("div",{className:nb.e("icon-item"),title:Uc.t.value("exitSession"),onClick:function(){return L(!1)},children:na(Nc,{})})]})]}),e.controller.isSelectMode.value?na("div",{className:nb.e("select-bar"),children:[na("span",{className:nb.e("select-info"),children:Uc.t.value("selectedCount",{count:e.controller.selectedTopicIds.value.size})}),na("div",{className:"".concat(nb.e("cancel-select")),title:Uc.t.value("cancelMultiSelect"),onClick:function(){return e.controller.exitSelectMode()},children:na(Ls,{})})]}):na(tl,{value:u.value,placeholder:Uc.t.value("searchTopics"),onChange:function(e){u.value=e}.bind(void 0)})]}),na("div",{ref:c,className:nb.e("main"),children:e.controller.topics.value.length>0?d.value.map(function(e){return j(e)}):na("div",{className:nb.e("empty"),children:Uc.t.value("noTopic")})}),e.controller.isSelectMode.value?na("div",{className:"".concat(nb.e("footer")," ").concat(nb.is("select-mode",e.controller.isSelectMode.value)),children:[na("div",{title:Uc.t.value(s?"unpin":"pinTop"),className:"".concat(nb.e("action")," ").concat(nb.is("disabled",0===e.controller.selectedTopicIds.value.size)),onClick:function(){return s?e.controller.batchUnPinTop():e.controller.batchPinTop()},children:[na(s?Bc:fc,{}),na("span",{children:Uc.t.value(s?"unpin":"pinTop")})]}),na("div",{title:Uc.t.value("delete"),className:"".concat(nb.e("action")," ").concat(nb.is("disabled",0===e.controller.selectedTopicIds.value.size)),onClick:function(t){return e.controller.batchDeleteTopics(t)},children:[na(Gs,{}),na("span",{children:Uc.t.value("delete")})]})]}):!0===f.value&&na("div",{className:nb.e("footer"),children:na("div",{title:Uc.t.value("clearSession"),className:nb.e("action"),onClick:function(){return e.controller.clearTopic(!0)},children:[na(Gs,{}),na("span",{children:Uc.t.value("clearSession")})]})})]}),S.value&&na("div",{className:nb.e("modal-mask"),style:{zIndex:E},onClick:function(){return R()},children:na("div",{className:nb.e("modal"),style:{left:"".concat(null!==(t=null===(n=_.value)||void 0===n?void 0:n.left)&&void 0!==t?t:0,"px"),top:"".concat(null!==(i=null===(r=_.value)||void 0===r?void 0:r.top)&&void 0!==i?i:0,"px")},onClick:function(e){return e.stopPropagation()},children:[na("div",{className:nb.em("modal","header"),children:[na("span",{children:Uc.t.value("newCreateConversation")}),na("span",{className:nb.em("modal","close"),title:Uc.t.value("close"),onClick:function(){R()},children:na(Ls,{})})]}),na("div",{className:nb.em("modal","body"),children:[na("label",{className:nb.em("modal","label"),children:[Uc.t.value("selectScope"),na("span",{className:nb.em("modal","required"),children:"*"})]}),na("div",{className:nb.em("modal","select-wrapper"),children:[na("div",{className:"".concat(nb.em("modal","select-trigger")," ").concat(nb.is("focus",M.value)),onClick:function(){M.value=!M.value},children:[na("span",{className:"".concat(nb.em("modal","select-value")," ").concat(nb.is("placeholder",!P.value)),children:null!==(o=P.value)&&void 0!==o?o:Uc.t.value("selectScopePlaceholder")}),na("span",{className:"".concat(nb.em("modal","select-arrow")," ").concat(nb.is("open",M.value)),children:na(Hc,{})})]}),M.value&&na("div",{className:nb.em("modal","dropdown"),children:[na("div",{className:nb.em("modal","dropdown-search"),children:na(tl,{value:T.value,placeholder:Uc.t.value("searchScopePlaceholder"),autoFocus:!0,onChange:function(e){T.value=e}})}),na("ul",{className:nb.em("modal","options"),children:z.value.length>0?z.value.map(function(e){return na("li",{className:"".concat(nb.em("modal","option")," ").concat(nb.is("selected",String(e.id)===String(x.value))),title:e.text,onClick:function(){x.value=e.id,M.value=!1,T.value=""},children:e.text},String(e.id))}):na("li",{className:"el-empty ".concat(nb.em("modal","option-empty")),children:[Sc,na("div",{className:nb.em("modal","option-empty-text"),children:Uc.t.value("noData")})]})})]})]}),na("div",{className:nb.em("modal","tip"),children:Uc.t.value("selectScopeTip")})]}),na("div",{className:nb.em("modal","footer"),children:[na("div",{className:nb.em("modal","btn"),onClick:function(){R()},children:Uc.t.value("cancel")}),na("div",{className:"".concat(nb.em("modal","btn")," ").concat(nb.is("primary",!0)," ").concat(nb.is("disabled",void 0===x.value||""===x.value)),onClick:function(){return function(){if(x.value){var t=e.controller.scopeList.find(function(e){return String(e.id)===String(x.value)});S.value=!1,e.controller.globalNewTopic(t?t.id:x.value)}}()},children:Uc.t.value("confirm")})]})]})})]})},rb=new ra("chat-minimize"),ob=function(e){var t=e.options||{},n=t.containerId,i=t.offset,r=qa(null),o=n?document.getElementById(n):null,a=g(Wa(""),2),s=a[0],c=a[1],l=g(Wa(0),2),u=l[0],d=l[1],h=g(Wa("center"),2),f=h[0],p=h[1],v=qa(!1),m={x:(window.innerWidth-86)/window.innerWidth,y:(window.innerHeight-86)/window.innerHeight},y=Is(function(){var t=e.controller.messages.value[e.controller.messages.value.length-1];return!!t&&("ASSISTANT"===t.role&&20===t.state&&!0!==t.completed)}),k=Is(function(){var t="";if(!y.value)return c(""),d(0),t;var n=e.controller.messages.value[e.controller.messages.value.length-1];if(t=n.content,n.content&&-1!==n.content.indexOf("<think>")){var i=function(e){var t=e.indexOf("<think>"),n=e.indexOf("</think>"),i="",r="";return-1===n?(i=e.slice(t+7),r=""):(i=e.slice(t+7,n),r=e.slice(n+8)),{thoughtContent:i,answerContent:r}}(n.content);t=i.thoughtContent+i.answerContent}return t}),w=function(){var e=r.current;if(e){var t=e.getBoundingClientRect(),n=t.left+t.width/2;n-110<0?p("left"):n+110>window.innerWidth?p("right"):p("center")}},b=function(){Object.assign(r.current.style,{left:"".concat(100*m.x,"%"),top:"".concat(100*m.y,"%")}),localStorage.setItem(Sw.MINIMIZE_STYLY_CHCHE,JSON.stringify(m)),w()};return $a(function(){if(e.isMinimize&&o&&r.current){var t=function(){if(r.current){var e=o.getBoundingClientRect(),t=e.left+(e.right-e.left)/2+((null==i?void 0:i.x)||0),n=e.top-38;Object.assign(r.current.style,{left:"".concat(t,"px"),top:"".concat(n,"px")}),w()}};t();var n=new ResizeObserver(t);n.observe(o);var a=function(){return requestAnimationFrame(t)};window.addEventListener("scroll",a,!0),window.addEventListener("resize",a);var s=new MutationObserver(t);return s.observe(o,{attributes:!0,attributeFilter:["style","class"]}),o.parentElement&&s.observe(o.parentElement,{attributes:!0,attributeFilter:["style","class"]}),function(){n.disconnect(),s.disconnect(),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}}},[e.isMinimize,o]),$a(function(){var e,t=localStorage.getItem(Sw.MINIMIZE_STYLY_CHCHE);if(t)try{var n=JSON.parse(t);Sa(n)&&Object.assign(m,n)}catch(vs){console.warn("解析最小化样式缓存失败,已做容错处理",{value:t,error:vs})}b(),(e=r.current)&&(e.onmousedown=function(t){document.body.style.userSelect="none";var n=t.clientX-e.offsetLeft,i=t.clientY-e.offsetTop,r=Date.now(),o=function(e){var t=56/window.innerWidth,r=56/window.innerHeight,o=xa(e.clientX-n,e.clientY-i,t,r),a=o.x,s=o.y;Object.assign(m,{x:a,y:s}),requestAnimationFrame(function(){b()})},a=function(){var e=Date.now();v.current=e-r>300,document.body.style.userSelect="",document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)})},[]),$a(function(){if(u<k.value.length){var e=setTimeout(function(){c(function(e){return e+k.value[u]}),d(function(e){return e+1})},100);return function(){return clearTimeout(e)}}},[u,k.value]),na("div",o?{ref:r,className:"".concat(rb.b("container")," ").concat(rb.is("hidden",!e.isMinimize)),children:na("div",{className:"".concat(rb.be("container","content")),children:s&&na("div",{className:"chat-minimize-popover ".concat(rb.is("align-".concat(f),!0)),children:na("div",{className:"typewriter",children:s})})})}:{ref:r,title:e.title,className:"".concat(rb.b()," ").concat(rb.is("hidden",!e.isMinimize)," ").concat(rb.is("show-halo",y.value)),onClick:function(){v.current||e.onClick()},children:na("div",{className:"".concat(rb.e("content")," ").concat(rb.is("show-border",!y.value)),children:[s&&na("div",{className:"".concat(rb.em("content","popover")," ").concat(rb.is("align-".concat(f),!0)),children:na("div",{className:"typewriter",children:s})}),na(Ws,{})]})})},ab=ea({zIndex:10,enableBackFill:!0}),sb=function(e){function t(e){var i,r,o,a,s,c;C(this,t),T(c=n(this,t,[e]),"listenedAIChat",void 0),T(c,"onCompleteMessageHandler",function(){var e,t=(null===(e=c.props.containerOptions)||void 0===e?void 0:e.minimizeOptions)||{},n=t.enable,i=void 0!==n&&n,r=t.openMode,o=void 0===r?"default":r;if(i&&c.props.autoClose){var a=c.props.autoClose,s=a.mode,l=a.duration,u=void 0===l?3:l;switch(s){case"minimize":c.minimize();break;case"close":c.close();break;case"closetime":setTimeout(function(){c.close()},1e3*u)}}"autoexpand"===o&&c.exitMinimize()}),T(c,"onMinimizeChangeHandler",function(e){e?c.minimize():c.exitMinimize()}),T(c,"ns",new ra("chat-container")),T(c,"containerRef",{current:null}),T(c,"dragHandle",{current:null}),T(c,"footerRef",{current:null}),T(c,"data",{side:{y:0,height:1,width:750/window.innerWidth,x:(window.innerWidth-750)/window.innerWidth},window:{y:0,width:750/window.innerWidth,height:750/window.innerHeight,x:(window.innerWidth-750)/window.innerWidth},minWidth:650,minHeight:400,showMode:"side"}),T(c,"disabled",!1),T(c,"isDragging",!1),T(c,"sidebarDragStartWidth",0),T(c,"resizing",{width:!1,height:!1}),T(c,"inputDragStartHeight",0),T(c,"inputDragContainerHeight",0),T(c,"containerContext",{zIndex:(null===(i=c.props.containerOptions)||void 0===i?void 0:i.zIndex)||10,enableBackFill:void 0===(null===(r=c.props)||void 0===r?void 0:r.enableBackFill)||null===(null===(o=c.props)||void 0===o?void 0:o.enableBackFill)||(null===(a=c.props)||void 0===a?void 0:a.enableBackFill)}),T(c,"handleSidebarResizeStart",function(){c.sidebarDragStartWidth=c.props.aiTopic.topicSidebarWidth.value}),T(c,"handleSidebarResizeMove",function(e){c.props.aiTopic.topicSidebarWidth.value=c.clampSidebarWidth(c.sidebarDragStartWidth+e)}),T(c,"handleSidebarResizeEnd",function(){c.props.aiTopic.updateTopicSidebarWidth()}),T(c,"syncSidebarWidth",function(){c.props.hideTopicSidebar||c.props.aiTopic.topicSidebarCollapse.value||(c.props.aiTopic.topicSidebarWidth.value=c.clampSidebarWidth(c.props.aiTopic.topicSidebarWidth.value))}),T(c,"commitSidebarWidth",function(){c.props.hideTopicSidebar||c.props.aiTopic.topicSidebarCollapse.value||c.props.aiTopic.updateTopicSidebarWidth()}),T(c,"handleInputHeightDragStart",function(){var e=c.footerRef.current;e&&e.parentElement&&(c.inputDragStartHeight=e.offsetHeight,c.inputDragContainerHeight=e.parentElement.offsetHeight)}),T(c,"handleInputHeightDragMove",function(e){var t=c.footerRef.current;if(t){var n=Math.max(168,c.inputDragContainerHeight-200-4),i=Math.min(n,Math.max(168,c.inputDragStartHeight-e));t.style.height="".concat(i,"px")}}),T(c,"handleInputHeightDragEnd",function(){var e=c.footerRef.current;if(e){var t=e.offsetHeight;c.setState({inputHeight:t});var n=c.getInputHeightCacheKey();localStorage.setItem(n,String(t))}}),T(c,"syncInputHeight",function(){var e,t=c.footerRef.current;if(t&&t.parentElement){var n=t.parentElement.offsetHeight,i=Math.max(168,n-200-4),r=null!==(e=c.state.inputHeight)&&void 0!==e?e:168,o=Math.min(i,Math.max(168,r));t.style.height="".concat(o,"px")}}),T(c,"commitInputHeight",function(){var e=c.footerRef.current;if(e){var t=e.offsetHeight;c.setState({inputHeight:t});var n=c.getInputHeightCacheKey();localStorage.setItem(n,String(t))}});var l=(null==e||null===(s=e.containerOptions)||void 0===s?void 0:s.minimizeOptions)||{},u=l.enable,d=void 0!==u&&u,h=l.openMode,f=void 0===h?"default":h;return c.state={isFullScreen:!1,enableAIMinimize:d,isMinimize:d&&("minimize"===f||"autoexpand"===f),inputHeight:c.readInputHeight()},c}return i(t,e),x(t,[{key:"listener",value:function(){var e=this.props.aiChat;e&&this.listenedAIChat!==e&&(this.listenedAIChat&&(this.listenedAIChat.evt.off("onCompleteMessage",this.onCompleteMessageHandler),this.listenedAIChat.evt.off("onMinimizeChange",this.onMinimizeChangeHandler)),e.evt.on("onCompleteMessage",this.onCompleteMessageHandler),e.evt.on("onMinimizeChange",this.onMinimizeChangeHandler),this.listenedAIChat=e)}},{key:"componentDidUpdate",value:function(){this.listener()}},{key:"calcWindowStyle",value:function(){var e,t="window"===this.data.showMode?this.data.window:this.data.side;return{left:"".concat(100*t.x,"%"),top:"".concat(100*t.y,"%"),width:"".concat(100*t.width,"%"),height:"".concat(100*t.height,"%"),minWidth:"".concat(this.data.minWidth,"px"),minHeight:"".concat(this.data.minHeight,"px"),"z-index":(null===(e=this.props.containerOptions)||void 0===e||null===(e=e.zIndex)||void 0===e?void 0:e.toString())||"10"}}},{key:"calcSideModeStyle",value:function(e){Object.assign(this.data,{side:{y:0,x:"left"===e?0:(window.innerWidth-750)/window.innerWidth,height:1,width:750/window.innerWidth},showMode:"side"})}},{key:"setStyle",value:function(){Object.assign(this.containerRef.current.style,this.calcWindowStyle()),localStorage.setItem(Sw.STYLE_CACHE,JSON.stringify(this.data))}},{key:"snapToEdge",value:function(){var e=20/window.innerWidth,t=20/window.innerHeight,n=this.data.window,i=n.x,r=n.y,o=n.width,a=n.height;i<e||i+o>1-e?this.calcSideModeStyle(i<e?"left":"right"):(r<t&&(this.data.window.y=0),r+a>1-t&&(this.data.window.y=1-a)),this.setStyle()}},{key:"registerDragDialog",value:function(){var e=this;this.dragHandle.current.onmousedown=function(t){if(!e.state.isFullScreen){document.body.style.userSelect="none";var n=t.clientX-e.containerRef.current.offsetLeft,i=t.clientY-e.containerRef.current.offsetTop,r=function(t){if(!e.disabled){e.data.showMode="window";var r=xa(t.clientX-n,t.clientY-i,e.data.window.width,e.data.window.height),o=r.x,a=r.y;Object.assign(e.data.window,{x:o,y:a}),e.setStyle()}},o=function(){document.body.style.userSelect="",document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o),e.disabled||(e.snapToEdge(),e.syncSidebarWidth(),e.syncInputHeight(),e.commitSidebarWidth(),e.commitInputHeight())};document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)}}}},{key:"registerDragDialogBorder",value:function(){var e=this;a(this.containerRef.current).resizable({edges:{top:!0,right:!0,bottom:!0,left:!0},margin:6,modifiers:[a.modifiers.restrictEdges({outer:document.body}),a.modifiers.restrictSize({min:{width:this.data.minWidth,height:this.data.minHeight}})],inertia:!0,listeners:{move:function(t){if(!e.state.isFullScreen){var n="side"===e.data.showMode?e.data.side:e.data.window;n.x=t.rect.left/window.innerWidth,n.y=t.rect.top/window.innerHeight,n.width=t.rect.width/window.innerWidth,n.height=t.rect.height/window.innerHeight,e.setStyle();var i=t.edges,r=i.left,o=i.right,a=i.top,s=i.bottom;e.resizing.width=!(!r&&!o),e.resizing.height=!(!a&&!s),e.resizing.height&&e.syncInputHeight(),e.resizing.width&&e.syncSidebarWidth()}},start:function(){e.disabled=!0,document.body.style.userSelect="none"},end:function(){e.disabled=!1,document.body.style.userSelect="",e.resizing.height&&e.commitInputHeight(),e.resizing.width&&e.commitSidebarWidth()}}})}},{key:"handleFullScreenChange",value:function(){this.setState({isFullScreen:null!==document.fullscreenElement})}},{key:"componentDidMount",value:function(){this.handleFullScreenChange=this.handleFullScreenChange.bind(this);var e=localStorage.getItem(Sw.STYLE_CACHE);if(e)try{var t=JSON.parse(e);t.side&&Sa(t.side)&&t.window&&Sa(t.window)&&Object.assign(this.data,t)}catch(vs){console.warn("解析样式缓存失败,已做容错处理",{value:e,error:vs})}this.setStyle(),this.registerDragDialog(),this.registerDragDialogBorder(),document.addEventListener("fullscreenchange",this.handleFullScreenChange)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("fullscreenchange",this.handleFullScreenChange),this.listenedAIChat&&(this.listenedAIChat.evt.off("onCompleteMessage",this.onCompleteMessageHandler),this.listenedAIChat.evt.off("onMinimizeChange",this.onMinimizeChangeHandler),this.listenedAIChat=void 0)}},{key:"close",value:function(){this.props.close()}},{key:"fullScreen",value:function(){var e=this.containerRef.current;e&&(e.requestFullscreen(),this.props.fullscreen(!0))}},{key:"closeFullScreen",value:function(){var e;this.state.isFullScreen&&(null===(e=document)||void 0===e||e.exitFullscreen(),this.props.fullscreen(!1),this.setStyle())}},{key:"minimize",value:function(){this.closeFullScreen(),this.setState({isMinimize:!0}),this.props.minimize(!0)}},{key:"exitMinimize",value:function(){this.setState({isMinimize:!1}),this.props.minimize(!1)}},{key:"stopPropagation",value:function(e){e.stopPropagation()}},{key:"renderSidebarSplitter",value:function(){return this.props.hideTopicSidebar||this.props.aiTopic.topicSidebarCollapse.value?null:na(Cw,{direction:"vertical",onDragStart:this.handleSidebarResizeStart,onMove:this.handleSidebarResizeMove,onDragEnd:this.handleSidebarResizeEnd})}},{key:"getRightWidth",value:function(){if(this.props.hideTopicSidebar)return"100%";var e=this.props.aiTopic.topicSidebarWidth.value;return this.props.aiTopic.topicSidebarCollapse.value?"calc(100% - ".concat(e,"px)"):"calc(100% - ".concat(e,"px - ").concat(4,"px)")}},{key:"clampSidebarWidth",value:function(e){var t,n,i,r,o,a=null!==(t=null===(n=this.containerRef.current)||void 0===n?void 0:n.offsetWidth)&&void 0!==t?t:0,s=230+(null!==(i=this.props.aiChat)&&void 0!==i&&i.enableKnowledgeBaseSelect.value?90:0)+(null!==(r=this.props.aiChat)&&void 0!==r&&r.opts.enableAIProject?90:0)+(null!==(o=this.props.aiChat)&&void 0!==o&&o.enableRecallConfigSetting.value?16:0);return Math.min(a/2,a-s,Math.max(200,e))}},{key:"getInputHeightCacheKey",value:function(){return"".concat(this.props.compWrapperId||"DEFAULT","__").concat(Sw.INPUT_HEIGHT)}},{key:"readInputHeight",value:function(){var e=this.getInputHeightCacheKey(),t=localStorage.getItem(e);if(null===t)return null;var n=Number(t);return Number.isFinite(n)&&n>0?n:null}},{key:"getFooterStyle",value:function(){return null===this.state.inputHeight?{height:"168px"}:{height:"".concat(this.state.inputHeight,"px")}}},{key:"render",value:function(){var e;return na(ab.Provider,{value:this.containerContext,children:na("div",{className:"".concat(this.ns.b()),children:[na("div",{className:"".concat(this.ns.e("dialog")," ").concat(this.ns.is("full-screen",this.state.isFullScreen)," ").concat(this.ns.is("hidden",this.state.isMinimize)),ref:this.containerRef,children:[na("div",{ref:this.dragHandle,className:this.ns.b("header"),children:[na("div",{className:this.ns.b("header-caption"),children:this.props.caption||Uc.t.value("aiAssistant")}),na("div",{className:this.ns.b("header-action-wrapper"),children:[this.state.enableAIMinimize&&na("div",{title:Uc.t.value("minimize"),className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","minimize")),onMouseDown:this.stopPropagation.bind(this),onClick:this.minimize.bind(this),children:na(Vs,{})}),this.state.isFullScreen?na("div",{title:Uc.t.value("exitFullscreen"),className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","close-full-screen")),onMouseDown:this.stopPropagation.bind(this),onClick:this.closeFullScreen.bind(this),children:na(js,{})}):na("div",{title:Uc.t.value("fullscreen"),className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","full-screen")),onMouseDown:this.stopPropagation.bind(this),onClick:this.fullScreen.bind(this),children:na(Hs,{})}),na("div",{title:Uc.t.value("close"),className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","action-close")),onMouseDown:this.stopPropagation.bind(this),onClick:this.close.bind(this),children:na(Ls,{})})]})]}),this.props.isLoading?na("div",{className:"".concat(this.ns.be("main","loading")),children:[na("div",{className:"".concat(this.ns.be("main","spinner"))}),na("div",{className:"".concat(this.ns.be("main","text")),children:Uc.t.value("loading")})]}):"TOPIC"===this.props.mode?na("div",{className:"".concat(this.ns.b("main")),children:[!this.props.hideTopicSidebar&&na("div",{className:"".concat(this.ns.be("main","left")),style:{width:"".concat(this.props.aiTopic.topicSidebarWidth.value,"px")},children:"WORKSPACE"===this.props.aiTopic.workMode?na(ib,{controller:this.props.aiTopic}):na(tb,{controller:this.props.aiTopic})}),this.renderSidebarSplitter(),na("div",{className:"".concat(this.ns.be("main","right")),style:{width:this.getRightWidth()},children:[na("div",{className:this.ns.b("content"),children:na(ww,{controller:this.props.aiChat,toolbarItems:this.props.contentToolbarItems,children:na(gw,{type:"footer",mode:this.props.mode,hideTopicSidebar:this.props.hideTopicSidebar,data:this.props.aiTopic.activedTopic.value,controller:this.props.aiChat,items:this.props.footerToolbarItems})})}),na(Cw,{direction:"horizontal",onDragStart:this.handleInputHeightDragStart,onMove:this.handleInputHeightDragMove,onDragEnd:this.handleInputHeightDragEnd}),na("div",{ref:this.footerRef,className:"".concat(this.ns.b("footer")),style:this.getFooterStyle(),children:na(Yw,{controller:this.props.aiChat,questionToolbarItems:this.props.questionToolbarItems})})]},this.props.aiChat.topicId)]}):na("div",{className:"".concat(this.ns.be("main","default")),children:[na("div",{className:this.ns.b("content"),children:na(ww,{controller:this.props.aiChat,toolbarItems:this.props.contentToolbarItems,children:na(gw,{type:"footer",mode:this.props.mode,hideTopicSidebar:this.props.hideTopicSidebar,data:this.props.aiTopic.activedTopic.value,controller:this.props.aiChat,items:this.props.footerToolbarItems})})}),na(Cw,{direction:"horizontal",onDragStart:this.handleInputHeightDragStart,onMove:this.handleInputHeightDragMove,onDragEnd:this.handleInputHeightDragEnd}),na("div",{ref:this.footerRef,className:"".concat(this.ns.b("footer")),style:this.getFooterStyle(),children:na(Yw,{controller:this.props.aiChat,questionToolbarItems:this.props.questionToolbarItems})})]})]}),!this.props.isLoading&&na(ob,{options:null===(e=this.props.containerOptions)||void 0===e?void 0:e.minimizeOptions,title:this.props.caption||Uc.t.value("aiAssistant"),controller:this.props.aiChat,isMinimize:this.state.isMinimize,onClick:this.exitMinimize.bind(this)},this.props.aiChat.topicId)]})})}}])}(Io);t("ChatContainer",sb);var cb=ea({enableBackFill:!0}),lb=function(e){function t(){var e,i,r,o;C(this,t);for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return T(o=n(this,t,[].concat(s)),"ns",new ra("flat-chat-container")),T(o,"headerRef",{current:null}),T(o,"messagesRef",{current:null}),T(o,"toolbarsRef",{current:null}),T(o,"topicRef",{current:null}),T(o,"containerRef",{current:null}),T(o,"footerRef",{current:null}),T(o,"sidebarDragStartWidth",0),T(o,"inputDragStartHeight",0),T(o,"inputDragContainerHeight",0),T(o,"state",{mountedSlots:{},inputHeight:o.readInputHeight()}),T(o,"containerContext",{enableBackFill:void 0===(null===(e=o.props)||void 0===e?void 0:e.enableBackFill)||null===(null===(i=o.props)||void 0===i?void 0:i.enableBackFill)||(null===(r=o.props)||void 0===r?void 0:r.enableBackFill)}),T(o,"handleSidebarResizeStart",function(){o.sidebarDragStartWidth=o.props.aiTopic.topicSidebarWidth.value}),T(o,"handleSidebarResizeMove",function(e){var t,n,i,r,a,s=null!==(t=null===(n=o.containerRef.current)||void 0===n?void 0:n.offsetWidth)&&void 0!==t?t:0,c=230+(null!==(i=o.props.aiChat)&&void 0!==i&&i.enableKnowledgeBaseSelect.value?90:0)+(null!==(r=o.props.aiChat)&&void 0!==r&&r.opts.enableAIProject?90:0)+(null!==(a=o.props.aiChat)&&void 0!==a&&a.enableRecallConfigSetting.value?16:0),l=Math.min(s/2,s-c,Math.max(200,o.sidebarDragStartWidth+e));o.props.aiTopic.topicSidebarWidth.value=l}),T(o,"handleSidebarResizeEnd",function(){o.props.aiTopic.updateTopicSidebarWidth()}),T(o,"handleInputHeightDragStart",function(){var e=o.footerRef.current;e&&e.parentElement&&(o.inputDragStartHeight=e.offsetHeight,o.inputDragContainerHeight=e.parentElement.offsetHeight)}),T(o,"handleInputHeightDragMove",function(e){var t=o.footerRef.current;if(t){var n=Math.max(168,o.inputDragContainerHeight-200-4),i=Math.min(n,Math.max(168,o.inputDragStartHeight-e));t.style.height="".concat(i,"px")}}),T(o,"handleInputHeightDragEnd",function(){var e=o.footerRef.current;if(e){var t=e.offsetHeight;o.setState({inputHeight:t});var n=o.getInputHeightCacheKey();localStorage.setItem(n,String(t))}}),o}return i(t,e),x(t,[{key:"appendExternalSlot",value:function(e,t,n){!this.state.mountedSlots[e]&&n&&t.current&&(t.current.appendChild(n),this.setState(function(t){return{mountedSlots:d(d({},t.mountedSlots),{},T({},e,!0))}}))}},{key:"componentDidMount",value:function(){this.syncExternalSlots()}},{key:"componentDidUpdate",value:function(e){e.aiChat!==this.props.aiChat&&this.setState({mountedSlots:{}}),this.syncExternalSlots()}},{key:"syncExternalSlots",value:function(){var e=this.props.extension;e&&(this.appendExternalSlot("header",this.headerRef,e.headerContainer),this.appendExternalSlot("messages",this.messagesRef,e.messagesContainer),this.appendExternalSlot("toolbar",this.toolbarsRef,e.toolbarContainer),this.appendExternalSlot("topic",this.topicRef,e.topicContainer))}},{key:"renderLoading",value:function(){return na("div",{className:"".concat(this.ns.be("main","loading")),children:[na("div",{className:"".concat(this.ns.be("main","spinner"))}),na("div",{className:"".concat(this.ns.be("main","text")),children:Uc.t.value("loading")})]})}},{key:"renderSidebarSplitter",value:function(){return this.props.hideTopicSidebar||this.props.aiTopic.topicSidebarCollapse.value?null:na(Cw,{direction:"vertical",onDragStart:this.handleSidebarResizeStart,onMove:this.handleSidebarResizeMove,onDragEnd:this.handleSidebarResizeEnd})}},{key:"getRightWidth",value:function(){if(this.props.hideTopicSidebar)return"100%";var e=this.props.aiTopic.topicSidebarWidth.value;return this.props.aiTopic.topicSidebarCollapse.value?"calc(100% - ".concat(e,"px)"):"calc(100% - ".concat(e,"px - ").concat(4,"px)")}},{key:"getInputHeightCacheKey",value:function(){return"".concat(this.props.compWrapperId||"DEFAULT","__").concat(Sw.INPUT_HEIGHT)}},{key:"readInputHeight",value:function(){var e=this.getInputHeightCacheKey(),t=localStorage.getItem(e);if(null===t)return null;var n=Number(t);return Number.isFinite(n)&&n>0?n:null}},{key:"getFooterStyle",value:function(){return null===this.state.inputHeight?{height:"168px"}:{height:"".concat(this.state.inputHeight,"px")}}},{key:"renderContent",value:function(){if(this.props.aiChat){if(!this.props.aiChat.inited.value)return this.renderLoading();var e=this.props,t=e.mode,n=e.aiChat,i=e.aiTopic,r=e.extension,o=e.hideTopicSidebar,a=e.contentToolbarItems,s=e.footerToolbarItems,c=e.questionToolbarItems;return[na("div",{className:this.ns.b("content"),ref:this.messagesRef,children:!(null!=r&&r.messagesContainer)&&na(ww,{controller:n,toolbarItems:a,children:null!=r&&r.toolbarContainer?na("div",{className:"toolbar-slot",ref:this.toolbarsRef}):na(gw,{type:"footer",mode:t,hideTopicSidebar:o,data:i.activedTopic.value,controller:n,items:s})})},1),na(Cw,{direction:"horizontal",onDragStart:this.handleInputHeightDragStart,onMove:this.handleInputHeightDragMove,onDragEnd:this.handleInputHeightDragEnd},2),na("div",{ref:this.footerRef,className:"".concat(this.ns.b("footer")),style:this.getFooterStyle(),children:na(Yw,{controller:n,questionToolbarItems:c})},3)]}}},{key:"renderHeader",value:function(){var e;return na("div",{className:this.ns.b("header"),ref:this.headerRef,children:!(null!==(e=this.props.extension)&&void 0!==e&&e.headerContainer)&&na("div",{className:this.ns.b("header-caption"),children:this.props.caption||Uc.t.value("aiAssistant")})})}},{key:"render",value:function(){var e=this.props,t=e.isLoading,n=e.mode,i=e.hideTopicSidebar,r=e.aiChat,o=e.aiTopic,a=e.extension,s=!(r&&r.messages.value.length>0);return na(cb.Provider,{value:this.containerContext,children:na("div",{ref:this.containerRef,className:"".concat(this.ns.b()," ").concat(this.ns.is("empty-message",s)),children:[this.renderHeader(),t?this.renderLoading():na("div","TOPIC"===n?{className:"".concat(this.ns.b("main")),children:[!i&&na("div",{ref:this.topicRef,className:"".concat(this.ns.be("main","left")),style:{width:"".concat(o.topicSidebarWidth.value,"px")},children:!(null!=a&&a.topicContainer)&&("WORKSPACE"===o.workMode?na(ib,{controller:o}):na(tb,{controller:o}))}),this.renderSidebarSplitter(),na("div",{className:"".concat(this.ns.be("main","right")),style:{width:this.getRightWidth()},children:this.renderContent()},null==r?void 0:r.topicId)]}:{className:"".concat(this.ns.be("main","default")),children:this.renderContent()})]})})}}])}(Io);t("FlatChatContainer",lb);var ub=window.SpeechRecognition||window.webkitSpeechRecognition,db=new ra("simple-chat-input"),hb=function(e){var t,n=g(Wa(!1),2),i=n[0],r=n[1],o=e.controller.input,a=Ds(!1),s=qa(),c=qa(null);ub&&!s.current&&(s.current=new ub,s.current.onstart=function(){a.value=!0},s.current.onend=function(){a.value=!1},s.current.onresult=function(e){var t,n,i=null===(t=e.results)||void 0===t||null===(t=t[0])||void 0===t||null===(t=t[0])||void 0===t?void 0:t.transcript;i&&(null===(n=c.current)||void 0===n||n.commands.insertContent(i))});var l=Is(function(){return va(o.value).length<=0}),u=function(){try{var t,n,i,r=va(o.value);o.value="",null===(t=c.current)||void 0===t||t.chain().clearContent().run();var a=e.controller.stringlyMaterialResource(!0);null===(n=(i=e.controller.opts).action)||void 0===n||n.call(i,"send",{content:r,resources:a,agentId:e.controller.activeAIAgentID,knowledgeId:e.controller.getQueryKnowledgeBases()})}catch(s){console.error(s)}},d=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return i=Lw.getMaterialHelper("ossfile",e.controller),t.n=1,i.excuteAction(n);case 1:r(!1);case 2:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),f=function(){var t=v(h().m(function t(n,i){var o;return h().w(function(t){for(;;)switch(t.n){case 0:return o=Lw.getMaterialHelper("common",e.controller),t.n=1,o.excuteAction(n,i);case 1:r(!1);case 2:return t.a(2)}},t)}));return function(e,n){return t.apply(this,arguments)}}(),p=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.controller.knowledgeRemoteSearch(n);case 1:return i=t.v,t.a(2,i)}},t)}));return function(e){return t.apply(this,arguments)}}(),m=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.controller.searchAIAgent(n);case 1:return i=t.v,t.a(2,i)}},t)}));return function(e){return t.apply(this,arguments)}}();return na("div",{className:db.b(),children:[na("div",{className:db.e("body"),children:[na("div",{className:db.em("body","wrapper"),children:[na(Fw,{controller:e.controller}),na(ew,{value:o.value,c:e.controller,onCreate:function(e){c.current=e},onChange:function(e){o.value=e},onKeyDown:function(e){l.value||"Enter"!==e.code||"Enter"!==e.key||!1!==e.shiftKey||u()},placeholder:e.controller.placeholder.value,disabled:e.controller.isLoading.value})]}),na("div",{className:db.em("body","operation"),children:[na(Fl,{position:"top",triggerMode:"click",isOpen:i,onToggleOpen:r,content:na("div",{className:db.b("popup"),children:[na("div",{onClick:d,className:db.be("popup","item"),children:[na("div",{className:db.bem("popup","item","icon"),children:na(Zs,{})}),na("div",{className:db.bem("popup","item","title"),children:Uc.t.value("documentation")})]}),null===(t=e.questionToolbarItems)||void 0===t?void 0:t.map(function(e){var t,n,i;return na("div",{className:db.be("popup","item"),onClick:function(t){return f(t,e)},children:[na("div",{className:db.bem("popup","item","icon"),children:"function"==typeof e.icon?e.icon():(null===(t=e.icon)||void 0===t?void 0:t.showIcon)&&na(Do,{children:null!==(n=e.icon)&&void 0!==n&&n.cssClass?na("i",{className:e.icon.cssClass}):null!==(i=e.icon)&&void 0!==i&&i.imagePath?ha(e.icon.imagePath)?na("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):na("img",{src:e.icon.imagePath}):null})}),na("div",{className:db.bem("popup","item","title"),children:e.label})]},e.id)})]}),children:na("div",{className:"".concat(db.e("icon")," ").concat(db.em("icon","upload")," ").concat(db.em("body","left")),title:Uc.t.value("uploadDocument"),children:na(Qs,{})})}),na("div",{className:db.em("body","right"),children:[na("div",{className:"".concat(db.e("icon")," ").concat(db.em("icon","voice")," ").concat(db.is("recording",a.value)),title:a.value?Uc.t.value("voiceInputProgress"):Uc.t.value("voiceInput"),onClick:function(){s.current&&(a.value?s.current.abort():s.current.start())},children:a.value?na(qs,{}):na(Us,{})}),na("div",{onClick:u,title:Uc.t.value("sendMessage"),className:"".concat(db.e("icon")," ").concat(db.em("icon","send")," ").concat(db.is("disabled",l.value)),children:na(zs,{className:db.e("send-icon")})})]})]})]}),na("div",{className:db.e("footer"),children:[na(ol,{showBorder:!1,enableSearch:!0,placeholder:"Auto",popperStyle:{height:"220px"},className:"".concat(db.e("action")," ").concat(db.em("action","agent")),value:e.controller.activeAIAgentID,options:e.controller.agentList.value,icon:function(){return na("div",{title:Uc.t.value("agent"),children:lc()})},disabled:!e.controller.enableAIAgentChange,onSearch:m,onChange:function(t){return n=t,void e.controller.setActiveAIAgentID(n);var n}}),e.controller.enableKnowledgeBaseSelect.value&&na(sl,{className:"".concat(db.e("action")," ").concat(db.em("action","knowledge")," ").concat(db.is("active",e.controller.selectionKnowledgeBases.value.length>0)),enableSearch:!0,popperStyle:{height:"220px"},options:e.controller.knowledgeBases.value,icon:function(){return na("div",{title:Uc.t.value("knowledge"),children:bc})},placeholder:Uc.t.value("knowledgeSearch"),value:e.controller.selectionKnowledgeBases.value,onSearch:function(e){return p(e)},onChange:function(t){e.controller.setSelectionKnowledge(t)}})]})]})},fb=function(e){function t(){var e;C(this,t);for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return T(e=n(this,t,[].concat(r)),"ns",new ra("simple-chat-container")),e}return i(t,e),x(t,[{key:"render",value:function(){return na("div",{className:this.ns.b(),children:this.props.isLoading?na("div",{className:this.ns.e("loading"),children:[na("div",{className:this.ns.em("loading","spinner")}),na("div",{className:this.ns.em("loading","text"),children:Uc.t.value("loading")})]}):na(hb,{controller:this.props.aiChat,questionToolbarItems:this.props.questionToolbarItems})})}}])}(Io)}}})}();
1
+ !function(){function e(e,n,i,r){var o=t(s(1&r?e.prototype:e),n,i);return 2&r&&"function"==typeof o?function(e){return o.apply(i,e)}:o}function t(){return t="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},t.apply(null,arguments)}function n(e,t,n){return t=s(t),function(e,t){if(t&&("object"==_(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,o()?Reflect.construct(t,n||[],s(e).constructor):t.apply(e,n))}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}function r(e){var t="function"==typeof Map?new Map:void 0;return r=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(o())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var r=new(e.bind.apply(e,i));return n&&a(r,n.prototype),r}(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)},r(e)}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function c(e){return function(e){if(Array.isArray(e))return w(e)}(e)||l(e)||k(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach(function(t){T(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function h(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var c=i&&i.prototype instanceof s?i:s,l=Object.create(c.prototype);return f(l,"_invoke",function(n,i,r){var o,s,c,l=0,u=r||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,c=e,h.n=n,a}};function f(n,i){for(s=n,c=i,t=0;!d&&l&&!r&&t<u.length;t++){var r,o=u[t],f=h.p,p=o[2];n>3?(r=p===i)&&(c=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((r=n<2&&f<o[1])?(s=0,h.v=i,h.n=o[1]):f<p&&(r=n<3||o[0]>i||i>p)&&(o[4]=n,o[5]=i,h.n=p,s=0))}if(r||n>1)return a;throw d=!0,i}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,p),s=u,c=p;(t=s<2?e:c)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,c)):h.n=c:h.v=c);try{if(l=2,o){if(s||(r="next"),t=o[r]){if(!(t=t.call(o,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);o=e}else if((t=(d=h.n<0)?c:n.call(i,h))!==a)break}catch(t){o=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,r,o),!0),l}var a={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][i]?t(t([][i]())):(f(t={},i,function(){return this}),t),d=l.prototype=s.prototype=Object.create(u);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,f(e,r,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=l,f(d,"constructor",l),f(l,"constructor",c),c.displayName="GeneratorFunction",f(l,r,"GeneratorFunction"),f(d),f(d,r,"Generator"),f(d,i,function(){return this}),f(d,"toString",function(){return"[object Generator]"}),(h=function(){return{w:o,m:p}})()}function f(e,t,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}f=function(e,t,n,i){function o(t,n){f(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},f(e,t,n,i)}function p(e,t,n,i,r,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(i,r)}function v(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function a(e){p(o,i,r,a,s,"next",e)}function s(e){p(o,i,r,a,s,"throw",e)}a(void 0)})}}function m(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=k(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function g(e,t){return b(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],c=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);c=!0);}catch(e){l=!0,r=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return s}}(e,t)||k(e,t)||y()}function y(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function k(e,t){if(e){if("string"==typeof e)return w(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(e,t):void 0}}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function b(e){if(Array.isArray(e))return e}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function S(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,M(i.key),i)}}function x(e,t,n){return t&&S(e.prototype,t),n&&S(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function T(e,t,n){return(t=M(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e){var t=function(e,t){if("object"!=_(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=_(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==_(t)?t:t+""}function _(e){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_(e)}System.register(["interactjs","cherry-markdown","lodash-es","qx-util"],function(t,o){"use strict";var a,s,u,f,p;return{setters:[function(e){a=e.default},function(e){s=e.default},function(e){u=e.isUndefined,f=e.cloneDeep},function(e){p=e.QXEvent}],execute:function(){t("createFlatChat",function(){return new Hw});var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},w=function(e){return e&&e.Math===Math&&e},S=w("object"==("undefined"==typeof globalThis?"undefined":_(globalThis))&&globalThis)||w("object"==("undefined"==typeof window?"undefined":_(window))&&window)||w("object"==("undefined"==typeof self?"undefined":_(self))&&self)||w("object"==_(o)&&o)||w("object"==_(o)&&o)||function(){return this}()||Function("return this")(),M={},N=function(e){try{return!!e()}catch(t){return!0}},O=!N(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),E=!N(function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}),A=E,D=Function.prototype.call,I=A?D.bind(D):function(){return D.apply(D,arguments)},L={},R={}.propertyIsEnumerable,P=Object.getOwnPropertyDescriptor,z=P&&!R.call({1:2},1);L.f=z?function(e){var t=P(this,e);return!!t&&t.enumerable}:R;var B,H,F=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},j=E,V=Function.prototype,W=V.call,$=j&&V.bind.bind(W,W),U=j?$:function(e){return function(){return W.apply(e,arguments)}},q=U,K=q({}.toString),J=q("".slice),G=function(e){return J(K(e),8,-1)},Y=N,X=G,Q=Object,Z=U("".split),ee=Y(function(){return!Q("z").propertyIsEnumerable(0)})?function(e){return"String"===X(e)?Z(e,""):Q(e)}:Q,te=function(e){return null==e},ne=te,ie=TypeError,re=function(e){if(ne(e))throw new ie("Can't call method on "+e);return e},oe=ee,ae=re,se=function(e){return oe(ae(e))},ce="object"==("undefined"==typeof document?"undefined":_(document))&&document.all,le=void 0===ce&&void 0!==ce?function(e){return"function"==typeof e||e===ce}:function(e){return"function"==typeof e},ue=le,de=function(e){return"object"==_(e)?null!==e:ue(e)},he=S,fe=le,pe=function(e,t){return arguments.length<2?(n=he[e],fe(n)?n:void 0):he[e]&&he[e][t];var n},ve=U({}.isPrototypeOf),me=S.navigator,ge=me&&me.userAgent,ye=S,ke=ge?String(ge):"",we=ye.process,be=ye.Deno,Ce=we&&we.versions||be&&be.version,Se=Ce&&Ce.v8;Se&&(H=(B=Se.split("."))[0]>0&&B[0]<4?1:+(B[0]+B[1])),!H&&ke&&(!(B=ke.match(/Edge\/(\d+)/))||B[1]>=74)&&(B=ke.match(/Chrome\/(\d+)/))&&(H=+B[1]);var xe=H,Te=N,Me=S.String,_e=!!Object.getOwnPropertySymbols&&!Te(function(){var e=Symbol("symbol detection");return!Me(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&xe&&xe<41}),Ne=_e&&!Symbol.sham&&"symbol"==_(Symbol.iterator),Oe=pe,Ee=le,Ae=ve,De=Object,Ie=Ne?function(e){return"symbol"==_(e)}:function(e){var t=Oe("Symbol");return Ee(t)&&Ae(t.prototype,De(e))},Le=String,Re=le,Pe=function(e){try{return Le(e)}catch(t){return"Object"}},ze=TypeError,Be=function(e){if(Re(e))return e;throw new ze(Pe(e)+" is not a function")},He=Be,Fe=te,je=I,Ve=le,We=de,$e=TypeError,Ue={exports:{}},qe=S,Ke=Object.defineProperty,Je=function(e,t){try{Ke(qe,e,{value:t,configurable:!0,writable:!0})}catch(n){qe[e]=t}return t},Ge=S,Ye=Je,Xe="__core-js_shared__",Qe=Ue.exports=Ge[Xe]||Ye(Xe,{});(Qe.versions||(Qe.versions=[])).push({version:"3.49.0",mode:"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Ze=Ue.exports,et=Ze,tt=function(e,t){return et[e]||(et[e]=t||{})},nt=re,it=Object,rt=function(e){return it(nt(e))},ot=rt,at=U({}.hasOwnProperty),st=Object.hasOwn||function(e,t){return at(ot(e),t)},ct=U,lt=0,ut=Math.random(),dt=ct(1.1.toString),ht=function(e){return"Symbol("+(void 0===e?"":e)+")_"+dt(++lt+ut,36)},ft=tt,pt=st,vt=ht,mt=_e,gt=Ne,yt=S.Symbol,kt=ft("wks"),wt=gt?yt.for||yt:yt&&yt.withoutSetter||vt,bt=function(e){return pt(kt,e)||(kt[e]=mt&&pt(yt,e)?yt[e]:wt("Symbol."+e)),kt[e]},Ct=I,St=de,xt=Ie,Tt=function(e,t){var n=e[t];return Fe(n)?void 0:He(n)},Mt=function(e,t){var n,i;if("string"===t&&Ve(n=e.toString)&&!We(i=je(n,e)))return i;if(Ve(n=e.valueOf)&&!We(i=je(n,e)))return i;if("string"!==t&&Ve(n=e.toString)&&!We(i=je(n,e)))return i;throw new $e("Can't convert object to primitive value")},_t=TypeError,Nt=bt("toPrimitive"),Ot=function(e,t){if(!St(e)||xt(e))return e;var n,i=Tt(e,Nt);if(i){if(void 0===t&&(t="default"),n=Ct(i,e,t),!St(n)||xt(n))return n;throw new _t("Can't convert object to primitive value")}return void 0===t&&(t="number"),Mt(e,t)},Et=Ie,At=function(e){var t=Ot(e,"string");return Et(t)?t:t+""},Dt=de,It=S.document,Lt=Dt(It)&&Dt(It.createElement),Rt=function(e){return Lt?It.createElement(e):{}},Pt=Rt,zt=!O&&!N(function(){return 7!==Object.defineProperty(Pt("div"),"a",{get:function(){return 7}}).a}),Bt=O,Ht=I,Ft=L,jt=F,Vt=se,Wt=At,$t=st,Ut=zt,qt=Object.getOwnPropertyDescriptor;M.f=Bt?qt:function(e,t){if(e=Vt(e),t=Wt(t),Ut)try{return qt(e,t)}catch(n){}if($t(e,t))return jt(!Ht(Ft.f,e,t),e[t])};var Kt={},Jt=O&&N(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),Gt=de,Yt=String,Xt=TypeError,Qt=function(e){if(Gt(e))return e;throw new Xt(Yt(e)+" is not an object")},Zt=O,en=zt,tn=Jt,nn=Qt,rn=At,on=TypeError,an=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,cn="enumerable",ln="configurable",un="writable";Kt.f=Zt?tn?function(e,t,n){if(nn(e),t=rn(t),nn(n),"function"==typeof e&&"prototype"===t&&"value"in n&&un in n&&!n[un]){var i=sn(e,t);i&&i[un]&&(e[t]=n.value,n={configurable:ln in n?n[ln]:i[ln],enumerable:cn in n?n[cn]:i[cn],writable:!1})}return an(e,t,n)}:an:function(e,t,n){if(nn(e),t=rn(t),nn(n),en)try{return an(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new on("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var dn=Kt,hn=F,fn=O?function(e,t,n){return dn.f(e,t,hn(1,n))}:function(e,t,n){return e[t]=n,e},pn={exports:{}},vn=O,mn=st,gn=Function.prototype,yn=vn&&Object.getOwnPropertyDescriptor,kn=mn(gn,"name"),wn={EXISTS:kn,PROPER:kn&&"something"===function(){}.name,CONFIGURABLE:kn&&(!vn||vn&&yn(gn,"name").configurable)},bn=le,Cn=Ze,Sn=U(Function.toString);bn(Cn.inspectSource)||(Cn.inspectSource=function(e){return Sn(e)});var xn,Tn,Mn,_n=Cn.inspectSource,Nn=le,On=S.WeakMap,En=Nn(On)&&/native code/.test(String(On)),An=ht,Dn=tt("keys"),In=function(e){return Dn[e]||(Dn[e]=An(e))},Ln={},Rn=En,Pn=S,zn=de,Bn=fn,Hn=st,Fn=Ze,jn=In,Vn=Ln,Wn="Object already initialized",$n=Pn.TypeError,Un=Pn.WeakMap;if(Rn||Fn.state){var qn=Fn.state||(Fn.state=new Un);qn.get=qn.get,qn.has=qn.has,qn.set=qn.set,xn=function(e,t){if(qn.has(e))throw new $n(Wn);return t.facade=e,qn.set(e,t),t},Tn=function(e){return qn.get(e)||{}},Mn=function(e){return qn.has(e)}}else{var Kn=jn("state");Vn[Kn]=!0,xn=function(e,t){if(Hn(e,Kn))throw new $n(Wn);return t.facade=e,Bn(e,Kn,t),t},Tn=function(e){return Hn(e,Kn)?e[Kn]:{}},Mn=function(e){return Hn(e,Kn)}}var Jn={set:xn,get:Tn,has:Mn,enforce:function(e){return Mn(e)?Tn(e):xn(e,{})},getterFor:function(e){return function(t){var n;if(!zn(t)||(n=Tn(t)).type!==e)throw new $n("Incompatible receiver, "+e+" required");return n}}},Gn=U,Yn=N,Xn=le,Qn=st,Zn=O,ei=wn.CONFIGURABLE,ti=_n,ni=Jn.enforce,ii=Jn.get,ri=String,oi=Object.defineProperty,ai=Gn("".slice),si=Gn("".replace),ci=Gn([].join),li=Zn&&!Yn(function(){return 8!==oi(function(){},"length",{value:8}).length}),ui=String(String).split("String"),di=pn.exports=function(e,t,n){"Symbol("===ai(ri(t),0,7)&&(t="["+si(ri(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Qn(e,"name")||ei&&e.name!==t)&&(Zn?oi(e,"name",{value:t,configurable:!0}):e.name=t),li&&n&&Qn(n,"arity")&&e.length!==n.arity&&oi(e,"length",{value:n.arity});try{n&&Qn(n,"constructor")&&n.constructor?Zn&&oi(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(r){}var i=ni(e);return Qn(i,"source")||(i.source=ci(ui,"string"==typeof t?t:"")),e};Function.prototype.toString=di(function(){return Xn(this)&&ii(this).source||ti(this)},"toString");var hi=pn.exports,fi=le,pi=Kt,vi=hi,mi=Je,gi={},yi=Math.ceil,ki=Math.floor,wi=Math.trunc||function(e){var t=+e;return(t>0?ki:yi)(t)},bi=wi,Ci=function(e){var t=+e;return t!=t||0===t?0:bi(t)},Si=Ci,xi=Math.max,Ti=Math.min,Mi=Ci,_i=Math.min,Ni=function(e){var t=Mi(e);return t>0?_i(t,9007199254740991):0},Oi=function(e){return Ni(e.length)},Ei=se,Ai=function(e,t){var n=Si(e);return n<0?xi(n+t,0):Ti(n,t)},Di=Oi,Ii=function(e){return function(t,n,i){var r=Ei(t),o=Di(r);if(0===o)return!e&&-1;var a,s=Ai(i,o);if(e&&n!=n){for(;o>s;)if((a=r[s++])!=a)return!0}else for(;o>s;s++)if((e||s in r)&&r[s]===n)return e||s||0;return!e&&-1}},Li={includes:Ii(!0),indexOf:Ii(!1)},Ri=st,Pi=se,zi=Li.indexOf,Bi=Ln,Hi=U([].push),Fi=function(e,t){var n,i=Pi(e),r=0,o=[];for(n in i)!Ri(Bi,n)&&Ri(i,n)&&Hi(o,n);for(;t.length>r;)Ri(i,n=t[r++])&&(~zi(o,n)||Hi(o,n));return o},ji=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Vi=Fi,Wi=ji.concat("length","prototype");gi.f=Object.getOwnPropertyNames||function(e){return Vi(e,Wi)};var $i={};$i.f=Object.getOwnPropertySymbols;var Ui=pe,qi=gi,Ki=$i,Ji=Qt,Gi=U([].concat),Yi=Ui("Reflect","ownKeys")||function(e){var t=qi.f(Ji(e)),n=Ki.f;return n?Gi(t,n(e)):t},Xi=st,Qi=Yi,Zi=M,er=Kt,tr=N,nr=le,ir=/#|\.prototype\./,rr=function(e,t){var n=ar[or(e)];return n===cr||n!==sr&&(nr(t)?tr(t):!!t)},or=rr.normalize=function(e){return String(e).replace(ir,".").toLowerCase()},ar=rr.data={},sr=rr.NATIVE="N",cr=rr.POLYFILL="P",lr=rr,ur=S,dr=M.f,hr=fn,fr=function(e,t,n,i){i||(i={});var r=i.enumerable,o=void 0!==i.name?i.name:t;if(fi(n)&&vi(n,o,i),i.global)r?e[t]=n:mi(t,n);else{try{i.unsafe?e[t]&&(r=!0):delete e[t]}catch(a){}r?e[t]=n:pi.f(e,t,{value:n,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},pr=Je,vr=function(e,t,n){for(var i=Qi(t),r=er.f,o=Zi.f,a=0;a<i.length;a++){var s=i[a];Xi(e,s)||n&&Xi(n,s)||r(e,s,o(t,s))}},mr=lr,gr=G,yr=U,kr=function(e){if("Function"===gr(e))return yr(e)},wr=Be,br=E,Cr=kr(kr.bind),Sr=function(e,t){return wr(e),void 0===t?e:br?Cr(e,t):function(){return e.apply(t,arguments)}},xr=ee,Tr=rt,Mr=Oi,_r=function(e){var t=1===e;return function(n,i,r){for(var o,a=Tr(n),s=xr(a),c=Mr(s),l=Sr(i,r);c-- >0;)if(l(o=s[c],c,a))switch(e){case 0:return o;case 1:return c}return t?-1:void 0}},Nr={findLast:_r(0),findLastIndex:_r(1)},Or={},Er=Fi,Ar=ji,Dr=Object.keys||function(e){return Er(e,Ar)},Ir=O,Lr=Jt,Rr=Kt,Pr=Qt,zr=se,Br=Dr;Or.f=Ir&&!Lr?Object.defineProperties:function(e,t){Pr(e);for(var n,i=zr(t),r=Br(t),o=r.length,a=0;o>a;)Rr.f(e,n=r[a++],i[n]);return e};var Hr,Fr=pe("document","documentElement"),jr=Qt,Vr=Or,Wr=ji,$r=Ln,Ur=Fr,qr=Rt,Kr="prototype",Jr="script",Gr=In("IE_PROTO"),Yr=function(){},Xr=function(e){return"<"+Jr+">"+e+"</"+Jr+">"},Qr=function(e){e.write(Xr("")),e.close();var t=e.parentWindow.Object;return e=null,t},Zr=function(){try{Hr=new ActiveXObject("htmlfile")}catch(r){}var e,t,n;Zr="undefined"!=typeof document?document.domain&&Hr?Qr(Hr):(t=qr("iframe"),n="java"+Jr+":",t.style.display="none",Ur.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(Xr("document.F=Object")),e.close(),e.F):Qr(Hr);for(var i=Wr.length;i--;)delete Zr[Kr][Wr[i]];return Zr()};$r[Gr]=!0;var eo=Object.create||function(e,t){var n;return null!==e?(Yr[Kr]=jr(e),n=new Yr,Yr[Kr]=null,n[Gr]=e):n=Zr(),void 0===t?n:Vr.f(n,t)},to=bt,no=eo,io=Kt.f,ro=to("unscopables"),oo=Array.prototype;void 0===oo[ro]&&io(oo,ro,{configurable:!0,value:no(null)});var ao=Nr.findLast,so=function(e){oo[ro][e]=!0};(function(e,t){var n,i,r,o,a,s=e.target,c=e.global,l=e.stat;if(n=c?ur:l?ur[s]||pr(s,{}):ur[s]&&ur[s].prototype)for(i in t){if(o=t[i],r=e.dontCallGetSet?(a=dr(n,i))&&a.value:n[i],!mr(c?i:s+(l?".":"#")+i,e.forced)&&void 0!==r){if(_(o)==_(r))continue;vr(o,r)}(e.sham||r&&r.sham)&&hr(o,"sham",!0),fr(n,i,o,e)}})({target:"Array",proto:!0},{findLast:function(e){return ao(this,e,arguments.length>1?arguments[1]:void 0)}}),so("findLast");var co=S,lo=U;(function(e,t){lo(co[e].prototype[t])})("Array","findLast");var uo,ho,fo,po,vo,mo,go,yo,ko,wo,bo,Co,So,xo={},To=[],Mo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_o=Array.isArray;function No(e,t){for(var n in t)e[n]=t[n];return e}function Oo(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Eo(e,t,n){var i,r,o,a={};for(o in t)"key"==o?i=t[o]:"ref"==o?r=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?uo.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===a[o]&&(a[o]=e.defaultProps[o]);return Ao(e,a,i,r,null)}function Ao(e,t,n,i,r){var o={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==r?++fo:r,__i:-1,__u:0};return null==r&&null!=ho.vnode&&ho.vnode(o),o}function Do(e){return e.children}function Io(e,t){this.props=e,this.context=t}function Lo(e,t){if(null==t)return e.__?Lo(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?Lo(e):null}function Ro(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return Ro(e)}}function Po(e){(!e.__d&&(e.__d=!0)&&vo.push(e)&&!zo.__r++||mo!=ho.debounceRendering)&&((mo=ho.debounceRendering)||go)(zo)}function zo(){for(var e,t,n,i,r,o,a,s=1;vo.length;)vo.length>s&&vo.sort(yo),e=vo.shift(),s=vo.length,e.__d&&(n=void 0,i=void 0,r=(i=(t=e).__v).__e,o=[],a=[],t.__P&&((n=No({},i)).__v=i.__v+1,ho.vnode&&ho.vnode(n),Uo(t.__P,n,i,t.__n,t.__P.namespaceURI,32&i.__u?[r]:null,o,null==r?Lo(i):r,!!(32&i.__u),a),n.__v=i.__v,n.__.__k[n.__i]=n,Ko(o,n,a),i.__e=i.__=null,n.__e!=r&&Ro(n)));zo.__r=0}function Bo(e,t,n,i,r,o,a,s,c,l,u){var d,h,f,p,v,m,g,y=i&&i.__k||To,k=t.length;for(c=function(e,t,n,i,r){var o,a,s,c,l,u=n.length,d=u,h=0;for(e.__k=new Array(r),o=0;o<r;o++)null!=(a=t[o])&&"boolean"!=typeof a&&"function"!=typeof a?(c=o+h,(a=e.__k[o]="string"==typeof a||"number"==typeof a||"bigint"==typeof a||a.constructor==String?Ao(null,a,null,null,null):_o(a)?Ao(Do,{children:a},null,null,null):null==a.constructor&&a.__b>0?Ao(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,s=null,-1!=(l=a.__i=jo(a,n,c,d))&&(d--,(s=n[l])&&(s.__u|=2)),null==s||null==s.__v?(-1==l&&(r>u?h--:r<u&&h++),"function"!=typeof a.type&&(a.__u|=4)):l!=c&&(l==c-1?h--:l==c+1?h++:(l>c?h--:h++,a.__u|=4))):e.__k[o]=null;if(d)for(o=0;o<u;o++)null!=(s=n[o])&&!(2&s.__u)&&(s.__e==i&&(i=Lo(s)),Xo(s,s));return i}(n,t,y,c,k),d=0;d<k;d++)null!=(f=n.__k[d])&&(h=-1==f.__i?xo:y[f.__i]||xo,f.__i=d,m=Uo(e,f,h,r,o,a,s,c,l,u),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&Yo(h.ref,null,f),u.push(f.ref,f.__c||p,f)),null==v&&null!=p&&(v=p),(g=!!(4&f.__u))||h.__k===f.__k?c=Ho(f,c,e,g):"function"==typeof f.type&&void 0!==m?c=m:p&&(c=p.nextSibling),f.__u&=-7);return n.__e=v,c}function Ho(e,t,n,i){var r,o;if("function"==typeof e.type){for(r=e.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=e,t=Ho(r[o],t,n,i));return t}e.__e!=t&&(i&&(t&&e.type&&!t.parentNode&&(t=Lo(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function Fo(e,t){return t=t||[],null==e||"boolean"==typeof e||(_o(e)?e.some(function(e){Fo(e,t)}):t.push(e)),t}function jo(e,t,n,i){var r,o,a,s=e.key,c=e.type,l=t[n],u=null!=l&&!(2&l.__u);if(null===l&&null==e.key||u&&s==l.key&&c==l.type)return n;if(i>(u?1:0))for(r=n-1,o=n+1;r>=0||o<t.length;)if(null!=(l=t[a=r>=0?r--:o++])&&!(2&l.__u)&&s==l.key&&c==l.type)return a;return-1}function Vo(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||Mo.test(t)?n:n+"px"}function Wo(e,t,n,i,r){var o,a;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof i&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||Vo(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||Vo(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])o=t!=(t=t.replace(ko,"$1")),a=t.toLowerCase(),t=a in e||"onFocusOut"==t||"onFocusIn"==t?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?i?n.u=i.u:(n.u=wo,e.addEventListener(t,o?Co:bo,o)):e.removeEventListener(t,o?Co:bo,o);else{if("http://www.w3.org/2000/svg"==r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function $o(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t.t)t.t=wo++;else if(t.t<n.u)return;return n(ho.event?ho.event(t):t)}}}function Uo(e,t,n,i,r,o,a,s,c,l){var u,d,h,f,p,v,m,g,y,k,w,b,C,S,x,T,M,_=t.type;if(null!=t.constructor)return null;128&n.__u&&(c=!!(32&n.__u),o=[s=t.__e=n.__e]),(u=ho.__b)&&u(t);e:if("function"==typeof _)try{if(g=t.props,y="prototype"in _&&_.prototype.render,k=(u=_.contextType)&&i[u.__c],w=u?k?k.props.value:u.__:i,n.__c?m=(d=t.__c=n.__c).__=d.__E:(y?t.__c=d=new _(g,w):(t.__c=d=new Io(g,w),d.constructor=_,d.render=Qo),k&&k.sub(d),d.props=g,d.state||(d.state={}),d.context=w,d.__n=i,h=d.__d=!0,d.__h=[],d._sb=[]),y&&null==d.__s&&(d.__s=d.state),y&&null!=_.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=No({},d.__s)),No(d.__s,_.getDerivedStateFromProps(g,d.__s))),f=d.props,p=d.state,d.__v=t,h)y&&null==_.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),y&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(y&&null==_.getDerivedStateFromProps&&g!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(g,w),!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(g,d.__s,w)||t.__v==n.__v){for(t.__v!=n.__v&&(d.props=g,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),b=0;b<d._sb.length;b++)d.__h.push(d._sb[b]);d._sb=[],d.__h.length&&a.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(g,d.__s,w),y&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(f,p,v)})}if(d.context=w,d.props=g,d.__P=e,d.__e=!1,C=ho.__r,S=0,y){for(d.state=d.__s,d.__d=!1,C&&C(t),u=d.render(d.props,d.state,d.context),x=0;x<d._sb.length;x++)d.__h.push(d._sb[x]);d._sb=[]}else do{d.__d=!1,C&&C(t),u=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++S<25);d.state=d.__s,null!=d.getChildContext&&(i=No(No({},i),d.getChildContext())),y&&!h&&null!=d.getSnapshotBeforeUpdate&&(v=d.getSnapshotBeforeUpdate(f,p)),T=u,null!=u&&u.type===Do&&null==u.key&&(T=Jo(u.props.children)),s=Bo(e,_o(T)?T:[T],t,n,i,r,o,a,s,c,l),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),m&&(d.__E=d.__=null)}catch(e){if(t.__v=null,c||null!=o)if(e.then){for(t.__u|=c?160:128;s&&8==s.nodeType&&s.nextSibling;)s=s.nextSibling;o[o.indexOf(s)]=null,t.__e=s}else{for(M=o.length;M--;)Oo(o[M]);qo(t)}else t.__e=n.__e,t.__k=n.__k,e.then||qo(t);ho.__e(e,t,n)}else null==o&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Go(n.__e,t,n,i,r,o,a,c,l);return(u=ho.diffed)&&u(t),128&t.__u?void 0:s}function qo(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(qo)}function Ko(e,t,n){for(var i=0;i<n.length;i++)Yo(n[i],n[++i],n[++i]);ho.__c&&ho.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){ho.__e(e,t.__v)}})}function Jo(e){return"object"!=_(e)||null==e||e.__b&&e.__b>0?e:_o(e)?e.map(Jo):No({},e)}function Go(e,t,n,i,r,o,a,s,c){var l,u,d,h,f,p,v,m=n.props,g=t.props,y=t.type;if("svg"==y?r="http://www.w3.org/2000/svg":"math"==y?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),null!=o)for(l=0;l<o.length;l++)if((f=o[l])&&"setAttribute"in f==!!y&&(y?f.localName==y:3==f.nodeType)){e=f,o[l]=null;break}if(null==e){if(null==y)return document.createTextNode(g);e=document.createElementNS(r,y,g.is&&g),s&&(ho.__m&&ho.__m(t,o),s=!1),o=null}if(null==y)m===g||s&&e.data==g||(e.data=g);else{if(o=o&&uo.call(e.childNodes),m=n.props||xo,!s&&null!=o)for(m={},l=0;l<e.attributes.length;l++)m[(f=e.attributes[l]).name]=f.value;for(l in m)if(f=m[l],"children"==l);else if("dangerouslySetInnerHTML"==l)d=f;else if(!(l in g)){if("value"==l&&"defaultValue"in g||"checked"==l&&"defaultChecked"in g)continue;Wo(e,l,null,f,r)}for(l in g)f=g[l],"children"==l?h=f:"dangerouslySetInnerHTML"==l?u=f:"value"==l?p=f:"checked"==l?v=f:s&&"function"!=typeof f||m[l]===f||Wo(e,l,f,m[l],r);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),Bo("template"==t.type?e.content:e,_o(h)?h:[h],t,n,i,"foreignObject"==y?"http://www.w3.org/1999/xhtml":r,o,a,o?o[0]:n.__k&&Lo(n,0),s,c),null!=o)for(l=o.length;l--;)Oo(o[l]);s||(l="value","progress"==y&&null==p?e.removeAttribute("value"):null!=p&&(p!==e[l]||"progress"==y&&!p||"option"==y&&p!=m[l])&&Wo(e,l,p,m[l],r),l="checked",null!=v&&v!=e[l]&&Wo(e,l,v,m[l],r))}return e}function Yo(e,t,n){try{if("function"==typeof e){var i="function"==typeof e.__u;i&&e.__u(),i&&null==t||(e.__u=e(t))}else e.current=t}catch(e){ho.__e(e,n)}}function Xo(e,t,n){var i,r;if(ho.unmount&&ho.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Yo(i,null,t)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){ho.__e(e,t)}i.base=i.__P=null}if(i=e.__k)for(r=0;r<i.length;r++)i[r]&&Xo(i[r],t,n||"function"!=typeof e.type);n||Oo(e.__e),e.__c=e.__=e.__e=void 0}function Qo(e,t,n){return this.constructor(e,n)}function Zo(e,t,n){var i,r,o,a;t==document&&(t=document.documentElement),ho.__&&ho.__(e,t),r=(i="function"==typeof n)?null:n&&n.__k||t.__k,o=[],a=[],Uo(t,e=(!i&&n||t).__k=Eo(Do,null,[e]),r||xo,xo,t.namespaceURI,!i&&n?[n]:r?null:t.firstChild?uo.call(t.childNodes):null,o,!i&&n?n:r?r.__e:t.firstChild,i,a),Ko(o,e,a)}function ea(e){function t(e){var n,i;return this.getChildContext||(n=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,Po(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+So++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}uo=To.slice,ho={__e:function(e,t,n,i){for(var r,o,a;t=t.__;)if((r=t.__c)&&!r.__)try{if((o=r.constructor)&&null!=o.getDerivedStateFromError&&(r.setState(o.getDerivedStateFromError(e)),a=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,i||{}),a=r.__d),a)return r.__E=r}catch(t){e=t}throw e}},fo=0,po=function(e){return null!=e&&null==e.constructor},Io.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=No({},this.state),"function"==typeof e&&(e=e(No({},n),this.props)),e&&No(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),Po(this))},Io.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Po(this))},Io.prototype.render=Do,vo=[],go="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,yo=function(e,t){return e.__v.__b-t.__v.__b},zo.__r=0,ko=/(PointerCapture)$|Capture$/i,wo=0,bo=$o(!1),Co=$o(!0),So=0;var ta=0;function na(e,t,n,i,r,o){t||(t={});var a,s,c=t;if("ref"in c)for(s in c={},t)"ref"==s?a=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ta,__i:-1,__u:0,__source:r,__self:o};if("function"==typeof e&&(a=e.defaultProps))for(s in a)void 0===c[s]&&(c[s]=a[s]);return ho.vnode&&ho.vnode(l),l}function ia(e,t,n,i,r){var o="".concat(e,"-").concat(t);return n&&(o+="-".concat(n)),i&&(o+="__".concat(i)),r&&(o+="--".concat(r)),o}var ra=function(){return x(function e(t,n){C(this,e),T(this,"namespace",void 0),this.block=t,this.namespace=n||"ibiz"},[{key:"b",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return ia(this.namespace,this.block,e,"","")}},{key:"e",value:function(e){return e?ia(this.namespace,this.block,"",e,""):""}},{key:"m",value:function(e){return e?ia(this.namespace,this.block,"","",e):""}},{key:"be",value:function(e,t){return e&&t?ia(this.namespace,this.block,e,t,""):""}},{key:"em",value:function(e,t){return e&&t?ia(this.namespace,this.block,"",e,t):""}},{key:"bm",value:function(e,t){return e&&t?ia(this.namespace,this.block,e,"",t):""}},{key:"bem",value:function(e,t,n){return e&&t&&n?ia(this.namespace,this.block,e,t,n):""}},{key:"is",value:function(e,t){return e&&t?"".concat("is-").concat(e):""}},{key:"cssVar",value:function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarName(n)]=e[n]);return t}},{key:"cssVarBlock",value:function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarBlockName(n)]=e[n]);return t}},{key:"cssVarName",value:function(e){return"--".concat(this.namespace,"-").concat(e)}},{key:"cssVarBlockName",value:function(e){return"--".concat(this.namespace,"-").concat(this.block,"-").concat(e)}}])}();function oa(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function aa(e,t){for(var n,i="",r=0,o=-1,a=0,s=0;s<=e.length;++s){if(s<e.length)n=e.charCodeAt(s);else{if(47===n)break;n=47}if(47===n){if(o===s-1||1===a);else if(o!==s-1&&2===a){if(i.length<2||2!==r||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2))if(i.length>2){var c=i.lastIndexOf("/");if(c!==i.length-1){-1===c?(i="",r=0):r=(i=i.slice(0,c)).length-1-i.lastIndexOf("/"),o=s,a=0;continue}}else if(2===i.length||1===i.length){i="",r=0,o=s,a=0;continue}t&&(i.length>0?i+="/..":i="..",r=2)}else i.length>0?i+="/"+e.slice(o+1,s):i=e.slice(o+1,s),r=s-o-1;o=s,a=0}else 46===n&&-1!==a?++a:a=-1}return i}var sa={resolve:function(){for(var e,t="",n=!1,i=arguments.length-1;i>=-1&&!n;i--){var r;i>=0?r=arguments[i]:(void 0===e&&(e=process.cwd()),r=e),oa(r),0!==r.length&&(t=r+"/"+t,n=47===r.charCodeAt(0))}return t=aa(t,!n),n?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(oa(e),0===e.length)return".";var t=47===e.charCodeAt(0),n=47===e.charCodeAt(e.length-1);return 0!==(e=aa(e,!t)).length||t||(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return oa(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];oa(n),n.length>0&&(void 0===e?e=n:e+="/"+n)}return void 0===e?".":sa.normalize(e)},relative:function(e,t){if(oa(e),oa(t),e===t)return"";if((e=sa.resolve(e))===(t=sa.resolve(t)))return"";for(var n=1;n<e.length&&47===e.charCodeAt(n);++n);for(var i=e.length,r=i-n,o=1;o<t.length&&47===t.charCodeAt(o);++o);for(var a=t.length-o,s=r<a?r:a,c=-1,l=0;l<=s;++l){if(l===s){if(a>s){if(47===t.charCodeAt(o+l))return t.slice(o+l+1);if(0===l)return t.slice(o+l)}else r>s&&(47===e.charCodeAt(n+l)?c=l:0===l&&(c=0));break}var u=e.charCodeAt(n+l);if(u!==t.charCodeAt(o+l))break;47===u&&(c=l)}var d="";for(l=n+c+1;l<=i;++l)l!==i&&47!==e.charCodeAt(l)||(0===d.length?d+="..":d+="/..");return d.length>0?d+t.slice(o+c):(o+=c,47===t.charCodeAt(o)&&++o,t.slice(o))},_makeLong:function(e){return e},dirname:function(e){if(oa(e),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,i=-1,r=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!r){i=o;break}}else r=!1;return-1===i?n?"/":".":n&&1===i?"//":e.slice(0,i)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');oa(e);var n,i=0,r=-1,o=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,s=-1;for(n=e.length-1;n>=0;--n){var c=e.charCodeAt(n);if(47===c){if(!o){i=n+1;break}}else-1===s&&(o=!1,s=n+1),a>=0&&(c===t.charCodeAt(a)?-1===--a&&(r=n):(a=-1,r=s))}return i===r?r=s:-1===r&&(r=e.length),e.slice(i,r)}for(n=e.length-1;n>=0;--n)if(47===e.charCodeAt(n)){if(!o){i=n+1;break}}else-1===r&&(o=!1,r=n+1);return-1===r?"":e.slice(i,r)},extname:function(e){oa(e);for(var t=-1,n=0,i=-1,r=!0,o=0,a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47!==s)-1===i&&(r=!1,i=a+1),46===s?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!r){n=a+1;break}}return-1===t||-1===i||0===o||1===o&&t===i-1&&t===n+1?"":e.slice(t,i)},format:function(e){if(null===e||"object"!==_(e))throw new TypeError('The "pathObject" argument must be of type Object. Received type '+_(e));return function(e,t){var n=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+i:n+e+i:i}("/",e)},parse:function(e){oa(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var n,i=e.charCodeAt(0),r=47===i;r?(t.root="/",n=1):n=0;for(var o=-1,a=0,s=-1,c=!0,l=e.length-1,u=0;l>=n;--l)if(47!==(i=e.charCodeAt(l)))-1===s&&(c=!1,s=l+1),46===i?-1===o?o=l:1!==u&&(u=1):-1!==o&&(u=-1);else if(!c){a=l+1;break}return-1===o||-1===s||0===u||1===u&&o===s-1&&o===a+1?-1!==s&&(t.base=t.name=0===a&&r?e.slice(1,s):e.slice(a,s)):(0===a&&r?(t.name=e.slice(1,o),t.base=e.slice(1,s)):(t.name=e.slice(a,o),t.base=e.slice(a,s)),t.ext=e.slice(o,s)),a>0?t.dir=e.slice(0,a-1):r&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};function ca(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function la(){return"".concat(ca()+ca(),"-").concat(ca(),"-").concat(ca(),"-").concat(ca(),"-").concat(ca()).concat(ca()).concat(ca())}function ua(e){var t=e.lastIndexOf("@");return-1===t?e:e.substring(0,t)}sa.posix=sa;var da=/<svg\b[^>]*>[\s\S]*?<\/svg>/;function ha(e){return da.test(e)}function fa(e,t){var n="";switch(e){case"TOPIC":n+="topic";break;case"INLINE":n+="inline";break;case"TEMP":n+="temp";break;default:n+="unknow"}return n+="@".concat(t||la(),"@").concat((new Date).getTime())}function pa(e){var t=new URL(e),n={},i={};if(t.searchParams.size>0){var r=t.searchParams.get("srfnavctx");if(r){try{Object.assign(n,JSON.parse(r))}catch(d){console.warn("解析 srfnavctx 参数失败,已做容错处理",{value:r,error:d})}t.searchParams.delete("srfnavctx")}t.searchParams.forEach(function(e,t){i[t]=e})}else if(t.search){var o=function(e){var t={};e.startsWith("?")&&(e=e.substring(1));for(var n=e.split("&"),i=0;i<n.length;i++){var r=g(n[i].split("="),2),o=r[0],a=r[1];t[o]=a}return t}(t.search),a=o.srfnavctx;if(a){try{var s=decodeURIComponent(a);Object.assign(n,JSON.parse(s))}catch(d){console.warn("解析 srfnavctx 参数失败,已做容错处理",{value:a,error:d})}delete o.srfnavctx}Object.keys(o).forEach(function(e){i[e]=o[e]})}var c=g((t.pathname||t.hostname).replace("//","").split("/"),2),l=c[0],u=c[1];return{context:n,params:i,typeId:u||l}}function va(e){var t=(new DOMParser).parseFromString(e,"text/html");var n=Array.from(t.body.childNodes).map(function e(t){if(t.nodeType===Node.TEXT_NODE)return t.textContent||"";if(t.nodeType!==Node.ELEMENT_NODE)return"";var n=t,i=n.tagName.toLowerCase(),r=Array.from(n.childNodes).map(function(t){return e(t)}).join("");switch(i){case"p":return"".concat(r,"\n");case"br":return"\n";case"img":var o=n.getAttribute("src")||"",a=n.getAttribute("alt")||"";return o?"\n![".concat(a,"](").concat(o,")\n"):"";default:return t.textContent||""}}).join("").replace(/\n+/g,"\n").replace(/^\n|\n$/g,"");return n}function ma(e){var t,n=[],i="",r=m(e.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1">').split("\n"));try{for(r.s();!(t=r.n()).done;){var o=t.value.trim();o?o.startsWith("<img")&&o.endsWith(">")?(i&&(n.push("<p>".concat(i,"</p>")),i=""),n.push(o)):i?i+="<br>".concat(o):i=o:i&&(n.push("<p>".concat(i,"</p>")),i="")}}catch(a){r.e(a)}finally{r.f()}return i&&n.push("<p>".concat(i,"</p>")),n.join("")}function ga(e){if("string"!=typeof e||!e.trim())return{};var t=e.length,n=0;function i(){for(;n<t&&/\s/.test(e[n]);)n+=1}function r(){var i=function(n){for(var i="{"===e[n]?"}":"]",r=0,o=n;o<t;o+=1)if(e[o]===e[n])r+=1;else if(e[o]===i&&0==(r-=1))return o;return-1}(n);if(-1!==i)try{var r=JSON.parse(e.slice(n,i+1));return n=i+1,r}catch(o){return}}function o(){var a=arguments.length>0&&void 0!==arguments[0]&&arguments[0];i();var s=e[n];if("{"===s){var c=r();return void 0!==c?c:function(){var r={};if(n+=1,i(),"}"===e[n])return n+=1,r;for(;n<t;){i();for(var a=n;n<t&&"="!==e[n]&&","!==e[n]&&"}"!==e[n];)n+=1;var s=e.slice(a,n).trim();if(!s||"="!==e[n])break;if(n+=1,r[s]=o(),i(),","!==e[n]){"}"===e[n]&&(n+=1);break}n+=1}return r}()}if("["===s){for(var l=n+1;l<t&&/\s/.test(e[l]);)l+=1;if("]"===e[l]||"{"===e[l]){var u=r();return void 0!==u?u:function(){var r=[];if(n+=1,i(),"]"===e[n])return n+=1,r;for(;n<t;){if(r.push(o(!0)),i(),","!==e[n]){"]"===e[n]&&(n+=1);break}n+=1}return r}()}}for(var d,h=n;n<t&&","!==e[n]&&"}"!==e[n]&&(!a||"]"!==e[n]);)n+=1;return"true"===(d=e.slice(h,n).trim())||"false"!==d&&("null"===d?null:/^-?\d+$/.test(d)&&!/^-?0\d/.test(d)||/^-?\d+\.\d+$/.test(d)?Number(d):d)}i();var a=o();return"object"!==_(a)||null===a||Array.isArray(a)?{}:a}var ya=function(){return x(function e(){C(this,e)},null,[{key:"copy",value:function(e){return this.element||(this.element=document.createElement("textarea"),this.element.style.position="absolute",this.element.style.left="-9999px",document.body.appendChild(this.element)),this.element.value=e,this.element.select(),document.execCommand("copy")}}])}();T(ya,"element",null);var ka=function(){function e(){C(this,e)}return x(e,null,[{key:"checkDataBaseExists",value:(u=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,indexedDB.databases();case 1:return n=e.v,e.a(2,n.some(function(e){return e.name===t}));case 2:return e.p=2,i=e.v,console.error("检查数据库是否存在时出错:",i),e.a(2,!1)}},e,null,[[0,2]])})),function(e){return u.apply(this,arguments)})},{key:"deleteDatabase",value:(l=v(h().m(function t(n){var i,r;return h().w(function(t){for(;;)if(0===t.n)return e.lastLink&&(null===(i=(r=e.lastLink).close)||void 0===i||i.call(r)),t.a(2,new Promise(function(e,t){var i=indexedDB.deleteDatabase(n);i.onsuccess=function(){e(!0)},i.onerror=function(){e(!1)},i.onblocked=function(){console.warn("删除数据库 ".concat(n," 被阻塞,可能有其他连接正在使用该数据库。")),t(new Error("删除数据库 ".concat(n," 被阻塞")))}}))},t)})),function(e){return l.apply(this,arguments)})},{key:"checkTableExists",value:(c=v(h().m(function t(n,i){return h().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.checkDataBaseExists(n);case 1:if(t.v){t.n=2;break}return t.a(2,!1);case 2:return t.a(2,new Promise(function(t,r){var o=indexedDB.open(n);o.onupgradeneeded=function(t){e.db=t.target.result,e.version=e.db.version},o.onsuccess=function(n){e.db=n.target.result,e.lastLink=o.result;var r=e.db.objectStoreNames.contains(i);o.result.close(),t(r)},o.onerror=function(e){r(e.target.error)}}))}},t)})),function(e,t){return c.apply(this,arguments)})},{key:"createTable",value:(s=v(h().m(function t(n,i,r){var o,a=arguments;return h().w(function(t){for(;;)if(0===t.n)return o=a.length>3&&void 0!==a[3]&&a[3],t.a(2,new Promise(function(t){var a,s;e.version+=1,e.lastLink&&(null===(a=(s=e.lastLink).close)||void 0===a||a.call(s));var c=indexedDB.open(n,e.version);c.onupgradeneeded=function(t){if(e.db=t.target.result,!e.db.objectStoreNames.contains(i)){var n={};r?n.keyPath=r:o&&(n.autoIncrement=!0),e.db.createObjectStore(i,n)}},c.onsuccess=function(){e.lastLink=c.result,c.result.close(),t(!0)},c.onerror=function(){t(!1)}}))},t)})),function(e,t,n){return s.apply(this,arguments)})},{key:"deleteTable",value:(a=v(h().m(function t(n,i){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t){var r,o;e.version+=1,e.lastLink&&(null===(r=(o=e.lastLink).close)||void 0===r||r.call(o));var a=indexedDB.open(n,e.version);a.onupgradeneeded=function(t){e.db=t.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(i)&&e.db.deleteObjectStore(i)},a.onsuccess=function(n){e.db=n.target.result,e.lastLink=a.result,a.result.close(),t(!0)},a.onerror=function(){a.result.close(),t(!1)}}))},t)})),function(e,t){return a.apply(this,arguments)})},{key:"addData",value:(o=v(h().m(function t(n,i,r){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(i)){var o=e.db.transaction([i],"readwrite").objectStore(i).add(r);o.onsuccess=function(e){t(r)},o.onerror=function(){t(null)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return o.apply(this,arguments)})},{key:"deleteData",value:(r=v(h().m(function t(n,i,r){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(i)){var o=e.db.transaction([i],"readwrite").objectStore(i).delete(r);o.onsuccess=function(e){t(!0)},o.onerror=function(){t(!1)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return r.apply(this,arguments)})},{key:"updateData",value:(i=v(h().m(function t(n,i,r){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(i)){var o=e.db.transaction([i],"readwrite").objectStore(i).put(r);o.onsuccess=function(e){t(r)},o.onerror=function(){t(r)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return i.apply(this,arguments)})},{key:"getData",value:(n=v(h().m(function t(n,i,r){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(i)){var s=e.db.transaction([i],"readonly").objectStore(i).get(r);s.onsuccess=function(e){t(s.result)},s.onerror=function(){o(new Error("未找到数据".concat(r)))}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,i){return n.apply(this,arguments)})},{key:"getAllData",value:(t=v(h().m(function t(n,i){return h().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,r){var o=indexedDB.open(n);o.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=o.result,e.db.objectStoreNames.contains(i)){var r=e.db.transaction([i],"readonly").objectStore(i).getAll();r.onsuccess=function(e){t(r.result)},r.onerror=function(){t([])}}o.result.close()},o.onerror=function(){o.result.close(),r()}}))},t)})),function(e,n){return t.apply(this,arguments)})}]);var t,n,i,r,o,a,s,c,l,u}();T(ka,"version",1),T(ka,"db",null),T(ka,"lastLink",void 0);var wa=function(){return x(function e(t){C(this,e),T(this,"options",void 0),this.options=d({multiple:!0,accept:"*/*",maxSize:5242880},t)},[{key:"openFilePicker",value:function(){var e=this,t=document.createElement("input");t.type="file",t.multiple=this.options.multiple,t.accept=this.options.accept||"",t.onchange=function(t){var n=Array.from(t.target.files||[]);e.handleFiles(n)},t.click()}},{key:"handleFiles",value:(t=v(h().m(function e(t){var n,i,r,o=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(0!==t.length){e.n=1;break}return e.a(2);case 1:return r=t.filter(function(e){var t,n;return!(o.options.maxSize&&e.size>o.options.maxSize&&(null===(t=(n=o.options).onError)||void 0===t||t.call(n,new Error("文件大小超过限制 (".concat(o.formatSize(e.size)," > ").concat(o.formatSize(o.options.maxSize),")")),e),1))}),null===(n=(i=this.options).onSelect)||void 0===n||n.call(i,r),e.n=2,Promise.all(r.map(function(e){return o.processFile(e)}));case 2:return e.a(2)}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"processFile",value:(e=v(h().m(function e(t){var n,i,r,o,a,s,c,l,u,d=this;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,a=function(e){var n,i;null===(n=(i=d.options).onProgress)||void 0===n||n.call(i,t,e)},e.n=1,this.options.onUpload(t,a);case 1:s=e.v,null===(n=(i=this.options).onProgress)||void 0===n||n.call(i,t,100),null===(r=(o=this.options).onSuccess)||void 0===r||r.call(o,s,t),e.n=3;break;case 2:e.p=2,u=e.v,null===(c=(l=this.options).onError)||void 0===c||c.call(l,u instanceof Error?u:new Error("上传失败"),t);case 3:return e.a(2)}},e,this,[[0,2]])})),function(t){return e.apply(this,arguments)})},{key:"formatSize",value:function(e){if(0===e)return"0 B";var t=Math.floor(Math.log(e)/Math.log(1024));return"".concat((e/Math.pow(1024,t)).toFixed(2)," ").concat(["B","KB","MB","GB"][t])}}]);var e,t}(),ba=function(){return x(function e(){C(this,e)},null,[{key:"getCdataContent",value:function(e){if(!e)return null;var t=Array.from(e.childNodes).find(function(e){return e.nodeType===e.CDATA_SECTION_NODE});return(null==t?void 0:t.nodeValue)||e.textContent}},{key:"parse",value:function(e){var t=this,n=(new DOMParser).parseFromString(e,"text/xml");return Array.from(n.querySelectorAll("resource")).map(function(e){var n=e.getAttribute("type")||"",i=e.querySelector("data"),r=e.querySelector("metadata"),o=t.getCdataContent(i),a=t.getCdataContent(r),s={},c={};try{o&&(s=JSON.parse(o))}catch(vs){console.warn("解析 resource data 失败,已做容错处理",{value:o,error:vs})}try{a&&(c=JSON.parse(a))}catch(vs){console.warn("解析 resource metadata 失败,已做容错处理",{value:a,error:vs})}return{id:s.id,type:n,data:s,metadata:c}})}},{key:"parseMixedContent",value:function(e){if(!e)return{resources:[],remainingText:"",hasResources:!1};var t=/<resources\b[^>]*>[\s\S]*?<\/resources>/i.exec(e);if(!t)return{resources:[],remainingText:e,hasResources:!1};var n=g(t,1)[0],i=t.index,r=i+n.length,o=(e.slice(0,i)+e.slice(r)).replace(/\n/g,"").replace(/(!\[[^\]]*\]\([^)]+\))/g,"\n$1\n").replace(/\n+/g,"\n").replace(/^\n|\n$/g,"");try{return{resources:this.parse(n),remainingText:o,hasResources:!0}}catch(a){return{resources:[],remainingText:o,hasResources:!0,error:"资源解析失败: ".concat(a.message)}}}},{key:"stringify",value:function(e){var t=document.implementation.createDocument(null,null,null),n=t.createElement("resources");n.setAttribute("version","1.0");var i=function(e){return"\n".concat(" ".repeat(e))};return e.forEach(function(e){n.appendChild(t.createTextNode(i(1)));var r=t.createElement("resource");r.setAttribute("type",e.type),r.setAttribute("version","1.0");var o=function(e,n){var r=t.createElement(e);r.appendChild(t.createTextNode(i(2)));var o=t.createCDATASection(JSON.stringify(n));return r.appendChild(o),r.appendChild(t.createTextNode(i(1))),r};r.appendChild(t.createTextNode(i(2))),r.appendChild(o("data",e.data)),r.appendChild(t.createTextNode(i(2))),r.appendChild(o("metadata",e.metadata)),r.appendChild(t.createTextNode(i(1))),n.appendChild(r)}),n.appendChild(t.createTextNode("\n")),t.appendChild(n),(new XMLSerializer).serializeToString(t).replace(/></g,">\n<")}}])}(),Ca=function(){return x(function e(){C(this,e)},null,[{key:"getCdataContent",value:function(e){if(!e)return null;var t=Array.from(e.childNodes).find(function(e){return e.nodeType===e.CDATA_SECTION_NODE});return(null==t?void 0:t.nodeValue)||e.textContent}},{key:"parse",value:function(e){var t=this,n=(new DOMParser).parseFromString(e,"text/xml");return Array.from(n.querySelectorAll("suggestion")).map(function(e){var n=e.getAttribute("type")||"",i=e.querySelector("data"),r=e.querySelector("metadata"),o=t.getCdataContent(i),a=t.getCdataContent(r),s={},c={};try{o&&(s=JSON.parse(o))}catch(vs){console.warn("解析 suggestion data 失败,已做容错处理",{value:o,error:vs})}try{a&&(c=JSON.parse(a))}catch(vs){console.warn("解析 suggestion metadata 失败,已做容错处理",{value:a,error:vs})}return{type:n,data:s,metadata:c}})}},{key:"parseMixedContent",value:function(e){var t=/<suggestions\b[^>]*>[\s\S]*?<\/suggestions>/i.exec(e);if(!t)return{suggestions:[],remainingText:e,hasSuggestions:!1};var n=g(t,1)[0],i=t.index,r=i+n.length,o=(e.slice(0,i)+e.slice(r)).replace(/\n/g,"");try{return{suggestions:this.parse(n),remainingText:o,hasSuggestions:!0}}catch(a){return{suggestions:[],remainingText:o,hasSuggestions:!0,error:"资源解析失败: ".concat(a.message)}}}},{key:"stringify",value:function(e){var t=document.implementation.createDocument(null,null,null),n=t.createElement("suggestions");n.setAttribute("version","1.0");var i=function(e){return"\n".concat(" ".repeat(e))};return e.forEach(function(e){n.appendChild(t.createTextNode(i(1)));var r=t.createElement("suggestion");r.setAttribute("type",e.type),r.setAttribute("version","1.0");var o=function(e,n){var r=t.createElement(e);r.appendChild(t.createTextNode(i(2)));var o=t.createCDATASection(JSON.stringify(n));return r.appendChild(o),r.appendChild(t.createTextNode(i(1))),r};r.appendChild(t.createTextNode(i(2))),r.appendChild(o("data",e.data)),r.appendChild(t.createTextNode(i(2))),r.appendChild(o("metadata",e.metadata)),r.appendChild(t.createTextNode(i(1))),n.appendChild(r)}),n.appendChild(t.createTextNode("\n")),t.appendChild(n),(new XMLSerializer).serializeToString(t).replace(/></g,">\n<")}}])}();function Sa(e){return e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1}function xa(e,t,n,i){var r=e/window.innerWidth,o=t/window.innerHeight;return{x:Math.max(0,Math.min(r,1-n)),y:Math.max(0,Math.min(o,1-i))}}var Ta=function(){return x(function e(){C(this,e)},null,[{key:"parse",value:function(e){var t,n=e.replace(/<think>[\s\S]*?<\/think>/g,"").replace(/<chatstep>[\s\S]*?<\/chatstep>/g,""),i=(n.match(/<tool_call>/g)||[]).length===(n.match(/<\/tool_call>/g)||[]).length,r=new RegExp("<tool_call>\\s*({[\\s\\S]*?})\\s*</tool_call>","g"),o=[],a=m(n.matchAll(r));try{for(a.s();!(t=a.n()).done;){var s=t.value;try{var c=JSON.parse(s[1]),l={name:c.name,parameters:c.parameters,error:c.error||!1,type:c.type};if(c.result){var u=c.result;try{["desc_oss_image","fetch_chunks"].includes(c.type)&&(u=JSON.parse(c.result))}catch(d){console.warn("解析 ".concat(l.type," 工具调用结果失败,已做容错处理"),{value:c.result,error:d})}finally{Object.assign(l,{result:u})}}o.push(l)}catch(vs){console.warn("解析工具调用失败,已做容错处理",{value:s[1],error:vs})}}}catch(h){a.e(h)}finally{a.f()}return{completed:i,toolCalls:o}}}])}(),Ma=function(){return x(function e(){C(this,e)},null,[{key:"parse",value:function(e){var t,n=(e.match(/<chatstep>/g)||[]).length===(e.match(/<\/chatstep>/g)||[]).length,i=new RegExp("<chatstep>\\s*({[\\s\\S]*?})\\s*</chatstep>","g"),r=[],o=m(e.matchAll(i));try{for(o.s();!(t=o.n()).done;){var a=t.value;try{var s=JSON.parse(a[1]),c={title:s.title,content:s.content,status:s.status||"success"};r.push(c)}catch(vs){console.warn("解析聊天步骤失败,已做容错处理",{value:a[1],error:vs})}}}catch(p){o.e(p)}finally{o.f()}if(!n){for(var l=[],u=0;-1!==(u=e.indexOf("<chatstep>",u));)l.push(u),u+=10;var d=[];for(u=0;-1!==(u=e.indexOf("</chatstep>",u));)d.push(u),u+=11;for(var h=l.filter(function(e){return!d.find(function(t){return t>e})}),f=0;f<h.length;f++)r.push({title:"",content:"",status:"pending"})}return r}}])}(),_a=function(){return x(function e(){C(this,e)},null,[{key:"parse",value:function(e){var t=[],n=e.indexOf("<chatuiaction>"),i=e.indexOf("</chatuiaction>");if(-1===n||-1===i)return t;var r=e.substring(n,i+17);r=r.replace(/\\r/g,"\r").replace(/\\n/g,"\n");var o,a=new RegExp("<chatuiaction>\\s*({[\\s\\S]*?})\\s*</chatuiaction>","g"),s=m(r.matchAll(a));try{for(s.s();!(o=s.n()).done;){var l=o.value;try{var u=l[1].replace(/\\/g,"").replace(/"\[/g,"[").replace(/\]"/g,"]").replace(/\n/g,""),d=JSON.parse(u);d&&d.content&&d.content.length>0&&(t=c(d.content))}catch(vs){console.warn("解析聊天界面操作失败,已做容错处理",{value:l[1],error:vs})}}}catch(h){s.e(h)}finally{s.f()}return t}}])}(),Na=function(){function e(){C(this,e)}return x(e,null,[{key:"protect",value:function(t){return t?e.rules.reduce(function(e,t){return t(e)},t):t}},{key:"protectMermaid",value:function(e){return e.replace(/(```mermaid[^\n]*\n)([\s\S]*?)(```)/g,function(e,t,n,i){var r=n.replace(/([A-Za-z_][\w-]*)\s*(\[|\{)([^"'`\n[\]{}]+)(\]|\})/g,'$1$2"$3"$4');return"".concat(t).concat(r).concat(i)})}}])}();T(Na,"rules",[Na.protectMermaid]);var Oa,Ea,Aa,Da,Ia=0,La=[],Ra=ho,Pa=Ra.__b,za=Ra.__r,Ba=Ra.diffed,Ha=Ra.__c,Fa=Ra.unmount,ja=Ra.__;function Va(e,t){Ra.__h&&Ra.__h(Ea,e,Ia||t),Ia=0;var n=Ea.__H||(Ea.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Wa(e){return Ia=1,function(e,t,n){var i=Va(Oa++,2);if(i.t=e,!i.__c&&(i.__=[n?n(t):is(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],n=i.t(t,e);t!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=Ea,!Ea.__f)){var r=function(e,t,n){if(!i.__c.__H)return!0;var r=i.__c.__H.__.filter(function(e){return!!e.__c});if(r.every(function(e){return!e.__N}))return!o||o.call(this,e,t,n);var a=i.__c.props!==e;return r.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(a=!0)}}),o&&o.call(this,e,t,n)||a};Ea.__f=!0;var o=Ea.shouldComponentUpdate,a=Ea.componentWillUpdate;Ea.componentWillUpdate=function(e,t,n){if(this.__e){var i=o;o=void 0,r(e,t,n),o=i}a&&a.call(this,e,t,n)},Ea.shouldComponentUpdate=r}return i.__N||i.__}(is,e)}function $a(e,t){var n=Va(Oa++,3);!Ra.__s&&ns(n.__H,t)&&(n.__=e,n.u=t,Ea.__H.__h.push(n))}function Ua(e,t){var n=Va(Oa++,4);!Ra.__s&&ns(n.__H,t)&&(n.__=e,n.u=t,Ea.__h.push(n))}function qa(e){return Ia=5,Ja(function(){return{current:e}},[])}function Ka(e,t,n){Ia=6,Ua(function(){if("function"==typeof e){var n=e(t());return function(){e(null),n&&"function"==typeof n&&n()}}if(e)return e.current=t(),function(){return e.current=null}},null==n?n:n.concat(e))}function Ja(e,t){var n=Va(Oa++,7);return ns(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ga(e,t){return Ia=8,Ja(function(){return e},t)}function Ya(e){var t=Ea.context[e.__c],n=Va(Oa++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(Ea)),t.props.value):e.__}function Xa(){for(var e;e=La.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(es),e.__H.__h.forEach(ts),e.__H.__h=[]}catch(as){e.__H.__h=[],Ra.__e(as,e.__v)}}Ra.__b=function(e){Ea=null,Pa&&Pa(e)},Ra.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ja&&ja(e,t)},Ra.__r=function(e){za&&za(e),Oa=0;var t=(Ea=e.__c).__H;t&&(Aa===Ea?(t.__h=[],Ea.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(es),t.__h.forEach(ts),t.__h=[],Oa=0)),Aa=Ea},Ra.diffed=function(e){Ba&&Ba(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==La.push(t)&&Da===Ra.requestAnimationFrame||((Da=Ra.requestAnimationFrame)||Za)(Xa)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Aa=Ea=null},Ra.__c=function(e,t){t.some(function(e){try{e.__h.forEach(es),e.__h=e.__h.filter(function(e){return!e.__||ts(e)})}catch(Ea){t.some(function(e){e.__h&&(e.__h=[])}),t=[],Ra.__e(Ea,e.__v)}}),Ha&&Ha(e,t)},Ra.unmount=function(e){Fa&&Fa(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{es(e)}catch(e){t=e}}),n.__H=void 0,t&&Ra.__e(t,n.__v))};var Qa="function"==typeof requestAnimationFrame;function Za(e){var t,n=function(){clearTimeout(i),Qa&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,35);Qa&&(t=requestAnimationFrame(n))}function es(e){var t=Ea,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Ea=t}function ts(e){var t=Ea;e.__c=e.__(),Ea=t}function ns(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function is(e,t){return"function"==typeof t?t(e):t}var rs=Symbol.for("preact-signals");function as(){if(hs>1)hs--;else{for(var e,t=!1;void 0!==ds;){var n=ds;for(ds=void 0,fs++;void 0!==n;){var i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&ys(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=i}}if(fs=0,hs--,t)throw e}}var ss=void 0;function cs(e){var t=ss;ss=void 0;try{return e()}finally{ss=t}}var ls,us,ds=void 0,hs=0,fs=0,ps=0;function vs(e){if(void 0!==ss){var t=e.n;if(void 0===t||t.t!==ss)return t={i:0,S:e,p:ss.s,n:void 0,t:ss,e:void 0,x:void 0,r:t},void 0!==ss.s&&(ss.s.n=t),ss.s=t,e.n=t,32&ss.f&&e.S(t),t;if(-1===t.i)return t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=ss.s,t.n=void 0,ss.s.n=t,ss.s=t),t}}function ms(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function gs(e,t){return new ms(e,t)}function ys(e){for(var t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function ks(e){for(var t=e.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function ws(e){for(var t=e.s,n=void 0;void 0!==t;){var i=t.p;-1===t.i?(t.S.U(t),void 0!==i&&(i.n=t.n),void 0!==t.n&&(t.n.p=i)):n=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=i}e.s=n}function bs(e,t){ms.call(this,void 0),this.x=e,this.s=void 0,this.g=ps-1,this.f=4,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function Cs(e,t){return new bs(e,t)}function Ss(e){var t=e.u;if(e.u=void 0,"function"==typeof t){hs++;var n=ss;ss=void 0;try{t()}catch(as){throw e.f&=-2,e.f|=8,xs(e),as}finally{ss=n,as()}}}function xs(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ss(e)}function Ts(e){if(ss!==this)throw new Error("Out-of-order effect");ws(this),ss=e,this.f&=-2,8&this.f&&xs(this),as()}function Ms(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==t?void 0:t.name}function _s(e,t){var n=new Ms(e,t);try{n.c()}catch(e){throw n.d(),e}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}function Ns(e,t){ho[e]=t.bind(null,ho[e]||function(){})}function Os(e){us&&us(),us=e&&e.S()}function Es(e){var t=this,n=e.data,i=Ds(n);i.value=n;var r=Ja(function(){for(var e=t.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return t.__$u.c=function(){var e,n=t.__$u.S(),i=r.value;n(),po(i)||3!==(null==(e=t.base)?void 0:e.nodeType)?(t.__$f|=1,t.setState({})):t.base.data=i},Cs(function(){var e=i.value.value;return 0===e?0:!0===e?"":e||""})},[]);return r.value}function As(e,t,n,i){var r=t in e&&void 0===e.ownerSVGElement,o=gs(n);return{o:function(e,t){o.value=e,i=t},d:_s(function(){var n=o.value.value;i[t]!==n&&(i[t]=n,r?e[t]=n:n?e.setAttribute(t,n):e.removeAttribute(t))})}}function Ds(e){return Ja(function(){return gs(e)},[])}function Is(e){var t=qa(e);return t.current=e,ls.__$f|=4,Ja(function(){return Cs(function(){return t.current()})},[])}ms.prototype.brand=rs,ms.prototype.h=function(){return!0},ms.prototype.S=function(e){var t=this,n=this.t;n!==e&&void 0===e.e&&(e.x=n,this.t=e,void 0!==n?n.e=e:cs(function(){var e;null==(e=t.W)||e.call(t)}))},ms.prototype.U=function(e){var t=this;if(void 0!==this.t){var n=e.e,i=e.x;void 0!==n&&(n.x=i,e.e=void 0),void 0!==i&&(i.e=n,e.x=void 0),e===this.t&&(this.t=i,void 0===i&&cs(function(){var e;null==(e=t.Z)||e.call(t)}))}},ms.prototype.subscribe=function(e){var t=this;return _s(function(){var n=t.value,i=ss;ss=void 0;try{e(n)}finally{ss=i}},{name:"sub"})},ms.prototype.valueOf=function(){return this.value},ms.prototype.toString=function(){return this.value+""},ms.prototype.toJSON=function(){return this.value},ms.prototype.peek=function(){var e=ss;ss=void 0;try{return this.value}finally{ss=e}},Object.defineProperty(ms.prototype,"value",{get:function(){var e=vs(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(fs>100)throw new Error("Cycle detected");this.v=e,this.i++,ps++,hs++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{as()}}}}),bs.prototype=new ms,bs.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===ps)return!0;if(this.g=ps,this.f|=1,this.i>0&&!ys(this))return this.f&=-2,!0;var e=ss;try{ks(this),ss=this;var t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return ss=e,ws(this),this.f&=-2,!0},bs.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}ms.prototype.S.call(this,e)},bs.prototype.U=function(e){if(void 0!==this.t&&(ms.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}},bs.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(bs.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=vs(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Ms.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.u=t)}finally{e()}},Ms.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ss(this),ks(this),hs++;var e=ss;return ss=this,Ts.bind(this,e)},Ms.prototype.N=function(){2&this.f||(this.f|=2,this.o=ds,ds=this)},Ms.prototype.d=function(){this.f|=8,1&this.f||xs(this)},Ms.prototype.dispose=function(){this.d()},Es.displayName="_st",Object.defineProperties(ms.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Es},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Ns("__b",function(e,t){if("string"==typeof t.type){var n,i=t.props;for(var r in i)if("children"!==r){var o=i[r];o instanceof ms&&(n||(t.__np=n={}),n[r]=o,i[r]=o.peek())}}e(t)}),Ns("__r",function(e,t){Os();var n,i=t.__c;i&&(i.__$f&=-2,void 0===(n=i.__$u)&&(i.__$u=n=function(){var e;return _s(function(){e=this}),e.c=function(){i.__$f|=1,i.setState({})},e}())),ls=i,Os(n),e(t)}),Ns("__e",function(e,t,n,i){Os(),ls=void 0,e(t,n,i)}),Ns("diffed",function(e,t){var n;if(Os(),ls=void 0,"string"==typeof t.type&&(n=t.__e)){var i=t.__np,r=t.props;if(i){var o=n.U;if(o)for(var a in o){var s=o[a];void 0===s||a in i||(s.d(),o[a]=void 0)}else n.U=o={};for(var c in i){var l=o[c],u=i[c];void 0===l?(l=As(n,c,u,r),o[c]=l):l.o(u,r)}}}e(t)}),Ns("unmount",function(e,t){if("string"==typeof t.type){var n=t.__e;if(n){var i=n.U;if(i)for(var r in n.U=void 0,i){var o=i[r];o&&o.d()}}}else{var a=t.__c;if(a){var s=a.__$u;s&&(a.__$u=void 0,s.d())}}e(t)}),Ns("__h",function(e,t,n,i){(i<3||9===i)&&(t.__$f|=2),e(t,n,i)}),Io.prototype.shouldComponentUpdate=function(e,t){var n=this.__$u,i=n&&void 0!==n.s;for(var r in t)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(i||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(i||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var o in e)if("__source"!==o&&e[o]!==this.props[o])return!0;for(var a in this.props)if(!(a in e))return!0;return!1};var Ls=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M843.904 783.573333 783.573333 843.904 512.042667 572.373333 240.512 843.904 180.181333 783.573333 451.712 512.042667 180.181333 240.512 240.512 180.181333 512.042667 451.712 783.573333 180.181333 843.904 240.512 572.373333 512.042667 843.904 783.573333Z"})})},Rs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M900.64 379.808l-263.072-256.032c-36.448-35.328-105.76-35.392-142.304 0.096l-327.04 319.904c-56.416 54.72-70.72 76.704-70.72 150.976l0 143.936c0 132.768 26.976 192 186.912 192l131.872 0c81.12 0 128.448-46.656 193.952-111.264l290.016-297.696c18.592-17.984 29.248-43.968 29.248-71.264C929.504 423.36 918.976 397.6 900.64 379.808zM323.008 786.752c-52.928 0-96-43.072-96-96s43.072-96 96-96 96 43.072 96 96S375.936 786.752 323.008 786.752z"})})},Ps=function(e){return na("svg",{viewBox:"0 0 1024 1024",id:"send",className:e.className,version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M931.4 498.9L94.9 79.5c-3.4-1.7-7.3-2.1-11-1.2-8.5 2.1-13.8 10.7-11.7 19.3l86.2 352.2c1.3 5.3 5.2 9.6 10.4 11.3l147.7 50.7-147.6 50.7c-5.2 1.8-9.1 6-10.3 11.3L72.2 926.5c-0.9 3.7-0.5 7.6 1.2 10.9 3.9 7.9 13.5 11.1 21.5 7.2l836.5-417c3.1-1.5 5.6-4.1 7.2-7.1 3.9-8 0.7-17.6-7.2-21.6zM170.8 826.3l50.3-205.6 295.2-101.3c2.3-0.8 4.2-2.6 5-5 1.4-4.2-0.8-8.7-5-10.2L221.1 403 171 198.2l628 314.9-628.2 313.2z"})})},zs=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M962 197.61H747v-60c0-55.14-44.86-100-100-100H377c-55.14 0-100 44.86-100 100v60H62c-11.05 0-20 8.95-20 20s8.95 20 20 20h60v630.57c0 66.17 53.83 120 120 120h540c66.17 0 120-53.83 120-120V237.61h60c11.05 0 20-8.95 20-20s-8.95-20-20-20zM637.34 457.66v260c0 12.01-10.72 21.63-23.06 19.77-9.84-1.48-16.94-10.25-16.94-20.2V458.09c0-9.95 7.1-18.72 16.94-20.2 12.34-1.86 23.06 7.76 23.06 19.77z m-210.68 0v260c0 11-9 20-20 20s-20-9-20-20v-260c0-11 9-20 20-20s20 9 20 20zM317 137.61c0-33.08 26.92-60 60-60h270c33.08 0 60 26.92 60 60v60H317v-60z"})})},Bs=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M511.582491 63.413262C265.134543 63.413262 64.62588 263.921925 64.62588 510.369873s200.508663 446.957635 446.957635 446.957635 446.957635-200.508663 446.957635-446.957635S758.031463 63.413262 511.582491 63.413262zM509.001713 751.859903c-98.517781 0-182.467775-62.623269-214.771505-150.056598l0.327458-0.134053c-2.007727-4.036943-3.38305-8.422833-3.38305-13.237489 0-16.647145 13.494339-30.142507 30.142507-30.142507 13.389962 0 24.358781 8.877181 28.2893 20.955264l0.422625-0.172939c23.269983 65.442478 85.645612 112.503307 158.972665 112.503307 93.106538 0 168.845523-75.738985 168.845523-168.845523s-75.738985-168.845523-168.845523-168.845523c-20.432355 0-39.874149 3.980661-58.013275 10.66899l21.248953 40.742936c2.486634 2.677992 4.0175 6.2831 4.0175 10.243295 0 8.417717-8.404414 14.921851-15.365966 15.07023-0.102331 0-0.206708 0-0.309038 0-0.220011 0-0.427742 0-0.647753-0.013303l-150.579507-6.463202c-5.372358-0.234337-10.229992-3.310396-12.716626-8.093329-2.486634-4.76963-2.236947-10.509355 0.647753-15.055904l80.890308-127.179564c2.8847-4.533246 8.006348-7.151887 13.365402-6.960529 5.372358 0.234337 10.227945 3.312442 12.71458 8.095375l18.580171 35.625382c26.629497-10.855232 55.683207-16.963347 86.168522-16.963347 126.338407 0 229.130537 102.791108 229.130537 229.130537S635.340119 751.859903 509.001713 751.859903z"})})},Hs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M746.932 698.108",fill:"#A9B7B7"}),na("path",{d:"M925.731 288.698c-1.261-1.18-3.607-3.272-6.902-6.343-5.486-5.112-11.615-10.758-18.236-16.891-18.921-17.526-38.003-35.028-56.046-51.397-2.038-1.848-2.038-1.835-4.077-3.682-24.075-21.795-44.156-39.556-58.996-52.076-8.682-7.325-15.517-12.807-20.539-16.426-3.333-2.402-6.043-4.13-8.715-5.396-3.365-1.595-6.48-2.566-10.905-2.483C729.478 134.227 720 143.77 720 155.734l0 42.475 0 42.475 0 84.95L720 347l21.205 0L890 347l0 595L358.689 942C323.429 942 295 913.132 295 877.922L295 177l361.205 0c11.736 0 21.25-9.771 21.25-21.5s-9.514-21.5-21.25-21.5l-382.5 0L252 134l0 21.734L252 813l-52.421 0C166.646 813 140 786.928 140 754.678L140 72l566.286 0C739.29 72 766 98.154 766 130.404L766 134l40 0 0-3.596C806 76.596 761.271 33 706.286 33L119.958 33 100 33l0 19.506 0 702.172C100 808.463 144.642 852 199.579 852L252 852l0 25.922C252 936.612 299.979 984 358.689 984l552.515 0L932 984l0-21.237L932 325.635 932 304l0.433 0C932.432 299 930.196 292.878 925.731 288.698zM762 304l0-63.315L762 198.21l0-0.273c14 11.479 30.3 26.369 49.711 43.942 2.022 1.832 2.136 1.832 4.157 3.665 17.923 16.259 36.957 33.492 55.779 50.926 2.878 2.666 5.713 5.531 8.391 7.531L762 304.001z",fill:"currentColor"}),na("path",{d:"M816.936 436 407.295 436c-10.996 0-19.91 8.727-19.91 19.5 0 10.77 8.914 19.5 19.91 19.5l409.641 0c11 0 19.914-8.73 19.914-19.5C836.85 444.727 827.936 436 816.936 436z",fill:"currentColor"}),na("path",{d:"M816.936 553 407.295 553c-10.996 0-19.91 8.727-19.91 19.5 0 10.774 8.914 19.5 19.91 19.5l409.641 0c11 0 19.914-8.726 19.914-19.5C836.85 561.727 827.936 553 816.936 553z",fill:"currentColor"}),na("path",{d:"M816.936 689 407.295 689c-10.996 0-19.91 8.729-19.91 19.503 0 10.769 8.914 19.497 19.91 19.497l409.641 0c11 0 19.914-8.729 19.914-19.497C836.85 697.729 827.936 689 816.936 689z",fill:"currentColor"})]})},Fs=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M547.4 197.4v46l200.3 0.1L546.1 444l32.4 32.6 201.9-200.7v200.9h46V197.5zM471.4 584.4l-32.6-32.6L243.6 747V547.9h-46v278.7h279v-46H275z"})})},js=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M544 480V282.944h52.224l0.064 107.968L763.072 224l36.928 36.928-166.976 166.976 108.032-0.128V480H544zM260.928 800l-36.928-36.928 166.912-166.784-107.968-0.064V544H480v197.056h-52.224l0.064-107.968L260.928 800z"})})},Vs=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M960 544H64a32 32 0 1 1 0-64h896a32 32 0 1 1 0 64"})})},Ws=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[na("path",{d:"M481.0752 263.3728l50.9952 1.024 1.8432-105.8816-50.9952-0.8192z"}),na("path",{d:"M486.441426 180.895362a66.56 66.56 0 1 0 42.091944-126.290153 66.56 66.56 0 1 0-42.091944 126.290153Z"}),na("path",{d:"M138.8544 664.3712c-52.8384 0-95.8464-43.008-95.8464-95.8464s43.008-95.8464 95.8464-95.8464M880.0256 472.6784c52.8384 0 95.8464 43.008 95.8464 95.8464s-43.008 95.8464-95.8464 95.8464"}),na("path",{d:"M507.4944 220.5696c-220.16 0-398.7456 162.816-398.7456 363.7248s178.5856 363.7248 398.7456 363.7248 398.7456-162.816 398.7456-363.7248-178.5856-363.7248-398.7456-363.7248z m0 559.9232c-166.2976 0-301.2608-100.5568-301.2608-224.4608s134.9632-224.4608 301.2608-224.4608S808.7552 432.128 808.7552 556.032 673.792 780.4928 507.4944 780.4928z"}),na("path",{d:"M319.6928 556.032a47.9232 38.912 90 1 0 77.824 0 47.9232 38.912 90 1 0-77.824 0Z"}),na("path",{d:"M617.472 556.032a47.9232 38.912 90 1 0 77.824 0 47.9232 38.912 90 1 0-77.824 0Z"})]})},$s=function(){return na("svg",{viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[na("path",{d:"M5.856 17.121a.979.979 0 0 1-.327-.06.839.839 0 0 1-.283-.177.739.739 0 0 1-.187-.255.724.724 0 0 1-.07-.303l-.02-1.609a4.663 4.663 0 0 1-1.446-.455 4.252 4.252 0 0 1-.637-.401c-.199-.146-.385-.31-.553-.492a4.442 4.442 0 0 1-.45-.577 4.303 4.303 0 0 1-.327-.637 3.823 3.823 0 0 1-.206-.686 3.729 3.729 0 0 1-.064-.704V6.478c0-.261.025-.516.077-.771a4.43 4.43 0 0 1 .244-.747 4.062 4.062 0 0 1 .932-1.28c.2-.183.418-.347.65-.493.23-.145.482-.267.739-.364a4.21 4.21 0 0 1 .81-.225c.27-.054.553-.078.835-.078H8.55c.103 0 .2.018.29.054a.7.7 0 0 1 .411.376.667.667 0 0 1-.161.766.736.736 0 0 1-.25.151.764.764 0 0 1-.29.055H5.573c-.186 0-.366.012-.54.049-.18.03-.353.079-.52.145-.167.061-.328.14-.482.237-.148.091-.29.2-.418.316a2.897 2.897 0 0 0-.347.388c-.097.14-.187.286-.257.444a2.473 2.473 0 0 0-.206.977v4.287c0 .17.013.333.051.503a2.549 2.549 0 0 0 .772 1.33 2.721 2.721 0 0 0 .913.559c.167.066.347.115.527.152.18.03.36.048.546.048a.904.904 0 0 1 .61.23.848.848 0 0 1 .194.262.84.84 0 0 1 .07.303l.007.99 1.915-1.293a2.877 2.877 0 0 1 1.64-.492h2.372c.186 0 .366-.018.54-.048.18-.03.353-.08.52-.146.168-.067.329-.146.483-.237.148-.091.29-.2.418-.316.128-.121.244-.249.347-.388a2.8 2.8 0 0 0 .257-.444 2.47 2.47 0 0 0 .206-.977V8.585a.646.646 0 0 1 .225-.492.679.679 0 0 1 .244-.152.814.814 0 0 1 .585 0c.09.03.174.085.244.152a.657.657 0 0 1 .225.492V10.8c0 .261-.032.516-.083.771a4.192 4.192 0 0 1-.245.74c-.109.244-.244.468-.398.687a3.735 3.735 0 0 1-.534.6c-.2.183-.418.347-.65.493a4.134 4.134 0 0 1-.738.364 4.7 4.7 0 0 1-.81.225c-.27.054-.553.079-.836.079h-1.877c-.604 0-1.144.164-1.633.491l-2.54 1.713a.913.913 0 0 1-.514.157z",fill:"currentColor"}),na("path",{d:"M15.866 4.125h-4.174c-.41 0-.741.313-.741.7 0 .387.332.7.741.7h4.174c.41 0 .742-.313.742-.7 0-.387-.332-.7-.742-.7z",fill:"currentColor"}),na("path",{d:"M14.537 2.932c0-.396-.34-.717-.759-.717s-.758.32-.758.717v3.786c0 .396.34.717.758.717.42 0 .76-.321.76-.717V2.932z",fill:"currentColor"})]})},Us=function(){return na("svg",{viewBox:"64 64 896 896",focusable:"false",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",children:na("path",{d:"M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"})})},qs=function(){var e=1e3,t=140,n=250,i=.8;return na("svg",{fill:"currentColor",viewBox:"0 0 ".concat(e," ").concat(e),xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",children:Array.from({length:4}).map(function(e,r){return na("rect",{fill:"currentColor",rx:70,ry:70,height:n,width:t,x:r*(440/3+t),y:375,children:[na("animate",{attributeName:"height",values:"".concat(n,"; ").concat(500,"; ").concat(n),keyTimes:"0; 0.5; 1",dur:"".concat(i,"s"),begin:"".concat(.2*r,"s"),repeatCount:"indefinite"}),na("animate",{attributeName:"y",values:"".concat(375,"; ").concat(250,"; ").concat(375),keyTimes:"0; 0.5; 1",dur:"".concat(i,"s"),begin:"".concat(.2*r,"s"),repeatCount:"indefinite"})]},r)})})},Ks=function(e){return na("svg",{className:e.className,onClick:e.onClick,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M128 384a128 128 0 1 1 0 256 128 128 0 0 1 0-256z m768 0a128 128 0 1 1 0 256 128 128 0 0 1 0-256z m-372.4288 0a128 128 0 1 1 0 256 128 128 0 0 1 0-256z"})})},Js=function(e){return na("svg",{className:e.className,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M498.33984 607.8464c-10.99776-32.9728-50.09408-73.5232-82.6368-85.74976L150.9376 422.8096c-38.54336-14.4384-36.98688-69.46816 2.27328-81.73568L844.92288 124.90752c33.30048-10.40384 64.57344 20.8896 54.1696 54.1696L682.92608 870.78912a43.2128 43.2128 0 0 1-81.36704 3.25632 121682.5344 121682.5344 0 0 1-103.2192-266.19904z"})})},Gs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M972.657609 209.348408C987.158609 209.36839 998.930114 197.571202 998.949999 182.99865 998.969882 168.426097 987.230618 156.59651 972.729617 156.576528L32.457975 155.280806C17.956974 155.260823 6.18547 167.058012 6.165585 181.630564 6.1457 196.203116 17.884965 208.032703 32.385966 208.052686L972.657609 209.348408ZM180.466902 992.356169 180.466902 1019.014859 206.993296 1018.74074 833.361858 1012.267947 859.348284 1011.999407 859.348284 985.883377 859.348284 289.397297C859.348284 274.824732 847.59289 263.011332 833.091874 263.011332 818.590859 263.011332 806.835465 274.824732 806.835465 289.397297L806.835465 985.883377 832.82189 959.498805 206.453329 965.971599 232.979723 992.356169 232.979723 282.67005C232.979723 268.097483 221.224329 256.284085 206.723313 256.284085 192.222298 256.284085 180.466902 268.097483 180.466902 282.67005L180.466902 992.356169ZM656.410257 847.079027C656.410257 861.651593 668.165651 873.464992 682.666667 873.464992 697.167682 873.464992 708.923076 861.651593 708.923076 847.079027L708.923076 372.131659C708.923076 357.559091 697.167682 345.745694 682.666667 345.745694 668.165651 345.745694 656.410257 357.559091 656.410257 372.131659L656.410257 847.079027ZM341.333333 847.079027C341.333333 861.651593 353.08873 873.464992 367.589743 873.464992 382.090758 873.464992 393.846155 861.651593 393.846155 847.079027L393.846155 372.131659C393.846155 357.559091 382.090758 345.745694 367.589743 345.745694 353.08873 345.745694 341.333333 357.559091 341.333333 372.131659L341.333333 847.079027ZM498.871795 847.079027C498.871795 861.651593 510.627189 873.464992 525.128205 873.464992 539.62922 873.464992 551.384614 861.651593 551.384614 847.079027L551.384614 372.131659C551.384614 357.559091 539.62922 345.745694 525.128205 345.745694 510.627189 345.745694 498.871795 357.559091 498.871795 372.131659L498.871795 847.079027ZM392.147755 116.721777C392.147755 102.063669 403.758665 90.363507 418.40134 90.363507L622.925796 90.363507C637.408947 90.363507 649.179381 102.1619 649.179381 116.549585L649.179381 171.644875 701.692203 171.644875 701.692203 116.549585C701.692203 72.986607 666.38105 37.591577 622.925796 37.591577L418.40134 37.591577C374.724427 37.591577 339.634933 72.950804 339.634933 116.721777L339.634933 165.310801 392.147755 165.310801 392.147755 116.721777Z"})})},Ys=function(e){return na("svg",{className:e.className,width:"16",height:"16",viewBox:"0 0 50 50",xmlns:"http://www.w3.org/2000/svg",children:na("circle",{cx:"25",cy:"25",r:"20",stroke:"currentColor",strokeWidth:"5",fill:"none",strokeDasharray:"31.415, 31.415",strokeLinecap:"round",children:na("animateTransform",{attributeName:"transform",type:"rotate",from:"0 25 25",to:"360 25 25",dur:"1s",repeatCount:"indefinite"})})})},Xs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M512 61.44a40.96 40.96 0 0 1 40.96 40.96v122.88a40.96 40.96 0 1 1-81.92 0V102.4A40.96 40.96 0 0 1 512 61.44z",fill:"currentColor",opacity:".9"}),na("path",{d:"M737.28 121.792a40.96 40.96 0 0 1 14.992 55.952l-61.44 106.432a40.96 40.96 0 1 1-70.944-40.96l61.44-106.432a40.96 40.96 0 0 1 55.952-14.992z",fill:"currentColor",opacity:".8"}),na("path",{d:"M902.208 286.72a40.96 40.96 0 0 1-14.992 55.952l-106.432 61.44a40.96 40.96 0 0 1-40.96-70.944l106.432-61.44a40.96 40.96 0 0 1 55.952 14.992z",fill:"currentColor",opacity:".76"}),na("path",{d:"M962.56 512a40.96 40.96 0 0 1-40.96 40.96h-122.88a40.96 40.96 0 1 1 0-81.92h122.88A40.96 40.96 0 0 1 962.56 512z",fill:"currentColor",opacity:".7"}),na("path",{d:"M902.208 737.28a40.96 40.96 0 0 1-55.952 14.992l-106.432-61.44a40.96 40.96 0 1 1 40.96-70.944l106.432 61.44a40.96 40.96 0 0 1 14.992 55.952z",fill:"currentColor",opacity:".6"}),na("path",{d:"M737.28 902.208a40.96 40.96 0 0 1-55.952-14.992l-61.44-106.432a40.96 40.96 0 0 1 70.944-40.96l61.44 106.432a40.96 40.96 0 0 1-14.992 55.952z",fill:"currentColor",opacity:".5"}),na("path",{d:"M512 962.56a40.96 40.96 0 0 1-40.96-40.96v-122.88a40.96 40.96 0 1 1 81.92 0v122.88A40.96 40.96 0 0 1 512 962.56z",fill:"currentColor",opacity:".4"}),na("path",{d:"M286.72 902.208a40.96 40.96 0 0 1-14.992-55.952l61.44-106.432a40.96 40.96 0 1 1 70.944 40.96l-61.44 106.432a40.96 40.96 0 0 1-55.952 14.992z",fill:"currentColor",opacity:".3"}),na("path",{d:"M121.792 737.28a40.96 40.96 0 0 1 14.992-55.952l106.432-61.44a40.96 40.96 0 0 1 40.96 70.944l-106.432 61.44a40.96 40.96 0 0 1-55.952-14.992z",fill:"currentColor",opacity:".2"}),na("path",{d:"M61.44 512a40.96 40.96 0 0 1 40.96-40.96h122.88a40.96 40.96 0 1 1 0 81.92H102.4A40.96 40.96 0 0 1 61.44 512z",fill:"currentColor",opacity:".1"}),na("path",{d:"M121.792 286.72a40.96 40.96 0 0 1 55.952-14.992l106.432 61.44a40.96 40.96 0 1 1-40.96 70.944l-106.432-61.44a40.96 40.96 0 0 1-14.992-55.952z",fill:"currentColor",opacity:".04"}),na("path",{d:"M286.72 121.792a40.96 40.96 0 0 1 55.952 14.992l61.44 106.432a40.96 40.96 0 0 1-70.944 40.96l-61.44-106.432a40.96 40.96 0 0 1 14.992-55.952z",fill:"currentColor"})]})},Qs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:na("path",{d:"M704 256v490.666667a170.666667 170.666667 0 0 1-170.666667 170.666666 170.666667 170.666667 0 0 1-170.666666-170.666666V213.333333A106.666667 106.666667 0 0 1 469.333333 106.666667 106.666667 106.666667 0 0 1 576 213.333333v448a42.666667 42.666667 0 0 1-42.666667 42.666667 42.666667 42.666667 0 0 1-42.666666-42.666667V256H426.666667v405.333333a106.666667 106.666667 0 0 0 106.666666 106.666667 106.666667 106.666667 0 0 0 106.666667-106.666667V213.333333a170.666667 170.666667 0 0 0-170.666667-170.666666 170.666667 170.666667 0 0 0-170.666666 170.666666v533.333334a234.666667 234.666667 0 0 0 234.666666 234.666666 234.666667 234.666667 0 0 0 234.666667-234.666666V256h-64z"})})},Zs=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[na("path",{d:"M842.666667 285.866667l-187.733334-187.733334c-14.933333-14.933333-32-21.333333-53.333333-21.333333H234.666667C194.133333 74.666667 160 108.8 160 149.333333v725.333334c0 40.533333 34.133333 74.666667 74.666667 74.666666h554.666666c40.533333 0 74.666667-34.133333 74.666667-74.666666V337.066667c0-19.2-8.533333-38.4-21.333333-51.2z m-44.8 44.8c-2.133333 2.133333-4.266667 0-8.533334 0h-170.666666c-6.4 0-10.666667-4.266667-10.666667-10.666667V149.333333c0-2.133333 0-6.4-2.133333-8.533333 0 0 2.133333 0 2.133333 2.133333l189.866667 187.733334z m-8.533334 554.666666H234.666667c-6.4 0-10.666667-4.266667-10.666667-10.666666V149.333333c0-6.4 4.266667-10.666667 10.666667-10.666666h311.466666c-2.133333 4.266667-2.133333 6.4-2.133333 10.666666v170.666667c0 40.533333 34.133333 74.666667 74.666667 74.666667h170.666666c4.266667 0 6.4 0 10.666667-2.133334V874.666667c0 6.4-4.266667 10.666667-10.666667 10.666666z",fill:"currentColor"}),na("path",{d:"M640 693.333333H341.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h298.666667c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM640 522.666667H341.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h298.666667c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM341.333333 416h85.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-85.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32z",fill:"currentColor"})]})},ec=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:na("path",{d:"M557.248 511.68l135.776-135.744-45.248-45.28L512 466.432l-135.776-135.776-45.248 45.28 135.776 135.744-135.776 135.776 45.248 45.248L512 556.928l135.776 135.776 45.248-45.248-135.776-135.776zM512 64c247.136 0 448 200.864 448 448s-200.864 448-448 448S64 759.136 64 512 264.864 64 512 64z",fill:"currentColor"})})},tc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:na("path",{d:"M512.43945313 904.51953125c-6.06445313 0-12.12890625-1.58203125-17.57812501-4.74609375L136.70703125 689.71484375c-10.63476563-6.24023438-17.13867188-17.66601563-17.13867188-29.97070313s6.50390625-23.73046875 17.13867188-29.97070312l76.37695313-44.91210938L136.97070312 540.125c-10.63476563-6.24023438-17.13867188-17.66601563-17.13867187-29.97070313s6.50390625-23.73046875 17.13867188-29.97070312l73.38867187-43.15429688-73.125-42.890625C126.51171875 387.81054687 120.0078125 376.38476562 120.0078125 364.08007812c0-12.3046875 6.50390625-23.73046875 17.13867188-29.97070312L495.828125 122.99609375c10.8984375-6.41601563 24.34570313-6.41601563 35.24414063 0l358.15429687 210.05859375c10.63476563 6.24023438 17.13867188 17.66601563 17.13867188 29.97070313s-6.50390625 23.73046875-17.13867188 29.97070312l-73.38867188 43.15429688 73.12500001 42.890625c10.63476563 6.24023438 17.13867188 17.66601563 17.13867187 29.97070312s-6.50390625 23.73046875-17.13867187 29.97070313L812.5859375 583.89453125l76.11328125 44.6484375c10.63476563 6.24023438 17.13867188 17.66601563 17.13867188 29.97070313s-6.50390625 23.73046875-17.13867188 29.97070312l-358.59375 211.2890625c-5.44921875 3.1640625-11.6015625 4.74609375-17.66601563 4.74609375zM223.015625 659.65625l289.42382813 169.8046875 290.12695312-170.77148438-58.44726563-34.27734374L530.28125 750.18359375a34.67285156 34.67285156 0 0 1-35.24414063 0L281.7265625 625.02734375 223.015625 659.65625z m76.90429688-104.58984375l212.69531249 124.8046875 290.12695313-170.77148438-55.546875-32.60742187-216.65039063 127.6171875a34.67285156 34.67285156 0 0 1-35.24414062 0L279.00195312 477.28320312l-55.81054687 32.78320313 75.49804688 44.296875c0.43945313 0.26367188 0.79101563 0.52734375 1.23046874 0.703125z m-2.81250001-147.83203125l215.68359376 126.5625 216.12304687-127.17773438c0.3515625-0.26367188 0.703125-0.43945313 1.0546875-0.61523437l72.86132813-42.890625-289.33593751-169.8046875-290.12695312 170.68359375 72.59765625 42.62695313c0.43945313 0.17578125 0.79101563 0.43945313 1.14257813 0.61523437z"})})},nc=function(e){return na("svg",{className:e.className,id:"stop",viewBox:"0 0 1025 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[na("path",{d:"M512.268258 1022.835842c-68.658678 0-135.399619-13.564433-198.369591-40.316509-60.752236-25.809077-115.373446-62.712976-162.346233-109.685763-46.971763-46.971763-83.875662-101.592974-109.685763-162.346233C15.115619 647.517366 1.551186 580.777449 1.551186 512.118771S15.115619 376.719151 41.866671 313.74918c25.810101-60.752236 62.714-115.373446 109.685763-162.346233 46.972787-46.971763 101.593997-83.875662 162.346233-109.685763 62.969971-26.751052 129.710912-40.315485 198.369591-40.315485s135.398595 13.564433 198.368567 40.315485c60.752236 25.810101 115.373446 62.714 162.346233 109.685763 46.971763 46.972787 83.875662 101.593997 109.685763 162.346233 26.752076 62.969971 40.316509 129.710912 40.316509 198.369591s-13.564433 135.398595-40.316509 198.368567c-25.809077 60.75326-62.712976 115.37447-109.685763 162.346233-46.971763 46.972787-101.592974 83.876686-162.346233 109.685763C647.666853 1009.27141 580.925912 1022.835842 512.268258 1022.835842zM512.268258 50.548195c-62.018782 0-122.293887 12.247716-179.152287 36.403219-54.923257 23.333323-104.317532 56.709936-146.810821 99.204249s-75.870926 91.888588-99.204249 146.810821c-24.155503 56.8584-36.403219 117.133505-36.403219 179.152287 0 62.017758 12.247716 122.292863 36.403219 179.152287 23.333323 54.923257 56.709936 104.317532 99.204249 146.811845 42.493289 42.493289 91.888588 75.870926 146.810821 99.204249 56.8584 24.155503 117.133505 36.403219 179.152287 36.403219 62.017758 0 122.292863-12.247716 179.152287-36.403219 54.923257-23.333323 104.317532-56.71096 146.811845-99.204249 42.493289-42.494313 75.870926-91.888588 99.204249-146.811845 24.155503-56.8584 36.403219-117.133505 36.403219-179.152287s-12.247716-122.293887-36.403219-179.152287c-23.334347-54.923257-56.71096-104.317532-99.205273-146.810821-42.493289-42.493289-91.887565-75.870926-146.810821-99.204249C634.561121 62.795911 574.286016 50.548195 512.268258 50.548195z",fill:"currentColor"}),na("path",{d:"M655.434047 694.244421 367.12637 694.244421c-21.046987 0-38.170445-17.123458-38.170445-38.170445L328.955925 367.766298c0-21.046987 17.123458-38.170445 38.170445-38.170445l288.307678 0c21.048011 0 38.170445 17.123458 38.170445 38.170445l0 288.307678C693.604492 677.120962 676.482058 694.244421 655.434047 694.244421zM380.150191 643.050154l262.260035 0L642.410226 380.79012 380.150191 380.79012 380.150191 643.050154z",fill:"currentColor"})]})},ic=function(e){return na("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,viewBox:"0 0 512 512",children:na("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})})},rc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[na("path",{d:"M394.688 126.208a32 32 0 0 1 32-32h170.688a32 32 0 0 1 32 32v138.624h288a32 32 0 0 1 32 32v170.688a32 32 0 0 1-32 32H106.688a32 32 0 0 1-32-32V296.832a32 32 0 0 1 32-32h288V126.208z m64 32v138.624a32 32 0 0 1-32 32h-288v106.688h746.688V328.832h-288a32 32 0 0 1-32-32V158.208H458.688z"}),na("path",{d:"M138.688 469.376a32 32 0 0 1 32-32h682.688a32 32 0 0 1 32 32v384a32 32 0 0 1-32 32H170.688a32 32 0 0 1-32-32v-384z m64 32v320h618.688v-320H202.688z"}),na("path",{d:"M341.376 691.52a32 32 0 0 1 32 32V851.2a32 32 0 1 1-64 0v-127.68a32 32 0 0 1 32-32zM512 691.2a32 32 0 0 1 32 32v128a32 32 0 0 1-64 0v-128a32 32 0 0 1 32-32zM682.688 691.52a32 32 0 0 1 32 32V851.2a32 32 0 1 1-64 0v-127.68a32 32 0 0 1 32-32z"})]})},oc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:na("path",{d:"M843.251 424.407l43.828-74.898c10.194-17.946 32.596-22.158 48.956-11.598 16.298 10.499 23.44 32.658 14.223 49.566l-113.11 195.212-61.164-40.044-126.418-82.285c-16.115-11.598-20.632-34.428-10.194-51.702 9.705-17.397 31.009-23.501 47.857-13.734l89.67 59.028C748.576 295.547 615.81 180.667 461.008 180.667c-177.387 0-320.042 148.758-320.042 331.335 0 183.613 143.692 331.334 319.981 331.334 107.861 0.184 208.58-56.158 268.034-149.858 1.099-1.038 1.099-2.075 2.075-2.075 6.348-9.949 17.092-15.871 28.568-15.81 19.35 0 35.648 16.848 35.648 36.93 0 7.508-2.137 14.833-6.104 21.059-72.823 114.698-196.066 183.675-328.099 183.614-216.088 0-391.4-181.478-391.4-405.195 0-223.718 175.312-405.195 391.339-405.195 183.125-0.427 342.016 131.606 382.243 317.601z"})})},ac=function(){return na("svg",{version:"1.1",className:"icon",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M627.498667 55.168l170.666666 170.666667a42.624 42.624 0 0 1 0 60.330666l-469.333333 469.333334A42.538667 42.538667 0 0 1 298.666667 768H128a42.666667 42.666667 0 0 1-42.666667-42.666667v-170.666666c0-11.306667 4.48-22.186667 12.501334-30.165334l469.333333-469.333333a42.624 42.624 0 0 1 60.330667 0zM896 896a42.666667 42.666667 0 0 1 0 85.333333H128a42.666667 42.666667 0 0 1 0-85.333333h768zM597.333333 145.664l-426.666666 426.666667V682.666667h110.336l426.666666-426.666667L597.333333 145.664z"})})},sc=function(e){return na("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,viewBox:"0 0 512 512",children:na("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M184 112l144 144-144 144"})})},cc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M896 870.4l-128-128c55.467-68.267 89.6-149.333 89.6-238.933 0-98.134-38.4-192-110.933-264.534-149.334-149.333-384-149.333-533.334-4.266-145.066 145.066-145.066 384 0 529.066 72.534 72.534 166.4 110.934 264.534 110.934 89.6 0 174.933-29.867 238.933-89.6l128 128c4.267 4.266 12.8 8.533 21.333 8.533s17.067-4.267 21.334-8.533c17.066-8.534 17.066-29.867 8.533-42.667zM260.267 721.067c-119.467-123.734-119.467-320 0-439.467 59.733-59.733 140.8-89.6 217.6-89.6 81.066 0 157.866 29.867 217.6 89.6 59.733 59.733 89.6 136.533 89.6 217.6 0 81.067-34.134 162.133-89.6 217.6-55.467 59.733-132.267 93.867-217.6 93.867-81.067 0-157.867-34.134-217.6-89.6z"})})},lc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",width:"1em",height:"1em",children:na("path",{d:"M497.0496 55.7056a38.4 38.4 0 0 1 38.912 0l362.7008 213.2992c11.776 6.912 18.944 19.456 18.944 33.1264v426.6496a38.4 38.4 0 0 1-18.944 33.0752l-362.6496 213.3504a38.4 38.4 0 0 1-38.912 0L134.3488 761.856a38.4 38.4 0 0 1-18.944-33.0752V302.1312a38.4 38.4 0 0 1 18.944-33.1264z m19.456 77.6192L192.3072 324.096v382.72l324.3008 190.7712 324.2496-190.7712V324.096l-324.2496-190.7712zM345.9584 370.3296c7.68 0 14.848 2.2528 20.8384 6.144l149.6576 93.696 149.8624-93.696a38.4512 38.4512 0 0 1 49.1008 58.2656l-1.792 1.792a38.6048 38.6048 0 0 1-6.656 5.12l-152.0128 94.976v170.4448a38.4 38.4 0 0 1-0.1536 3.7376l-0.512 3.7376a38.0928 38.0928 0 0 1-23.04 27.9552 38.0928 38.0928 0 0 1-35.9936-3.5328 38.1952 38.1952 0 0 1-17.0496-31.8976v-170.2912l-152.064-95.1296a38.4 38.4 0 0 1 19.7632-71.3216z"})})},uc=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return na("svg",{className:e.className?"icon ".concat(e.className):"icon",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",width:"1em",height:"1em",children:na("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})},dc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[na("path",{d:"M190.193225 471.411583c14.446014 0 26.139334-11.718903 26.139334-26.13831 0-14.44499-11.69332-26.164916-26.139334-26.164916-0.271176 0-0.490164 0.149403-0.73678 0.149403l-62.496379 0.146333c-1.425466-0.195451-2.90005-0.295735-4.373611-0.295735-19.677155 0-35.621289 16.141632-35.621289 36.114522L86.622358 888.550075c0 19.949354 15.96767 35.597753 35.670407 35.597753 1.916653 0 3.808746 0.292666 5.649674 0l61.022819 0.022513c0.099261 0 0.148379 0.048095 0.24764 0.048095 0.097214 0 0.146333-0.048095 0.24457-0.048095l0.73678 0 0-0.148379c13.413498-0.540306 24.174586-11.422144 24.174586-24.960485 0-13.55983-10.760065-24.441669-24.174586-24.981974l0-0.393973-50.949392 0 1.450025-402.275993L190.193225 471.409536z"}),na("path",{d:"M926.52241 433.948343c-19.283182-31.445176-47.339168-44.172035-81.289398-45.546336-1.77032-0.246617-3.536546-0.39295-5.380544-0.39295l-205.447139-0.688685c13.462616-39.059598 22.698978-85.58933 22.698978-129.317251 0-28.349675-3.193739-55.962569-9.041934-82.542948l-0.490164 0.049119c-10.638291-46.578852-51.736315-81.31498-100.966553-81.31498-57.264215 0-95.466282 48.15065-95.466282 106.126063 0 3.241834-0.294712 6.387477 0 9.532097-2.996241 108.386546-91.240027 195.548698-196.23636 207.513194l0 54.881958-0.785899 222.227314 0 229.744521 10.709923 0 500.025271 0.222057 8.746198-0.243547c19.35686 0.049119 30.239721-4.817726 47.803749-16.116049 16.682961-10.761088 29.236881-25.50079 37.490869-42.156122 2.260483-3.341095 4.028757-7.075139 5.106298-11.20111l77.018118-344.324116c1.056052-4.053316 1.348718-8.181333 1.056052-12.160971C943.643346 476.446249 938.781618 453.944769 926.52241 433.948343zM893.82573 486.837924l-82.983993 367.783411-0.099261-0.049119c-2.555196 6.141884-6.879688 11.596106-12.872169 15.427364-4.177136 2.727111-8.773827 4.351098-13.414521 4.964058-1.49812-0.195451-3.046383 0-4.620227 0l-477.028511-0.540306-0.171915-407.408897c89.323375-40.266076 154.841577-79.670527 188.596356-173.661202 0.072655 0.024559 0.124843 0.049119 0.195451 0.072655 2.99931-9.137101 6.313799-20.73423 8.697079-33.164331 5.551436-29.185716 5.258771-58.123792 5.258771-58.123792-4.937452-37.98001 25.940812-52.965306 44.364417-52.965306 25.304316 0.860601 50.263777 33.656541 50.263777 52.326762 0 0 5.600555 27.563776 5.649674 57.190537 0.048095 37.366026-4.6673 56.847729-4.6673 56.847729l-0.466628 0c-5.872754 30.879288-16.214287 60.138682-30.464849 86.964654l0.36839 0.342808c-2.358721 4.815679-3.709485 10.220782-3.709485 15.943111 0 19.922748 19.088754 21.742187 38.765909 21.742187l238.761895 0.270153c0 0 14.666024 0.465604 14.690584 0.465604l0 0.100284c12.132318-0.638543 24.221658 5.207605 31.100322 16.409738 5.504364 9.016351 6.437619 19.6045 3.486404 28.988218L893.82573 486.837924z"}),na("path",{d:"M264.827039 924.31872c0.319272 0.024559 0.441045 0.024559 0.295735-0.024559 0.243547-0.048095 0.367367-0.074701-0.295735-0.074701s-0.539282 0.026606-0.271176 0.074701C264.43409 924.343279 264.532327 924.343279 264.827039 924.31872z"})]})},hc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:na("path",{d:"M190.208 552.576a26.176 26.176 0 0 1 0 52.288L189.44 604.8l-62.464-0.128a35.84 35.84 0 0 1-40-35.84l-0.384-433.28c0-19.968 16-35.648 35.712-35.648 1.92 0 3.84-0.256 5.632 0h62.272v0.128c13.44 0.576 24.192 11.456 24.192 24.96a25.024 25.024 0 0 1-24.192 24.96v0.448h-50.944l1.408 402.24h49.536z m736.32 37.504c-19.264 31.36-47.36 44.16-81.28 45.504a38.656 38.656 0 0 1-5.376 0.384l-205.44 0.704c13.44 39.04 22.656 85.568 22.656 129.28 0 28.416-3.2 56-9.024 82.56h-0.512a103.936 103.936 0 0 1-100.928 81.28c-57.28 0-95.488-48.128-95.488-106.112 0-3.2-0.32-6.4 0-9.536-3.008-108.352-91.264-195.52-196.224-207.488V551.68L254.08 329.6v-229.76h10.688l500.032-0.192 8.704 0.192c19.392 0 30.272 4.864 47.808 16.128 16.704 10.752 29.248 25.536 37.504 42.176 2.304 3.328 4.032 7.04 5.12 11.2l76.992 344.32a37.568 37.568 0 0 1 1.088 12.16c1.536 21.76-3.328 44.288-15.552 64.32z m-32.704-52.928l-83.008-367.744h-0.064a33.408 33.408 0 0 0-26.24-20.352c-1.536 0.192-3.072 0-4.672 0l-477.056 0.512-0.128 407.424c89.28 40.32 154.88 79.68 188.544 173.632h0.256c2.944 9.088 6.272 20.672 8.64 33.088 5.568 29.184 5.312 58.176 5.312 58.176-4.992 37.952 25.92 52.928 44.352 52.928 25.28-0.832 50.24-33.664 50.24-52.288 0 0 5.632-27.584 5.632-57.216 0.064-37.376-4.608-56.832-4.608-56.832h-0.512a307.84 307.84 0 0 0-30.464-87.04l0.384-0.256a36.16 36.16 0 0 1-3.712-16c0-19.84 19.072-21.76 38.784-21.76l238.72-0.192 14.72-0.512v-0.064c12.16 0.64 24.192-5.248 31.104-16.448a35.2 35.2 0 0 0 3.456-28.992h0.32zM267.52 96.768c2.048-0.192 2.816-0.192 1.92 0.128 1.536 0.32 2.304 0.512-1.92 0.512s-3.456-0.192-1.728-0.512c-0.768-0.32-0.192-0.32 1.728-0.128z"})})},fc=function(){return na("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[na("path",{d:"M8.65991 0.963799L14.9886 7.29249L13.2306 7.64409L9.71469 11.16L9.20318 14.2291C9.12295 14.7105 8.53216 14.8998 8.18708 14.5547L1.39767 7.76533C1.05258 7.42024 1.24191 6.82946 1.72329 6.74923L4.79237 6.23771L8.30831 2.72177L8.65991 0.963799Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",fill:"#fff"}),na("path",{d:"M4.41056 12.8146C3.98733 12.3893 3.56409 11.964 3.14085 11.5388C3.0912 11.6014 3.04156 11.664 2.99192 11.7266C2.09834 12.854 1.20476 13.9814 0.311181 15.1087C0.261538 15.1713 0.211895 15.234 0.162251 15.2966C0.320966 15.4561 0.479681 15.6156 0.638396 15.775C0.701265 15.7257 0.764135 15.6764 0.827004 15.627C1.95865 14.7389 3.09031 13.8508 4.22196 12.9626C4.28483 12.9133 4.3477 12.864 4.41056 12.8146Z",fill:"currentColor"})]})},pc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M342.464 368.576l73.344 42.368-8.512 7.936a32 32 0 0 1-14.272 7.68l-5.44 0.832-2.88 0.192-19.456 2.24a442.88 442.88 0 0 0-53.504 10.688 245.12 245.12 0 0 0-64.32 25.984l-7.488 4.928 150.144 86.784a32 32 0 0 1 15.808 31.168l-1.024 5.312-61.568 215.168 155.584-160.896a32 32 0 0 1 34.112-7.744l4.928 2.304 152.32 87.872 1.472-8.192c4.992-38.272-7.68-83.456-31.552-128.832l-6.784-12.416a32 32 0 0 1-3.456-23.04l2.56-11.328 78.016 44.992c27.328 61.44 36.672 122.816 15.168 177.856l-5.12 11.84-6.208 11.648a32 32 0 0 1-43.712 11.712l-163.072-94.272-227.2 235.072c-21.632 22.336-57.728 3.84-55.04-24.768l1.28-6.272L336.448 600.96l-163.072-94.08a32 32 0 0 1-14.144-38.464l2.432-5.248c23.936-41.6 71.36-67.84 133.504-84.48 20.48-5.568 41.28-9.6 61.312-12.288l-14.016 2.112zM267.968 218.688l609.664 352a32 32 0 1 1-32 55.424l-609.664-352a32 32 0 1 1 32-55.424z m258.816-106.24a32 32 0 0 1 40.384-42.752l5.056 2.432 295.552 170.624a32 32 0 0 1-12.16 59.52l-83.584 9.984-31.68 138.24-57.984-33.408 32.32-140.992a32 32 0 0 1 21.76-23.424l5.632-1.216 10.56-1.344-129.28-74.624 4.16 9.856a32 32 0 0 1-3.84 31.808l-3.84 4.224L513.92 319.808l-57.984-33.472 104-96.64z"})})},vc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M509.4 900.5c-11.6 0-21-9.4-21-21v-168c0-11.6 9.4-21 21-21s21 9.4 21 21v168c0 11.6-9.4 21-21 21z"}),na("path",{d:"M509.4 933.3c-5.4 0-10.7-2.1-14.8-6.2-8.2-8.2-8.2-21.5 0-29.7l74.2-74.3c8.2-8.2 21.5-8.2 29.7 0s8.2 21.5 0 29.7l-74.2 74.3c-4.2 4.1-9.6 6.2-14.9 6.2z"}),na("path",{d:"M509.4 933.3c-5.4 0-10.7-2.1-14.8-6.2l-74.2-74.2c-8.2-8.2-8.2-21.5 0-29.7s21.5-8.2 29.7 0l74.2 74.2c8.2 8.2 8.2 21.5 0 29.7-4.2 4.1-9.6 6.2-14.9 6.2zM742.7 803.1c-56 0-110.1-20.3-152.2-57.2-8.7-7.6-9.6-20.9-1.9-29.6 7.6-8.7 20.9-9.6 29.6-1.9 34.4 30.2 78.6 46.8 124.5 46.8 104.2 0 189-84.8 189-189 0-91.8-65.6-170-156.1-185.9l-16.2-2.8-1.1-16.4c-9.2-131.4-119.5-234.3-251.1-234.3-120.4 0-224.4 85.7-247.3 203.8l-2.7 13.8-13.8 2.8C155.8 371 92.2 448.9 92.2 538.4c0 104.2 84.8 189 189 189 43.1 0 83.6-14.1 117.3-40.9 9.1-7.2 22.3-5.7 29.5 3.4 7.2 9.1 5.7 22.3-3.4 29.5-41.2 32.7-90.7 50-143.4 50-127.4 0-231-103.6-231-231 0-104.8 71.3-196.5 171.4-223.2C253.4 184.3 371.4 90.7 507.2 90.7c148.3 0 273.3 111.8 291.5 257.5 102.3 25.4 175 117.1 175 224 0 127.3-103.6 230.9-231 230.9z"})]})},mc=function(){return na("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M934.4 770.133333L605.866667 181.333333C586.666667 147.2 550.4 128 512 128s-74.666667 21.333333-93.866667 53.333333L89.6 770.133333c-19.2 34.133333-19.2 76.8 0 110.933334S145.066667 938.666667 183.466667 938.666667h657.066666c40.533333 0 74.666667-21.333333 93.866667-57.6 19.2-34.133333 19.2-76.8 0-110.933334zM480 362.666667c0-17.066667 14.933333-32 32-32s29.866667 12.8 32 29.866666V640c0 17.066667-14.933333 32-32 32s-29.866667-12.8-32-29.866667V362.666667zM512 832c-23.466667 0-42.666667-19.2-42.666667-42.666667s19.2-42.666667 42.666667-42.666666 42.666667 19.2 42.666667 42.666666-19.2 42.666667-42.666667 42.666667z",fill:"red"})})},gc=na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"red",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:"margin-left: 6px;",children:[na("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),na("path",{d:"M12 9v4"}),na("path",{d:"M12 17h.01"})]}),yc=na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"rgb(0, 185, 107)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-check","aria-hidden":"true",style:"margin-left: 6px;",children:na("path",{d:"M20 6 9 17l-5-5"})}),kc=na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:"margin-left: 6px;",children:[na("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),na("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]}),wc=function(e){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:e.style,children:na("path",{d:"m9 18 6-6-6-6"})})},bc=na("svg",{className:"icon",title:"知识库",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",xmlnsXlink:"http://www.w3.org/1999/xlink",children:na("path",{d:"M849.2 80H267.7c-73.8 0.1-133.6 58.2-133.6 129.9v606.7c0.1 70.3 58.6 127.2 130.9 127.3h584.3c22.5 0 40.8-17.8 40.8-39.7V119.6C890 97.8 871.7 80 849.2 80z m-40.9 784.6H264.8c-27.2 0-49.2-21.5-49.2-47.9s22-47.9 49.2-47.9h543.5v95.8z m0-175.1H264.8c-16.9 0-33.6 3.1-49.2 9.3V209.9c0-27.9 23.3-50.5 52-50.6h276.8v224.4c0 5.9 6.3 9.8 11.6 7.2l67.7-33.8c4.5-2.3 9.8-2.3 14.3 0l67.7 33.8c5.3 2.7 11.6-1.2 11.6-7.2V159.4h91.1l-0.1 530.1z"})}),Cc=na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M85.312 85.312h853.376v853.376H85.312V85.312z m85.376 768h579.648L384 487.04l-213.312 213.376v152.96z m682.624-17.664V170.688H170.688v408.96L384 366.336l469.312 469.312z m-179.328-526.336a42.688 42.688 0 1 0 0 85.376 42.688 42.688 0 0 0 0-85.376z m-128 42.688a128 128 0 1 1 256 0 128 128 0 0 1-256 0z",fill:"currentColor"})}),Sc=na("svg",{viewBox:"0 0 79 86",version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",children:[na("defs",{children:[na("linearGradient",{id:"linearGradient-1-el-id-655-578",x1:"38.8503086%",y1:"0%",x2:"61.1496914%",y2:"100%",children:[na("stop",{stopColor:"var(--el-empty-fill-color-1)",offset:"0%"}),na("stop",{stopColor:"var(--el-empty-fill-color-4)",offset:"100%"})]}),na("linearGradient",{id:"linearGradient-2-el-id-655-578",x1:"0%",y1:"9.5%",x2:"100%",y2:"90.5%",children:[na("stop",{stopColor:"var(--el-empty-fill-color-1)",offset:"0%"}),na("stop",{stopColor:"var(--el-empty-fill-color-6)",offset:"100%"})]}),na("rect",{id:"path-3-el-id-655-578",x:"0",y:"0",width:"17",height:"36"})]}),na("g",{id:"Illustrations",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:na("g",{id:"B-type",transform:"translate(-1268.000000, -535.000000)",children:na("g",{id:"Group-2",transform:"translate(1268.000000, 535.000000)",children:[na("path",{id:"Oval-Copy-2",d:"M39.5,86 C61.3152476,86 79,83.9106622 79,81.3333333 C79,78.7560045 57.3152476,78 35.5,78 C13.6847524,78 0,78.7560045 0,81.3333333 C0,83.9106622 17.6847524,86 39.5,86 Z",fill:"var(--el-empty-fill-color-3)"}),na("polygon",{id:"Rectangle-Copy-14",fill:"var(--el-empty-fill-color-7)",transform:"translate(27.500000, 51.500000) scale(1, -1) translate(-27.500000, -51.500000) ",points:"13 58 53 58 42 45 2 45"}),na("g",{id:"Group-Copy",transform:"translate(34.500000, 31.500000) scale(-1, 1) rotate(-25.000000) translate(-34.500000, -31.500000) translate(7.000000, 10.000000)",children:[na("polygon",{id:"Rectangle-Copy-10",fill:"var(--el-empty-fill-color-7)",transform:"translate(11.500000, 5.000000) scale(1, -1) translate(-11.500000, -5.000000) ",points:"2.84078316e-14 3 18 3 23 7 5 7"}),na("polygon",{id:"Rectangle-Copy-11",fill:"var(--el-empty-fill-color-5)",points:"-3.69149156e-15 7 38 7 38 43 -3.69149156e-15 43"}),na("rect",{id:"Rectangle-Copy-12",fill:"var(--el-empty-fill-color-3)",transform:"translate(46.500000, 25.000000) scale(-1, 1) translate(-46.500000, -25.000000) ",x:"38",y:"7",width:"17",height:"36"}),na("polygon",{id:"Rectangle-Copy-13",fill:"var(--el-empty-fill-color-2)",transform:"translate(39.500000, 3.500000) scale(-1, 1) translate(-39.500000, -3.500000) ",points:"24 7 41 7 55 -3.63806207e-12 38 -3.63806207e-12"})]}),na("rect",{id:"Rectangle-Copy-15",fill:"var(--el-empty-fill-color-2)",x:"13",y:"45",width:"40",height:"36"}),na("g",{id:"Rectangle-Copy-17",transform:"translate(53.000000, 45.000000)",children:[na("use",{id:"Mask",fill:"var(--el-empty-fill-color-8)",transform:"translate(8.500000, 18.000000) scale(-1, 1) translate(-8.500000, -18.000000) ",xlinkHref:"#path-3-el-id-655-578"}),na("polygon",{id:"Rectangle-Copy",fill:"var(--el-empty-fill-color-9)",mask:"var(--el-empty-fill-color-5)",transform:"translate(12.000000, 9.000000) scale(-1, 1) translate(-12.000000, -9.000000) ",points:"7 0 24 0 20 18 7 16.5"})]}),na("polygon",{id:"Rectangle-Copy-18",fill:"var(--el-empty-fill-color-2)",transform:"translate(66.000000, 51.500000) scale(-1, 1) translate(-66.000000, -51.500000) ",points:"62 45 79 45 70 58 53 58"})]})})})]}),xc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M516.461 20.457c-274.346 0-496.742 222.394-496.742 496.742s222.394 496.742 496.742 496.742 496.742-222.394 496.742-496.742-222.394-496.742-496.742-496.742zM516.461 964.278c-246.527 0-447.079-200.547-447.079-447.079s200.547-447.079 447.079-447.079 447.079 200.547 447.079 447.079-200.547 447.079-447.079 447.079z",fill:""}),na("path",{d:"M741.978 291.67c-12.099-12.117-31.79-12.117-43.905 0l-181.633 181.633-181.633-181.633c-12.102-12.117-31.795-12.117-43.905 0-12.117 12.102-12.117 31.79 0 43.905l181.633 181.633-181.633 181.633c-12.117 12.102-12.117 31.79 0 43.905 6.032 6.061 13.984 9.073 21.942 9.073 7.926 0 15.886-3.03 21.942-9.073l181.633-181.633 181.633 181.633c6.061 6.061 14.002 9.073 21.942 9.073s15.886-3.03 21.942-9.073c12.117-12.102 12.117-31.79 0-43.905l-181.669-181.633 181.633-181.633c12.117-12.102 12.117-31.79 0-43.905z",fill:""})]})},Tc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M512 85.333333C276.48 85.333333 85.333333 276.48 85.333333 512S276.48 938.666667 512 938.666667 938.666667 747.52 938.666667 512 747.52 85.333333 512 85.333333z m0 796.444445c-203.662222 0-369.777778-166.115556-369.777778-369.777778S308.337778 142.222222 512 142.222222 881.777778 308.337778 881.777778 512 715.662222 881.777778 512 881.777778z"}),na("path",{d:"M678.115556 385.706667L461.937778 591.644444l-116.053334-110.364444c-11.377778-11.377778-29.582222-10.24-39.822222 1.137778-11.377778 11.377778-10.24 29.582222 1.137778 39.822222l135.395556 129.706667c5.688889 5.688889 12.515556 7.964444 19.342222 7.964444s13.653333-2.275556 19.342222-7.964444L716.8 426.666667c11.377778-11.377778 11.377778-28.444444 1.137778-39.822223-10.24-12.515556-28.444444-12.515556-39.822222-1.137777z"})]})},Mc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M896 170.688c47.104 0 85.312 38.144 85.312 85.312v512c0 47.104-38.208 85.312-85.312 85.312H128A85.312 85.312 0 0 1 42.688 768V256c0-47.168 38.208-85.312 85.312-85.312h768z m-533.312 64H128c-10.496 0-19.2 7.488-20.992 17.472L106.688 256v512c0 10.496 7.552 19.2 17.472 20.992l3.84 0.32h234.688V234.688z m533.312 0H426.688v554.624H896c10.496 0 19.2-7.552 20.992-17.472l0.32-3.84V256c0-10.496-7.552-19.2-17.472-20.992L896 234.624zM298.688 469.248a21.312 21.312 0 0 1 0 42.688h-128a21.312 21.312 0 1 1 0-42.688h128z m0-85.312a21.312 21.312 0 0 1 0 42.688h-128a21.312 21.312 0 1 1 0-42.688h128z m0-85.312a21.312 21.312 0 0 1 0 42.624h-128a21.312 21.312 0 1 1 0-42.688h128z",fill:"currentColor"})})},_c=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M204.288 285.696c9.728 0 19.456-3.584 27.136-11.264 48.64-49.152 110.592-84.48 179.712-101.888 20.48-5.12 32.768-26.112 27.648-46.08-5.12-20.48-26.112-32.768-46.08-27.648-82.432 20.992-156.672 62.976-215.04 121.856-14.848 14.848-14.848 38.912 0.512 53.76 7.168 7.68 16.384 11.264 26.112 11.264zM602.112 92.16c-20.48-4.096-40.448 9.728-44.544 30.208-4.096 20.48 9.728 40.448 30.208 44.544 72.192 13.824 138.24 46.08 190.976 94.208 7.168 6.656 16.384 9.728 25.6 9.728 10.24 0 20.48-4.096 28.16-12.288 14.336-15.36 13.312-39.424-2.56-53.76-62.464-57.344-141.824-96.256-227.84-112.64zM948.736 386.56c-6.656-19.968-28.16-30.72-48.128-24.576-19.968 6.656-30.72 28.16-24.576 48.128 10.752 32.768 15.872 67.072 15.872 101.376 0 42.496-8.192 83.456-24.064 122.88-7.68 19.456 1.536 41.472 20.992 49.664 4.608 2.048 9.728 2.56 14.336 2.56 14.848 0 29.184-9.216 35.328-24.064 19.456-48.128 29.184-99.328 29.184-151.552 0.512-41.472-6.144-83.968-18.944-124.416zM775.168 765.952c-52.224 46.592-117.248 77.824-187.904 91.136-20.48 3.584-34.304 23.552-30.208 44.544 3.584 18.432 19.456 31.232 37.376 31.232 2.048 0 4.608 0 7.168-0.512 84.48-15.872 161.792-53.248 224.768-109.056 15.872-13.824 16.896-37.888 3.072-53.76-14.336-16.384-38.4-17.408-54.272-3.584zM415.232 851.968c-2.048-0.512-4.608-1.024-7.68-2.048-13.312-3.584-27.136-5.632-40.96-5.632H166.4l35.328-98.816c4.608-12.8 2.56-27.136-5.632-37.888-12.288-16.896-36.352-20.992-53.248-8.704-9.216 6.656-14.848 16.896-15.36 27.648l-49.152 138.24c-4.608 12.8-2.56 26.624 5.12 37.376 7.68 10.752 20.48 17.408 33.792 17.408h240.128c11.776 0 24.064 1.024 35.84 4.096 6.144 1.536 11.776 2.56 12.8 2.56 16.896 0 32.768-11.776 36.864-29.184 5.12-19.456-7.168-39.936-27.648-45.056zM108.032 651.264c3.584 0 7.168-0.512 10.752-1.536 19.968-5.632 31.744-27.136 26.112-47.104-8.704-29.696-12.8-59.904-12.8-91.136 0-33.792 5.12-66.56 15.36-98.816 6.144-19.968-4.608-41.472-24.576-47.616-19.968-6.144-41.472 4.608-47.616 24.576-12.288 39.424-18.944 80.384-18.944 121.344 0 37.888 5.12 75.776 15.872 112.128 4.096 17.408 19.456 28.16 35.84 28.16z"})})},Nc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M204.288 285.184c9.728 0 19.456-3.584 27.136-11.264 48.64-49.152 111.104-84.48 179.712-101.888 20.48-5.12 32.768-26.112 27.648-46.08-5.12-20.48-26.112-32.768-46.08-27.648-82.432 20.992-156.672 62.976-215.04 121.856-14.848 14.848-14.848 38.912 0.512 53.76 6.656 7.68 16.384 11.264 26.112 11.264zM602.624 92.16c-20.48-4.096-40.448 9.728-44.544 30.208-4.096 20.48 9.728 40.448 30.208 44.544 72.192 13.824 138.24 46.08 190.976 94.72 7.168 6.656 16.384 9.728 25.6 9.728 10.24 0 20.48-4.096 28.16-12.288 14.336-15.36 13.312-39.424-2.56-53.76-62.976-57.856-141.824-97.28-227.84-113.152zM949.248 386.56c-6.656-19.968-28.16-30.72-48.128-24.576-19.968 6.656-30.72 28.16-24.576 48.128 10.752 32.768 15.872 67.072 15.872 101.888 0 42.496-8.192 83.968-24.064 122.88-7.68 19.456 1.536 41.472 20.992 49.664 4.608 2.048 9.728 2.56 14.336 2.56 14.848 0 29.184-9.216 35.328-24.064 19.456-48.64 29.696-99.328 29.696-151.552 0-42.496-6.656-84.48-19.456-124.928zM775.68 765.952c-52.224 46.592-117.248 77.824-187.904 91.136-20.48 3.584-34.304 23.552-30.72 44.544 3.584 18.432 19.456 31.232 37.376 31.232 2.048 0 4.608 0 7.168-0.512 84.48-15.872 162.304-53.248 224.768-109.056 15.872-13.824 17.408-37.888 3.072-53.76-14.336-15.872-38.4-17.408-53.76-3.584zM415.232 852.48c-2.048-0.512-4.608-1.024-7.68-2.048-13.312-3.584-27.136-5.632-40.96-5.632H166.4l35.328-98.816c4.608-12.8 2.56-27.136-5.632-37.888-12.288-16.896-36.352-20.992-53.248-8.704-9.216 6.656-14.848 16.896-15.36 27.648l-49.664 138.24c-4.608 12.8-2.56 26.624 5.12 37.376 7.68 10.752 20.48 17.408 33.792 17.408h240.64c11.776 0 24.064 1.024 35.84 4.096 6.144 1.536 11.776 2.56 13.312 2.56 16.896 0 32.768-11.776 36.864-29.184 4.608-19.456-8.192-39.936-28.16-45.056zM107.52 651.776c3.584 0 7.168-0.512 10.752-1.536 19.968-5.632 31.744-27.136 26.112-47.104-8.704-29.696-12.8-59.904-12.8-91.136 0-33.792 5.12-67.072 15.36-98.816 6.144-19.968-4.608-41.472-25.088-47.616-19.968-6.144-41.472 4.608-47.616 25.088-12.288 39.424-18.944 80.384-18.944 121.856 0 37.888 5.12 75.776 15.872 112.128 4.608 15.872 19.968 27.136 36.352 27.136zM658.944 390.656c-17.408-11.776-40.96-7.168-52.736 10.752l-141.824 212.48-71.68-71.68c-14.848-14.848-38.912-14.848-53.76 0-14.848 14.848-14.848 38.912 0 53.76l104.96 104.96c7.168 7.168 16.896 11.264 27.136 11.264h3.584c11.264-1.024 21.504-7.168 28.16-16.896l167.424-251.392c10.752-17.92 6.144-41.472-11.264-53.248z"})})},Oc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",children:na("path",{d:"M811.097325 675.11798a38.455724 38.455724 0 0 1-54.382232 0L511.992078 430.406848 267.269064 675.11798a38.453744 38.453744 0 0 1-54.383222-54.380252l271.91116-271.899277a38.454734 38.454734 0 0 1 54.383222 0l271.911159 271.899277a38.450773 38.450773 0 0 1 0.005942 54.380252z",fill:"currentColor"})})},Ec=function(){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-lightbulb","aria-hidden":"true",style:"transition: width, height, 150ms;",children:[na("path",{fill:"none",d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}),na("path",{d:"M9 18h6"}),na("path",{d:"M10 22h4"})]})},Ac=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M671.744 107.666286a128 128 0 1 1 177.371429 183.369143l-87.478858 87.478857L580.608 197.485714l90.477714-90.477714 0.658286 0.658286z m-362.642286 723.382857v0.146286H128V650.093714L535.405714 242.761143l181.028572 181.028571-407.259429 407.259429zM0 896h1024V1024H0v-128z",fill:"currentColor"})})},Dc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M1008.64 993.28h-117.76v-460.8c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v460.8h-150.016v-209.92c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v209.92h-150.016v-250.88c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v250.88H349.696v-296.96c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v296.96H168.96v-174.08c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v174.08H30.72V107.52c0-8.704-6.656-15.36-15.36-15.36s-15.36 6.656-15.36 15.36v901.12c0 8.192 6.656 15.36 15.36 15.36h993.28c8.704 0 15.36-7.168 15.36-15.36 0-8.704-6.656-15.36-15.36-15.36z"}),na("path",{d:"M153.6 450.56c3.584 0 7.168-1.536 10.24-4.096l169.984-155.136 168.96 125.44c2.56 2.048 5.12 3.072 8.192 3.072l184.32 10.24c5.12 0.512 10.24-2.048 13.312-6.656l179.2-256c5.12-7.168 3.072-16.384-3.584-21.504-7.168-5.12-16.384-3.072-21.504 3.584l-174.08 248.832-171.008-9.728-175.616-129.536c-6.144-4.608-14.336-4.096-19.456 1.024l-179.2 163.84c-6.144 5.632-6.656 15.36-1.024 21.504 3.072 3.584 7.168 5.12 11.264 5.12z"})]})},Ic=function(){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[na("path",{d:"M3 3v18h18"}),na("path",{d:"M7 16V12"}),na("path",{d:"M11 16V8"}),na("path",{d:"M15 16V4"}),na("path",{d:"M19 16v-6"})]})},Lc=function(){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[na("path",{d:"M12 3v14"}),na("path",{d:"m5 10 7 7 7-7"}),na("path",{d:"M5 21h14"})]})},Rc=function(){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[na("path",{d:"M12 21V7"}),na("path",{d:"m5 14 7-7 7 7"}),na("path",{d:"M5 3h14"})]})},Pc=function(){return na("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:na("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})})},zc=function(){return na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[na("path",{d:"M849.558588 496.941176a26.352941 26.352941 0 0 1 3.312941 52.495059l-3.312941 0.210824h-421.647059a26.352941 26.352941 0 0 1-3.312941-52.495059l3.312941-0.210824h421.647059z",fill:"currentColor"}),na("path",{d:"M849.558588 742.912a26.352941 26.352941 0 0 1 3.312941 52.495059l-3.312941 0.210823h-421.647059a26.352941 26.352941 0 0 1-3.312941-52.525176l3.312941-0.180706h421.647059z",fill:"currentColor"}),na("path",{d:"M849.558588 250.970353a26.352941 26.352941 0 0 1 3.312941 52.525176l-3.312941 0.180706h-421.647059a26.352941 26.352941 0 0 1-3.312941-52.495059l3.312941-0.210823h421.647059zM287.382588 672.617412H146.823529a26.352941 26.352941 0 0 0-26.352941 26.352941v140.559059c0 14.546824 11.806118 26.352941 26.352941 26.352941h140.559059a26.352941 26.352941 0 0 0 26.352941-26.352941v-140.559059a26.352941 26.352941 0 0 0-26.352941-26.352941z m-26.383059 52.705882V813.176471H173.176471v-87.853177h87.823058zM287.382588 426.676706H146.823529a26.352941 26.352941 0 0 0-26.352941 26.352941v140.528941c0 14.576941 11.806118 26.352941 26.352941 26.352941h140.559059a26.352941 26.352941 0 0 0 26.352941-26.352941v-140.528941a26.352941 26.352941 0 0 0-26.352941-26.352941z m-26.383059 52.675765v87.853176H173.176471v-87.853176h87.823058zM287.382588 180.705882H146.823529A26.352941 26.352941 0 0 0 120.470588 207.058824v140.559058c0 14.546824 11.806118 26.352941 26.352941 26.352942h140.559059a26.352941 26.352941 0 0 0 26.352941-26.352942V207.058824A26.352941 26.352941 0 0 0 287.382588 180.705882z m-26.383059 52.705883v87.823059H173.176471V233.411765h87.823058z",fill:"currentColor"})]})},Bc=function(){return na("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[na("path",{d:"M4.89417 7.25418L2.48694 7.65555L8.34338 13.5139L8.74475 11.1057L9.96155 12.3216L9.69299 13.9358C9.51911 14.9787 8.23949 15.3883 7.49182 14.6409L1.35999 8.50809C0.612717 7.76035 1.02323 6.48076 2.06604 6.30692L3.67737 6.03738L4.89417 7.25418ZM8.28381 1.00711C8.53085 0.932418 8.79958 0.999393 8.98206 1.18192L14.817 7.01883C14.9991 7.20132 15.0665 7.46932 14.9918 7.71609C14.917 7.96306 14.7116 8.14878 14.4586 8.19949L13.0455 8.48172L11.5631 9.96414L10.5739 8.97488L12.2057 7.34305L12.2838 7.27567C12.3663 7.2145 12.4616 7.17202 12.5631 7.15164L12.902 7.08328L8.91663 3.09695L8.84924 3.43582C8.82213 3.57112 8.75536 3.69562 8.65784 3.79324L7.02502 5.42508L6.03479 4.43387L7.51721 2.95242L7.80042 1.53934L7.82581 1.44754C7.89864 1.23769 8.06759 1.0726 8.28381 1.00711Z",fill:"currentColor"}),na("path",{d:"M4.65713 12.6155C4.23145 12.1927 3.80577 11.7698 3.38008 11.347C3.34021 11.4005 3.30033 11.4539 3.26045 11.5074C2.54263 12.4699 1.82481 13.4324 1.107 14.3948C1.06712 14.4483 1.02724 14.5018 0.987361 14.5553C1.14699 14.7138 1.30662 14.8724 1.46625 15.031C1.51943 14.9907 1.57262 14.9504 1.6258 14.9102C2.58306 14.1855 3.54032 13.4609 4.49758 12.7363C4.55077 12.696 4.60395 12.6558 4.65713 12.6155Z",fill:"currentColor"}),na("path",{d:"M1.85059 2.22839L13.77 14.1506",stroke:"currentColor",strokeWidth:"1.4"})]})},Hc=function(){return na("svg",{viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:na("path",{d:"M7 1.167v11.666M1.167 7h11.666",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})},Fc=function(e){var t=e.text,n=g(Wa(t),2),i=n[0],r=n[1],o=qa(null);return $a(function(){return o.current&&clearTimeout(o.current),o.current=setTimeout(function(){r(t)},100),function(){o.current&&clearTimeout(o.current)}},[t]),na("div",{className:"streaming-content",children:i})},jc={disabled:"Disabled",enable:"Enable",automatic:"Automatic",customize:"Customize",default:"Default",settings:"Settings",chunkRerank:"Recall and reordering",chunkPageIndex:"Data catalog recall",maxChunks:"Maximum recall quantity",chunkThreshold:"Recall similarity threshold",aiAssistant:"AI assistant",minimize:"Minimize",exitFullscreen:"Exit fullscreen",fullscreen:"Fullscreen",close:"Close",loading:"Loading...",agent:"Agent",knowledge:"Knowledge",knowledgeSearch:"Knowledge search",uploadDocument:"Upload document",documentation:"Documentation",voiceInput:"Voice input",voiceInputProgress:"Voice input progress...",stopGenerating:"Stop generating",sendMessage:"Send message",instantSteer:"Instant steer",instantSteerTip:"Send supplementary content without interrupting the current conversation",meterialResources:"Meterial resources",preview:"Preview",uploadSuccess:"Upload success",uploading:"Uploading",uploadFailed:"Upload failed",unknownState:"Unknown state",download:"Download",thinkThrough:"Think through",stopThinking:"Stop thinking",thinking:"Thinking",requestTimeout:"Request timeout",unsupportedMessageType:"Message types not currently supported: {type}",me:"Me",retry:"Failed to send, please try again",expand:"Expand",foldUp:"Foldup",stepExpand:"Expand the execution steps",stepFoldUp:"Execute step contraction",expandAll:"Expand all",copy:"Copy",copyMarkdown:"Copy Markdown",copied:"Copied",used:"Used",second:"Second",agentTool:"Intelligent agent tool call execution in progress",toolCallContraction:"Tool call contraction",toolCallExpansion:"Tool call expansion",summaryGeneration:"Intelligent summary generated from {count} original paragraphs",guidance:"[Guidance]",vector:"(Vector{count})",abstract:"[Abstract]",hitParagraph:"Hit the {count} sub paragraph",noData:"No data",knowledgeRetrieval:"Knowledge base retrieval:",imageContent:"Image content recognition",more:"More",resetConversation:"Reset conversation",resetTopicConfirmTip:"Resetting will delete all chat history in this conversation. Are you sure you want to reset?",clearConversation:"Clear the conversation",clearTopicConfirmTip:"Clearing will delete all chat history in this conversation. Are you sure you want to clear?",refresh:"Refresh",delete:"Delete",backfill:"Backfill",pinTop:"Pin to top",unpin:"Unpin",rename:"Rename",deleteTopic:"Delete topic",jumpMainView:"Jump to the main view",openSidebar:"Open the sidebar",enterSession:"Enter temporary session",exitSession:"Exit temporary session",collapseSidebar:"Collapse the sidebar",newConversation:"New conversation",historySession:"History session ({count})",newCreateConversation:"Create new conversation",searchTopics:"Search topics",noTopic:"No topic at the moment",clearSession:"Clear conversation",clearSessionConfirmTip:"Are you sure you want to clear all session data except the currently active one?",clearSessionWithGroupConfirmTip:"Are you sure you want to clear all session and group data except the currently active one?",deleteConversation:"Delete conversation",deleteConversationConfirmTip:"Once deleted, this conversation cannot be recovered. Are you sure you want to delete?",batchDeleteConversation:"Delete {count} selected conversations",batchDeleteSession:"Batch delete conversations",batchDeleteConversationConfirmTip:"Once deleted, the selected conversations cannot be recovered. Are you sure you want to delete?",multiSelect:"Multi-select",selectedCount:"{count} conversations selected",cancelMultiSelect:"Exit multi-select",unclassifiedTopic:"Unclassified",newGroup:"New Group",deleteGroup:"Delete Group",deleteGroupConfirmTip:"Once deleted, this group and all conversations under it cannot be recovered. Are you sure you want to delete?",deleteScope:"Delete Catalog",deleteScopeConfirmTip:"Once deleted, all groups and conversations under this catalog cannot be recovered. Are you sure you want to delete?",selectScope:"Select Catalog",selectScopePlaceholder:"Please select a catalog",selectScopeTip:"The conversation will be assigned to the selected catalog",searchScopePlaceholder:"Search catalogs",confirm:"Confirm",temporarySession:"Temporary session",like:"Like",downvote:"Downvote",search:"Search",searchFailed:"Search failed",errorOccurred:"An error occurred",protocol:"Not currently supporting {protocol} type protocols",downloadCannotEmpty:"The download action identifier [downloadactionid] cannot be empty",downloadExContext:"Download extension context [downloadContext] parameter parsing exception, correct format such as abc: 123; cde:456",userInterrupt:"User interrupt",actionIdCannotEmpty:"[actionid] cannot be empty",actionExContext:"Exception in parsing the parameter for behavior extension context [action_comtext], correct format: abc: 123; cde:456",notSupportingType:"Not supporting {type} recommendation type",chunkView:"The document fragment viewing interface does not exist. Please confirm if chunkView is configured",chunkEntity:"The document fragment entity identifier does not exist. Please confirm if chunkEntity is configured",extensionToolbarClick:"Extension toolbar click event not found",temporarySessionFailed:"Temporary session failed, no topic configuration backup configuration",reedit:"Re edit",cancel:"Cancel",questionPrev:"Previous",questionNext:"Next",questionSubmit:"Done",questionInputPlaceholder:"Please enter",questionOther:"Other",questionNoData:"No questions",send:"Send",unknownError:"Unknown error",statistics:"Statistics",totalTokens:"Total tokens",inputTokens:"Input tokens",outputTokens:"Output tokens",toolCallCount:"Tool calls",notCounted:"Not counted",notCalled:"Not called",noResearchContent:"There is currently no research content available",light:"Light",dark:"Dark",generateVisualReport:"Generate visual report",sourceMaterial:"Find the source of {docCount} article information",searchKeyword:"Search keywords: {keyword}",deepResearch:"Depth research report",textReport:"Text report",deepResearchReport:"In depth research report",noTextReportContent:"No text report content available at the moment",chatInputPlaceholder:"Ask AI",projectPlaceholder:"Please select directory"},Vc={disabled:"禁用",enable:"启用",automatic:"自动",customize:"自定义",default:"默认",settings:"设置",chunkRerank:"召回重排",chunkPageIndex:"资料目录召回",maxChunks:"最大召回数量",chunkThreshold:"召回相似度阈值",aiAssistant:"AI助手",minimize:"最小化",exitFullscreen:"退出全屏",fullscreen:"全屏",close:"关闭",loading:"加载中...",agent:"智能体",knowledge:"知识库",knowledgeSearch:"知识库搜索",uploadDocument:"上传资料",documentation:"文件资料",voiceInput:"语音输入",voiceInputProgress:"语音输入中...",stopGenerating:"停止生成",sendMessage:"发送消息",instantSteer:"即时引导",instantSteerTip:"发送补充内容,不中断当前对话",meterialResources:"素材资源",preview:"预览",uploadSuccess:"上传成功",uploading:"上传中",uploadFailed:"上传失败",unknownState:"未知状态",download:"下载",thinkThrough:"思考完成",stopThinking:"思考停止",thinking:"思考中",requestTimeout:"请求超时",unsupportedMessageType:"暂未支持的消息类型: {type}",me:"我",retry:"未发送成功,请重试",expand:"展开",foldUp:"收起",stepExpand:"执行步骤 展开",stepFoldUp:"执行步骤 收缩",expandAll:"展开全部",copy:"复制",copyMarkdown:"复制 Markdown",copied:"已复制",used:"已用",second:"秒",agentTool:"智能体工具调用执行中",toolCallContraction:"工具调用 收缩",toolCallExpansion:"工具调用 展开",summaryGeneration:"由{count}个原文段落智能总结生成",guidance:"[引导]",vector:"(向量{count})",abstract:"[摘要]",hitParagraph:"命中 {count} 个子段落",noData:"无数据",knowledgeRetrieval:"知识库检索:",imageContent:"图片内容识别",more:"更多",resetConversation:"重置对话",resetTopicConfirmTip:"重置操作会删除本会话内全部历史聊天记录,确认要重置么?",clearConversation:"清空对话",clearTopicConfirmTip:"清空操作会删除本会话内全部历史聊天记录,确认要清空么?",refresh:"刷新",delete:"删除",backfill:"回填",pinTop:"置顶",unpin:"取消置顶",rename:"重命名",deleteTopic:"删除话题",jumpMainView:"跳转主视图",openSidebar:"打开侧边栏",enterSession:"进入临时会话",exitSession:"退出临时会话",collapseSidebar:"收起侧边栏",newConversation:"新会话",historySession:"历史会话({count})",newCreateConversation:"新建对话",searchTopics:"搜索话题",noTopic:"暂无话题",clearSession:"清空会话",clearSessionConfirmTip:"确认清空除当前激活项外的所有会话数据?",clearSessionWithGroupConfirmTip:"确认清空除当前激活项外的所有会话及分组数据?",deleteConversation:"删除对话",deleteConversationConfirmTip:"删除后,该对话将不可恢复。确认删除吗?",batchDeleteConversation:"删除选择的 {count} 个对话",batchDeleteSession:"批量删除会话",batchDeleteConversationConfirmTip:"删除后,选中的对话将不可恢复,确定删除吗?",multiSelect:"多选",selectedCount:"已选择 {count} 个对话",cancelMultiSelect:"退出多选",unclassifiedTopic:"无分类会话",newGroup:"新建分组",deleteGroup:"删除分组",deleteGroupConfirmTip:"删除后,该分组及其下所有会话数据将不可恢复。确认删除吗?",deleteScope:"删除目录",deleteScopeConfirmTip:"删除后,该目录下所有分组与会话数据将不可恢复。确认删除吗?",selectScope:"选择目录",selectScopePlaceholder:"请选择目录",selectScopeTip:"会话将归属到所选目录",searchScopePlaceholder:"搜索目录",confirm:"确认",temporarySession:"临时会话",like:"点赞",downvote:"点踩",search:"搜索",searchFailed:"搜索失败",errorOccurred:"发生错误",protocol:"暂不支持{protocol}类型协议",downloadCannotEmpty:"下载行为标识 [downloadactionid] 不能为空",downloadExContext:"下载扩展上下文 [downloadContext] 参数解析异常,正确格式如:abc:123;cde:456",userInterrupt:"用户中断",actionIdCannotEmpty:"行为标识 [actionid] 不能为空",actionExContext:"行为扩展上下文 [action_context] 参数解析异常,正确格式如:abc:123;cde:456",notSupportingType:"不支持{type}推荐类型",chunkView:"文档分片查看界面不存在,请确认chunkView是否配置",chunkEntity:"文档分片实体标识不存在,请确认chunkEntity是否配置",extensionToolbarClick:"未找到扩展工具栏点击事件",temporarySessionFailed:"临时会话失败,无话题配置备份配置",reedit:"重新编辑",cancel:"取消",questionPrev:"上一步",questionNext:"下一个",questionSubmit:"完成",questionInputPlaceholder:"请输入",questionOther:"其它",questionNoData:"暂无问题",send:"发送",unknownError:"未知错误",statistics:"统计",totalTokens:"Token消耗总数",inputTokens:"输入Token消耗",outputTokens:"输出Token消耗",toolCallCount:"工具调用次数",notCounted:"未统计",notCalled:"未调用",noResearchContent:"暂无研究内容",light:"亮色",dark:"暗色",generateVisualReport:"生成可视化报告",sourceMaterial:"找到 {docCount} 篇资料来源",searchKeyword:"搜索关键词:{keyword}",deepResearch:"深度研报",textReport:"文本报告",deepResearchReport:"深度研究报告",noTextReportContent:"暂无文本报告内容",chatInputPlaceholder:"问问 AI",projectPlaceholder:"请选择目录"},Wc=function(){return x(function e(){var t=this;C(this,e),T(this,"locale",gs("zh-CN")),T(this,"language",T(T({},"en",jc),"zh-CN",Vc)),T(this,"t",Cs(function(){var e=t.locale.value;return function(n,i){var r=t.language[e][n];return r?"function"==typeof r?r(i):i?r.replace(/\{(\w+)\}/g,function(e,t){return void 0!==i[t]?String(i[t]):e}):r:n}}))},[{key:"setLocale",value:function(e){this.locale.value=e}},{key:"setLanguage",value:function(e){var t=this;Object.keys(e).forEach(function(n){t.language.hasOwnProperty(n)?Object.assign(t.language[n],e[n]):t.language[n]=e[n]})}}])}(),$c=new Wc,Uc=function(e){var t,n=e.item,i=new ra("chat-think"),r=qa(null),o=Ds(""),a=Ds(n.collapse||!0),s=Ds(!1);$a(function(){if(n.beginTime){var e=n.endTime||Date.now();o.value=((e-n.beginTime)/1e3).toFixed(1)}var t;n.done||((t=r.current)&&n.collapse&&t.scrollTo({top:t.scrollHeight,behavior:"auto"}),n.description&&(n.description=n.description.replace(/^\n+/,"").replace(/\n\n/g,"\n"))),u(n.collapse)||(a.value=n.collapse)},[n]);if(n.description)return na("div",{className:"".concat(i.b()," ").concat(i.is("collapsed",a.value)," ").concat(i.is("loading",!n.done)),children:[na("div",{className:i.e("header"),children:[na("div",{className:i.e("icon"),children:na(Ec,{})}),na("div",{className:i.e("title"),onClick:function(){return a.value=!a.value,void(n.collapse=a.value)},children:[n.title,o.value?na("span",{className:i.e("time"),children:["(",$c.t.value("used")," ",o.value," ",$c.t.value("second"),")"]}):null,na(wc,{})]})]}),na("div",{className:i.e("content"),ref:r,children:na(Fc,{text:n.description})}),na("span",{title:$c.t.value("copy"),className:i.e("copy"),onClick:function(i){return function(i){var r;i.stopPropagation(),s.value||(t&&clearTimeout(t),s.value=!0,ya.copy(JSON.stringify(n.description,void 0,2)),null===(r=e.controller.opts.utils)||void 0===r||r.message.success($c.t.value("copied")),t=setTimeout(function(){s.value=!1},2e3))}(i)},children:s.value?yc:kc})]})},qc=function(e){var t=e.suggestions,n=e.onSuggestionClick,i=e.uiactions,r=e.onUIActionClick,o=new ra("chat-suggestions");return na("div",{className:"".concat(o.b()),children:[t&&t.length>0&&t.map(function(e,t){return na("div",{className:"".concat(o.e("item")," ").concat(o.is("action","action"===e.type)),onClick:function(t){return function(e,t){null==n||n(e,t)}(e,t)},title:e.metadata.content_name,children:[e.metadata.content_name,na(sc,{className:"".concat(o.e("item-icon"))})]},t)}),i&&i.length>0&&i.map(function(e,t){return na("div",{className:"".concat(o.e("item")," ").concat(o.is("action","action"===e.type)),onClick:function(t){return function(e,t){null==r||r(e,t)}(e,t)},title:e.metadata.content_name,children:[e.metadata.content_name,na(sc,{className:"".concat(o.e("item-icon"))})]},"action-".concat(t))})]})},Kc=function(e){var t,n,i,r=new ra("default-tool-call"),o=Ds(!1),a=Ds(!1);$a(function(){return function(){i&&clearTimeout(i)}},[]);var s=function(e){return"string"==typeof e?e.includes("Failed")||e.includes("Error")||e.includes("ERR_")?'<span class="error">"'.concat(e,'"</span>'):'<span class="string">"'.concat(e,'"</span>'):"number"==typeof e?'<span class="number">'.concat(e,"</span>"):"boolean"==typeof e?'<span class="boolean">'.concat(e,"</span>"):null===e?'<span class="null">null</span>':""},l=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=" ".repeat(t),i=[];if(Array.isArray(e)){if(0===e.length)return["".concat(n,'<span class="array">[]</span>')];i.push("".concat(n,'<span class="array">[</span>')),e.forEach(function(n,r){var o=l(n,t+1),a=r<e.length-1?",":"";"object"===_(n)&&null!==n?(i.push.apply(i,c(o.slice(0,-1))),i.push("".concat(o[o.length-1]).concat(a))):i.push("".concat(o[0]).concat(a))}),i.push("".concat(n,'<span class="array">]</span>'))}else if("object"===_(e)&&null!==e){var r=Object.keys(e);if(0===r.length)return["".concat(n,'<span class="property">{}</span>')];i.push("".concat(n,'<span class="property">{</span>')),r.forEach(function(o,a){var u=e[o],d=a<r.length-1?",":"",h='<span class="json-key">"'.concat(o,'":</span>');if("object"===_(u)&&null!==u){var f=l(u,t+1);i.push("".concat(n," ").concat(h," ").concat(f[0].trim())),f.length>1&&(i.push.apply(i,c(f.slice(1,-1))),i.push("".concat(f[f.length-1]).concat(d)))}else{var p=s(u);i.push("".concat(n," ").concat(h," ").concat(p).concat(d))}}),i.push("".concat(n,'<span class="property">}</span>'))}else i.push("".concat(n).concat(s(e)));return i},u=Is(function(){return l(e.item,0).map(function(e,t){return'<span class="line-number">'.concat(t+1,"</span>").concat(e)})});return na("div",{className:"".concat(r.b()," ").concat(e.className||""),children:[na("div",{className:r.e("header"),onClick:function(){return o.value=!o.value,void(null===(t=e.onCollapseChange)||void 0===t||t.call(e,o.value));var t},children:[na("div",{className:r.e("header-left"),children:[na("div",{className:r.em("header-left","caption"),children:e.item.name}),na("div",{className:r.em("header-left","desc"),title:(null===(t=e.item.parameters)||void 0===t?void 0:t.desc)||"",children:(null===(n=e.item.parameters)||void 0===n?void 0:n.desc)||""})]}),na("div",{className:r.e("header-right"),children:[e.item.error&&na("span",{style:"color: red;",children:$c.t.value("errorOccurred")}),e.item.error&&gc,na("span",{title:$c.t.value("copy"),className:r.e("copy"),onClick:function(t){return function(t){var n;t.stopPropagation(),a.value||(i&&clearTimeout(i),a.value=!0,ya.copy(JSON.stringify(e.item,void 0,2)),null===(n=e.controller.opts.utils)||void 0===n||n.message.success($c.t.value("copied")),i=setTimeout(function(){a.value=!1},2e3))}(t)},children:a.value?yc:kc}),na(wc,{style:{"margin-left":" 6px",transform:o.value?"rotate(90deg)":"rotate(0deg)"}})]})]}),o.value&&na("div",{className:r.e("content"),children:u.value.map(function(e,t){return na("div",{className:"code-line",dangerouslySetInnerHTML:{__html:e}},t)})})]})},Jc=function(e){var t,n,i,r=new ra("chunk-tool-call"),o=Ds([]),a=Ds(!1),s=Ds(!1);$a(function(){var t,n=f((null===(t=e.item.result)||void 0===t?void 0:t.chunks)||[]),i=n.filter(function(e){return"SOURCE"===e.type}),r=n.filter(function(e){return"SOURCE"!==e.type});r.forEach(function(e){"CLUSTER"===e.type&&(e.children=i.filter(function(t){return t.pid===e.id}),e.isExpand=!1)}),o.value=r},[e.item]),$a(function(){return function(){i&&clearTimeout(i)}},[]);var l=function(t){return na("div",{onClick:function(t){return e.onLinkClick(t)},dangerouslySetInnerHTML:{__html:t.replace(/\[(.+?)\]\((.+?)\)/g,function(e,t,n){return'<a href="'.concat(n,'">').concat(t,"</a>")})}})},u=function(e){return na("div",{className:r.e("footer"),children:["CLUSTER"===e.type&&(e.source_count||0===e.source_count)&&na("div",{className:r.em("footer","description"),children:$c.t.value("summaryGeneration",{count:e.source_count})}),na("div",{className:r.em("footer","docname"),children:e.docname})]})},d=function(e){var t;return na("div",{className:"".concat(r.e("item")," ").concat(r.em("item",(null===(t=e.type)||void 0===t?void 0:t.toLowerCase())||"default")),children:["KBGUIDANCE"===e.type?na("div",{className:r.e("kbguidance"),children:$c.t.value("guidance")}):na("div",{className:r.e("similarity"),style:"--percent: ".concat((100*(e.similarity||0)).toFixed(2),"%;"),children:"SCORE ".concat((e.similarity||0).toFixed(2))}),e.original&&na("div",{className:r.e("original"),children:$c.t.value("vector",{count:(e.original||0).toFixed(2)})}),na("div",{className:r.em("item","content"),title:e.content,children:l(e.content)})]},e.id)},h=function(e){var t,n;return"CLUSTER"===e.type?na("div",{className:"".concat(r.e("chunk")," ").concat(r.e("cluster")),children:[na("div",{className:r.em("cluster","header"),children:[na("div",{className:r.e("similarity"),style:"--percent: ".concat((100*(e.similarity||0)).toFixed(2),"%;"),children:"SCORE ".concat((e.similarity||0).toFixed(2))}),e.original&&na("div",{className:r.e("original"),children:$c.t.value("vector",{count:(e.original||0).toFixed(2)})}),na("div",{className:r.em("cluster","title"),children:$c.t.value("abstract")}),na("div",{className:r.em("cluster","summary"),title:e.content,children:l(e.content)})]}),na("div",{className:r.em("cluster","content"),children:[na("div",{className:r.em("cluster","icon"),onClick:function(t){return function(e,t){e.stopPropagation(),t.isExpand=!t.isExpand,o.value=c(o.value)}(t,e)},children:[na(wc,{style:{transform:e.isExpand?"rotate(90deg)":"rotate(0deg)"}}),$c.t.value("hitParagraph",{count:(null===(t=e.children)||void 0===t?void 0:t.length)||0})]}),e.isExpand&&na("div",{className:r.em("cluster","children"),children:null===(n=e.children)||void 0===n?void 0:n.map(function(e){return d(e)})})]}),u(e)]},e.id):na("div",{className:"".concat(r.e("chunk")," ").concat(r.e("default")),children:[d(e),u(e)]},e.id)};return na("div",{className:"".concat(r.b()," ").concat(e.className||""),children:[na("div",{className:r.e("header"),onClick:function(){return a.value=!a.value,void(null===(t=e.onCollapseChange)||void 0===t||t.call(e,a.value));var t},children:[na("div",{className:r.e("header-left"),children:[na("div",{className:r.em("header-left","icon"),children:bc}),na("div",{className:r.em("header-left","caption"),children:$c.t.value("knowledgeRetrieval")}),na("div",{className:r.em("header-left","desc"),title:null===(t=e.item.result)||void 0===t?void 0:t.query,children:null===(n=e.item.result)||void 0===n?void 0:n.query})]}),na("div",{className:r.e("header-right"),children:[e.item.error&&na("span",{style:"color: red;",children:$c.t.value("errorOccurred")}),e.item.error&&gc,na("span",{title:$c.t.value("copy"),className:r.e("copy"),onClick:function(t){return function(t){var n;t.stopPropagation(),s.value||(i&&clearTimeout(i),s.value=!0,ya.copy(JSON.stringify(e.item,void 0,2)),null===(n=e.controller.opts.utils)||void 0===n||n.message.success($c.t.value("copied")),i=setTimeout(function(){s.value=!1},2e3))}(t)},children:s.value?yc:kc}),na(wc,{style:{"margin-left":" 6px",transform:a.value?"rotate(90deg)":"rotate(0deg)"}})]})]}),a.value&&na("div",{className:r.e("content"),children:e.item.error?na("div",{className:"".concat(r.e("error")," ").concat(r.e("center-text")),children:e.item.result}):o.value.length>0?o.value.map(function(e){return h(e)}):na("div",{className:"".concat(r.e("center-text")),children:$c.t.value("noData")})})]})},Gc=function(e){var t=new ra("chat-image-preview");return na("div",{className:"el-image-viewer__wrapper ".concat(t.b()),children:[na("div",{className:"el-image-viewer__mask",onClick:function(t){var n;return null===(n=e.onClose)||void 0===n?void 0:n.call(e,t)}}),na("span",{className:"el-image-viewer__btn el-image-viewer__close",onClick:function(t){var n;return null===(n=e.onClose)||void 0===n?void 0:n.call(e,t)},children:na("i",{className:"el-icon",children:na("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",children:na("path",{fill:"currentColor",d:"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"})})})}),na("div",{className:"el-image-viewer__canvas",onClick:function(e){return e.stopPropagation()},children:na("img",{src:e.src,className:"el-image-viewer__img",style:"transform: scale(1) rotate(0deg) translate(0px, 0px);"})})]})},Yc=function(e){var t,n,i,r,o=new ra("image-tool-call"),a=Ds(!1),s=Ds(!1),c=Ds(!1);$a(function(){return function(){r&&clearTimeout(r)}},[]);var l,u,d,h,f=function(){var t;null!==(t=e.item.result)&&void 0!==t&&t.image_url&&(a.value=!a.value)};return na("div",{className:"".concat(o.b()," ").concat(e.className||""),children:[na("div",{className:o.e("header"),onClick:function(){return s.value=!s.value,void(null===(t=e.onCollapseChange)||void 0===t||t.call(e,s.value));var t},children:[na("div",{className:o.e("header-left"),children:[na("div",{className:o.em("header-left","icon"),children:Cc}),na("div",{className:o.em("header-left","caption"),children:$c.t.value("imageContent")}),na("div",{className:o.em("header-left","desc"),title:(null===(t=e.item.parameters)||void 0===t?void 0:t.desc)||"",children:(null===(n=e.item.parameters)||void 0===n?void 0:n.desc)||""})]}),na("div",{className:o.e("header-right"),children:[e.item.error&&na("span",{style:"color: red;",children:$c.t.value("errorOccurred")}),e.item.error&&gc,na("span",{title:$c.t.value("copy"),className:o.e("copy"),onClick:function(t){return function(t){var n;t.stopPropagation(),c.value||(r&&clearTimeout(r),c.value=!0,ya.copy(JSON.stringify(e.item,void 0,2)),null===(n=e.controller.opts.utils)||void 0===n||n.message.success($c.t.value("copied")),r=setTimeout(function(){c.value=!1},2e3))}(t)},children:c.value?yc:kc}),na(wc,{style:{"margin-left":" 6px",transform:s.value?"rotate(90deg)":"rotate(0deg)"}})]})]}),s.value&&na("div",{className:o.e("content"),children:e.item.error?na("div",{className:"".concat(o.e("error")," ").concat(o.e("center-text")),children:e.item.result}):null!==(l=e.item.result)&&void 0!==l&&l.image_url||null!==(u=e.item.result)&&void 0!==u&&u.content?[na("img",{className:o.e("image"),src:null===(d=e.item.result)||void 0===d?void 0:d.image_url,onClick:f},"image"),na("div",{className:o.e("description"),children:null===(h=e.item.result)||void 0===h?void 0:h.content},"description")]:na("div",{className:"".concat(o.e("center-text")),children:$c.t.value("noData")})}),a.value&&na(Gc,{src:null===(i=e.item.result)||void 0===i?void 0:i.image_url,onClose:f})]})},Xc=function(e){var t=new ra("chat-tool-call-item"),n=null;switch(e.item.type){case"fetch_chunks":n=Jc;break;case"desc_oss_image":n=Yc;break;default:n=Kc}return Eo(n,{item:e.item,className:t.b(),controller:e.controller,onLinkClick:function(t){e.onLinkClick(t)},onCollapseChange:function(t){var n;null===(n=e.onCollapseChange)||void 0===n||n.call(e,t)}})},Qc=function(e){var t=e.items,n=e.onLinkClick,i=e.onCollapseChange,r=new ra("chat-tool-call"),o=Ds([]),a=Ds(!1),s=Ds(!1),c=function(e){null==n||n(e)};$a(function(){o.value=t.filter(function(e){return e}),s.value=t.length>4},[t]);var l=Is(function(){return s.value&&!a.value?o.value.slice(0,4):o.value});return na("div",{className:"".concat(r.b()),children:[!e.toolcallCompleted&&na("div",{className:r.e("loading-container"),children:[na("div",{className:r.e("loading-text"),children:$c.t.value("agentTool")}),na("div",{className:r.e("loading-dot")}),na("div",{className:r.e("loading-dot")}),na("div",{className:r.e("loading-dot")})]}),e.toolcallCompleted&&l.value.map(function(t,n){return na(Xc,{item:t,controller:e.controller,onLinkClick:c,onCollapseChange:function(e){return null==i?void 0:i(e)}},n)}),e.toolcallCompleted&&s.value&&na("div",{className:r.e("toggle"),onClick:function(){a.value=!a.value},children:na("span",{className:r.e("toggle-label"),children:a.value?$c.t.value("toolCallContraction"):$c.t.value("toolCallExpansion")})})]})},Zc=new ra("chat-search"),el=function(e){var t=e.value,n=e.className,i=e.placeholder,r=e.autoFocus,o=void 0!==r&&r,a=e.onChange,s=e.onEnter,c=g(Wa(!1),2),l=c[0],u=c[1],d=qa(null);$a(function(){var e;o&&(null===(e=d.current)||void 0===e||e.focus())},[]);var h=function(e){var t;e.stopPropagation(),null==a||a(null===(t=e.target)||void 0===t?void 0:t.value)};return na("div",{className:"".concat(Zc.b()," ").concat(Zc.is("focus",l)," ").concat(n||""),children:[na("div",{className:Zc.e("prefix"),children:na(cc,{})}),na("input",{value:t,ref:d,className:Zc.e("inner"),placeholder:i,onFocus:function(){return u(!0)},onBlur:function(){return u(!1)},onChange:function(e){return h(e)},onKeyDown:function(e){var t;"Enter"===e.code&&(null==s||s(null===(t=e.target)||void 0===t?void 0:t.value))}})]})},tl=new ra("chat-loading"),nl=function(e){var t=e.size,n=void 0===t?24:t;return na("div",{className:tl.b(),children:na("div",{className:tl.e("spinner"),style:{width:"".concat(n,"px"),height:"".concat(n,"px")},children:na(Xs,{})})})},il=new ra("chat-single-select"),rl=function(e){var t,n=e.value,i=e.options,r=e.popperStyle,o=e.className,a=void 0===o?"":o,s=e.disabled,c=void 0!==s&&s,l=e.showBorder,u=void 0===l||l,d=e.enableSearch,f=void 0!==d&&d,p=e.placeholder,m=void 0===p?"请选择":p,y=e.icon,k=e.onChange,w=e.onSearch,b=!!i.length&&!c,C=qa(null),S=qa(null),x=Ds(""),T=g(Wa(n),2),M=T[0],_=T[1],N=g(Wa(i),2),O=N[0],E=N[1],A=g(Wa(!1),2),D=A[0],I=A[1],L=g(Wa(!1),2),R=L[0],P=L[1],z=(null===(t=i.find(function(e){return e.value===M}))||void 0===t?void 0:t.label)||m;$a(function(){!1===D&&(x.value="",E(i))},[D]),$a(function(){_(n)},[n]),$a(function(){E(i)},[i]),$a(function(){var e=function(e){var t,n;!b||c||null!==(t=S.current)&&void 0!==t&&t.contains(e.target)||(null!==(n=C.current)&&void 0!==n&&n.contains(e.target)?I(function(e){return!e}):I(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var B=function(){var e=v(h().m(function e(t){var n,r;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,P(!0),n=[],!w){e.n=2;break}return e.n=1,w(t);case 1:n=e.v,e.n=3;break;case 2:n=i.filter(function(e){return e.label.toLowerCase().includes(t.toLowerCase())});case 3:E(n),e.n=5;break;case 4:e.p=4,r=e.v,E([]),console.error($c.t.value("searchFailed"),r);case 5:return e.p=5,P(!1),e.f(5);case 6:return e.a(2)}},e,null,[[0,4,5,6]])}));return function(t){return e.apply(this,arguments)}}();return na("div",{className:"".concat(il.b()," ").concat(a),children:[na("div",{className:"".concat(il.e("button")," ").concat(u?il.em("button","border"):""," ").concat(il.is("focus",D)),ref:C,children:[y?na("span",{className:"".concat(il.em("button","icon")," ").concat(il.em("button","prefix")),children:y()}):null,na("span",{title:z,className:il.em("button","caption"),children:z}),b?na("span",{className:"".concat(il.em("button","icon")," ").concat(il.em("button","suffix")),children:D?Oc():uc()}):null]}),D?na("div",{className:il.e("dropdown"),ref:S,style:r,children:[f?na("div",{className:il.em("dropdown","search"),children:na(el,{placeholder:$c.t.value("search"),autoFocus:!0,value:x.value,onEnter:B,onChange:function(e){x.value=e}})}):null,na("ul",{className:il.em("dropdown","list"),children:R?na(nl,{}):O.length?O.map(function(e){return na("li",{title:e.label,onClick:function(){return function(e){_(e.value),null==k||k(e.value),I(!1)}(e)},className:"".concat(il.em("dropdown","item")," ").concat(il.is("active",e.value===M)),children:e.label},e.value)}):na("li",{className:"el-empty ".concat(il.e("empty")),children:[Sc,na("div",{className:il.em("empty","text"),children:$c.t.value("noData")})]})})]}):null]})},ol=new ra("chat-multiple-select"),al=function(e){var t=e.value,n=e.options,i=e.placeholder,r=e.popperStyle,o=e.enableSearch,a=void 0!==o&&o,s=e.icon,l=e.onChange,u=e.onSearch,d=qa(null),f=qa(null),p=Ds(""),y=g(Wa(!1),2),k=y[0],w=y[1],b=g(Wa(!1),2),C=b[0],S=b[1],x=g(Wa(t||[]),2),T=x[0],M=x[1],_=g(Wa(n),2),N=_[0],O=_[1];$a(function(){M(t||[])},[t]),$a(function(){O(n)},[n]),$a(function(){var e=function(e){var t,n;e.stopPropagation(),e.target&&null!==(t=f.current)&&void 0!==t&&t.contains(e.target)||(null!==(n=d.current)&&void 0!==n&&n.contains(e.target)?w(function(e){return!e}):w(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var E=function(e){var n,i=new Set(t||[]),r=[],o=[],a=m(e);try{for(a.s();!(n=a.n()).done;){var s=n.value;i.has(s.value)?r.push(s):o.push(s)}}catch(c){a.e(c)}finally{a.f()}return[].concat(r,o)},A=function(){var e=v(h().m(function e(t){var i,r;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,S(!0),i=[],!u){e.n=2;break}return e.n=1,u(t);case 1:i=e.v,i=E(i),e.n=3;break;case 2:i=n.filter(function(e){return e.label.toLowerCase().includes(t.toLowerCase())});case 3:O(i),e.n=5;break;case 4:e.p=4,r=e.v,O([]),console.error($c.t.value("searchFailed"),r);case 5:return e.p=5,S(!1),e.f(5);case 6:return e.a(2)}},e,null,[[0,4,5,6]])}));return function(t){return e.apply(this,arguments)}}();$a(function(){!0===k&&(p.value="",A(p.value))},[k]);return na("div",{className:"".concat(ol.b()," ").concat(e.className?e.className:""),children:[na("div",{className:ol.e("button"),ref:d,title:i,children:[s?na("span",{className:"".concat(ol.em("button","icon")," ").concat(ol.em("button","prefix")),children:s()}):null,i?[na("span",{className:ol.em("button","caption"),children:i},"placeholder"),na("span",{className:"".concat(ol.em("button","icon")," ").concat(ol.em("button","suffix")),children:k?Oc():uc()},"icon")]:null]}),k?na("div",{className:ol.e("dropdown"),ref:f,style:r,children:[a?na("div",{className:ol.em("dropdown","search"),children:na(el,{placeholder:$c.t.value("search"),autoFocus:!0,value:p.value,onEnter:A,onChange:function(e){p.value=e}})}):null,na("ul",{className:ol.em("dropdown","list"),children:C?na(nl,{}):N.length?N.map(function(e){return na("li",{title:e.label,className:"".concat(ol.em("dropdown","item")," ").concat(ol.is("active",T.includes(e.value))),onClick:function(){return function(e){var t=T.includes(e.value)?T.filter(function(t){return t!==e.value}):[].concat(c(T),[e.value]);M(t),null==l||l(t)}(e)},children:[na("input",{type:"checkbox",value:e.value,className:ol.em("dropdown","item-checkbox"),checked:T.includes(e.value)}),na("div",{className:ol.em("dropdown","item-label"),children:e.label})]},e.value)}):na("li",{className:"el-empty ".concat(ol.e("empty")),children:[Sc,na("div",{className:ol.em("empty","text"),children:$c.t.value("noData")})]})})]}):null]})};function sl(e,t){for(var n in t)e[n]=t[n];return e}function cl(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var i in t)if("__source"!==i&&e[i]!==t[i])return!0;return!1}function ll(e,t){this.props=e,this.context=t}(ll.prototype=new Io).isPureReactComponent=!0,ll.prototype.shouldComponentUpdate=function(e,t){return cl(this.props,e)||cl(this.state,t)};var ul=ho.__b;ho.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ul&&ul(e)};var dl="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function hl(e){function t(t){var n=sl({},t);return delete n.ref,e(n,t.ref||null)}return t.$$typeof=dl,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var fl=ho.__e;ho.__e=function(e,t,n,i){if(e.then)for(var r,o=t;o=o.__;)if((r=o.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t);fl(e,t,n,i)};var pl=ho.unmount;function vl(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),e.__c.__H=null),null!=(e=sl({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return vl(e,t,n)})),e}function ml(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return ml(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function gl(){this.__u=0,this.o=null,this.__b=null}function yl(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function kl(){this.i=null,this.l=null}ho.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),pl&&pl(e)},(gl.prototype=new Io).__c=function(e,t){var n=t.__c,i=this;null==i.o&&(i.o=[]),i.o.push(n);var r=yl(i.__v),o=!1,a=function(){o||(o=!0,n.__R=null,r?r(s):s())};n.__R=a;var s=function(){if(! --i.__u){if(i.state.__a){var e=i.state.__a;i.__v.__k[0]=ml(e,e.__c.__P,e.__c.__O)}var t;for(i.setState({__a:i.__b=null});t=i.o.pop();)t.forceUpdate()}};i.__u++||32&t.__u||i.setState({__a:i.__b=i.__v.__k[0]}),e.then(a,a)},gl.prototype.componentWillUnmount=function(){this.o=[]},gl.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=vl(this.__b,n,i.__O=i.__P)}this.__b=null}var r=t.__a&&Eo(Do,null,e.fallback);return r&&(r.__u&=-33),[Eo(Do,null,t.__a?null:e.children),r]};var wl=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function bl(e){return this.getChildContext=function(){return e.context},e.children}function Cl(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Zo(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var i=t.__v;null!==i&&!i.__m&&null!==i.__;)i=i.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:i.__m},contains:function(){return!0},insertBefore:function(e,n){this.childNodes.push(e),t.h.insertBefore(e,n)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),t.h.removeChild(e)}}}Zo(Eo(bl,{context:t.context},e.__v),t.v)}function Sl(e,t){var n=Eo(Cl,{__v:e,h:t});return n.containerInfo=t,n}(kl.prototype=new Io).__a=function(e){var t=this,n=yl(t.__v),i=t.l.get(e);return i[0]++,function(r){var o=function(){t.props.revealOrder?(i.push(r),wl(t,e,i)):r()};n?n(o):o()}},kl.prototype.render=function(e){this.i=null,this.l=new Map;var t=Fo(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},kl.prototype.componentDidUpdate=kl.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){wl(e,n,t)})};var xl="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,Tl=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Ml=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,_l=/[A-Z0-9]/g,Nl="undefined"!=typeof document,Ol=function(e){return("undefined"!=typeof Symbol&&"symbol"==_(Symbol())?/fil|che|rad/:/fil|che|ra/).test(e)};Io.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(Io.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var El=ho.event;function Al(){}function Dl(){return this.cancelBubble}function Il(){return this.defaultPrevented}ho.event=function(e){return El&&(e=El(e)),e.persist=Al,e.isPropagationStopped=Dl,e.isDefaultPrevented=Il,e.nativeEvent=e};var Ll={enumerable:!1,configurable:!0,get:function(){return this.class}},Rl=ho.vnode;ho.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,i={},r=-1===n.indexOf("-");for(var o in t){var a=t[o];if(!("value"===o&&"defaultValue"in t&&null==a||Nl&&"children"===o&&"noscript"===n||"class"===o||"className"===o)){var s=o.toLowerCase();"defaultValue"===o&&"value"in t&&null==t.value?o="value":"download"===o&&!0===a?a="":"translate"===s&&"no"===a?a=!1:"o"===s[0]&&"n"===s[1]?"ondoubleclick"===s?o="ondblclick":"onchange"!==s||"input"!==n&&"textarea"!==n||Ol(t.type)?"onfocus"===s?o="onfocusin":"onblur"===s?o="onfocusout":Ml.test(o)&&(o=s):s=o="oninput":r&&Tl.test(o)?o=o.replace(_l,"-$&").toLowerCase():null===a&&(a=void 0),"oninput"===s&&i[o=s]&&(o="oninputCapture"),i[o]=a}}"select"==n&&i.multiple&&Array.isArray(i.value)&&(i.value=Fo(t.children).forEach(function(e){e.props.selected=-1!=i.value.indexOf(e.props.value)})),"select"==n&&null!=i.defaultValue&&(i.value=Fo(t.children).forEach(function(e){e.props.selected=i.multiple?-1!=i.defaultValue.indexOf(e.props.value):i.defaultValue==e.props.value})),t.class&&!t.className?(i.class=t.class,Object.defineProperty(i,"className",Ll)):(t.className&&!t.class||t.class&&t.className)&&(i.class=i.className=t.className),e.props=i}(e),e.$$typeof=xl,Rl&&Rl(e)};var Pl=ho.__r;ho.__r=function(e){Pl&&Pl(e),e.__c};var zl=ho.diffed;ho.diffed=function(e){zl&&zl(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value)};var Bl=function(e){var t=e.triggerMode,n=e.children,i=e.actions,r=e.content,o=e.position,a=void 0===o?"bottom":o,s=e.isOpen,c=e.onToggleOpen,l=e.onAction,u=new ra("pop"),h=Ya(cb),f=g(Wa(s||!1),2),p=f[0],v=f[1],m=qa(null),y=qa(null),k=qa(null);$a(function(){void 0!==s&&v(s)},[s]),$a(function(){return y.current||(y.current=document.createElement("div"),y.current.className=u.b("content-container"),document.body.appendChild(y.current)),function(){y.current&&document.body.removeChild(y.current)}},[]),$a(function(){var e=function(e){!m.current||m.current.contains(e.target)||e.target.closest(".".concat(u.b()))||e.target.closest(".ibiz-quick-edit")||e.target.closest(".ibiz-picker__transfer")||(v(!1),null==c||c(!1))};return p&&document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[p,c]);var w=function(){k.current&&"hover"===t&&(clearTimeout(k.current),k.current=null)},b=function(){"hover"===t&&(w(),k.current=setTimeout(function(){v(!1),null==c||c(!1)},100))};return na("span",{className:"".concat(u.b("trigger-container")),children:[na("span",{className:"".concat(u.b("trigger-element")),ref:m,onClick:function(e){!function(e){if("click"===t){e.stopPropagation();var n=!p;v(n),null==c||c(n)}}(e)},onMouseEnter:function(e){!function(e){if("hover"===t){e.stopPropagation(),w();var n=!0;v(n),null==c||c(n)}}(e)},onMouseLeave:function(e){e.stopPropagation(),b()},children:n}),p&&y.current&&Sl(na("div",{className:"".concat(u.b()," pop-").concat(a),style:function(){if(!m.current)return{};var e=m.current.getBoundingClientRect(),t={position:"absolute",zIndex:h.zIndex+1},n={bottom:{top:e.bottom+window.scrollY,left:e.left+window.scrollX},top:{bottom:window.innerHeight-e.top+window.scrollY,left:e.left+window.scrollX},left:{top:e.top+window.scrollY,right:window.innerWidth-e.left+window.scrollX},right:{top:e.top+window.scrollY,left:e.right+window.scrollX},"top-left":{bottom:window.innerHeight-e.top+window.scrollY,right:window.innerWidth-e.left+window.scrollX}};return d(d({},t),n[a])}(),onMouseEnter:w,onMouseLeave:b,children:r||(null==i?void 0:i.map(function(e){return na("div",{className:"".concat(u.e("item")," ").concat(u.em("item",e.id.toLowerCase())),onMouseDown:function(t){t.stopPropagation(),null==l||l(e.id,t)},children:[e.icon,na("div",{className:u.em("item","caption"),children:e.caption})]},e.id)}))}),y.current)]})},Hl=new ra("messsage-toolbar"),Fl=function(e){var t=e.controller,n=e.message,i=e.onCopy,r=g(Wa(!1),2),o=r[0],a=r[1],s=g(Wa(!1),2),c=s[0],l=s[1],u=[{id:"markdown",caption:$c.t.value("copyMarkdown")},{id:"default",caption:$c.t.value("copy")}],d=[{id:"islike",label:$c.t.value("like"),title:$c.t.value("like"),icon:function(){return na(dc,{})},onClick:function(){t.messageLike(n._origin)}},{id:"isdislike",label:$c.t.value("downvote"),title:$c.t.value("downvote"),icon:function(){return na(hc,{})},onClick:function(){t.messageDisLike(n._origin)}}],h=function(e){var t,n,i,r;return"function"==typeof e.icon?e.icon():null!==(t=e.icon)&&void 0!==t&&t.showIcon&&null!==(n=e.icon)&&void 0!==n&&n.cssClass?na("i",{className:e.icon.cssClass}):null!==(i=e.icon)&&void 0!==i&&i.showIcon&&null!==(r=e.icon)&&void 0!==r&&r.imagePath?ha(e.icon.imagePath)?na("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):na("img",{src:e.icon.imagePath}):void 0},f=Ja(function(){return 20===n.state&&!0!==n.completed},[n.state,n.completed]),p="REMOTE"!==t.resourceMode||t.currentTopicDisableStorage;return f?na(Do,{}):na("div",{className:"".concat(Hl.b()),children:[na(Bl,{position:"top",triggerMode:"hover",isOpen:o,actions:u,onToggleOpen:a,onAction:function(e,t){return i(e)},children:na("div",{title:$c.t.value("copy"),className:"".concat(Hl.e("item")),children:na(Hs,{})})}),!p&&d.map(function(e,i){var r="islike"===e.id&&"1"===n.islike||"isdislike"===e.id&&"1"===n.isdislike;return na("div",{title:e.title,onClick:function(i){return function(e,i){var r;null===(r=i.onClick)||void 0===r||r.call(i,e,i,t.context,t.params,n)}(i,e)},className:"".concat(Hl.e("item")," ").concat(Hl.is("actived",r)),children:h(e)},i)}),n.usage&&na(Bl,{position:"top",triggerMode:"hover",isOpen:c,onToggleOpen:l,content:na("div",{className:Hl.b("statistics"),children:[na("div",{className:Hl.be("statistics","item"),children:[na("span",{className:Hl.be("statistics","icon"),children:na(Ic,{})}),na("span",{className:Hl.be("statistics","label"),children:$c.t.value("totalTokens")}),na("span",{className:Hl.be("statistics","value"),children:n.usage.totaltokens||$c.t.value("notCounted")})]}),na("div",{className:Hl.be("statistics","item"),children:[na("span",{className:Hl.be("statistics","icon"),children:na(Lc,{})}),na("span",{className:Hl.be("statistics","label"),children:$c.t.value("inputTokens")}),na("span",{className:Hl.be("statistics","value"),children:n.usage.prompttokens||$c.t.value("notCounted")})]}),na("div",{className:Hl.be("statistics","item"),children:[na("span",{className:Hl.be("statistics","icon"),children:na(Rc,{})}),na("span",{className:Hl.be("statistics","label"),children:$c.t.value("outputTokens")}),na("span",{className:Hl.be("statistics","value"),children:n.usage.completiontokens||$c.t.value("notCounted")})]}),na("div",{className:Hl.be("statistics","item"),children:[na("span",{className:Hl.be("statistics","icon"),children:na(Pc,{})}),na("span",{className:Hl.be("statistics","label"),children:$c.t.value("toolCallCount")}),na("span",{className:Hl.be("statistics","value"),children:n.usage.toolcalls||$c.t.value("notCalled")})]})]}),children:na("div",{title:$c.t.value("statistics"),className:"".concat(Hl.e("item")),children:na(Dc,{})})})]})},jl=new ra("chat-slider"),Vl=hl(function(e,t){var n=e.min,i=e.max,r=e.step,o=e.onChange,a=qa(null),s=Ds(e.value),c=Math.max.apply(null,[n,i,r].map(function(e){var t="".concat(e).split(".")[1];return t?t.length:0})),l=qa({dragging:!1,startX:0,newPosition:0,startPosition:0}),u=Is(function(){return"".concat((s.value-n)/(i-n)*100,"%")});$a(function(){s.value=e.value},[e.value]);var d=function(e){var t,n;return e.type.startsWith("touch")?(n=e.touches[0].clientY,t=e.touches[0].clientX):(n=e.clientY,t=e.clientX),{clientX:t,clientY:n}},f=function(){var t=v(h().m(function t(a){var s,l,u;return h().w(function(t){for(;;)switch(t.n){case 0:if(null!==a&&!Number.isNaN(+a)){t.n=1;break}return t.a(2);case 1:a<0?a=0:a>100&&(a=100),s=100/((i-n)/r),l=Math.round(a/s),u=l*s*(i-n)*.01+n,(u=Number.parseFloat(u.toFixed(c)))!==e.value&&o(u);case 2:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),p=function(e){if(l.current.dragging){var t=d(e).clientX,n=a.current.parentElement.clientWidth,i=(t-l.current.startX)/n*100;l.current.newPosition=l.current.startPosition+i,f(l.current.newPosition)}},m=function(){l.current.dragging&&(l.current.dragging=!1,window.removeEventListener("mousemove",p),window.removeEventListener("touchmove",p),window.removeEventListener("mouseup",m),window.removeEventListener("touchend",m))},g=function(e){e.preventDefault(),function(e){var t=d(e).clientX,n=Number.parseFloat(u.value);Object.assign(l.current,{dragging:!0,startX:t,startPosition:n,newPosition:n})}(e),window.addEventListener("mousemove",p),window.addEventListener("touchmove",p),window.addEventListener("mouseup",m),window.addEventListener("touchend",m),a.current.focus()};return Ka(t,function(){return{state:l,onButtonDown:g,setPosition:f}}),na("div",{ref:a,className:jl.e("button-wrapper"),onMouseDown:g,onTouchStart:g,style:{left:u.value},children:na("div",{className:jl.e("button")})})}),Wl=new ra("chat-slider"),$l=function(e){var t=e.step,n=void 0===t?1:t,i=e.min,r=void 0===i?0:i,o=e.max,a=void 0===o?100:o,s=e.value,c=void 0===s?0:s,l=e.showText,u=void 0!==l&&l,d=e.className,h=void 0===d?"":d,f=e.onChange,p=qa(null),v=qa(null),m=Ds(c),g=Is(function(){return{width:"".concat(100*(m.value-r)/(a-r),"%"),left:"0%"}});$a(function(){void 0!==c&&(m.value=c)},[c]);var y=function(e){var t,n;if(v.current&&!v.current.state.current.dragging){var i,r=null!==(t=null===(n=e.touches)||void 0===n||null===(n=n.item(0))||void 0===n?void 0:n.clientX)&&void 0!==t?t:e.clientX,o=p.current.getBoundingClientRect();(i=(r-o.left)/o.width*100)<0||i>100||(v.current.setPosition(i),setTimeout(function(){v.current.onButtonDown(e)},0))}};return na("div",{className:"".concat(Wl.b()," ").concat(h),title:"".concat(m.value),children:[na("div",{ref:p,className:Wl.e("runway"),onMouseDown:y,onTouchStart:y,children:[na("div",{className:Wl.e("bar"),style:g.value}),na(Vl,{min:r,max:a,step:n,ref:v,value:m.value,onChange:function(e){m.value=e,null==f||f(e)}})]}),u?na("div",{className:Wl.e("text"),children:m.value}):void 0]})},Ul=new ra("chat-switch"),ql=function(e){var t=e.value,n=e.className,i=void 0===n?"":n,r=e.showText,o=void 0!==r&&r,a=e.onChange,s=g(Wa(void 0),2),c=s[0],l=s[1],u=g(Wa(t),2),d=u[0],h=u[1];$a(function(){h(t)},[t]);return na("div",{className:"".concat(Ul.b()," ").concat(i),children:[na("div",{onClick:function(){var e;void 0===d&&(e=1===c?0:1),l(d),h(e),null==a||a(e)},className:"".concat(Ul.e("wrapper")," ").concat(Ul.is(0===d?"left":1===d?"right":"center",!0))}),o?na("div",{className:Ul.e("text"),children:[0===d?$c.t.value("disabled"):void 0,1===d?$c.t.value("enable"):void 0]}):void 0]})},Kl=new ra("chat-step-item"),Jl=function(e){var t=e.element,n=g(Wa(t.title),2),i=n[0],r=n[1],o=g(Wa(!1),2),a=o[0],s=o[1],c=g(Wa(!1),2),l=c[0],u=c[1],d=g(Wa(0),2),h=d[0],f=d[1],p=Ds(t.content),v=Ds([]),m=Ds({title:$c.t.value("thinkThrough"),description:"",done:!0,collapse:!0}),y=qa(null),k=qa(null),w=function(){if(y.current){var e=y.current;f(e.clientHeight)}};$a(function(){w(),function(){if(k.current){var e=k.current;e.style.display="block";var t=e.scrollHeight;e.style.display="-webkit-box";var n=e.clientHeight;s(!!(t>n))}}(),function(){var e="",n=t.content||"",i=n.indexOf("<think>"),r=n.indexOf("</think>");-1!==i&&-1!==r&&(e=n.slice(i+7,r),n=n.slice(r+8));var o=Ta.parse(n).toolCalls||[];n=n.replace(/<tool_call>[\s\S]*?<\/tool_call>/g,""),m.value.description=e||"",p.value=n||"",v.value=o}(),function(){var e="";t.title?e=t.title:p.value&&(e=p.value);var n=(e=e.replace(/<tool_call>[\s\S]*?<\/tool_call>/g,"")).indexOf("<tool_call>");-1!==n&&-1===e.indexOf("</tool_call>")&&(e=e.substring(0,n)),r(e)}()},[]),$a(function(){setTimeout(function(){w()},0)},[e.element.content]);return na("div",{ref:y,className:"".concat(Kl.b()),style:{"--ibiz-chat-step-item-height":"".concat(h,"px")},children:[na("div",{className:"".concat(Kl.e("left")),children:na("div",{className:"".concat(Kl.e("icon")),children:["success"===t.status&&na(Tc,{}),"failed"===t.status&&na(xc,{}),"pending"===t.status&&na(Ys,{})]})}),na("div",{className:"".concat(Kl.e("right")," ").concat("pending"===t.status?"is-loadding":""),children:["pending"!==t.status&&na("div",{className:"".concat(Kl.e("title")),title:i,children:i}),"pending"!==t.status&&na("div",{className:"".concat(Kl.e("content")),children:[na("div",{ref:k,className:"".concat(Kl.e("content-text")," ").concat(l?"expanded":""),children:[v.value.length>0&&l&&na("div",{className:"".concat(Kl.e("content-tool-call-container")),children:na(Qc,{toolcallCompleted:!0,items:v.value,controller:e.controller,onLinkClick:e.onLinkClick,onCollapseChange:function(e){setTimeout(function(){w()},0)}})}),m.value.description&&l&&na("div",{className:"".concat(Kl.e("content-think-container")),children:na(Uc,{item:m.value,controller:e.controller})}),p.value||""]}),a&&na("button",{className:"".concat(Kl.e("toggle-btn")),onClick:function(){u(!l),setTimeout(function(){w()},0)},children:l?$c.t.value("foldUp"):$c.t.value("expandAll")})]}),"pending"===t.status&&na("div",{className:"".concat(Kl.e("loadding-text")),children:$c.t.value("loading")})]})]})},Gl=new ra("chat-step"),Yl=function(e){var t=e.items,n=Ds(!1),i=Ds(!0),r=Ds([]);$a(function(){n.value=t.length>1,r.value=n.value&&!i.value?[t[t.length-1]]:t},[t]);return na("div",{className:"".concat(Gl.b()),children:[na("div",{className:Gl.e("container"),children:r.value.map(function(t,n){return na(Jl,{element:t,controller:e.controller,onLinkClick:e.onLinkClick},"".concat(t.title,"_").concat(t.content,"_").concat(n))})}),n.value&&na("div",{className:Gl.e("toggle"),onClick:function(){i.value=!i.value,r.value=n.value&&!i.value?[t[t.length-1]]:t},children:na("span",{className:Gl.e("toggle-label"),children:i.value?$c.t.value("stepFoldUp"):$c.t.value("stepExpand")})})]})},Xl=new ra("ossfile-material"),Ql=function(e){var t=Is(function(){return e.material.data.name}),n=Is(function(){var t,n=e.material.metadata.size;return(t=n)>=1048576?"".concat((t/1048576).toFixed(2),"M"):t>=1024?"".concat((t/1024).toFixed(2),"K"):"".concat(t,"B")}),i=Is(function(){return e.material.metadata.state}),r=Is(function(){var t=e.material.metadata.state;return"successed"===t?$c.t.value("uploadSuccess"):"uploading"===t?$c.t.value("uploading"):"failed"===t?$c.t.value("uploadFailed"):$c.t.value("unknownState")}),o=Is(function(){switch(e.material.metadata.state){case"successed":return"#1890ff";case"uploading":return"#52c41a";default:return"#ff4d4f"}});return na("div",{className:Xl.b(),children:[na("div",{className:Xl.b("left"),children:na(Zs,{})}),na("div",{className:Xl.b("right"),children:[na("div",{className:Xl.e("name"),title:t,children:t}),na("div",{className:Xl.b("metadata"),children:[na("div",{children:n}),"successed"!==i.value&&na("div",{style:{color:o.value},children:r}),"successed"===i.value&&na("div",{className:Xl.be("metadata","img"),title:$c.t.value("download"),onClick:function(){var t=e.material.metadata;e.controller.opts.uploader.onDownLoad(t,{context:e.controller.context,params:e.controller.params})},children:na(vc,{})})]})]})]})},Zl=new ra("common-material"),eu=function(e){var t,n,i,r,o=null===(t=e.controller.opts.questionToolbarItems)||void 0===t?void 0:t.find(function(t){return t.id===e.material.metadata.actionId}),a=Is(function(){return e.material.metadata.name}),s=Is(function(){return e.material.metadata.downloadactionid});return na("div",{className:Zl.b(),children:[na("div",{className:Zl.b("left"),children:o&&o.icon?"function"==typeof o.icon?o.icon():(null===(n=o.icon)||void 0===n?void 0:n.showIcon)&&na(Do,{children:null!==(i=o.icon)&&void 0!==i&&i.cssClass?na("i",{className:o.icon.cssClass}):null!==(r=o.icon)&&void 0!==r&&r.imagePath?ha(o.icon.imagePath)?na("div",{dangerouslySetInnerHTML:{__html:o.icon.imagePath}}):na("img",{src:o.icon.imagePath}):null}):na(tc,{})}),na("div",{className:Zl.b("right"),children:[na("div",{className:Zl.e("name"),title:a,children:a}),na("div",{className:Zl.b("metadata"),children:[na("div",{children:(null==o?void 0:o.label)||$c.t.value("meterialResources")}),s&&na("div",{className:Zl.be("metadata","img"),title:$c.t.value("preview"),onClick:function(t){var n=e.material.metadata,i=e.controller.opts.extendToolbarClick;if(i&&"function"==typeof i){var r=n.downloadactionid;if(!s)throw new Error($c.t.value("downloadCannotEmpty"));var o=n.downloadAppId,a=d({},e.controller.context);if(n.downloadContext)try{var c=n.downloadContext.split(";").reduce(function(e,t){if(t.trim()){var n=g(t.split(":"),2),i=n[0],r=n[1];i&&r&&(e[i.trim()]=r.trim())}return e},{});c&&Object.keys(c).length>0&&Object.assign(a,c)}catch(l){throw new Error($c.t.value("downloadExContext"))}i(t,{id:r,isPluginApp:!!o,appId:o||a.srfappid},a,e.controller.params,{})}},children:na(vc,{})})]})]})]})},tu=new ra("chat-input-material-item"),nu=function(e){var t=e.material,n=null;if("ossfile"===t.type)n=Ql;else n=eu;return na("div",{className:"".concat(tu.b()," ").concat(tu.is("disabled",e.disabled)),children:[na("div",{className:tu.e("icon"),onClick:function(){e.controller.deleteMaterial(t)},children:na(ec,{})}),Eo(n,{material:t,controller:e.controller})]})},iu=new ra("markdown-message"),ru=function(e){var t=e.message,n=e.size,i=qa(null),r=Ds(null),o=Ds(""),a=Ds({resources:[],remainingText:"",hasResources:!1}),c=function(e){var t=ba.parseMixedContent(e),n=t.resources,i=t.remainingText,r=t.hasResources,o=t.error;a.value={resources:n,remainingText:i,hasResources:r,error:o}},l=Ja(function(){return 20===t.state&&!0!==t.completed},[t.state,t.completed]),u=Ja(function(){return 20===t.state&&!0===t.completed},[t.state,t.completed]);t.think||(t.think={title:"",description:"",collapse:!0});var h=function(e,n){t.think=d(d({},t.think),{},{title:e?$c.t.value("thinkThrough"):!0===t.completed?$c.t.value("stopThinking"):$c.t.value("thinking"),description:n||"",done:e||!0===t.completed}),t.think.done||(t.think.beginTime||(t.think.beginTime=Date.now()),t.think.endTime=void 0),t.think.done&&!t.think.endTime&&(t.think.endTime=Date.now(),t.think.collapse=!0)},f=Ds({hasSuggestions:!1,suggestions:[]}),p=function(e){var t=e.indexOf("<think>"),n=e.indexOf("</think>"),i="",r="",o=!1;return-1===n?(o=!1,i=e.slice(t+7),r=""):(o=!0,i=e.slice(t+7,n),r=e.slice(n+8)),{isThoughtCompleted:o,thoughtContent:i,answerContent:r}},v=function(t){var n=t.target,i=null==n?void 0:n.closest('a[href^="chunkview://"], a[href^="view://"], a[href^="action://"]');if(i){t.preventDefault();var r=i.getAttribute("href");if(r){var o="";switch(r.startsWith("chunkview://")?o="chunkview":r.startsWith("view://")?o="view":r.startsWith("action://")&&(o="action"),o){case"chunkview":case"view":case"action":e.controller.handlePredefinedClick(o,r,e.message,t);break;default:console.error($c.t.value("protocol",{protocol:o}))}}return!1}};$a(function(){if(t.content&&-1!==t.content.indexOf("<think>")){var n=p(t.content),i=n.isThoughtCompleted,r=n.thoughtContent,a=n.answerContent;h(i,r),c(a)}else c(t.content);!function(){var n="";if(t.agent_tag&&(n=t.agent_tag),n){var i=e.controller.agentList.value.find(function(e){return e.id===n});o.value=(null==i?void 0:i.caption)||""}}()},[]),$a(function(){var e;e=Na.protect(a.value.remainingText||""),r.value?r.value.setMarkdown(e):r.value=new s({el:i.current,value:e,editor:{defaultModel:"previewOnly",codemirror:{autofocus:!1}},themeSettings:{mainTheme:"dark",codeBlockTheme:"dark"},previewer:{enablePreviewerBubble:!1},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}},callback:{onClickPreview:v}})},[a.value.remainingText]),$a(function(){if(n>=0&&r.value){if(t.content&&-1!==t.content.indexOf("<think>")){var e=p(t.content),i=e.isThoughtCompleted,o=e.thoughtContent,a=e.answerContent;h(i,o),c(a)}else c(t.content);(s=t.suggestions)&&s.length>0?f.value={hasSuggestions:!0,suggestions:s}:f.value={hasSuggestions:!1,suggestions:[]}}var s},[t,n]);return na("div",{className:"".concat(iu.b()," ").concat(iu.is("loading",l)),children:[na("div",{className:iu.b("header"),children:[na("div",{className:iu.be("header","caption"),children:["AI",o.value&&" | ".concat(o.value)]}),e.children,u?na("div",{className:iu.be("header","timeout"),children:$c.t.value("requestTimeout")}):null]}),na("div",{className:"".concat(iu.b("content")," pre-wrap-container"),children:[a.value.hasResources&&na("div",{className:"content-material-container",children:a.value.resources.map(function(t){return na(nu,{material:t,disabled:!0,controller:e.controller},t.id)})}),t.chatsteps&&t.chatsteps.length>0&&na(Yl,{items:t.chatsteps||[],controller:e.controller,onLinkClick:v}),na(Qc,{toolcallCompleted:!!t.toolcallcompleted,items:t.toolcalls||[],controller:e.controller,onLinkClick:v}),na(Uc,{item:t.think,controller:e.controller}),na("div",{className:iu.e("markdown"),ref:i})]}),na("div",{className:iu.b("footer"),children:[na(Fl,{onCopy:function(n){var o,a,s=("markdown"===n?null===(o=r.value)||void 0===o?void 0:o.getMarkdown():null===(a=i.current)||void 0===a?void 0:a.innerText)||"";e.controller.copyMessage(s,t)},message:t,controller:e.controller},"".concat(t.messageid,"_").concat(t.islike,"_").concat(t.isdislike)),f.value.hasSuggestions||t.chatuiactions&&t.chatuiactions.length>0?na(qc,{uiactions:t.chatuiactions||[],suggestions:f.value.suggestions,onSuggestionClick:function(t,n){!function(t,n){e.controller.handleSuggestionClick(e.message,t,n)}(t,n)},onUIActionClick:function(t,n){!function(t,n){e.controller.handleUIActionClick(e.message,t,n)}(t,n)}}):null]})]})};function ou(e){this.content=e}function au(e,t,n){for(var i=0;;i++){if(i==e.childCount||i==t.childCount)return e.childCount==t.childCount?null:n;var r=e.child(i),o=t.child(i);if(r!=o){if(!r.sameMarkup(o))return n;if(r.isText&&r.text!=o.text){for(var a=0;r.text[a]==o.text[a];a++)n++;return n}if(r.content.size||o.content.size){var s=au(r.content,o.content,n+1);if(null!=s)return s}n+=r.nodeSize}else n+=r.nodeSize}}function su(e,t,n,i){for(var r=e.childCount,o=t.childCount;;){if(0==r||0==o)return r==o?null:{a:n,b:i};var a=e.child(--r),s=t.child(--o),c=a.nodeSize;if(a!=s){if(!a.sameMarkup(s))return{a:n,b:i};if(a.isText&&a.text!=s.text){for(var l=0,u=Math.min(a.text.length,s.text.length);l<u&&a.text[a.text.length-l-1]==s.text[s.text.length-l-1];)l++,n--,i--;return{a:n,b:i}}if(a.content.size||s.content.size){var d=su(a.content,s.content,n-1,i-1);if(d)return d}n-=c,i-=c}else n-=c,i-=c}}ou.prototype={constructor:ou,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var i=n&&n!=e?this.remove(n):this,r=i.find(e),o=i.content.slice();return-1==r?o.push(n||e,t):(o[r+1]=t,n&&(o[r]=n)),new ou(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new ou(n)},addToStart:function(e,t){return new ou([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new ou(n)},addBefore:function(e,t,n){var i=this.remove(t),r=i.content.slice(),o=i.find(e);return r.splice(-1==o?r.length:o,0,t,n),new ou(r)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=ou.from(e)).size?new ou(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=ou.from(e)).size?new ou(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=ou.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},ou.from=function(e){if(e instanceof ou)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new ou(t)};var cu=function(){function e(t,n){if(C(this,e),this.content=t,this.size=n||0,null==n)for(var i=0;i<t.length;i++)this.size+=t[i].nodeSize}return x(e,[{key:"nodesBetween",value:function(e,t,n){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4?arguments[4]:void 0,o=0,a=0;a<t;o++){var s=this.content[o],c=a+s.nodeSize;if(c>e&&!1!==n(s,i+a,r||null,o)&&s.content.size){var l=a+1;s.nodesBetween(Math.max(0,e-l),Math.min(s.content.size,t-l),n,i+l)}a=c}}},{key:"descendants",value:function(e){this.nodesBetween(0,this.size,e)}},{key:"textBetween",value:function(e,t,n,i){var r="",o=!0;return this.nodesBetween(e,t,function(a,s){var c=a.isText?a.text.slice(Math.max(e,s)-s,t-s):a.isLeaf?i?"function"==typeof i?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&n&&(o?o=!1:r+=n),r+=c},0),r}},{key:"append",value:function(t){if(!t.size)return this;if(!this.size)return t;var n=this.lastChild,i=t.firstChild,r=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(i)&&(r[r.length-1]=n.withText(n.text+i.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new e(r,this.size+t.size)}},{key:"cut",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size;if(0==t&&n==this.size)return this;var i=[],r=0;if(n>t)for(var o=0,a=0;a<n;o++){var s=this.content[o],c=a+s.nodeSize;c>t&&((a<t||c>n)&&(s=s.isText?s.cut(Math.max(0,t-a),Math.min(s.text.length,n-a)):s.cut(Math.max(0,t-a-1),Math.min(s.content.size,n-a-1))),i.push(s),r+=s.nodeSize),a=c}return new e(i,r)}},{key:"cutByIndex",value:function(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}},{key:"replaceChild",value:function(t,n){var i=this.content[t];if(i==n)return this;var r=this.content.slice(),o=this.size+n.nodeSize-i.nodeSize;return r[t]=n,new e(r,o)}},{key:"addToStart",value:function(t){return new e([t].concat(this.content),this.size+t.nodeSize)}},{key:"addToEnd",value:function(t){return new e(this.content.concat(t),this.size+t.nodeSize)}},{key:"eq",value:function(e){if(this.content.length!=e.content.length)return!1;for(var t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}},{key:"firstChild",get:function(){return this.content.length?this.content[0]:null}},{key:"lastChild",get:function(){return this.content.length?this.content[this.content.length-1]:null}},{key:"childCount",get:function(){return this.content.length}},{key:"child",value:function(e){var t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}},{key:"maybeChild",value:function(e){return this.content[e]||null}},{key:"forEach",value:function(e){for(var t=0,n=0;t<this.content.length;t++){var i=this.content[t];e(i,n,t),n+=i.nodeSize}}},{key:"findDiffStart",value:function(e){return au(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0)}},{key:"findDiffEnd",value:function(e){return su(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size,arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.size)}},{key:"findIndex",value:function(e){if(0==e)return uu(0,e);if(e==this.size)return uu(this.content.length,e);if(e>this.size||e<0)throw new RangeError("Position ".concat(e," outside of fragment (").concat(this,")"));for(var t=0,n=0;;t++){var i=n+this.child(t).nodeSize;if(i>=e)return i==e?uu(t+1,i):uu(t,n);n=i}}},{key:"toString",value:function(){return"<"+this.toStringInner()+">"}},{key:"toStringInner",value:function(){return this.content.join(", ")}},{key:"toJSON",value:function(){return this.content.length?this.content.map(function(e){return e.toJSON()}):null}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new e(n.map(t.nodeFromJSON))}},{key:"fromArray",value:function(t){if(!t.length)return e.empty;for(var n,i=0,r=0;r<t.length;r++){var o=t[r];i+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(n||(n=t.slice(0,r)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,i)}},{key:"from",value:function(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}])}();cu.empty=new cu([],0);var lu={index:0,offset:0};function uu(e,t){return lu.index=e,lu.offset=t,lu}function du(e,t){if(e===t)return!0;if(!e||"object"!=_(e)||!t||"object"!=_(t))return!1;var n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(var i=0;i<e.length;i++)if(!du(e[i],t[i]))return!1}else{for(var r in e)if(!(r in t)||!du(e[r],t[r]))return!1;for(var o in t)if(!(o in e))return!1}return!0}var hu=function(){function e(t,n){C(this,e),this.type=t,this.attrs=n}return x(e,[{key:"addToSet",value:function(e){for(var t,n=!1,i=0;i<e.length;i++){var r=e[i];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,i));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(r)}}return t||(t=e.slice()),n||t.push(this),t}},{key:"removeFromSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}},{key:"eq",value:function(e){return this==e||this.type==e.type&&du(this.attrs,e.attrs)}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");var n=e.marks[t.type];if(!n)throw new RangeError("There is no mark type ".concat(t.type," in this schema"));var i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}},{key:"sameSet",value:function(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}},{key:"setFrom",value:function(t){if(!t||Array.isArray(t)&&0==t.length)return e.none;if(t instanceof e)return[t];var n=t.slice();return n.sort(function(e,t){return e.type.rank-t.type.rank}),n}}])}();hu.none=[];var fu=function(e){function t(){return C(this,t),n(this,t,arguments)}return i(t,e),x(t)}(r(Error)),pu=function(){function e(t,n,i){C(this,e),this.content=t,this.openStart=n,this.openEnd=i}return x(e,[{key:"size",get:function(){return this.content.size-this.openStart-this.openEnd}},{key:"insertAt",value:function(t,n){var i=mu(this.content,t+this.openStart,n);return i&&new e(i,this.openStart,this.openEnd)}},{key:"removeBetween",value:function(t,n){return new e(vu(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}},{key:"eq",value:function(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}},{key:"toString",value:function(){return this.content+"("+this.openStart+","+this.openEnd+")"}},{key:"toJSON",value:function(){if(!this.content.size)return null;var e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;var i=n.openStart||0,r=n.openEnd||0;if("number"!=typeof i||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new e(cu.fromJSON(t,n.content),i,r)}},{key:"maxOpen",value:function(t){for(var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=0,r=0,o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)i++;for(var a=t.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)r++;return new e(t,i,r)}}])}();function vu(e,t,n){var i=e.findIndex(t),r=i.index,o=i.offset,a=e.maybeChild(r),s=e.findIndex(n),c=s.index,l=s.offset;if(o==t||a.isText){if(l!=n&&!e.child(c).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=c)throw new RangeError("Removing non-flat range");return e.replaceChild(r,a.copy(vu(a.content,t-o-1,n-o-1)))}function mu(e,t,n,i){var r=e.findIndex(t),o=r.index,a=r.offset,s=e.maybeChild(o);if(a==t||s.isText)return i&&!i.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));var c=mu(s.content,t-a-1,n,s);return c&&e.replaceChild(o,s.copy(c))}function gu(e,t,n){if(n.openStart>e.depth)throw new fu("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new fu("Inconsistent open depths");return yu(e,t,n,0)}function yu(e,t,n,i){var r=e.index(i),o=e.node(i);if(r==t.index(i)&&i<e.depth-n.openStart){var a=yu(e,t,n,i+1);return o.copy(o.content.replaceChild(r,a))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=i||t.depth!=i){var s=function(e,t){for(var n=t.depth-e.openStart,i=t.node(n).copy(e.content),r=n-1;r>=0;r--)i=t.node(r).copy(cu.from(i));return{start:i.resolveNoCache(e.openStart+n),end:i.resolveNoCache(i.content.size-e.openEnd-n)}}(n,e);return Su(o,xu(e,s.start,s.end,t,i))}var c=e.parent,l=c.content;return Su(c,l.cut(0,e.parentOffset).append(n.content).append(l.cut(t.parentOffset)))}return Su(o,Tu(e,t,i))}function ku(e,t){if(!t.type.compatibleContent(e.type))throw new fu("Cannot join "+t.type.name+" onto "+e.type.name)}function wu(e,t,n){var i=e.node(n);return ku(i,t.node(n)),i}function bu(e,t){var n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Cu(e,t,n,i){var r=(t||e).node(n),o=0,a=t?t.index(n):r.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(bu(e.nodeAfter,i),o++));for(var s=o;s<a;s++)bu(r.child(s),i);t&&t.depth==n&&t.textOffset&&bu(t.nodeBefore,i)}function Su(e,t){return e.type.checkContent(t),e.copy(t)}function xu(e,t,n,i,r){var o=e.depth>r&&wu(e,t,r+1),a=i.depth>r&&wu(n,i,r+1),s=[];return Cu(null,e,r,s),o&&a&&t.index(r)==n.index(r)?(ku(o,a),bu(Su(o,xu(e,t,n,i,r+1)),s)):(o&&bu(Su(o,Tu(e,t,r+1)),s),Cu(t,n,r,s),a&&bu(Su(a,Tu(n,i,r+1)),s)),Cu(i,null,r,s),new cu(s)}function Tu(e,t,n){var i=[];(Cu(null,e,n,i),e.depth>n)&&bu(Su(wu(e,t,n+1),Tu(e,t,n+1)),i);return Cu(t,null,n,i),new cu(i)}pu.empty=new pu(cu.empty,0,0);var Mu=function(){function e(t,n,i){C(this,e),this.pos=t,this.path=n,this.parentOffset=i,this.depth=n.length/3-1}return x(e,[{key:"resolveDepth",value:function(e){return null==e?this.depth:e<0?this.depth+e:e}},{key:"parent",get:function(){return this.node(this.depth)}},{key:"doc",get:function(){return this.node(0)}},{key:"node",value:function(e){return this.path[3*this.resolveDepth(e)]}},{key:"index",value:function(e){return this.path[3*this.resolveDepth(e)+1]}},{key:"indexAfter",value:function(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}},{key:"start",value:function(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}},{key:"end",value:function(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}},{key:"before",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}},{key:"after",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}},{key:"textOffset",get:function(){return this.pos-this.path[this.path.length-1]}},{key:"nodeAfter",get:function(){var e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;var n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}},{key:"nodeBefore",get:function(){var e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}},{key:"posAtIndex",value:function(e,t){t=this.resolveDepth(t);for(var n=this.path[3*t],i=0==t?0:this.path[3*t-1]+1,r=0;r<e;r++)i+=n.child(r).nodeSize;return i}},{key:"marks",value:function(){var e=this.parent,t=this.index();if(0==e.content.size)return hu.none;if(this.textOffset)return e.child(t).marks;var n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){var r=n;n=i,i=r}for(var o=n.marks,a=0;a<o.length;a++)!1!==o[a].type.spec.inclusive||i&&o[a].isInSet(i.marks)||(o=o[a--].removeFromSet(o));return o}},{key:"marksAcross",value:function(e){var t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;for(var n=t.marks,i=e.parent.maybeChild(e.index()),r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||i&&n[r].isInSet(i.marks)||(n=n[r--].removeFromSet(n));return n}},{key:"sharedDepth",value:function(e){for(var t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}},{key:"blockRange",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this,t=arguments.length>1?arguments[1]:void 0;if(e.pos<this.pos)return e.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Eu(this,e,n);return null}},{key:"sameParent",value:function(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}},{key:"max",value:function(e){return e.pos>this.pos?e:this}},{key:"min",value:function(e){return e.pos<this.pos?e:this}},{key:"toString",value:function(){for(var e="",t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}}],[{key:"resolve",value:function(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");for(var i=[],r=0,o=n,a=t;;){var s=a.content.findIndex(o),c=s.index,l=s.offset,u=o-l;if(i.push(a,c,r+l),!u)break;if((a=a.child(c)).isText)break;o=u-1,r+=l+1}return new e(n,i,o)}},{key:"resolveCached",value:function(t,n){var i=Ou.get(t);if(i)for(var r=0;r<i.elts.length;r++){var o=i.elts[r];if(o.pos==n)return o}else Ou.set(t,i=new _u);var a=i.elts[i.i]=e.resolve(t,n);return i.i=(i.i+1)%Nu,a}}])}(),_u=x(function e(){C(this,e),this.elts=[],this.i=0}),Nu=12,Ou=new WeakMap,Eu=function(){return x(function e(t,n,i){C(this,e),this.$from=t,this.$to=n,this.depth=i},[{key:"start",get:function(){return this.$from.before(this.depth+1)}},{key:"end",get:function(){return this.$to.after(this.depth+1)}},{key:"parent",get:function(){return this.$from.node(this.depth)}},{key:"startIndex",get:function(){return this.$from.index(this.depth)}},{key:"endIndex",get:function(){return this.$to.indexAfter(this.depth)}}])}(),Au=Object.create(null),Du=function(){function e(t,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:hu.none;C(this,e),this.type=t,this.attrs=n,this.marks=r,this.content=i||cu.empty}return x(e,[{key:"children",get:function(){return this.content.content}},{key:"nodeSize",get:function(){return this.isLeaf?1:2+this.content.size}},{key:"childCount",get:function(){return this.content.childCount}},{key:"child",value:function(e){return this.content.child(e)}},{key:"maybeChild",value:function(e){return this.content.maybeChild(e)}},{key:"forEach",value:function(e){this.content.forEach(e)}},{key:"nodesBetween",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.content.nodesBetween(e,t,n,i,this)}},{key:"descendants",value:function(e){this.nodesBetween(0,this.content.size,e)}},{key:"textContent",get:function(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}},{key:"textBetween",value:function(e,t,n,i){return this.content.textBetween(e,t,n,i)}},{key:"firstChild",get:function(){return this.content.firstChild}},{key:"lastChild",get:function(){return this.content.lastChild}},{key:"eq",value:function(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}},{key:"sameMarkup",value:function(e){return this.hasMarkup(e.type,e.attrs,e.marks)}},{key:"hasMarkup",value:function(e,t,n){return this.type==e&&du(this.attrs,t||e.defaultAttrs||Au)&&hu.sameSet(this.marks,n||hu.none)}},{key:"copy",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}},{key:"mark",value:function(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}},{key:"cut",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size;return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}},{key:"slice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e==t)return pu.empty;var i=this.resolve(e),r=this.resolve(t),o=n?0:i.sharedDepth(t),a=i.start(o),s=i.node(o).content.cut(i.pos-a,r.pos-a);return new pu(s,i.depth-o,r.depth-o)}},{key:"replace",value:function(e,t,n){return gu(this.resolve(e),this.resolve(t),n)}},{key:"nodeAt",value:function(e){for(var t=this;;){var n=t.content.findIndex(e),i=n.index,r=n.offset;if(!(t=t.maybeChild(i)))return null;if(r==e||t.isText)return t;e-=r+1}}},{key:"childAfter",value:function(e){var t=this.content.findIndex(e),n=t.index,i=t.offset;return{node:this.content.maybeChild(n),index:n,offset:i}}},{key:"childBefore",value:function(e){if(0==e)return{node:null,index:0,offset:0};var t=this.content.findIndex(e),n=t.index,i=t.offset;if(i<e)return{node:this.content.child(n),index:n,offset:i};var r=this.content.child(n-1);return{node:r,index:n-1,offset:i-r.nodeSize}}},{key:"resolve",value:function(e){return Mu.resolveCached(this,e)}},{key:"resolveNoCache",value:function(e){return Mu.resolve(this,e)}},{key:"rangeHasMark",value:function(e,t,n){var i=!1;return t>e&&this.nodesBetween(e,t,function(e){return n.isInSet(e.marks)&&(i=!0),!i}),i}},{key:"isBlock",get:function(){return this.type.isBlock}},{key:"isTextblock",get:function(){return this.type.isTextblock}},{key:"inlineContent",get:function(){return this.type.inlineContent}},{key:"isInline",get:function(){return this.type.isInline}},{key:"isText",get:function(){return this.type.isText}},{key:"isLeaf",get:function(){return this.type.isLeaf}},{key:"isAtom",get:function(){return this.type.isAtom}},{key:"toString",value:function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Lu(this.marks,e)}},{key:"contentMatchAt",value:function(e){var t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}},{key:"canReplace",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:cu.empty,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:n.childCount,o=this.contentMatchAt(e).matchFragment(n,i,r),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(var s=i;s<r;s++)if(!this.type.allowsMarks(n.child(s).marks))return!1;return!0}},{key:"canReplaceWith",value:function(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;var r=this.contentMatchAt(e).matchType(n),o=r&&r.matchFragment(this.content,t);return!!o&&o.validEnd}},{key:"canAppend",value:function(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}},{key:"check",value:function(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);for(var e=hu.none,t=0;t<this.marks.length;t++){var n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!hu.sameSet(e,this.marks))throw new RangeError("Invalid collection of marks for node ".concat(this.type.name,": ").concat(this.marks.map(function(e){return e.type.name})));this.content.forEach(function(e){return e.check()})}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var 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(function(e){return e.toJSON()})),e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");var n=void 0;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}var i=cu.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,i,n);return r.type.checkAttrs(r.attrs),r}}])}();Du.prototype.text=void 0;var Iu=function(t){function r(e,t,i,o){var a;if(C(this,r),a=n(this,r,[e,t,null,o]),!i)throw new RangeError("Empty text nodes are not allowed");return a.text=i,a}return i(r,t),x(r,[{key:"toString",value:function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Lu(this.marks,JSON.stringify(this.text))}},{key:"textContent",get:function(){return this.text}},{key:"textBetween",value:function(e,t){return this.text.slice(e,t)}},{key:"nodeSize",get:function(){return this.text.length}},{key:"mark",value:function(e){return e==this.marks?this:new r(this.type,this.attrs,this.text,e)}},{key:"withText",value:function(e){return e==this.text?this:new r(this.type,this.attrs,e,this.marks)}},{key:"cut",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.text.length;return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}},{key:"eq",value:function(e){return this.sameMarkup(e)&&this.text==e.text}},{key:"toJSON",value:function(){var t=e(r,"toJSON",this,3)([]);return t.text=this.text,t}}])}(Du);function Lu(e,t){for(var n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var Ru=function(){function e(t){C(this,e),this.validEnd=t,this.next=[],this.wrapCache=[]}return x(e,[{key:"matchType",value:function(e){for(var t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}},{key:"matchFragment",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.childCount,i=this,r=t;i&&r<n;r++)i=i.matchType(e.child(r).type);return i}},{key:"inlineContent",get:function(){return 0!=this.next.length&&this.next[0].type.isInline}},{key:"defaultType",get:function(){for(var e=0;e<this.next.length;e++){var t=this.next[e].type;if(!t.isText&&!t.hasRequiredAttrs())return t}return null}},{key:"compatible",value:function(e){for(var t=0;t<this.next.length;t++)for(var n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}},{key:"fillBefore",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=[this];return function r(o,a){var s=o.matchFragment(e,n);if(s&&(!t||s.validEnd))return cu.from(a.map(function(e){return e.createAndFill()}));for(var c=0;c<o.next.length;c++){var l=o.next[c],u=l.type,d=l.next;if(!u.isText&&!u.hasRequiredAttrs()&&-1==i.indexOf(d)){i.push(d);var h=r(d,a.concat(u));if(h)return h}}return null}(this,[])}},{key:"findWrapping",value:function(e){for(var t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];var n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}},{key:"computeWrapping",value:function(e){for(var t=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var i=n.shift(),r=i.match;if(r.matchType(e)){for(var o=[],a=i;a.type;a=a.via)o.push(a.type);return o.reverse()}for(var s=0;s<r.next.length;s++){var c=r.next[s],l=c.type,u=c.next;l.isLeaf||l.hasRequiredAttrs()||l.name in t||i.type&&!u.validEnd||(n.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}},{key:"edgeCount",get:function(){return this.next.length}},{key:"edge",value:function(e){if(e>=this.next.length)throw new RangeError("There's no ".concat(e,"th edge in this content match"));return this.next[e]}},{key:"toString",value:function(){var e=[];return function t(n){e.push(n);for(var i=0;i<n.next.length;i++)-1==e.indexOf(n.next[i].next)&&t(n.next[i].next)}(this),e.map(function(t,n){for(var i=n+(t.validEnd?"*":" ")+" ",r=0;r<t.next.length;r++)i+=(r?", ":"")+t.next[r].type.name+"->"+e.indexOf(t.next[r].next);return i}).join("\n")}}],[{key:"parse",value:function(t,n){var i=new Pu(t,n);if(null==i.next)return e.empty;var r=zu(i);i.next&&i.err("Unexpected trailing text");var o=$u(function(e){var t=[[]];return r(o(e,0),n()),t;function n(){return t.push([])-1}function i(e,n,i){var r={term:i,to:n};return t[e].push(r),r}function r(e,t){e.forEach(function(e){return e.to=t})}function o(e,t){if("choice"==e.type)return e.exprs.reduce(function(e,n){return e.concat(o(n,t))},[]);if("seq"!=e.type){if("star"==e.type){var a=n();return i(t,a),r(o(e.expr,a),a),[i(a)]}if("plus"==e.type){var s=n();return r(o(e.expr,t),s),r(o(e.expr,s),s),[i(s)]}if("opt"==e.type)return[i(t)].concat(o(e.expr,t));if("range"==e.type){for(var c=t,l=0;l<e.min;l++){var u=n();r(o(e.expr,c),u),c=u}if(-1==e.max)r(o(e.expr,c),c);else for(var d=e.min;d<e.max;d++){var h=n();i(c,h),r(o(e.expr,c),h),c=h}return[i(c)]}if("name"==e.type)return[i(t,void 0,e.value)];throw new Error("Unknown expr type")}for(var f=0;;f++){var p=o(e.exprs[f],t);if(f==e.exprs.length-1)return p;r(p,t=n())}}}(r));return function(e,t){for(var n=0,i=[e];n<i.length;n++){for(var r=i[n],o=!r.validEnd,a=[],s=0;s<r.next.length;s++){var c=r.next[s],l=c.type,u=c.next;a.push(l.name),!o||l.isText||l.hasRequiredAttrs()||(o=!1),-1==i.indexOf(u)&&i.push(u)}o&&t.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,i),o}}])}();Ru.empty=new Ru(!0);var Pu=function(){return x(function e(t,n){C(this,e),this.string=t,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},[{key:"next",get:function(){return this.tokens[this.pos]}},{key:"eat",value:function(e){return this.next==e&&(this.pos++||!0)}},{key:"err",value:function(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}])}();function zu(e){var t=[];do{t.push(Bu(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function Bu(e){var t=[];do{t.push(Hu(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function Hu(e){for(var t=function(e){if(e.eat("(")){var t=zu(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(e,t){var n=e.nodeTypes,i=n[t];if(i)return[i];var r=[];for(var o in n){var a=n[o];a.isInGroup(t)&&r.push(a)}0==r.length&&e.err("No node type or group '"+t+"' found");return r}(e,e.next).map(function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}});return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}(e);;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=ju(e,t)}return t}function Fu(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");var t=Number(e.next);return e.pos++,t}function ju(e,t){var n=Fu(e),i=n;return e.eat(",")&&(i="}"!=e.next?Fu(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:t}}function Vu(e,t){return t-e}function Wu(e,t){var n=[];return function t(i){var r=e[i];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(i);for(var o=0;o<r.length;o++){var a=r[o],s=a.term,c=a.to;s||-1!=n.indexOf(c)||t(c)}}(t),n.sort(Vu)}function $u(e){var t=Object.create(null);return function n(i){var r=[];i.forEach(function(t){e[t].forEach(function(t){var n=t.term,i=t.to;if(n){for(var o,a=0;a<r.length;a++)r[a][0]==n&&(o=r[a][1]);Wu(e,i).forEach(function(e){o||r.push([n,o=[]]),-1==o.indexOf(e)&&o.push(e)})}})});for(var o=t[i.join(",")]=new Ru(i.indexOf(e.length-1)>-1),a=0;a<r.length;a++){var s=r[a][1].sort(Vu);o.next.push({type:r[a][0],next:t[s.join(",")]||n(s)})}return o}(Wu(e,0))}function Uu(e){var t=Object.create(null);for(var n in e){var i=e[n];if(!i.hasDefault)return null;t[n]=i.default}return t}function qu(e,t){var n=Object.create(null);for(var i in e){var r=t&&t[i];if(void 0===r){var o=e[i];if(!o.hasDefault)throw new RangeError("No value supplied for attribute "+i);r=o.default}n[i]=r}return n}function Ku(e,t,n,i){for(var r in t)if(!(r in e))throw new RangeError("Unsupported attribute ".concat(r," for ").concat(n," of type ").concat(r));for(var o in e){var a=e[o];a.validate&&a.validate(t[o])}}function Ju(e,t){var n=Object.create(null);if(t)for(var i in t)n[i]=new Yu(e,i,t[i]);return n}var Gu=function(){function e(t,n,i){C(this,e),this.name=t,this.schema=n,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Ju(t,i.attrs),this.defaultAttrs=Uu(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||"text"==t),this.isText="text"==t}return x(e,[{key:"isInline",get:function(){return!this.isBlock}},{key:"isTextblock",get:function(){return this.isBlock&&this.inlineContent}},{key:"isLeaf",get:function(){return this.contentMatch==Ru.empty}},{key:"isAtom",get:function(){return this.isLeaf||!!this.spec.atom}},{key:"isInGroup",value:function(e){return this.groups.indexOf(e)>-1}},{key:"whitespace",get:function(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}},{key:"hasRequiredAttrs",value:function(){for(var e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}},{key:"compatibleContent",value:function(e){return this==e||this.contentMatch.compatible(e.contentMatch)}},{key:"computeAttrs",value:function(e){return!e&&this.defaultAttrs?this.defaultAttrs:qu(this.attrs,e)}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Du(this,this.computeAttrs(e),cu.from(t),hu.setFrom(n))}},{key:"createChecked",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;return t=cu.from(t),this.checkContent(t),new Du(this,this.computeAttrs(e),t,hu.setFrom(n))}},{key:"createAndFill",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(e=this.computeAttrs(e),(t=cu.from(t)).size){var i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}var r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(cu.empty,!0);return o?new Du(this,e,t.append(o),hu.setFrom(n)):null}},{key:"validContent",value:function(e){var t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(var n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}},{key:"checkContent",value:function(e){if(!this.validContent(e))throw new RangeError("Invalid content for node ".concat(this.name,": ").concat(e.toString().slice(0,50)))}},{key:"checkAttrs",value:function(e){Ku(this.attrs,e,"node",this.name)}},{key:"allowsMarkType",value:function(e){return null==this.markSet||this.markSet.indexOf(e)>-1}},{key:"allowsMarks",value:function(e){if(null==this.markSet)return!0;for(var t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}},{key:"allowedMarks",value:function(e){if(null==this.markSet)return e;for(var t,n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:hu.none:e}}],[{key:"compile",value:function(t,n){var i=Object.create(null);t.forEach(function(t,r){return i[t]=new e(t,n,r)});var r=n.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(var o in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}}])}();var Yu=function(){return x(function e(t,n,i){C(this,e),this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate="string"==typeof i.validate?function(e,t,n){var i=n.split("|");return function(n){var r=null===n?"null":_(n);if(i.indexOf(r)<0)throw new RangeError("Expected value of type ".concat(i," for attribute ").concat(t," on type ").concat(e,", got ").concat(r))}}(t,n,i.validate):i.validate},[{key:"isRequired",get:function(){return!this.hasDefault}}])}(),Xu=function(){function e(t,n,i,r){C(this,e),this.name=t,this.rank=n,this.schema=i,this.spec=r,this.attrs=Ju(t,r.attrs),this.excluded=null;var o=Uu(this.attrs);this.instance=o?new hu(this,o):null}return x(e,[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return!e&&this.instance?this.instance:new hu(this,qu(this.attrs,e))}},{key:"removeFromSet",value:function(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}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(e[t].type==this)return e[t]}},{key:"checkAttrs",value:function(e){Ku(this.attrs,e,"mark",this.name)}},{key:"excludes",value:function(e){return this.excluded.indexOf(e)>-1}}],[{key:"compile",value:function(t,n){var i=Object.create(null),r=0;return t.forEach(function(t,o){return i[t]=new e(t,r++,n,o)}),i}}])}(),Qu=function(){return x(function e(t){var n=this;C(this,e),this.linebreakReplacement=null,this.cached=Object.create(null);var i=this.spec={};for(var r in t)i[r]=t[r];i.nodes=ou.from(t.nodes),i.marks=ou.from(t.marks||{}),this.nodes=Gu.compile(this.spec.nodes,this),this.marks=Xu.compile(this.spec.marks,this);var o=Object.create(null);for(var a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");var s=this.nodes[a],c=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=o[c]||(o[c]=Ru.parse(c,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?Zu(this,l.split(" ")):""!=l&&s.inlineContent?null:[]}for(var u in this.marks){var d=this.marks[u],h=d.spec.excludes;d.excluded=null==h?[d]:""==h?[]:Zu(this,h.split(" "))}this.nodeFromJSON=function(e){return Du.fromJSON(n,e)},this.markFromJSON=function(e){return hu.fromJSON(n,e)},this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)},[{key:"node",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Gu))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,i)}},{key:"text",value:function(e,t){var n=this.nodes.text;return new Iu(n,n.defaultAttrs,e,hu.setFrom(t))}},{key:"mark",value:function(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}},{key:"nodeType",value:function(e){var t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}])}();function Zu(e,t){for(var n=[],i=0;i<t.length;i++){var r=t[i],o=e.marks[r],a=o;if(o)n.push(o);else for(var s in e.marks){var c=e.marks[s];("_"==r||c.spec.group&&c.spec.group.split(" ").indexOf(r)>-1)&&n.push(a=c)}if(!a)throw new SyntaxError("Unknown mark type: '"+t[i]+"'")}return n}var ed=function(){function e(t,n){var i=this;C(this,e),this.schema=t,this.rules=n,this.tags=[],this.styles=[];var r=this.matchedStyles=[];n.forEach(function(e){if(function(e){return null!=e.tag}(e))i.tags.push(e);else if(function(e){return null!=e.style}(e)){var t=/[^=]*/.exec(e.style)[0];r.indexOf(t)<0&&r.push(t),i.styles.push(e)}}),this.normalizeLists=!this.tags.some(function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)})}return x(e,[{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new ad(this,t,!1);return n.addAll(e,hu.none,t.from,t.to),n.finish()}},{key:"parseSlice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new ad(this,t,!0);return n.addAll(e,hu.none,t.from,t.to),pu.maxOpen(n.finish())}},{key:"matchTag",value:function(e,t,n){for(var i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){var r=this.tags[i];if(sd(e,r.tag)&&(void 0===r.namespace||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){var o=r.getAttrs(e);if(!1===o)continue;r.attrs=o||void 0}return r}}}},{key:"matchStyle",value:function(e,t,n,i){for(var r=i?this.styles.indexOf(i)+1:0;r<this.styles.length;r++){var o=this.styles[r],a=o.style;if(!(0!=a.indexOf(e)||o.context&&!n.matchesContext(o.context)||a.length>e.length&&(61!=a.charCodeAt(e.length)||a.slice(e.length+1)!=t))){if(o.getAttrs){var s=o.getAttrs(t);if(!1===s)continue;o.attrs=s||void 0}return o}}}}],[{key:"schemaRules",value:function(e){var t=[];function n(e){for(var n=null==e.priority?50:e.priority,i=0;i<t.length;i++){var r=t[i];if((null==r.priority?50:r.priority)<n)break}t.splice(i,0,e)}var i=function(t){var i=e.marks[t].spec.parseDOM;i&&i.forEach(function(e){n(e=cd(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})};for(var r in e.marks)i(r);var o=function(t){var i=e.nodes[t].spec.parseDOM;i&&i.forEach(function(e){n(e=cd(e)),e.node||e.ignore||e.mark||(e.node=t)})};for(var a in e.nodes)o(a);return t}},{key:"fromSchema",value:function(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}}])}(),td={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},nd={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},id={ol:!0,ul:!0};function rd(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}var od=function(){return x(function e(t,n,i,r,o,a){C(this,e),this.type=t,this.attrs=n,this.marks=i,this.solid=r,this.options=a,this.content=[],this.activeMarks=hu.none,this.match=o||(4&a?null:t.contentMatch)},[{key:"findWrapping",value:function(e){if(!this.match){if(!this.type)return[];var t=this.type.contentMatch.fillBefore(cu.from(e));if(!t){var n,i=this.type.contentMatch;return(n=i.findWrapping(e.type))?(this.match=i,n):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}},{key:"finish",value:function(e){if(!(1&this.options)){var t,n=this.content[this.content.length-1];if(n&&n.isText&&(t=/[ \t\r\n\u000c]+$/.exec(n.text))){var i=n;n.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-t[0].length))}}var r=cu.from(this.content);return!e&&this.match&&(r=r.append(this.match.fillBefore(cu.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}},{key:"inlineContext",value:function(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!td.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}])}(),ad=function(){return x(function e(t,n,i){C(this,e),this.parser=t,this.options=n,this.isOpen=i,this.open=0,this.localPreserveWS=!1;var r,o=n.topNode,a=rd(null,n.preserveWhitespace,0)|(i?4:0);r=o?new od(o.type,o.attrs,hu.none,!0,n.topMatch||o.type.contentMatch,a):new od(i?null:t.schema.topNodeType,null,hu.none,!0,null,a),this.nodes=[r],this.find=n.findPositions,this.needsBlock=!1},[{key:"top",get:function(){return this.nodes[this.open]}},{key:"addDOM",value:function(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}},{key:"addTextNode",value:function(e,t){var n=e.nodeValue,i=this.top,r=2&i.options?"full":this.localPreserveWS||(1&i.options)>0,o=this.parser.schema;if("full"===r||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r)if("full"===r)n=n.replace(/\r\n?/g,"\n");else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){for(var a=n.split(/\r?\n|\r/),s=0;s<a.length;s++)s&&this.insertNode(o.linebreakReplacement.create(),t,!0),a[s]&&this.insertNode(o.text(a[s]),t,!/\S/.test(a[s]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){var c=i.content[i.content.length-1],l=e.previousSibling;(!c||l&&"BR"==l.nodeName||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}},{key:"addElement",value:function(e,t,n){var i=this.localPreserveWS,r=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);var o,a=e.nodeName.toLowerCase();id.hasOwnProperty(a)&&this.parser.normalizeLists&&function(e){for(var t=e.firstChild,n=null;t;t=t.nextSibling){var i=1==t.nodeType?t.nodeName.toLowerCase():null;i&&id.hasOwnProperty(i)&&n?(n.appendChild(t),t=n):"li"==i?n=t:i&&(n=null)}}(e);var s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(s?s.ignore:nd.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);var c,l=this.needsBlock;if(td.hasOwnProperty(a))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),c=!0,r.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}var u=s&&s.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(r),this.needsBlock=l}else{var d=this.readStyles(e,t);d&&this.addElementByRule(e,s,d,!1===s.consuming?o:void 0)}this.localPreserveWS=i}},{key:"leafFallback",value:function(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}},{key:"ignoreFallback",value:function(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}},{key:"readStyles",value:function(e,t){var n=this,i=e.style;if(i&&i.length)for(var r=0;r<this.parser.matchedStyles.length;r++){var o=this.parser.matchedStyles[r],a=i.getPropertyValue(o);if(a)for(var s,c=function(e){var i=n.parser.matchStyle(o,a,n,e);return i?i.ignore?{v:null}:(t=i.clearMark?t.filter(function(e){return!i.clearMark(e)}):t.concat(n.parser.schema.marks[i.mark].create(i.attrs)),!1!==i.consuming?(l=e,0):void(l=e=i)):(l=e,0)},l=void 0;0!==(s=c(l));)if(s)return s.v}return t}},{key:"addElementByRule",value:function(e,t,n,i){var r,o,a=this;if(t.node)if((o=this.parser.schema.nodes[t.node]).isLeaf)this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{var s=this.enter(o,t.attrs||null,n,t.preserveWhitespace);s&&(r=!0,n=s)}else{var c=this.parser.schema.marks[t.mark];n=n.concat(c.create(t.attrs))}var l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(function(e){return a.insertNode(e,n,!1)});else{var u=e;"string"==typeof t.contentElement?u=e.querySelector(t.contentElement):"function"==typeof t.contentElement?u=t.contentElement(e):t.contentElement&&(u=t.contentElement),this.findAround(e,u,!0),this.addAll(u,n),this.findAround(e,u,!1)}r&&this.sync(l)&&this.open--}},{key:"addAll",value:function(e,t,n,i){for(var r=n||0,o=n?e.childNodes[n]:e.firstChild,a=null==i?null:e.childNodes[i];o!=a;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o,t);this.findAtPoint(e,r)}},{key:"findPlace",value:function(e,t,n){for(var i,r,o=this.open,a=0;o>=0;o--){var s=this.nodes[o],c=s.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,r=s,!c.length))break;if(s.solid){if(n)break;a+=2}}if(!i)return null;this.sync(r);for(var l=0;l<i.length;l++)t=this.enterInner(i[l],null,t,!1);return t}},{key:"insertNode",value:function(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){var i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}var r=this.findPlace(e,t,n);if(r){this.closeExtra();var o=this.top;o.match&&(o.match=o.match.matchType(e.type));var a,s=hu.none,c=m(r.concat(e.marks));try{for(c.s();!(a=c.n()).done;){var l=a.value;(o.type?o.type.allowsMarkType(l.type):ld(l.type,e.type))&&(s=l.addToSet(s))}}catch(u){c.e(u)}finally{c.f()}return o.content.push(e.mark(s)),!0}return!1}},{key:"enter",value:function(e,t,n,i){var r=this.findPlace(e.create(t),n,!1);return r&&(r=this.enterInner(e,t,n,!0,i)),r}},{key:"enterInner",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0;this.closeExtra();var o=this.top;o.match=o.match&&o.match.matchType(e);var a=rd(e,r,o.options);4&o.options&&0==o.content.length&&(a|=4);var s=hu.none;return n=n.filter(function(t){return!(o.type?o.type.allowsMarkType(t.type):ld(t.type,e))||(s=t.addToSet(s),!1)}),this.nodes.push(new od(e,t,s,i,null,a)),this.open++,n}},{key:"closeExtra",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],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}}},{key:"finish",value:function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}},{key:"sync",value:function(e){for(var t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}},{key:"currentPos",get:function(){this.closeExtra();for(var e=0,t=this.open;t>=0;t--){for(var n=this.nodes[t].content,i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}},{key:"findAtPoint",value:function(e,t){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}},{key:"findInside",value:function(e){if(this.find)for(var t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}},{key:"findAround",value:function(e,t,n){if(e!=t&&this.find)for(var i=0;i<this.find.length;i++){if(null==this.find[i].pos&&1==e.nodeType&&e.contains(this.find[i].node))t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}}},{key:"findInText",value:function(e){if(this.find)for(var 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))}},{key:"matchesContext",value:function(e){var t=this;if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);var n=e.split("/"),i=this.options.context,r=!(this.isOpen||i&&i.parent.type!=this.nodes[0].type),o=-(i?i.depth+1:0)+(r?0:1),a=function(e,s){for(;e>=0;e--){var c=n[e];if(""==c){if(e==n.length-1||0==e)continue;for(;s>=o;s--)if(a(e-1,s))return!0;return!1}var l=s>0||0==s&&r?t.nodes[s].type:i&&s>=o?i.node(s-o).type:null;if(!l||l.name!=c&&!l.isInGroup(c))return!1;s--}return!0};return a(n.length-1,this.open)}},{key:"textblockFromContext",value:function(){var e=this.options.context;if(e)for(var t=e.depth;t>=0;t--){var n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var i in this.parser.schema.nodes){var r=this.parser.schema.nodes[i];if(r.isTextblock&&r.defaultAttrs)return r}}}])}();function sd(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function cd(e){var t={};for(var n in e)t[n]=e[n];return t}function ld(e,t){var n,i=t.schema.nodes,r=function(){var n=i[o];if(!n.allowsMarkType(e))return 0;var r=[],a=function(e){r.push(e);for(var n=0;n<e.edgeCount;n++){var i=e.edge(n),o=i.type,s=i.next;if(o==t)return!0;if(r.indexOf(s)<0&&a(s))return!0}};return a(n.contentMatch)?{v:!0}:void 0};for(var o in i)if(0!==(n=r())&&n)return n.v}var ud=function(){function e(t,n){C(this,e),this.nodes=t,this.marks=n}return x(e,[{key:"serializeFragment",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;i||(i=hd(n).createDocumentFragment());var r=i,o=[];return e.forEach(function(e){if(o.length||e.marks.length){for(var i=0,a=0;i<o.length&&a<e.marks.length;){var s=e.marks[a];if(t.marks[s.type.name]){if(!s.eq(o[i][0])||!1===s.type.spec.spanning)break;i++,a++}else a++}for(;i<o.length;)r=o.pop()[1];for(;a<e.marks.length;){var c=e.marks[a++],l=t.serializeMark(c,e.isInline,n);l&&(o.push([c,r]),r.appendChild(l.dom),r=l.contentDOM||l.dom)}}r.appendChild(t.serializeNodeInner(e,n))}),i}},{key:"serializeNodeInner",value:function(e,t){var n=vd(hd(t),this.nodes[e.type.name](e),null,e.attrs),i=n.dom,r=n.contentDOM;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}},{key:"serializeNode",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.serializeNodeInner(e,t),i=e.marks.length-1;i>=0;i--){var r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}},{key:"serializeMark",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.marks[e.type.name];return i&&vd(hd(n),i(e,t),null,e.attrs)}}],[{key:"renderSpec",value:function(e,t){return vd(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,arguments.length>3?arguments[3]:void 0)}},{key:"fromSchema",value:function(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}},{key:"nodesFromSchema",value:function(e){var t=dd(e.nodes);return t.text||(t.text=function(e){return e.text}),t}},{key:"marksFromSchema",value:function(e){return dd(e.marks)}}])}();function dd(e){var t={};for(var n in e){var i=e[n].spec.toDOM;i&&(t[n]=i)}return t}function hd(e){return e.document||window.document}var fd=new WeakMap;function pd(e){var t=fd.get(e);return void 0===t&&fd.set(e,t=function(e){var t=null;function n(e){if(e&&"object"==_(e))if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(var i=0;i<e.length;i++)n(e[i]);else for(var r in e)n(e[r])}return n(e),t}(e)),t}function vd(e,t,n,i){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;var r,o=t[0];if("string"!=typeof o)throw new RangeError("Invalid array passed to renderSpec");if(i&&(r=pd(i))&&r.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");var a,s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));var c=n?e.createElementNS(n,o):e.createElement(o),l=t[1],u=1;if(l&&"object"==_(l)&&null==l.nodeType&&!Array.isArray(l))for(var d in u=2,l)if(null!=l[d]){var h=d.indexOf(" ");h>0?c.setAttributeNS(d.slice(0,h),d.slice(h+1),l[d]):"style"==d&&c.style?c.style.cssText=l[d]:c.setAttribute(d,l[d])}for(var f=u;f<t.length;f++){var p=t[f];if(0===p){if(f<t.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}var v=vd(e,p,n,i),m=v.dom,g=v.contentDOM;if(c.appendChild(m),g){if(a)throw new RangeError("Multiple content holes");a=g}}return{dom:c,contentDOM:a}}var md=Math.pow(2,16);function gd(e,t){return e+t*md}function yd(e){return 65535&e}var kd=function(){return x(function e(t,n,i){C(this,e),this.pos=t,this.delInfo=n,this.recover=i},[{key:"deleted",get:function(){return(8&this.delInfo)>0}},{key:"deletedBefore",get:function(){return(5&this.delInfo)>0}},{key:"deletedAfter",get:function(){return(6&this.delInfo)>0}},{key:"deletedAcross",get:function(){return(4&this.delInfo)>0}}])}(),wd=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(C(this,e),this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}return x(e,[{key:"recover",value:function(e){var t=0,n=yd(e);if(!this.inverted)for(var i=0;i<n;i++)t+=this.ranges[3*i+2]-this.ranges[3*i+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/md}(e)}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!0)}},{key:"_map",value:function(e,t,n){for(var i=0,r=this.inverted?2:1,o=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var s=this.ranges[a]-(this.inverted?i:0);if(s>e)break;var c=this.ranges[a+r],l=this.ranges[a+o],u=s+c;if(e<=u){var d=s+i+((c?e==s?-1:e==u?1:t:t)<0?0:l);if(n)return d;var h=e==(t<0?s:u)?null:gd(a/3,e-s),f=e==s?2:e==u?1:4;return(t<0?e!=s:e!=u)&&(f|=8),new kd(d,f,h)}i+=l-c}return n?e+i:new kd(e+i,0,null)}},{key:"touches",value:function(e,t){for(var n=0,i=yd(t),r=this.inverted?2:1,o=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var s=this.ranges[a]-(this.inverted?n:0);if(s>e)break;var c=this.ranges[a+r];if(e<=s+c&&a==3*i)return!0;n+=this.ranges[a+o]-c}return!1}},{key:"forEach",value:function(e){for(var t=this.inverted?2:1,n=this.inverted?1:2,i=0,r=0;i<this.ranges.length;i+=3){var o=this.ranges[i],a=o-(this.inverted?r:0),s=o+(this.inverted?0:r),c=this.ranges[i+t],l=this.ranges[i+n];e(a,a+c,s,s+l),r+=l-c}}},{key:"invert",value:function(){return new e(this.ranges,!this.inverted)}},{key:"toString",value:function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}}],[{key:"offset",value:function(t){return 0==t?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}}])}();wd.empty=new wd([]);var bd=function(){function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t?t.length:0;C(this,e),this.mirror=n,this.from=i,this.to=r,this._maps=t||[],this.ownData=!(t||n)}return x(e,[{key:"maps",get:function(){return this._maps}},{key:"slice",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.maps.length;return new e(this._maps,this.mirror,t,n)}},{key:"appendMap",value:function(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),null!=t&&this.setMirror(this._maps.length-1,t)}},{key:"appendMapping",value:function(e){for(var t=0,n=this._maps.length;t<e._maps.length;t++){var i=e.getMirror(t);this.appendMap(e._maps[t],null!=i&&i<t?n+i:void 0)}}},{key:"getMirror",value:function(e){if(this.mirror)for(var t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}},{key:"setMirror",value:function(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}},{key:"appendMappingInverted",value:function(e){for(var t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){var i=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=i&&i>t?n-i-1:void 0)}}},{key:"invert",value:function(){var t=new e;return t.appendMappingInverted(this),t}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.mirror)return this._map(e,t,!0);for(var n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"_map",value:function(e,t,n){for(var i=0,r=this.from;r<this.to;r++){var o=this._maps[r].mapResult(e,t);if(null!=o.recover){var a=this.getMirror(r);if(null!=a&&a>r&&a<this.to){r=a,e=this._maps[a].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return n?e:new kd(e,i,null)}}])}(),Cd=Object.create(null),Sd=function(){return x(function e(){C(this,e)},[{key:"getMap",value:function(){return wd.empty}},{key:"merge",value:function(e){return null}}],[{key:"fromJSON",value:function(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=Cd[t.stepType];if(!n)throw new RangeError("No step type ".concat(t.stepType," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in Cd)throw new RangeError("Duplicate use of step JSON ID "+e);return Cd[e]=t,t.prototype.jsonID=e,t}}])}(),xd=function(){function e(t,n){C(this,e),this.doc=t,this.failed=n}return x(e,null,[{key:"ok",value:function(t){return new e(t,null)}},{key:"fail",value:function(t){return new e(null,t)}},{key:"fromReplace",value:function(t,n,i,r){try{return e.ok(t.replace(n,i,r))}catch(vs){if(vs instanceof fu)return e.fail(vs.message);throw vs}}}])}();function Td(e,t,n){for(var i=[],r=0;r<e.childCount;r++){var o=e.child(r);o.content.size&&(o=o.copy(Td(o.content,t,o))),o.isInline&&(o=t(o,n,r)),i.push(o)}return cu.fromArray(i)}var Md=function(e){function t(e,i,r){var o;return C(this,t),(o=n(this,t)).from=e,o.to=i,o.mark=r,o}return i(t,e),x(t,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),i=e.resolve(this.from),r=i.node(i.sharedDepth(this.to)),o=new pu(Td(n.content,function(e,n){return e.isAtom&&n.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e},r),n.openStart,n.openEnd);return xd.fromReplace(e,this.from,this.to,o)}},{key:"invert",value:function(){return new _d(this.from,this.to,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new t(n.pos,i.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}},{key:"toJSON",value:function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}}])}(Sd);Sd.jsonID("addMark",Md);var _d=function(e){function t(e,i,r){var o;return C(this,t),(o=n(this,t)).from=e,o.to=i,o.mark=r,o}return i(t,e),x(t,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),i=new pu(Td(n.content,function(e){return e.mark(t.mark.removeFromSet(e.marks))},e),n.openStart,n.openEnd);return xd.fromReplace(e,this.from,this.to,i)}},{key:"invert",value:function(){return new Md(this.from,this.to,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new t(n.pos,i.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}},{key:"toJSON",value:function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}}])}(Sd);Sd.jsonID("removeMark",_d);var Nd=function(e){function t(e,i){var r;return C(this,t),(r=n(this,t)).pos=e,r.mark=i,r}return i(t,e),x(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return xd.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return xd.fromReplace(e,this.pos,this.pos+1,new pu(cu.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var n=e.nodeAt(this.pos);if(n){var i=this.mark.addToSet(n.marks);if(i.length==n.marks.length){for(var r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(i))return new t(this.pos,n.marks[r]);return new t(this.pos,this.mark)}}return new Od(this.pos,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}}])}(Sd);Sd.jsonID("addNodeMark",Nd);var Od=function(e){function t(e,i){var r;return C(this,t),(r=n(this,t)).pos=e,r.mark=i,r}return i(t,e),x(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return xd.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return xd.fromReplace(e,this.pos,this.pos+1,new pu(cu.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new Nd(this.pos,this.mark):this}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}}])}(Sd);Sd.jsonID("removeNodeMark",Od);var Ed=function(e){function t(e,i,r){var o,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return C(this,t),(o=n(this,t)).from=e,o.to=i,o.slice=r,o.structure=a,o}return i(t,e),x(t,[{key:"apply",value:function(e){return this.structure&&Dd(e,this.from,this.to)?xd.fail("Structure replace would overwrite content"):xd.fromReplace(e,this.from,this.to,this.slice)}},{key:"getMap",value:function(){return new wd([this.from,this.to-this.from,this.slice.size])}},{key:"invert",value:function(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deletedAcross&&i.deletedAcross?null:new t(n.pos,Math.max(n.pos,i.pos),this.slice,this.structure)}},{key:"merge",value:function(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;var n=this.slice.size+e.slice.size==0?pu.empty:new pu(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}var i=this.slice.size+e.slice.size==0?pu.empty:new pu(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),i,this.structure)}},{key:"toJSON",value:function(){var e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,pu.fromJSON(e,n.slice),!!n.structure)}}])}(Sd);Sd.jsonID("replace",Ed);var Ad=function(e){function t(e,i,r,o,a,s){var c,l=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return C(this,t),(c=n(this,t)).from=e,c.to=i,c.gapFrom=r,c.gapTo=o,c.slice=a,c.insert=s,c.structure=l,c}return i(t,e),x(t,[{key:"apply",value:function(e){if(this.structure&&(Dd(e,this.from,this.gapFrom)||Dd(e,this.gapTo,this.to)))return xd.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return xd.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,t.content);return n?xd.fromReplace(e,this.from,this.to,n):xd.fail("Content does not fit in gap")}},{key:"getMap",value:function(){return new wd([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}},{key:"invert",value:function(e){var n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1),r=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return n.deletedAcross&&i.deletedAcross||r<n.pos||o>i.pos?null:new t(n.pos,i.pos,r,o,this.slice,this.insert,this.structure)}},{key:"toJSON",value:function(){var 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}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,pu.fromJSON(e,n.slice),n.insert,!!n.structure)}}])}(Sd);function Dd(e,t,n){for(var i=e.resolve(t),r=n-t,o=i.depth;r>0&&o>0&&i.indexAfter(o)==i.node(o).childCount;)o--,r--;if(r>0)for(var a=i.node(o).maybeChild(i.indexAfter(o));r>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,r--}return!1}function Id(e,t,n){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n.contentMatch,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=e.doc.nodeAt(t),a=[],s=t+1,c=0;c<o.childCount;c++){var l=o.child(c),u=s+l.nodeSize,d=i.matchType(l.type);if(d){i=d;for(var h=0;h<l.marks.length;h++)n.allowsMarkType(l.marks[h].type)||e.step(new _d(s,u,l.marks[h]));if(r&&l.isText&&"pre"!=n.whitespace)for(var f=void 0,p=/\r?\n|\r/g,v=void 0;f=p.exec(l.text);)v||(v=new pu(cu.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),a.push(new Ed(s+f.index,s+f.index+f[0].length,v))}else a.push(new Ed(s,u,pu.empty));s=u}if(!i.validEnd){var m=i.fillBefore(cu.empty,!0);e.replace(s,s,new pu(m,0,0))}for(var g=a.length-1;g>=0;g--)e.step(a[g])}function Ld(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Rd(e){for(var t=e.parent.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth,i=0,r=0;;--n){var o=e.$from.node(n),a=e.$from.index(n)+i,s=e.$to.indexAfter(n)-r;if(n<e.depth&&o.canReplace(a,s,t))return n;if(0==n||o.type.spec.isolating||!Ld(o,a,s))break;a&&(i=1),s<o.childCount&&(r=1)}return null}function Pd(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e,r=function(e,t){var n=e.parent,i=e.startIndex,r=e.endIndex,o=n.contentMatchAt(i).findWrapping(t);if(!o)return null;var a=o.length?o[0]:t;return n.canReplaceWith(i,r,a)?o:null}(e,t),o=r&&function(e,t){var n=e.parent,i=e.startIndex,r=e.endIndex,o=n.child(i),a=t.contentMatch.findWrapping(o.type);if(!a)return null;for(var s=(a.length?a[a.length-1]:t).contentMatch,c=i;s&&c<r;c++)s=s.matchType(n.child(c).type);return s&&s.validEnd?a:null}(i,t);return o?r.map(zd).concat({type:t,attrs:n}).concat(o.map(zd)):null}function zd(e){return{type:e,attrs:null}}function Bd(e,t,n,i){t.forEach(function(r,o){if(r.isText)for(var a,s=/\r?\n|\r/g;a=s.exec(r.text);){var c=e.mapping.slice(i).map(n+1+o+a.index);e.replaceWith(c,c+1,t.type.schema.linebreakReplacement.create())}})}function Hd(e,t,n,i){t.forEach(function(r,o){if(r.type==r.type.schema.linebreakReplacement){var a=e.mapping.slice(i).map(n+1+o);e.replaceWith(a,a+1,t.type.schema.text("\n"))}})}function Fd(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3?arguments[3]:void 0,r=e.resolve(t),o=r.depth-n,a=i&&i[i.length-1]||r.parent;if(o<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!a.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(var s=r.depth-1,c=n-2;s>o;s--,c--){var l=r.node(s),u=r.index(s);if(l.type.spec.isolating)return!1;var d=l.content.cutByIndex(u,l.childCount),h=i&&i[c+1];h&&(d=d.replaceChild(0,h.type.create(h.attrs)));var f=i&&i[c]||l;if(!l.canReplace(u+1,l.childCount)||!f.type.validContent(d))return!1}var p=r.indexAfter(o),v=i&&i[0];return r.node(o).canReplaceWith(p,p,v?v.type:r.node(o+1).type)}function jd(e,t){var n=e.resolve(t),i=n.index();return Vd(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(i,i+1)}function Vd(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);for(var n=e.contentMatchAt(e.childCount),i=e.type.schema.linebreakReplacement,r=0;r<t.childCount;r++){var o=t.child(r),a=o.type==i?e.type.schema.nodes.text:o.type;if(!(n=n.matchType(a)))return!1;if(!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(e,t))}function Wd(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=e.resolve(t),r=i.depth;;r--){var o=void 0,a=void 0,s=i.index(r);if(r==i.depth?(o=i.nodeBefore,a=i.nodeAfter):n>0?(o=i.node(r+1),s++,a=i.node(r).maybeChild(s)):(o=i.node(r).maybeChild(s-1),a=i.node(r+1)),o&&!o.isTextblock&&Vd(o,a)&&i.node(r).canReplace(s,s+1))return t;if(0==r)break;t=n<0?i.before(r):i.after(r)}}function $d(e,t,n){var i=e.resolve(t);if(!n.content.size)return t;for(var r=n.content,o=0;o<n.openStart;o++)r=r.firstChild.content;for(var a=1;a<=(0==n.openStart&&n.size?2:1);a++)for(var s=i.depth;s>=0;s--){var c=s==i.depth?0:i.pos<=(i.start(s+1)+i.end(s+1))/2?-1:1,l=i.index(s)+(c>0?1:0),u=i.node(s),d=!1;if(1==a)d=u.canReplace(l,l,r);else{var h=u.contentMatchAt(l).findWrapping(r.firstChild.type);d=h&&u.canReplaceWith(l,l,h[0])}if(d)return 0==c?i.pos:c<0?i.before(s+1):i.after(s+1)}return null}function Ud(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:pu.empty;if(t==n&&!i.size)return null;var r=e.resolve(t),o=e.resolve(n);return qd(r,o,i)?new Ed(t,n,i):new Kd(r,o,i).fit()}function qd(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}Sd.jsonID("replaceAround",Ad);var Kd=function(){return x(function e(t,n,i){C(this,e),this.$from=t,this.$to=n,this.unplaced=i,this.frontier=[],this.placed=cu.empty;for(var r=0;r<=t.depth;r++){var o=t.node(r);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(r))})}for(var a=t.depth;a>0;a--)this.placed=cu.from(t.node(a).copy(this.placed))},[{key:"depth",get:function(){return this.frontier.length-1}},{key:"fit",value:function(){for(;this.unplaced.size;){var e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}var t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,i=this.$from,r=this.close(t<0?this.$to:i.doc.resolve(t));if(!r)return null;for(var o=this.placed,a=i.depth,s=r.depth;a&&s&&1==o.childCount;)o=o.firstChild.content,a--,s--;var c=new pu(o,a,s);return t>-1?new Ad(i.pos,t,this.$to.pos,this.$to.end(),c,n):c.size||i.pos!=this.$to.pos?new Ed(i.pos,r.pos,c):null}},{key:"findFittable",value:function(){for(var e=this.unplaced.openStart,t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){var r=t.firstChild;if(t.childCount>1&&(i=0),r.type.spec.isolating&&i<=n){e=n;break}t=r.content}for(var o=1;o<=2;o++)for(var a=1==o?e:this.unplaced.openStart;a>=0;a--)for(var s=null,c=(a?(s=Yd(this.unplaced.content,a-1).firstChild).content:this.unplaced.content).firstChild,l=this.depth;l>=0;l--){var u=this.frontier[l],d=u.type,h=u.match,f=void 0,p=null;if(1==o&&(c?h.matchType(c.type)||(p=h.fillBefore(cu.from(c),!1)):s&&d.compatibleContent(s.type)))return{sliceDepth:a,frontierDepth:l,parent:s,inject:p};if(2==o&&c&&(f=h.findWrapping(c.type)))return{sliceDepth:a,frontierDepth:l,parent:s,wrap:f};if(s&&h.matchType(s.type))break}}},{key:"openMore",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,i=e.openEnd,r=Yd(t,n);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new pu(t,n+1,Math.max(i,r.size+n>=t.size-i?n+1:0)),!0)}},{key:"dropNode",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,i=e.openEnd,r=Yd(t,n);if(r.childCount<=1&&n>0){var o=t.size-n<=n+r.size;this.unplaced=new pu(Jd(t,n-1,1),n-1,o?n-1:i)}else this.unplaced=new pu(Jd(t,n,1),n,i)}},{key:"placeNodes",value:function(e){for(var t=e.sliceDepth,n=e.frontierDepth,i=e.parent,r=e.inject,o=e.wrap;this.depth>n;)this.closeFrontierNode();if(o)for(var a=0;a<o.length;a++)this.openFrontierNode(o[a]);var s=this.unplaced,c=i?i.content:s.content,l=s.openStart-t,u=0,d=[],h=this.frontier[n],f=h.match,p=h.type;if(r){for(var v=0;v<r.childCount;v++)d.push(r.child(v));f=f.matchFragment(r)}for(var m=c.size+t-(s.content.size-s.openEnd);u<c.childCount;){var g=c.child(u),y=f.matchType(g.type);if(!y)break;(++u>1||0==l||g.content.size)&&(f=y,d.push(Xd(g.mark(p.allowedMarks(g.marks)),1==u?l:0,u==c.childCount?m:-1)))}var k=u==c.childCount;k||(m=-1),this.placed=Gd(this.placed,n,cu.from(d)),this.frontier[n].match=f,k&&m<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var w=0,b=c;w<m;w++){var C=b.lastChild;this.frontier.push({type:C.type,match:C.contentMatchAt(C.childCount)}),b=C.content}this.unplaced=k?0==t?pu.empty:new pu(Jd(s.content,t-1,1),t-1,m<0?s.openEnd:t-1):new pu(Jd(s.content,t,u),s.openStart,s.openEnd)}},{key:"mustMoveInline",value:function(){if(!this.$to.parent.isTextblock)return-1;var e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Qd(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;for(var n=this.$to.depth,i=this.$to.after(n);n>1&&i==this.$to.end(--n);)++i;return i}},{key:"findCloseLevel",value:function(e){e:for(var t=Math.min(this.depth,e.depth);t>=0;t--){var n=this.frontier[t],i=n.match,r=n.type,o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Qd(e,t,r,i,o);if(a){for(var s=t-1;s>=0;s--){var c=this.frontier[s],l=c.match,u=Qd(e,s,c.type,l,!0);if(!u||u.childCount)continue e}return{depth:t,fit:a,move:o?e.doc.resolve(e.after(t+1)):e}}}}},{key:"close",value:function(e){var t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Gd(this.placed,t.depth,t.fit)),e=t.move;for(var n=t.depth+1;n<=e.depth;n++){var i=e.node(n),r=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,r)}return e}},{key:"openFrontierNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Gd(this.placed,this.depth,cu.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}},{key:"closeFrontierNode",value:function(){var e=this.frontier.pop().match.fillBefore(cu.empty,!0);e.childCount&&(this.placed=Gd(this.placed,this.frontier.length,e))}}])}();function Jd(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Jd(e.firstChild.content,t-1,n)))}function Gd(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Gd(e.lastChild.content,t-1,n)))}function Yd(e,t){for(var n=0;n<t;n++)e=e.firstChild.content;return e}function Xd(e,t,n){if(t<=0)return e;var i=e.content;return t>1&&(i=i.replaceChild(0,Xd(i.firstChild,t-1,1==i.childCount?n-1:0))),t>0&&(i=e.type.contentMatch.fillBefore(i).append(i),n<=0&&(i=i.append(e.type.contentMatch.matchFragment(i).fillBefore(cu.empty,!0)))),e.copy(i)}function Qd(e,t,n,i,r){var o=e.node(t),a=r?e.indexAfter(t):e.index(t);if(a==o.childCount&&!n.compatibleContent(o.type))return null;var s=i.fillBefore(o.content,!0,a);return s&&!function(e,t,n){for(var i=n;i<t.childCount;i++)if(!e.allowsMarks(t.child(i).marks))return!0;return!1}(n,o.content,a)?s:null}function Zd(e){return e.spec.defining||e.spec.definingForContent}function eh(e,t,n,i,r){if(t<n){var o=e.firstChild;e=e.replaceChild(0,o.copy(eh(o.content,t+1,n,i,o)))}if(t>i){var a=r.contentMatchAt(0),s=a.fillBefore(e).append(e);e=s.append(a.matchFragment(s).fillBefore(cu.empty,!0))}return e}function th(e,t){for(var n=[],i=Math.min(e.depth,t.depth);i>=0;i--){var r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var nh=function(e){function t(e,i,r){var o;return C(this,t),(o=n(this,t)).pos=e,o.attr=i,o.value=r,o}return i(t,e),x(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return xd.fail("No node at attribute step's position");var n=Object.create(null);for(var i in t.attrs)n[i]=t.attrs[i];n[this.attr]=this.value;var r=t.type.create(n,null,t.marks);return xd.fromReplace(e,this.pos,this.pos+1,new pu(cu.from(r),0,t.isLeaf?0:1))}},{key:"getMap",value:function(){return wd.empty}},{key:"invert",value:function(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}},{key:"toJSON",value:function(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos||"string"!=typeof n.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}}])}(Sd);Sd.jsonID("attr",nh);var ih=function(e){function t(e,i){var r;return C(this,t),(r=n(this,t)).attr=e,r.value=i,r}return i(t,e),x(t,[{key:"apply",value:function(e){var t=Object.create(null);for(var n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;var i=e.type.create(t,e.content,e.marks);return xd.ok(i)}},{key:"getMap",value:function(){return wd.empty}},{key:"invert",value:function(e){return new t(this.attr,e.attrs[this.attr])}},{key:"map",value:function(e){return this}},{key:"toJSON",value:function(){return{stepType:"docAttr",attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(e,n){if("string"!=typeof n.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}}])}(Sd);Sd.jsonID("docAttr",ih);var rh=Error;((rh=function e(t){var n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype)).constructor=rh,rh.prototype.name="TransformError";var oh=function(){return x(function e(t){C(this,e),this.doc=t,this.steps=[],this.docs=[],this.mapping=new bd},[{key:"before",get:function(){return this.docs.length?this.docs[0]:this.doc}},{key:"step",value:function(e){var t=this.maybeStep(e);if(t.failed)throw new rh(t.failed);return this}},{key:"maybeStep",value:function(e){var t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}},{key:"docChanged",get:function(){return this.steps.length>0}},{key:"addStep",value:function(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}},{key:"replace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:pu.empty,i=Ud(this.doc,e,t,n);return i&&this.step(i),this}},{key:"replaceWith",value:function(e,t,n){return this.replace(e,t,new pu(cu.from(n),0,0))}},{key:"delete",value:function(e,t){return this.replace(e,t,pu.empty)}},{key:"insert",value:function(e,t){return this.replaceWith(e,e,t)}},{key:"replaceRange",value:function(e,t,n){return function(e,t,n,i){if(!i.size)return e.deleteRange(t,n);var r=e.doc.resolve(t),o=e.doc.resolve(n);if(qd(r,o,i))return e.step(new Ed(t,n,i));var a=th(r,o);0==a[a.length-1]&&a.pop();var s=-(r.depth+1);a.unshift(s);for(var c=r.depth,l=r.pos-1;c>0;c--,l--){var u=r.node(c).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;a.indexOf(c)>-1?s=c:r.before(c)==l&&a.splice(1,0,-c)}for(var d=a.indexOf(s),h=[],f=i.openStart,p=i.content,v=0;;v++){var m=p.firstChild;if(h.push(m),v==i.openStart)break;p=m.content}for(var g=f-1;g>=0;g--){var y=h[g],k=Zd(y.type);if(k&&!y.sameMarkup(r.node(Math.abs(s)-1)))f=g;else if(k||!y.type.isTextblock)break}for(var w=i.openStart;w>=0;w--){var b=(w+f+1)%(i.openStart+1),C=h[b];if(C)for(var S=0;S<a.length;S++){var x=a[(S+d)%a.length],T=!0;x<0&&(T=!1,x=-x);var M=r.node(x-1),_=r.index(x-1);if(M.canReplaceWith(_,_,C.type,C.marks))return e.replace(r.before(x),T?o.after(x):n,new pu(eh(i.content,0,i.openStart,b),b,i.openEnd))}}for(var N=e.steps.length,O=a.length-1;O>=0&&(e.replace(t,n,i),!(e.steps.length>N));O--){var E=a[O];E<0||(t=r.before(E),n=o.after(E))}}(this,e,t,n),this}},{key:"replaceRangeWith",value:function(e,t,n){return function(e,t,n,i){if(!i.isInline&&t==n&&e.doc.resolve(t).parent.content.size){var r=function(e,t,n){var i=e.resolve(t);if(i.parent.canReplaceWith(i.index(),i.index(),n))return t;if(0==i.parentOffset)for(var r=i.depth-1;r>=0;r--){var o=i.index(r);if(i.node(r).canReplaceWith(o,o,n))return i.before(r+1);if(o>0)return null}if(i.parentOffset==i.parent.content.size)for(var a=i.depth-1;a>=0;a--){var s=i.indexAfter(a);if(i.node(a).canReplaceWith(s,s,n))return i.after(a+1);if(s<i.node(a).childCount)return null}return null}(e.doc,t,i.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new pu(cu.from(i),0,0))}(this,e,t,n),this}},{key:"deleteRange",value:function(e,t){return function(e,t,n){for(var i=e.doc.resolve(t),r=e.doc.resolve(n),o=th(i,r),a=0;a<o.length;a++){var s=o[a],c=a==o.length-1;if(c&&0==s||i.node(s).type.contentMatch.validEnd)return e.delete(i.start(s),r.end(s));if(s>0&&(c||i.node(s-1).canReplace(i.index(s-1),r.indexAfter(s-1))))return e.delete(i.before(s),r.after(s))}for(var l=1;l<=i.depth&&l<=r.depth;l++)if(t-i.start(l)==i.depth-l&&n>i.end(l)&&r.end(l)-n!=r.depth-l&&i.start(l-1)==r.start(l-1)&&i.node(l-1).canReplace(i.index(l-1),r.index(l-1)))return e.delete(i.before(l),n);e.delete(t,n)}(this,e,t),this}},{key:"lift",value:function(e,t){return function(e,t,n){for(var i=t.$from,r=t.$to,o=t.depth,a=i.before(o+1),s=r.after(o+1),c=a,l=s,u=cu.empty,d=0,h=o,f=!1;h>n;h--)f||i.index(h)>0?(f=!0,u=cu.from(i.node(h).copy(u)),d++):c--;for(var p=cu.empty,v=0,m=o,g=!1;m>n;m--)g||r.after(m+1)<r.end(m)?(g=!0,p=cu.from(r.node(m).copy(p)),v++):l++;e.step(new Ad(c,l,a,s,new pu(u.append(p),d,v),u.size-d,!0))}(this,e,t),this}},{key:"join",value:function(e){return function(e,t,n){var i=null,r=e.doc.type.schema.linebreakReplacement,o=e.doc.resolve(t-n),a=o.node().type;if(r&&a.inlineContent){var s="pre"==a.whitespace,c=!!a.contentMatch.matchType(r);s&&!c?i=!1:!s&&c&&(i=!0)}var l=e.steps.length;if(!1===i){var u=e.doc.resolve(t+n);Hd(e,u.node(),u.before(),l)}a.inlineContent&&Id(e,t+n-1,a,o.node().contentMatchAt(o.index()),null==i);var d=e.mapping.slice(l),h=d.map(t-n);if(e.step(new Ed(h,d.map(t+n,-1),pu.empty,!0)),!0===i){var f=e.doc.resolve(h);Bd(e,f.node(),f.before(),e.steps.length)}}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1),this}},{key:"wrap",value:function(e,t){return function(e,t,n){for(var i=cu.empty,r=n.length-1;r>=0;r--){if(i.size){var o=n[r].type.contentMatch.matchFragment(i);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=cu.from(n[r].type.create(n[r].attrs,i))}var a=t.start,s=t.end;e.step(new Ad(a,s,a,s,new pu(i,0,0),n.length,!0))}(this,e,t),this}},{key:"setBlockType",value:function(e){return function(e,t,n,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var o=e.steps.length;e.doc.nodesBetween(t,n,function(t,n){var a="function"==typeof r?r(t):r;if(t.isTextblock&&!t.hasMarkup(i,a)&&function(e,t,n){var i=e.resolve(t),r=i.index();return i.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(o).map(n),i)){var s=null;if(i.schema.linebreakReplacement){var c="pre"==i.whitespace,l=!!i.contentMatch.matchType(i.schema.linebreakReplacement);c&&!l?s=!1:!c&&l&&(s=!0)}!1===s&&Hd(e,t,n,o),Id(e,e.mapping.slice(o).map(n,1),i,void 0,null===s);var u=e.mapping.slice(o),d=u.map(n,1),h=u.map(n+t.nodeSize,1);return e.step(new Ad(d,h,d+1,h-1,new pu(cu.from(i.create(a,null,t.marks)),0,0),1,!0)),!0===s&&Bd(e,t,n,o),!1}})}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,arguments.length>2?arguments[2]:void 0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null),this}},{key:"setNodeMarkup",value:function(e,t){return function(e,t,n,i,r){var o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);var a=n.create(i,null,r||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,a);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Ad(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new pu(cu.from(a),0,0),1,!0))}(this,e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,arguments.length>3?arguments[3]:void 0),this}},{key:"setNodeAttribute",value:function(e,t,n){return this.step(new nh(e,t,n)),this}},{key:"setDocAttribute",value:function(e,t){return this.step(new ih(e,t)),this}},{key:"addNodeMark",value:function(e,t){return this.step(new Nd(e,t)),this}},{key:"removeNodeMark",value:function(e,t){var n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof hu)t.isInSet(n.marks)&&this.step(new Od(e,t));else{for(var i,r=n.marks,o=[];i=t.isInSet(r);)o.push(new Od(e,i)),r=i.removeFromSet(r);for(var a=o.length-1;a>=0;a--)this.step(o[a])}return this}},{key:"split",value:function(e){return function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3?arguments[3]:void 0,r=e.doc.resolve(t),o=cu.empty,a=cu.empty,s=r.depth,c=r.depth-n,l=n-1;s>c;s--,l--){o=cu.from(r.node(s).copy(o));var u=i&&i[l];a=cu.from(u?u.type.create(u.attrs,a):r.node(s).copy(a))}e.step(new Ed(t,t,new pu(o.append(a),n,n),!0))}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,arguments.length>2?arguments[2]:void 0),this}},{key:"addMark",value:function(e,t,n){return function(e,t,n,i){var r,o,a=[],s=[];e.doc.nodesBetween(t,n,function(e,c,l){if(e.isInline){var u=e.marks;if(!i.isInSet(u)&&l.type.allowsMarkType(i.type)){for(var d=Math.max(c,t),h=Math.min(c+e.nodeSize,n),f=i.addToSet(u),p=0;p<u.length;p++)u[p].isInSet(f)||(r&&r.to==d&&r.mark.eq(u[p])?r.to=h:a.push(r=new _d(d,h,u[p])));o&&o.to==d?o.to=h:s.push(o=new Md(d,h,i))}}}),a.forEach(function(t){return e.step(t)}),s.forEach(function(t){return e.step(t)})}(this,e,t,n),this}},{key:"removeMark",value:function(e,t,n){return function(e,t,n,i){var r=[],o=0;e.doc.nodesBetween(t,n,function(e,a){if(e.isInline){o++;var s=null;if(i instanceof Xu)for(var c,l=e.marks;c=i.isInSet(l);)(s||(s=[])).push(c),l=c.removeFromSet(l);else i?i.isInSet(e.marks)&&(s=[i]):s=e.marks;if(s&&s.length)for(var u=Math.min(a+e.nodeSize,n),d=0;d<s.length;d++){for(var h=s[d],f=void 0,p=0;p<r.length;p++){var v=r[p];v.step==o-1&&h.eq(r[p].style)&&(f=v)}f?(f.to=u,f.step=o):r.push({style:h,from:Math.max(a,t),to:u,step:o})}}}),r.forEach(function(t){return e.step(new _d(t.from,t.to,t.style))})}(this,e,t,n),this}},{key:"clearIncompatible",value:function(e,t,n){return Id(this,e,t,n),this}}])}(),ah=Object.create(null),sh=function(){return x(function e(t,n,i){C(this,e),this.$anchor=t,this.$head=n,this.ranges=i||[new ch(t.min(n),t.max(n))]},[{key:"anchor",get:function(){return this.$anchor.pos}},{key:"head",get:function(){return this.$head.pos}},{key:"from",get:function(){return this.$from.pos}},{key:"to",get:function(){return this.$to.pos}},{key:"$from",get:function(){return this.ranges[0].$from}},{key:"$to",get:function(){return this.ranges[0].$to}},{key:"empty",get:function(){for(var e=this.ranges,t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}},{key:"content",value:function(){return this.$from.doc.slice(this.from,this.to,!0)}},{key:"replace",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:pu.empty,n=t.content.lastChild,i=null,r=0;r<t.openEnd;r++)i=n,n=n.lastChild;for(var o=e.steps.length,a=this.ranges,s=0;s<a.length;s++){var c=a[s],l=c.$from,u=c.$to,d=e.mapping.slice(o);e.replaceRange(d.map(l.pos),d.map(u.pos),s?pu.empty:t),0==s&&yh(e,o,(n?n.isInline:i&&i.isTextblock)?-1:1)}}},{key:"replaceWith",value:function(e,t){for(var n=e.steps.length,i=this.ranges,r=0;r<i.length;r++){var o=i[r],a=o.$from,s=o.$to,c=e.mapping.slice(n),l=c.map(a.pos),u=c.map(s.pos);r?e.deleteRange(l,u):(e.replaceRangeWith(l,u,t),yh(e,n,t.isInline?-1:1))}}},{key:"getBookmark",value:function(){return dh.between(this.$anchor,this.$head).getBookmark()}}],[{key:"findFrom",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e.parent.inlineContent?new dh(e):gh(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(var r=e.depth-1;r>=0;r--){var o=t<0?gh(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):gh(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}},{key:"near",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.findFrom(e,t)||this.findFrom(e,-t)||new vh(e.node(0))}},{key:"atStart",value:function(e){return gh(e,e,0,0,1)||new vh(e)}},{key:"atEnd",value:function(e){return gh(e,e,e.content.size,e.childCount,-1)||new vh(e)}},{key:"fromJSON",value:function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=ah[t.type];if(!n)throw new RangeError("No selection type ".concat(t.type," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in ah)throw new RangeError("Duplicate use of selection JSON ID "+e);return ah[e]=t,t.prototype.jsonID=e,t}}])}();sh.prototype.visible=!0;var ch=x(function e(t,n){C(this,e),this.$from=t,this.$to=n}),lh=!1;function uh(e){lh||e.parent.inlineContent||(lh=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}var dh=function(t){function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return C(this,r),uh(e),uh(t),n(this,r,[e,t])}return i(r,t),x(r,[{key:"$cursor",get:function(){return this.$anchor.pos==this.$head.pos?this.$head:null}},{key:"map",value:function(e,t){var n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return sh.near(n);var i=e.resolve(t.map(this.anchor));return new r(i.parent.inlineContent?i:n,n)}},{key:"replace",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:pu.empty;if(e(r,"replace",this,3)([t,n]),n==pu.empty){var i=this.$from.marksAcross(this.$to);i&&t.ensureMarks(i)}}},{key:"eq",value:function(e){return e instanceof r&&e.anchor==this.anchor&&e.head==this.head}},{key:"getBookmark",value:function(){return new hh(this.anchor,this.head)}},{key:"toJSON",value:function(){return{type:"text",anchor:this.anchor,head:this.head}}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new r(e.resolve(t.anchor),e.resolve(t.head))}},{key:"create",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}},{key:"between",value:function(e,t,n){var i=e.pos-t.pos;if(n&&!i||(n=i>=0?1:-1),!t.parent.inlineContent){var o=sh.findFrom(t,n,!0)||sh.findFrom(t,-n,!0);if(!o)return sh.near(t,n);t=o.$head}return e.parent.inlineContent||(0==i||(e=(sh.findFrom(e,-n,!0)||sh.findFrom(e,n,!0)).$anchor).pos<t.pos!=i<0)&&(e=t),new r(e,t)}}])}(sh);sh.jsonID("text",dh);var hh=function(){function e(t,n){C(this,e),this.anchor=t,this.head=n}return x(e,[{key:"map",value:function(t){return new e(t.map(this.anchor),t.map(this.head))}},{key:"resolve",value:function(e){return dh.between(e.resolve(this.anchor),e.resolve(this.head))}}])}(),fh=function(e){function t(e){var i;C(this,t);var r=e.nodeAfter,o=e.node(0).resolve(e.pos+r.nodeSize);return(i=n(this,t,[e,o])).node=r,i}return i(t,e),x(t,[{key:"map",value:function(e,n){var i=n.mapResult(this.anchor),r=i.deleted,o=i.pos,a=e.resolve(o);return r?sh.near(a):new t(a)}},{key:"content",value:function(){return new pu(cu.from(this.node),0,0)}},{key:"eq",value:function(e){return e instanceof t&&e.anchor==this.anchor}},{key:"toJSON",value:function(){return{type:"node",anchor:this.anchor}}},{key:"getBookmark",value:function(){return new ph(this.anchor)}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}},{key:"create",value:function(e,n){return new t(e.resolve(n))}},{key:"isSelectable",value:function(e){return!e.isText&&!1!==e.type.spec.selectable}}])}(sh);fh.prototype.visible=!1,sh.jsonID("node",fh);var ph=function(){function e(t){C(this,e),this.anchor=t}return x(e,[{key:"map",value:function(t){var n=t.mapResult(this.anchor),i=n.deleted,r=n.pos;return i?new hh(r,r):new e(r)}},{key:"resolve",value:function(e){var t=e.resolve(this.anchor),n=t.nodeAfter;return n&&fh.isSelectable(n)?new fh(t):sh.near(t)}}])}(),vh=function(t){function r(e){return C(this,r),n(this,r,[e.resolve(0),e.resolve(e.content.size)])}return i(r,t),x(r,[{key:"replace",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:pu.empty;if(n==pu.empty){t.delete(0,t.doc.content.size);var i=sh.atStart(t.doc);i.eq(t.selection)||t.setSelection(i)}else e(r,"replace",this,3)([t,n])}},{key:"toJSON",value:function(){return{type:"all"}}},{key:"map",value:function(e){return new r(e)}},{key:"eq",value:function(e){return e instanceof r}},{key:"getBookmark",value:function(){return mh}}],[{key:"fromJSON",value:function(e){return new r(e)}}])}(sh);sh.jsonID("all",vh);var mh={map:function(){return this},resolve:function(e){return new vh(e)}};function gh(e,t,n,i,r){var o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(t.inlineContent)return dh.create(e,n);for(var a=i-(r>0?0:1);r>0?a<t.childCount:a>=0;a+=r){var s=t.child(a);if(s.isAtom){if(!o&&fh.isSelectable(s))return fh.create(e,n-(r<0?s.nodeSize:0))}else{var c=gh(e,s,n+r,r<0?s.childCount:0,r,o);if(c)return c}n+=s.nodeSize*r}return null}function yh(e,t,n){var i=e.steps.length-1;if(!(i<t)){var r,o=e.steps[i];if(o instanceof Ed||o instanceof Ad)e.mapping.maps[i].forEach(function(e,t,n,i){null==r&&(r=i)}),e.setSelection(sh.near(e.doc.resolve(r),n))}}var kh=function(t){function r(e){var t;return C(this,r),(t=n(this,r,[e.doc])).curSelectionFor=0,t.updated=0,t.meta=Object.create(null),t.time=Date.now(),t.curSelection=e.selection,t.storedMarks=e.storedMarks,t}return i(r,t),x(r,[{key:"selection",get:function(){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}},{key:"setSelection",value:function(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=-3&this.updated|1,this.storedMarks=null,this}},{key:"selectionSet",get:function(){return(1&this.updated)>0}},{key:"setStoredMarks",value:function(e){return this.storedMarks=e,this.updated|=2,this}},{key:"ensureMarks",value:function(e){return hu.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}},{key:"addStoredMark",value:function(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}},{key:"removeStoredMark",value:function(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}},{key:"storedMarksSet",get:function(){return(2&this.updated)>0}},{key:"addStep",value:function(t,n){e(r,"addStep",this,3)([t,n]),this.updated=-3&this.updated,this.storedMarks=null}},{key:"setTime",value:function(e){return this.time=e,this}},{key:"replaceSelection",value:function(e){return this.selection.replace(this,e),this}},{key:"replaceSelectionWith",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||hu.none))),n.replaceWith(this,e),this}},{key:"deleteSelection",value:function(){return this.selection.replace(this),this}},{key:"insertText",value:function(e,t,n){var i=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();if(null==n&&(n=t),!e)return this.deleteRange(t,n);var r=this.storedMarks;if(!r){var o=this.doc.resolve(t);r=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,r)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(sh.near(this.selection.$to)),this}},{key:"setMeta",value:function(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}},{key:"getMeta",value:function(e){return this.meta["string"==typeof e?e:e.key]}},{key:"isGeneric",get:function(){for(var e in this.meta)return!1;return!0}},{key:"scrollIntoView",value:function(){return this.updated|=4,this}},{key:"scrolledIntoView",get:function(){return(4&this.updated)>0}}])}(oh);function wh(e,t){return t&&e?e.bind(t):e}var bh=x(function e(t,n,i){C(this,e),this.name=t,this.init=wh(n.init,i),this.apply=wh(n.apply,i)}),Ch=[new bh("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new bh("selection",{init:function(e,t){return e.selection||sh.atStart(t.doc)},apply:function(e){return e.selection}}),new bh("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,n,i){return i.selection.$cursor?e.storedMarks:null}}),new bh("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],Sh=x(function e(t,n){var i=this;C(this,e),this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ch.slice(),n&&n.forEach(function(e){if(i.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");i.plugins.push(e),i.pluginsByKey[e.key]=e,e.spec.state&&i.fields.push(new bh(e.key,e.spec.state,e))})}),xh=function(){function e(t){C(this,e),this.config=t}return x(e,[{key:"schema",get:function(){return this.config.schema}},{key:"plugins",get:function(){return this.config.plugins}},{key:"apply",value:function(e){return this.applyTransaction(e).state}},{key:"filterTransaction",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=0;n<this.config.plugins.length;n++)if(n!=t){var i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}},{key:"applyTransaction",value:function(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};for(var t=[e],n=this.applyInner(e),i=null;;){for(var r=!1,o=0;o<this.config.plugins.length;o++){var a=this.config.plugins[o];if(a.spec.appendTransaction){var s=i?i[o].n:0,c=i?i[o].state:this,l=s<t.length&&a.spec.appendTransaction.call(a,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,o)){if(l.setMeta("appendedTransaction",e),!i){i=[];for(var u=0;u<this.config.plugins.length;u++)i.push(u<o?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),r=!0}i&&(i[o]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}},{key:"applyInner",value:function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var n=new e(this.config),i=this.config.fields,r=0;r<i.length;r++){var o=i[r];n[o.name]=o.apply(t,this[o.name],this,n)}return n}},{key:"tr",get:function(){return new kh(this)}},{key:"reconfigure",value:function(t){for(var n=new Sh(this.schema,t.plugins),i=n.fields,r=new e(n),o=0;o<i.length;o++){var a=i[o].name;r[a]=this.hasOwnProperty(a)?this[a]:i[o].init(t,r)}return r}},{key:"toJSON",value:function(e){var t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(function(e){return e.toJSON()})),e&&"object"==_(e))for(var n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var i=e[n],r=i.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(i,this[i.key]))}return t}}],[{key:"create",value:function(t){for(var n=new Sh(t.doc?t.doc.type.schema:t.schema,t.plugins),i=new e(n),r=0;r<n.fields.length;r++)i[n.fields[r].name]=n.fields[r].init(t,i);return i}},{key:"fromJSON",value:function(t,n,i){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var r=new Sh(t.schema,t.plugins),o=new e(r);return r.fields.forEach(function(e){if("doc"==e.name)o.doc=Du.fromJSON(t.schema,n.doc);else if("selection"==e.name)o.selection=sh.fromJSON(o.doc,n.selection);else if("storedMarks"==e.name)n.storedMarks&&(o.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(i)for(var r in i){var a=i[r],s=a.spec.state;if(a.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,r))return void(o[e.name]=s.fromJSON.call(a,t,n[r],o))}o[e.name]=e.init(t,o)}}),o}}])}();function Th(e,t,n){for(var i in e){var r=e[i];r instanceof Function?r=r.bind(t):"handleDOMEvents"==i&&(r=Th(r,t,{})),n[i]=r}return n}var Mh=function(){return x(function e(t){C(this,e),this.spec=t,this.props={},t.props&&Th(t.props,this,this.props),this.key=t.key?t.key.key:Nh("plugin")},[{key:"getState",value:function(e){return e[this.key]}}])}(),_h=Object.create(null);function Nh(e){return e in _h?e+"$"+ ++_h[e]:(_h[e]=0,e+"$")}var Oh=function(){return x(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"key";C(this,e),this.key=Nh(t)},[{key:"get",value:function(e){return e.config.pluginsByKey[this.key]}},{key:"getState",value:function(e){return e[this.key]}}])}();function Eh(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}function Ah(e,t,n){for(var i=t.nodeBefore,r=t.pos-1;!i.isTextblock;r--){if(i.type.spec.isolating)return!1;var o=i.lastChild;if(!o)return!1;i=o}for(var a=t.nodeAfter,s=t.pos+1;!a.isTextblock;s++){if(a.type.spec.isolating)return!1;var c=a.firstChild;if(!c)return!1;a=c}var l=Ud(e.doc,r,s,pu.empty);if(!l||l.from!=r||l instanceof Ed&&l.slice.size>=s-r)return!1;if(n){var u=e.tr.step(l);u.setSelection(dh.create(u.doc,r)),n(u.scrollIntoView())}return!0}function Dh(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e;i;i="start"==t?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(n&&1!=i.childCount)return!1}return!1}function Ih(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Lh(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}function Rh(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){var n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function Ph(e){for(var t=0;t<e.edgeCount;t++){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function zh(e,t,n,i){var r,o,a=t.nodeBefore,s=t.nodeAfter,c=a.type.spec.isolating||s.type.spec.isolating;if(!c&&function(e,t,n){var i=t.nodeBefore,r=t.nodeAfter,o=t.index();return!(!(i&&r&&i.type.compatibleContent(r.type))||(!i.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-i.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(o,o+1)||!r.isTextblock&&!jd(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;var l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(r=(o=a.contentMatchAt(a.childCount)).findWrapping(s.type))&&o.matchType(r[0]||s.type).validEnd){if(n){for(var u=t.pos+s.nodeSize,d=cu.empty,h=r.length-1;h>=0;h--)d=cu.from(r[h].create(null,d));d=cu.from(a.copy(d));var f=e.tr.step(new Ad(t.pos-1,u,t.pos,u,new pu(d,1,0),r.length,!0)),p=f.doc.resolve(u+2*r.length);p.nodeAfter&&p.nodeAfter.type==a.type&&jd(f.doc,p.pos)&&f.join(p.pos),n(f.scrollIntoView())}return!0}var v=s.type.spec.isolating||i>0&&c?null:sh.findFrom(t,1),m=v&&v.$from.blockRange(v.$to),g=m&&Rd(m);if(null!=g&&g>=t.depth)return n&&n(e.tr.lift(m,g).scrollIntoView()),!0;if(l&&Dh(s,"start",!0)&&Dh(a,"end")){for(var y=a,k=[];k.push(y),!y.isTextblock;)y=y.lastChild;for(var w=s,b=1;!w.isTextblock;w=w.firstChild)b++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(n){for(var C=cu.empty,S=k.length-1;S>=0;S--)C=cu.from(k[S].copy(C));n(e.tr.step(new Ad(t.pos-k.length,t.pos+s.nodeSize,t.pos+b,t.pos+s.nodeSize-b,new pu(C,k.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Bh(e){return function(t,n){for(var i=t.selection,r=e<0?i.$from:i.$to,o=r.depth;r.node(o).isInline;){if(!o)return!1;o--}return!!r.node(o).isTextblock&&(n&&n(t.tr.setSelection(dh.create(t.doc,e<0?r.start(o):r.end(o)))),!0)}}var Hh=Bh(-1),Fh=Bh(1);function jh(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,i){for(var r=!1,o=0;o<n.selection.ranges.length&&!r;o++){var a=n.selection.ranges[o],s=a.$from.pos,c=a.$to.pos;n.doc.nodesBetween(s,c,function(i,o){if(r)return!1;if(i.isTextblock&&!i.hasMarkup(e,t))if(i.type==e)r=!0;else{var a=n.doc.resolve(o),s=a.index();r=a.parent.canReplaceWith(s,s+1,e)}})}if(!r)return!1;if(i){for(var l=n.tr,u=0;u<n.selection.ranges.length;u++){var d=n.selection.ranges[u],h=d.$from.pos,f=d.$to.pos;l.setBlockType(h,f,e,t)}i(l.scrollIntoView())}return!0}}function Vh(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,i){var r=n.selection,o=r.$from,a=r.$to,s=o.blockRange(a);if(!s)return!1;var c=i?n.tr:null;return!!function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=!1,o=t,a=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;var s=a.resolve(t.start-2);o=new Eu(s,s,t.depth),t.endIndex<t.parent.childCount&&(t=new Eu(t.$from,a.resolve(t.$to.end(t.depth)),t.depth)),r=!0}var c=Pd(o,n,i,t);if(!c)return!1;e&&function(e,t,n,i,r){for(var o=cu.empty,a=n.length-1;a>=0;a--)o=cu.from(n[a].type.create(n[a].attrs,o));e.step(new Ad(t.start-(i?2:0),t.end,t.start,t.end,new pu(o,0,0),n.length,!0));for(var s=0,c=0;c<n.length;c++)n[c].type==r&&(s=c+1);for(var l=n.length-s,u=t.start+n.length-(i?2:0),d=t.parent,h=t.startIndex,f=t.endIndex,p=!0;h<f;h++,p=!1)!p&&Fd(e.doc,u,l)&&(e.split(u,l),u+=2*l),u+=d.child(h).nodeSize}(e,t,c,r,n);return!0}(c,s,e,t)&&(i&&i(c.scrollIntoView()),!0)}}function Wh(e){return function(t,n){var i=t.selection,r=i.$from,o=i.$to,a=r.blockRange(o,function(t){return t.childCount>0&&t.firstChild.type==e});return!!a&&(!n||(r.node(a.depth-1).type==e?function(e,t,n,i){var r=e.tr,o=i.end,a=i.$to.end(i.depth);o<a&&(r.step(new Ad(o-1,a,o,a,new pu(cu.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new Eu(r.doc.resolve(i.$from.pos),r.doc.resolve(a),i.depth));var s=Rd(i);if(null==s)return!1;r.lift(i,s);var c=r.doc.resolve(r.mapping.map(o,-1)-1);jd(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos);return t(r.scrollIntoView()),!0}(t,n,e,a):function(e,t,n){for(var i=e.tr,r=n.parent,o=n.end,a=n.endIndex-1,s=n.startIndex;a>s;a--)o-=r.child(a).nodeSize,i.delete(o-1,o+1);var c=i.doc.resolve(n.start),l=c.nodeAfter;if(i.mapping.map(n.end)!=n.start+c.nodeAfter.nodeSize)return!1;var u=0==n.startIndex,d=n.endIndex==r.childCount,h=c.node(-1),f=c.index(-1);if(!h.canReplace(f+(u?0:1),f+1,l.content.append(d?cu.empty:cu.from(r))))return!1;var p=c.pos,v=p+l.nodeSize;return i.step(new Ad(p-(u?1:0),v+(d?1:0),p+1,v-1,new pu((u?cu.empty:cu.from(r.copy(cu.empty))).append(d?cu.empty:cu.from(r.copy(cu.empty))),u?0:1,d?0:1),u?0:1)),t(i.scrollIntoView()),!0}(t,n,a)))}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();var $h=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Uh=function(e){var t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},qh=null,Kh=function(e,t,n){var i=qh||(qh=document.createRange());return i.setEnd(e,null==n?e.nodeValue.length:n),i.setStart(e,t||0),i},Jh=function(e,t,n,i){return n&&(Yh(e,t,n,i,-1)||Yh(e,t,n,i,1))},Gh=/^(img|br|input|textarea|hr)$/i;function Yh(e,t,n,i,r){for(var o;;){if(e==n&&t==i)return!0;if(t==(r<0?0:Xh(e))){var a=e.parentNode;if(!a||1!=a.nodeType||Qh(e)||Gh.test(e.nodeName)||"false"==e.contentEditable)return!1;t=$h(e)+(r<0?0:1),e=a}else{if(1!=e.nodeType)return!1;var s=e.childNodes[t+(r<0?-1:0)];if(1==s.nodeType&&"false"==s.contentEditable){if(!(null===(o=s.pmViewDesc)||void 0===o?void 0:o.ignoreForSelection))return!1;t+=r}else e=s,t=r<0?Xh(e):0}}}function Xh(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Qh(e){for(var t,n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Zh=function(e){return e.focusNode&&Jh(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function ef(e,t){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}var tf="undefined"!=typeof navigator?navigator:null,nf="undefined"!=typeof document?document:null,rf=tf&&tf.userAgent||"",of=/Edge\/(\d+)/.exec(rf),af=/MSIE \d/.exec(rf),sf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(rf),cf=!!(af||sf||of),lf=af?document.documentMode:sf?+sf[1]:of?+of[1]:0,uf=!cf&&/gecko\/(\d+)/i.test(rf);uf&&(/Firefox\/(\d+)/.exec(rf)||[0,0])[1];var df=!cf&&/Chrome\/(\d+)/.exec(rf),hf=!!df,ff=df?+df[1]:0,pf=!cf&&!!tf&&/Apple Computer/.test(tf.vendor),vf=pf&&(/Mobile\/\w+/.test(rf)||!!tf&&tf.maxTouchPoints>2),mf=vf||!!tf&&/Mac/.test(tf.platform),gf=!!tf&&/Win/.test(tf.platform),yf=/Android \d/.test(rf),kf=!!nf&&"webkitFontSmoothing"in nf.documentElement.style,wf=kf?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function bf(e){var t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Cf(e,t){return"number"==typeof e?e:e[t]}function Sf(e){var t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,i=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*i}}function xf(e,t,n){for(var i=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument,a=n||e.dom;a;)if(1==a.nodeType){var s=a,c=s==o.body,l=c?bf(o):Sf(s),u=0,d=0;if(t.top<l.top+Cf(i,"top")?d=-(l.top-t.top+Cf(r,"top")):t.bottom>l.bottom-Cf(i,"bottom")&&(d=t.bottom-t.top>l.bottom-l.top?t.top+Cf(r,"top")-l.top:t.bottom-l.bottom+Cf(r,"bottom")),t.left<l.left+Cf(i,"left")?u=-(l.left-t.left+Cf(r,"left")):t.right>l.right-Cf(i,"right")&&(u=t.right-l.right+Cf(r,"right")),u||d)if(c)o.defaultView.scrollBy(u,d);else{var h=s.scrollLeft,f=s.scrollTop;d&&(s.scrollTop+=d),u&&(s.scrollLeft+=u);var p=s.scrollLeft-h,v=s.scrollTop-f;t={left:t.left-p,top:t.top-v,right:t.right-p,bottom:t.bottom-v}}var m=c?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(m))break;a="absolute"==m?a.offsetParent:Uh(a)}else a=Uh(a)}function Tf(e){for(var t=[],n=e.ownerDocument,i=e;i&&(t.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),e!=n);i=Uh(i));return t}function Mf(e,t){for(var n=0;n<e.length;n++){var i=e[n],r=i.dom,o=i.top,a=i.left;r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var _f=null;function Nf(e,t){for(var n,i,r,o,a=2e8,s=0,c=t.top,l=t.top,u=e.firstChild,d=0;u;u=u.nextSibling,d++){var h=void 0;if(1==u.nodeType)h=u.getClientRects();else{if(3!=u.nodeType)continue;h=Kh(u).getClientRects()}for(var f=0;f<h.length;f++){var p=h[f];if(p.top<=c&&p.bottom>=l){c=Math.max(p.bottom,c),l=Math.min(p.top,l);var v=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(v<a){n=u,a=v,i=v&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==u.nodeType&&v&&(s=d+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!r&&p.left<=t.left&&p.right>=t.left&&(r=u,o={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(s=d+1)}}return!n&&r&&(n=r,i=o,a=0),n&&3==n.nodeType?function(e,t){for(var n,i=e.nodeValue.length,r=document.createRange(),o=0;o<i;o++){r.setEnd(e,o+1),r.setStart(e,o);var a=If(r,1);if(a.top!=a.bottom&&Of(t,a)){n={node:e,offset:o+(t.left>=(a.left+a.right)/2?1:0)};break}}return r.detach(),n||{node:e,offset:0}}(n,i):!n||a&&1==n.nodeType?{node:e,offset:s}:Nf(n,i)}function Of(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ef(e,t,n){var i=e.childNodes.length;if(i&&n.top<n.bottom)for(var r=Math.max(0,Math.min(i-1,Math.floor(i*(t.top-n.top)/(n.bottom-n.top))-2)),o=r;;){var a=e.childNodes[o];if(1==a.nodeType)for(var s=a.getClientRects(),c=0;c<s.length;c++){var l=s[c];if(Of(t,l))return Ef(a,t,l)}if((o=(o+1)%i)==r)break}return e}function Af(e,t){var n,i=e.dom.ownerDocument,r=0,o=function(e,t,n){if(e.caretPositionFromPoint)try{var i=e.caretPositionFromPoint(t,n);if(i)return{node:i.offsetNode,offset:Math.min(Xh(i.offsetNode),i.offset)}}catch(Ss){}if(e.caretRangeFromPoint){var r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Xh(r.startContainer),r.startOffset)}}}(i,t.left,t.top);o&&(n=o.node,r=o.offset);var a,s=(e.root.elementFromPoint?e.root:i).elementFromPoint(t.left,t.top);if(!s||!e.dom.contains(1!=s.nodeType?s.parentNode:s)){var c=e.dom.getBoundingClientRect();if(!Of(t,c))return null;if(!(s=Ef(e.dom,t,c)))return null}if(pf)for(var l=s;n&&l;l=Uh(l))l.draggable&&(n=void 0);if(s=function(e,t){var n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(s,t),n){if(uf&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length))<n.childNodes.length){var u,d=n.childNodes[r];"IMG"==d.nodeName&&(u=d.getBoundingClientRect()).right<=t.left&&u.bottom>t.top&&r++}var h;kf&&r&&1==n.nodeType&&1==(h=n.childNodes[r-1]).nodeType&&"false"==h.contentEditable&&h.getBoundingClientRect().top>=t.top&&r--,n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?a=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(a=function(e,t,n,i){for(var r=-1,o=t,a=!1;o!=e.dom;){var s=e.docView.nearestDesc(o,!0),c=void 0;if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((c=s.dom.getBoundingClientRect()).width||c.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!a&&c.left>i.left||c.top>i.top?r=s.posBefore:(!a&&c.right<i.left||c.bottom<i.top)&&(r=s.posAfter),a=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?i.top<(c.top+c.bottom)/2:i.left<(c.left+c.right)/2)?s.posBefore:s.posAfter;o=s.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,-1)}(e,n,r,t))}null==a&&(a=function(e,t,n){var i=Nf(t,n),r=i.node,o=i.offset,a=-1;if(1==r.nodeType&&!r.firstChild){var s=r.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(r,o,a)}(e,s,t));var f=e.docView.nearestDesc(s,!0);return{pos:a,inside:f?f.posAtStart-f.border:-1}}function Df(e){return e.top<e.bottom||e.left<e.right}function If(e,t){var n=e.getClientRects();if(n.length){var i=n[t<0?0:n.length-1];if(Df(i))return i}return Array.prototype.find.call(n,Df)||e.getBoundingClientRect()}var Lf=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Rf(e,t,n){var i=e.docView.domFromPos(t,n<0?-1:1),r=i.node,o=i.offset,a=i.atom,s=kf||uf;if(3==r.nodeType){if(!s||!Lf.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){var c=o,l=o,u=n<0?1:-1;return n<0&&!o?(l++,u=-1):n>=0&&o==r.nodeValue.length?(c--,u=1):n<0?c--:l++,Pf(If(Kh(r,c,l),u),u<0)}var d=If(Kh(r,o,o),n);if(uf&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){var h=If(Kh(r,o-1,o-1),-1);if(h.top==d.top){var f=If(Kh(r,o,o+1),-1);if(f.top!=d.top)return Pf(f,f.left<h.left)}}return d}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(null==a&&o&&(n<0||o==Xh(r))){var p=r.childNodes[o-1];if(1==p.nodeType)return zf(p.getBoundingClientRect(),!1)}if(null==a&&o<Xh(r)){var v=r.childNodes[o];if(1==v.nodeType)return zf(v.getBoundingClientRect(),!0)}return zf(r.getBoundingClientRect(),n>=0)}if(null==a&&o&&(n<0||o==Xh(r))){var m=r.childNodes[o-1],g=3==m.nodeType?Kh(m,Xh(m)-(s?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(g)return Pf(If(g,1),!1)}if(null==a&&o<Xh(r)){for(var y=r.childNodes[o];y.pmViewDesc&&y.pmViewDesc.ignoreForCoords;)y=y.nextSibling;var k=y?3==y.nodeType?Kh(y,0,s?0:1):1==y.nodeType?y:null:null;if(k)return Pf(If(k,-1),!0)}return Pf(If(3==r.nodeType?Kh(r):r,-n),n>=0)}function Pf(e,t){if(0==e.width)return e;var n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function zf(e,t){if(0==e.height)return e;var n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Bf(e,t,n){var i=e.state,r=e.root.activeElement;i!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{i!=t&&e.updateState(i),r!=e.dom&&r&&r.focus()}}var Hf=/[\u0590-\u08ac]/;var Ff=null,jf=null,Vf=!1;function Wf(e,t,n){return Ff==t&&jf==n?Vf:(Ff=t,jf=n,Vf="up"==n||"down"==n?function(e,t,n){var i=t.selection,r="up"==n?i.$from:i.$to;return Bf(e,t,function(){for(var t=e.docView.domFromPos(r.pos,"up"==n?-1:1).node;;){var i=e.docView.nearestDesc(t,!0);if(!i)break;if(i.node.isBlock){t=i.contentDOM||i.dom;break}t=i.dom.parentNode}for(var o=Rf(e,r.pos,1),a=t.firstChild;a;a=a.nextSibling){var s=void 0;if(1==a.nodeType)s=a.getClientRects();else{if(3!=a.nodeType)continue;s=Kh(a,0,a.nodeValue.length).getClientRects()}for(var c=0;c<s.length;c++){var l=s[c];if(l.bottom>l.top+1&&("up"==n?o.top-l.top>2*(l.bottom-o.top):l.bottom-o.bottom>2*(o.bottom-l.top)))return!1}}return!0})}(e,t,n):function(e,t,n){var i=t.selection.$head;if(!i.parent.isTextblock)return!1;var r=i.parentOffset,o=!r,a=r==i.parent.content.size,s=e.domSelection();return s?Hf.test(i.parent.textContent)&&s.modify?Bf(e,t,function(){var t=e.domSelectionRange(),r=t.focusNode,o=t.focusOffset,a=t.anchorNode,c=t.anchorOffset,l=s.caretBidiLevel;s.modify("move",n,"character");var u=i.depth?e.docView.domAfterPos(i.before()):e.dom,d=e.domSelectionRange(),h=d.focusNode,f=d.focusOffset,p=h&&!u.contains(1==h.nodeType?h:h.parentNode)||r==h&&o==f;try{s.collapse(a,c),r&&(r!=a||o!=c)&&s.extend&&s.extend(r,o)}catch(Ss){}return null!=l&&(s.caretBidiLevel=l),p}):"left"==n||"backward"==n?o:a:i.pos==i.start()||i.pos==i.end()}(e,t,n))}var $f=function(){return x(function e(t,n,i,r){C(this,e),this.parent=t,this.children=n,this.dom=i,this.contentDOM=r,this.dirty=0,i.pmViewDesc=this},[{key:"matchesWidget",value:function(e){return!1}},{key:"matchesMark",value:function(e){return!1}},{key:"matchesNode",value:function(e,t,n){return!1}},{key:"matchesHack",value:function(e){return!1}},{key:"parseRule",value:function(){return null}},{key:"stopEvent",value:function(e){return!1}},{key:"size",get:function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e}},{key:"border",get:function(){return 0}},{key:"destroy",value:function(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(var e=0;e<this.children.length;e++)this.children[e].destroy()}},{key:"posBeforeChild",value:function(e){for(var t=0,n=this.posAtStart;;t++){var i=this.children[t];if(i==e)return n;n+=i.size}}},{key:"posBefore",get:function(){return this.parent.posBeforeChild(this)}},{key:"posAtStart",get:function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}},{key:"posAfter",get:function(){return this.posBefore+this.size}},{key:"posAtEnd",get:function(){return this.posAtStart+this.size-2*this.border}},{key:"localPosFromDOM",value:function(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){var i,r;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&(!(r=i.pmViewDesc)||r.parent!=this);)i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}var o,a;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&(!(a=o.pmViewDesc)||a.parent!=this);)o=o.nextSibling;return o?this.posBeforeChild(a):this.posAtEnd}var s;if(e==this.dom&&this.contentDOM)s=t>$h(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(var c=e;;c=c.parentNode){if(c==this.dom){s=!1;break}if(c.previousSibling)break}if(null==s&&t==e.childNodes.length)for(var l=e;;l=l.parentNode){if(l==this.dom){s=!0;break}if(l.nextSibling)break}}return(null==s?n>0:s)?this.posAtEnd:this.posAtStart}},{key:"nearestDesc",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!0,i=e;i;i=i.parentNode){var r=this.getDesc(i),o=void 0;if(r&&(!t||r.node)){if(!n||!(o=r.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return r;n=!1}}}},{key:"getDesc",value:function(e){for(var t=e.pmViewDesc,n=t;n;n=n.parent)if(n==this)return t}},{key:"posFromDOM",value:function(e,t,n){for(var i=e;i;i=i.parentNode){var r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,n)}return-1}},{key:"descAt",value:function(e){for(var t=0,n=0;t<this.children.length;t++){var i=this.children[t],r=n+i.size;if(n==e&&r!=n){for(;!i.border&&i.children.length;)for(var o=0;o<i.children.length;o++){var a=i.children[o];if(a.size){i=a;break}}return i}if(e<r)return i.descAt(e-n-i.border);n=r}}},{key:"domFromPos",value:function(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};for(var n,i=0,r=0,o=0;i<this.children.length;i++){var a=this.children[i],s=o+a.size;if(s>e||a instanceof Xf){r=e-o;break}o=s}if(r)return this.children[i].domFromPos(r-this.children[i].border,t);for(;i&&!(n=this.children[i-1]).size&&n instanceof Uf&&n.side>=0;i--);if(t<=0){for(var c,l=!0;(c=i?this.children[i-1]:null)&&c.dom.parentNode!=this.contentDOM;i--,l=!1);return c&&t&&l&&!c.border&&!c.domAtom?c.domFromPos(c.size,t):{node:this.contentDOM,offset:c?$h(c.dom)+1:0}}for(var u,d=!0;(u=i<this.children.length?this.children[i]:null)&&u.dom.parentNode!=this.contentDOM;i++,d=!1);return u&&d&&!u.border&&!u.domAtom?u.domFromPos(0,t):{node:this.contentDOM,offset:u?$h(u.dom):this.contentDOM.childNodes.length}}},{key:"parseRange",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var i=-1,r=-1,o=n,a=0;;a++){var s=this.children[a],c=o+s.size;if(-1==i&&e<=c){var l=o+s.border;if(e>=l&&t<=c-s.border&&s.node&&s.contentDOM&&this.contentDOM.contains(s.contentDOM))return s.parseRange(e,t,l);e=o;for(var u=a;u>0;u--){var d=this.children[u-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=$h(d.dom)+1;break}e-=d.size}-1==i&&(i=0)}if(i>-1&&(c>t||a==this.children.length-1)){t=c;for(var h=a+1;h<this.children.length;h++){var f=this.children[h];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){r=$h(f.dom);break}t+=f.size}-1==r&&(r=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:r}}},{key:"emptyChildAt",value:function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}},{key:"domAfterPos",value:function(e){var t=this.domFromPos(e,0),n=t.node,i=t.offset;if(1!=n.nodeType||i==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[i]}},{key:"setSelection",value:function(e,t,n){for(var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=Math.min(e,t),o=Math.max(e,t),a=0,s=0;a<this.children.length;a++){var c=this.children[a],l=s+c.size;if(r>s&&o<l)return c.setSelection(e-s-c.border,t-s-c.border,n,i);s=l}var u=this.domFromPos(e,e?-1:1),d=t==e?u:this.domFromPos(t,t?-1:1),h=n.root.getSelection(),f=n.domSelectionRange(),p=!1;if((uf||pf)&&e==t){var v=u,m=v.node,g=v.offset;if(3==m.nodeType){if((p=!(!g||"\n"!=m.nodeValue[g-1]))&&g==m.nodeValue.length)for(var y,k=m;k;k=k.parentNode){if(y=k.nextSibling){"BR"==y.nodeName&&(u=d={node:y.parentNode,offset:$h(y)+1});break}var w=k.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{var b=m.childNodes[g-1];p=b&&("BR"==b.nodeName||"false"==b.contentEditable)}}if(uf&&f.focusNode&&f.focusNode!=d.node&&1==f.focusNode.nodeType){var C=f.focusNode.childNodes[f.focusOffset];C&&"false"==C.contentEditable&&(i=!0)}if(i||p&&pf||!Jh(u.node,u.offset,f.anchorNode,f.anchorOffset)||!Jh(d.node,d.offset,f.focusNode,f.focusOffset)){var S=!1;if((h.extend||e==t)&&(!p||!uf)){h.collapse(u.node,u.offset);try{e!=t&&h.extend(d.node,d.offset),S=!0}catch(Ss){}}if(!S){if(e>t){var x=u;u=d,d=x}var T=document.createRange();T.setEnd(d.node,d.offset),T.setStart(u.node,u.offset),h.removeAllRanges(),h.addRange(T)}}}},{key:"ignoreMutation",value:function(e){return!this.contentDOM&&"selection"!=e.type}},{key:"contentLost",get:function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}},{key:"markDirty",value:function(e,t){for(var n=0,i=0;i<this.children.length;i++){var r=this.children[i],o=n+r.size;if(n==o?e<=o&&t>=n:e<o&&t>n){var a=n+r.border,s=o-r.border;if(e>=a&&t<=s)return this.dirty=e==n||t==o?2:1,void(e!=a||t!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(e-a,t-a):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=o}this.dirty=2}},{key:"markParentsDirty",value:function(){for(var e=1,t=this.parent;t;t=t.parent,e++){var n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}},{key:"domAtom",get:function(){return!1}},{key:"ignoreForCoords",get:function(){return!1}},{key:"ignoreForSelection",get:function(){return!1}},{key:"isText",value:function(e){return!1}}])}(),Uf=function(t){function r(e,t,i,o){var a;C(this,r);var s,c=t.type.toDOM;if("function"==typeof c&&(c=c(i,function(){return s?s.parent?s.parent.posBeforeChild(s):void 0:o})),!t.type.spec.raw){if(1!=c.nodeType){var l=document.createElement("span");l.appendChild(c),c=l}c.contentEditable="false",c.classList.add("ProseMirror-widget")}return(a=n(this,r,[e,[],c,null])).widget=t,a.widget=t,s=a,a}return i(r,t),x(r,[{key:"matchesWidget",value:function(e){return 0==this.dirty&&e.type.eq(this.widget.type)}},{key:"parseRule",value:function(){return{ignore:!0}}},{key:"stopEvent",value:function(e){var t=this.widget.spec.stopEvent;return!!t&&t(e)}},{key:"ignoreMutation",value:function(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}},{key:"destroy",value:function(){this.widget.type.destroy(this.dom),e(r,"destroy",this,3)([])}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForSelection",get:function(){return!!this.widget.type.spec.relaxedSide}},{key:"side",get:function(){return this.widget.type.side}}])}($f),qf=function(e){function t(e,i,r,o){var a;return C(this,t),(a=n(this,t,[e,[],i,null])).textDOM=r,a.text=o,a}return i(t,e),x(t,[{key:"size",get:function(){return this.text.length}},{key:"localPosFromDOM",value:function(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}},{key:"domFromPos",value:function(e){return{node:this.textDOM,offset:e}}},{key:"ignoreMutation",value:function(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}])}($f),Kf=function(t){function r(e,t,i,o,a){var s;return C(this,r),(s=n(this,r,[e,[],i,o])).mark=t,s.spec=a,s}return i(r,t),x(r,[{key:"parseRule",value:function(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}},{key:"matchesMark",value:function(e){return 3!=this.dirty&&this.mark.eq(e)}},{key:"markDirty",value:function(t,n){if(e(r,"markDirty",this,3)([t,n]),0!=this.dirty){for(var i=this.parent;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=0}}},{key:"slice",value:function(e,t,n){var i=r.create(this.parent,this.mark,!0,n),o=this.children,a=this.size;t<a&&(o=up(o,t,a,n)),e>0&&(o=up(o,0,e,n));for(var s=0;s<o.length;s++)o[s].parent=i;return i.children=o,i}},{key:"ignoreMutation",value:function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e(r,"ignoreMutation",this,3)([t])}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),e(r,"destroy",this,3)([])}}],[{key:"create",value:function(e,t,n,i){var o=i.nodeViews[t.type.name],a=o&&o(t,i,n);return a&&a.dom||(a=ud.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new r(e,t,a.dom,a.contentDOM||a.dom,a)}}])}($f),Jf=function(e){function t(e,i,r,o,a,s,c,l,u){var d;return C(this,t),(d=n(this,t,[e,[],a,s])).node=i,d.outerDeco=r,d.innerDeco=o,d.nodeDOM=c,d}return i(t,e),x(t,[{key:"parseRule",value:function(){var e=this;if(this.node.type.spec.reparseInView)return null;var t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(var n=this.children.length-1;n>=0;n--){var i=this.children[n];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}t.contentElement||(t.getContent=function(){return cu.empty})}else t.contentElement=this.contentDOM;else t.getContent=function(){return e.node.content};return t}},{key:"matchesNode",value:function(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ap(t,this.outerDeco)&&n.eq(this.innerDeco)}},{key:"size",get:function(){return this.node.nodeSize}},{key:"border",get:function(){return this.node.isLeaf?0:1}},{key:"updateChildren",value:function(e,t){var n=this,i=this.node.inlineContent,r=t,o=e.composing?this.localCompositionInfo(e,t):null,a=o&&o.pos>-1?o:null,s=o&&o.pos<0,c=new cp(this,a&&a.node,e);!function(e,t,n,i){var r=t.locals(e),o=0;if(0==r.length){for(var a=0;a<e.childCount;a++){var s=e.child(a);i(s,r,t.forChild(o,s),a),o+=s.nodeSize}return}for(var c=0,l=[],u=null,d=0;;){for(var h=void 0,f=void 0;c<r.length&&r[c].to==o;){var p=r[c++];p.widget&&(h?(f||(f=[h])).push(p):h=p)}if(h)if(f){f.sort(lp);for(var v=0;v<f.length;v++)n(f[v],d,!!u)}else n(h,d,!!u);var m=void 0,g=void 0;if(u)g=-1,m=u,u=null;else{if(!(d<e.childCount))break;g=d,m=e.child(d++)}for(var y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;c<r.length&&r[c].from<=o&&r[c].to>o;)l.push(r[c++]);var k=o+m.nodeSize;if(m.isText){var w=k;c<r.length&&r[c].from<w&&(w=r[c].from);for(var b=0;b<l.length;b++)l[b].to<w&&(w=l[b].to);w<k&&(u=m.cut(w-o),m=m.cut(0,w-o),k=w,g=-1)}else for(;c<r.length&&r[c].to<k;)c++;var C=m.isInline&&!m.isLeaf?l.filter(function(e){return!e.inline}):l.slice();i(m,C,t.forChild(o,m),g),o=k}}(this.node,this.innerDeco,function(t,o,a){t.spec.marks?c.syncToMarks(t.spec.marks,i,e):t.type.side>=0&&!a&&c.syncToMarks(o==n.node.childCount?hu.none:n.node.child(o).marks,i,e),c.placeWidget(t,e,r)},function(t,n,a,l){var u;c.syncToMarks(t.marks,i,e),c.findNodeMatch(t,n,a,l)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=c.findIndexWithChild(o.node))>-1&&c.updateNodeAt(t,n,a,u,e)||c.updateNextNode(t,n,a,e,l,r)||c.addNode(t,n,a,e,r),r+=t.nodeSize}),c.syncToMarks([],i,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||2==this.dirty)&&(a&&this.protectLocalComposition(e,a),Zf(this.contentDOM,this.children,e),vf&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){var t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}},{key:"localCompositionInfo",value:function(e,t){var n=e.state.selection,i=n.from,r=n.to;if(!(e.state.selection instanceof dh)||i<t||r>t+this.node.content.size)return null;var o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){var a=o.nodeValue,s=function(e,t,n,i){for(var r=0,o=0;r<e.childCount&&o<=i;){var a=e.child(r++),s=o;if(o+=a.nodeSize,a.isText){for(var c=a.text;r<e.childCount;){var l=e.child(r++);if(o+=l.nodeSize,!l.isText)break;c+=l.text}if(o>=n){if(o>=i&&c.slice(i-t.length-s,i-s)==t)return i-t.length;var u=s<i?c.lastIndexOf(t,i-s-1):-1;if(u>=0&&u+t.length+s>=n)return s+u;if(n==i&&c.length>=i+t.length-s&&c.slice(i-s,i-s+t.length)==t)return i}}}return-1}(this.node.content,a,i-t,r-t);return s<0?null:{node:o,pos:s,text:a}}return{node:o,pos:-1,text:""}}},{key:"protectLocalComposition",value:function(e,t){var n=t.node,i=t.pos,r=t.text;if(!this.getDesc(n)){for(var o=n;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}var a=new qf(this,o,n,r);e.input.compositionNodes.push(a),this.children=up(this.children,i,i+r.length,e,a)}}},{key:"update",value:function(e,t,n,i){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,i),!0)}},{key:"updateInner",value:function(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=0}},{key:"updateOuterDeco",value:function(e){if(!ap(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=ip(this.dom,this.nodeDOM,np(this.outerDeco,this.node,t),np(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}}},{key:"selectNode",value:function(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}},{key:"deselectNode",value:function(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}},{key:"domAtom",get:function(){return this.node.isAtom}}],[{key:"create",value:function(e,n,i,r,o,a){var s,c=o.nodeViews[n.type.name],l=c&&c(n,o,function(){return s?s.parent?s.parent.posBeforeChild(s):void 0:a},i,r),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText)if(u){if(3!=u.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else u=document.createTextNode(n.text);else if(!u){var h=ud.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);u=h.dom,d=h.contentDOM}d||n.isText||"BR"==u.nodeName||(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));var f=u;return u=op(u,i,n),l?s=new Qf(e,n,i,r,u,d||null,f,l,o,a+1):n.isText?new Yf(e,n,i,r,u,f,o):new t(e,n,i,r,u,d||null,f,o,a+1)}}])}($f);function Gf(e,t,n,i,r){op(i,t,e);var o=new Jf(void 0,e,t,n,i,i,i,r,0);return o.contentDOM&&o.updateChildren(r,0),o}var Yf=function(t){function r(e,t,i,o,a,s,c){return C(this,r),n(this,r,[e,t,i,o,a,null,s,c,0])}return i(r,t),x(r,[{key:"parseRule",value:function(){for(var e=this.nodeDOM.parentNode;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}},{key:"update",value:function(e,t,n,i){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=0,!0)}},{key:"inParent",value:function(){for(var e=this.parent.contentDOM,t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}},{key:"domFromPos",value:function(e){return{node:this.nodeDOM,offset:e}}},{key:"localPosFromDOM",value:function(t,n,i){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):e(r,"localPosFromDOM",this,3)([t,n,i])}},{key:"ignoreMutation",value:function(e){return"characterData"!=e.type&&"selection"!=e.type}},{key:"slice",value:function(e,t,n){var i=this.node.cut(e,t),o=document.createTextNode(i.text);return new r(this.parent,i,this.outerDeco,this.innerDeco,o,o,n)}},{key:"markDirty",value:function(t,n){e(r,"markDirty",this,3)([t,n]),this.dom==this.nodeDOM||0!=t&&n!=this.nodeDOM.nodeValue.length||(this.dirty=3)}},{key:"domAtom",get:function(){return!1}},{key:"isText",value:function(e){return this.node.text==e}}])}(Jf),Xf=function(e){function t(){return C(this,t),n(this,t,arguments)}return i(t,e),x(t,[{key:"parseRule",value:function(){return{ignore:!0}}},{key:"matchesHack",value:function(e){return 0==this.dirty&&this.dom.nodeName==e}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForCoords",get:function(){return"IMG"==this.dom.nodeName}}])}($f),Qf=function(t){function r(e,t,i,o,a,s,c,l,u,d){var h;return C(this,r),(h=n(this,r,[e,t,i,o,a,s,c,u,d])).spec=l,h}return i(r,t),x(r,[{key:"update",value:function(t,n,i,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){var a=this.spec.update(t,n,i);return a&&this.updateInner(t,n,i,o),a}return!(!this.contentDOM&&!t.isLeaf)&&e(r,"update",this,3)([t,n,i,o])}},{key:"selectNode",value:function(){this.spec.selectNode?this.spec.selectNode():e(r,"selectNode",this,3)([])}},{key:"deselectNode",value:function(){this.spec.deselectNode?this.spec.deselectNode():e(r,"deselectNode",this,3)([])}},{key:"setSelection",value:function(t,n,i,o){this.spec.setSelection?this.spec.setSelection(t,n,i.root):e(r,"setSelection",this,3)([t,n,i,o])}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),e(r,"destroy",this,3)([])}},{key:"stopEvent",value:function(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}},{key:"ignoreMutation",value:function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e(r,"ignoreMutation",this,3)([t])}}])}(Jf);function Zf(e,t,n){for(var i=e.firstChild,r=!1,o=0;o<t.length;o++){var a=t[o],s=a.dom;if(s.parentNode==e){for(;s!=i;)i=sp(i),r=!0;i=i.nextSibling}else r=!0,e.insertBefore(s,i);if(a instanceof Kf){var c=i?i.previousSibling:e.lastChild;Zf(a.contentDOM,a.children,n),i=c?c.nextSibling:e.firstChild}}for(;i;)i=sp(i),r=!0;r&&n.trackWrites==e&&(n.trackWrites=null)}var ep=function(e){e&&(this.nodeName=e)};ep.prototype=Object.create(null);var tp=[new ep];function np(e,t,n){if(0==e.length)return tp;for(var i=n?tp[0]:new ep,r=[i],o=0;o<e.length;o++){var a=e[o].type.attrs;if(a)for(var s in a.nodeName&&r.push(i=new ep(a.nodeName)),a){var c=a[s];null!=c&&(n&&1==r.length&&r.push(i=new ep(t.isInline?"span":"div")),"class"==s?i.class=(i.class?i.class+" ":"")+c:"style"==s?i.style=(i.style?i.style+";":"")+c:"nodeName"!=s&&(i[s]=c))}}return r}function ip(e,t,n,i){if(n==tp&&i==tp)return t;for(var r=t,o=0;o<i.length;o++){var a=i[o],s=n[o];if(o){var c=void 0;s&&s.nodeName==a.nodeName&&r!=e&&(c=r.parentNode)&&c.nodeName.toLowerCase()==a.nodeName||((c=document.createElement(a.nodeName)).pmIsDeco=!0,c.appendChild(r),s=tp[0]),r=c}rp(r,s||tp[0],a)}return r}function rp(e,t,n){for(var i in t)"class"==i||"style"==i||"nodeName"==i||i in n||e.removeAttribute(i);for(var r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){for(var o=t.class?t.class.split(" ").filter(Boolean):[],a=n.class?n.class.split(" ").filter(Boolean):[],s=0;s<o.length;s++)-1==a.indexOf(o[s])&&e.classList.remove(o[s]);for(var c=0;c<a.length;c++)-1==o.indexOf(a[c])&&e.classList.add(a[c]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style)for(var l,u=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;l=u.exec(t.style);)e.style.removeProperty(l[1]);n.style&&(e.style.cssText+=n.style)}}function op(e,t,n){return ip(e,e,tp,np(t,n,1!=e.nodeType))}function ap(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function sp(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var cp=function(){return x(function e(t,n,i){C(this,e),this.lock=n,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(e,t){var n=t,i=n.children.length,r=e.childCount,o=new Map,a=[];e:for(;r>0;){for(var s=void 0;;)if(i){var c=n.children[i-1];if(!(c instanceof Kf)){s=c,i--;break}n=c,i=c.children.length}else{if(n==t)break e;i=n.parent.children.indexOf(n),n=n.parent}var l=s.node;if(l){if(l!=e.child(r-1))break;--r,o.set(s,r),a.push(s)}}return{index:r,matched:o,matches:a.reverse()}}(t.node.content,t)},[{key:"destroyBetween",value:function(e,t){if(e!=t){for(var n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}},{key:"destroyRest",value:function(){this.destroyBetween(this.index,this.top.children.length)}},{key:"syncToMarks",value:function(e,t,n){for(var i=0,r=this.stack.length>>1,o=Math.min(r,e.length);i<o&&(i==r-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);for(var a=-1,s=this.index;s<Math.min(this.index+3,this.top.children.length);s++){var c=this.top.children[s];if(c.matchesMark(e[r])&&!this.isLocked(c.dom)){a=s;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{var l=Kf.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,r++}}},{key:"findNodeMatch",value:function(e,t,n,i){var r,o=-1;if(i>=this.preMatch.index&&(r=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,n))o=this.top.children.indexOf(r,this.index);else for(var a=this.index,s=Math.min(this.top.children.length,a+5);a<s;a++){var c=this.top.children[a];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=a;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)}},{key:"updateNodeAt",value:function(e,t,n,i,r){var o=this.top.children[i];return 3==o.dirty&&o.dom==o.contentDOM&&(o.dirty=2),!!o.update(e,t,n,r)&&(this.destroyBetween(this.index,i),this.index++,!0)}},{key:"findIndexWithChild",value:function(e){for(;;){var t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){var n=e.pmViewDesc;if(n)for(var i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i;return-1}e=t}}},{key:"updateNextNode",value:function(e,t,n,i,r,o){for(var a=this.index;a<this.top.children.length;a++){var s=this.top.children[a];if(s instanceof Jf){var c=this.preMatch.matched.get(s);if(null!=c&&c!=r)return!1;var l=s.dom,u=void 0,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&3!=s.dirty&&ap(t,s.outerDeco));if(!d&&s.update(e,t,n,i))return this.destroyBetween(this.index,a),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,i,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=2,u.updateChildren(i,o+1),u.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}},{key:"recreateWrapper",value:function(e,t,n,i,r,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ap(n,e.outerDeco)||!i.eq(e.innerDeco))return null;var a=Jf.create(this.top,t,n,i,r,o);if(a.contentDOM){a.children=e.children,e.children=[];var s,c=m(a.children);try{for(c.s();!(s=c.n()).done;){s.value.parent=a}}catch(l){c.e(l)}finally{c.f()}}return e.destroy(),a}},{key:"addNode",value:function(e,t,n,i,r){var o=Jf.create(this.top,e,t,n,i,r);o.contentDOM&&o.updateChildren(i,r+1),this.top.children.splice(this.index++,0,o),this.changed=!0}},{key:"placeWidget",value:function(e,t,n){var i=this.index<this.top.children.length?this.top.children[this.index]:null;if(!i||!i.matchesWidget(e)||e!=i.widget&&i.widget.type.toDOM.parentNode){var r=new Uf(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}},{key:"addTextblockHacks",value:function(){for(var e=this.top.children[this.index-1],t=this.top;e instanceof Kf;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof Yf)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((pf||hf)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}},{key:"addHackNode",value:function(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{var n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");var i=new Xf(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}},{key:"isLocked",value:function(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}])}();function lp(e,t){return e.type.side-t.type.side}function up(e,t,n,i,r){for(var o=[],a=0,s=0;a<e.length;a++){var c=e[a],l=s,u=s+=c.size;l>=n||u<=t?o.push(c):(l<t&&o.push(c.slice(0,t-l,i)),r&&(o.push(r),r=void 0),u>n&&o.push(c.slice(n-l,c.size,i)))}return o}function dp(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e.domSelectionRange(),i=e.state.doc;if(!n.focusNode)return null;var r=e.docView.nearestDesc(n.focusNode),o=r&&0==r.size,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;var s,c,l=i.resolve(a);if(Zh(n)){for(s=a;r&&!r.node;)r=r.parent;var u=r.node;if(r&&u.isAtom&&fh.isSelectable(u)&&r.parent&&(!u.isInline||!function(e,t,n){for(var i=0==t,r=t==Xh(e);i||r;){if(e==n)return!0;var o=$h(e);if(!(e=e.parentNode))return!1;i=i&&0==o,r=r&&o==Xh(e)}}(n.focusNode,n.focusOffset,r.dom))){var d=r.posBefore;c=new fh(a==d?l:i.resolve(d))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){for(var h=a,f=a,p=0;p<n.rangeCount;p++){var v=n.getRangeAt(p);h=Math.min(h,e.docView.posFromDOM(v.startContainer,v.startOffset,1)),f=Math.max(f,e.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(h<0)return null;var m=g(f==e.state.selection.anchor?[f,h]:[h,f],2);s=m[0],a=m[1],l=i.resolve(a)}else s=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(s<0)return null}var y=i.resolve(s);c||(c=wp(e,y,l,"pointer"==t||e.state.selection.head<l.pos&&!o?1:-1));return c}function hp(e){return e.editable?e.hasFocus():Cp(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function fp(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.state.selection;if(yp(e,n),hp(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&hf){var i=e.domSelectionRange(),r=e.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&Jh(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){var t=e.domSelection();if(!t)return;var n=e.cursorWrapper.dom,i="IMG"==n.nodeName;i?t.collapse(n.parentNode,$h(n)+1):t.collapse(n,0);!i&&!e.state.selection.visible&&cf&&lf<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{var o,a,s=n.anchor,c=n.head;!pp||n instanceof dh||(n.$from.parent.inlineContent||(o=vp(e,n.from)),n.empty||n.$from.parent.inlineContent||(a=vp(e,n.to))),e.docView.setSelection(s,c,e,t),pp&&(o&&gp(o),a&&gp(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);var n=e.domSelectionRange(),i=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=function(){n.anchorNode==i&&n.anchorOffset==r||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(function(){hp(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var pp=pf||hf&&ff<63;function vp(e,t){var n=e.docView.domFromPos(t,0),i=n.node,r=n.offset,o=r<i.childNodes.length?i.childNodes[r]:null,a=r?i.childNodes[r-1]:null;if(pf&&o&&"false"==o.contentEditable)return mp(o);if(!(o&&"false"!=o.contentEditable||a&&"false"!=a.contentEditable)){if(o)return mp(o);if(a)return mp(a)}}function mp(e){return e.contentEditable="true",pf&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function gp(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function yp(e,t){if(t instanceof fh){var n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(kp(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else kp(e)}function kp(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function wp(e,t,n,i){return e.someProp("createSelectionBetween",function(i){return i(e,t,n)})||dh.between(t,n,i)}function bp(e){return!(e.editable&&!e.hasFocus())&&Cp(e)}function Cp(e){var t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(Ss){return!1}}function Sp(e,t){var n=e.selection,i=n.$anchor,r=n.$head,o=t>0?i.max(r):i.min(r),a=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return a&&sh.findFrom(a,t)}function xp(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Tp(e,t,n){var i=e.state.selection;if(!(i instanceof dh)){if(i instanceof fh&&i.node.isInline)return xp(e,new dh(t>0?i.$to:i.$from));var r=Sp(e.state,t);return!!r&&xp(e,r)}if(n.indexOf("s")>-1){var o=i.$head,a=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;var s=e.state.doc.resolve(o.pos+a.nodeSize*(t<0?-1:1));return xp(e,new dh(i.$anchor,s))}if(!i.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){var c=Sp(e.state,t);return!!(c&&c instanceof fh)&&xp(e,c)}if(!(mf&&n.indexOf("m")>-1)){var l,u=i.$head,d=u.textOffset?null:t<0?u.nodeBefore:u.nodeAfter;if(!d||d.isText)return!1;var h=t<0?u.pos-d.nodeSize:u.pos;return!!(d.isAtom||(l=e.docView.descAt(h))&&!l.contentDOM)&&(fh.isSelectable(d)?xp(e,new fh(t<0?e.state.doc.resolve(u.pos-d.nodeSize):u)):!!kf&&xp(e,new dh(e.state.doc.resolve(t<0?h:h+d.nodeSize))))}}function Mp(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function _p(e,t){var n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function Np(e,t){return t<0?function(e){var t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n)return;var r,o,a=!1;uf&&1==n.nodeType&&i<Mp(n)&&_p(n.childNodes[i],-1)&&(a=!0);for(;;)if(i>0){if(1!=n.nodeType)break;var s=n.childNodes[i-1];if(_p(s,-1))r=n,o=--i;else{if(3!=s.nodeType)break;i=(n=s).nodeValue.length}}else{if(Op(n))break;for(var c=n.previousSibling;c&&_p(c,-1);)r=n.parentNode,o=$h(c),c=c.previousSibling;if(c)i=Mp(n=c);else{if((n=n.parentNode)==e.dom)break;i=0}}a?Ep(e,n,i):r&&Ep(e,r,o)}(e):function(e){var t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n)return;for(var r,o,a=Mp(n);;)if(i<a){if(1!=n.nodeType)break;if(!_p(n.childNodes[i],1))break;r=n,o=++i}else{if(Op(n))break;for(var s=n.nextSibling;s&&_p(s,1);)r=s.parentNode,o=$h(s)+1,s=s.nextSibling;if(s)i=0,a=Mp(n=s);else{if((n=n.parentNode)==e.dom)break;i=a=0}}r&&Ep(e,r,o)}(e)}function Op(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ep(e,t,n){var i,r;3!=t.nodeType&&((r=function(e,t){for(;e&&t==e.childNodes.length&&!Qh(e);)t=$h(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){var n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(i=function(e,t){for(;e&&!t&&!Qh(e);)t=$h(e),e=e.parentNode;for(;e&&t;){var n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=i,n=i.nodeValue.length));var o=e.domSelection();if(o){if(Zh(o)){var a=document.createRange();a.setEnd(t,n),a.setStart(t,n),o.removeAllRanges(),o.addRange(a)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();var s=e.state;setTimeout(function(){e.state==s&&fp(e)},50)}}function Ap(e,t){var n=e.state.doc.resolve(t);if(!hf&&!gf&&n.parent.inlineContent){var i=e.coordsAtPos(t);if(t>n.start()){var r=e.coordsAtPos(t-1),o=(r.top+r.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(r.left-i.left)>1)return r.left<i.left?"ltr":"rtl"}if(t<n.end()){var a=e.coordsAtPos(t+1),s=(a.top+a.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Dp(e,t,n){var i=e.state.selection;if(i instanceof dh&&!i.empty||n.indexOf("s")>-1)return!1;if(mf&&n.indexOf("m")>-1)return!1;var r=i.$from,o=i.$to;if(!r.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){var a=Sp(e.state,t);if(a&&a instanceof fh)return xp(e,a)}if(!r.parent.inlineContent){var s=t<0?r:o,c=i instanceof vh?sh.near(s,t):sh.findFrom(s,t);return!!c&&xp(e,c)}return!1}function Ip(e,t){if(!(e.state.selection instanceof dh))return!0;var n=e.state.selection,i=n.$head,r=n.$anchor,o=n.empty;if(!i.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;var a=!i.textOffset&&(t<0?i.nodeBefore:i.nodeAfter);if(a&&!a.isText){var s=e.state.tr;return t<0?s.delete(i.pos-a.nodeSize,i.pos):s.delete(i.pos,i.pos+a.nodeSize),e.dispatch(s),!0}return!1}function Lp(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Rp(e,t){var n=t.keyCode,i=function(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||mf&&72==n&&"c"==i)return Ip(e,-1)||Np(e,-1);if(46==n&&!t.shiftKey||mf&&68==n&&"c"==i)return Ip(e,1)||Np(e,1);if(13==n||27==n)return!0;if(37==n||mf&&66==n&&"c"==i){var r=37==n?"ltr"==Ap(e,e.state.selection.from)?-1:1:-1;return Tp(e,r,i)||Np(e,r)}if(39==n||mf&&70==n&&"c"==i){var o=39==n?"ltr"==Ap(e,e.state.selection.from)?1:-1:1;return Tp(e,o,i)||Np(e,o)}return 38==n||mf&&80==n&&"c"==i?Dp(e,-1,i)||Np(e,-1):40==n||mf&&78==n&&"c"==i?function(e){if(!pf||e.state.selection.$head.parentOffset>0)return!1;var t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(n&&1==n.nodeType&&0==i&&n.firstChild&&"false"==n.firstChild.contentEditable){var r=n.firstChild;Lp(e,r,"true"),setTimeout(function(){return Lp(e,r,"false")},20)}return!1}(e)||Dp(e,1,i)||Np(e,1):i==(mf?"m":"c")&&(66==n||73==n||89==n||90==n)}function Pp(e,t){e.someProp("transformCopied",function(n){t=n(t,e)});for(var n=[],i=t,r=i.content,o=i.openStart,a=i.openEnd;o>1&&a>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,a--;var s=r.firstChild;n.push(s.type.name,s.attrs!=s.type.defaultAttrs?s.attrs:null),r=s.content}var c=e.someProp("clipboardSerializer")||ud.fromSchema(e.state.schema),l=qp(),u=l.createElement("div");u.appendChild(c.serializeFragment(r,{document:l}));for(var d,h=u.firstChild,f=0;h&&1==h.nodeType&&(d=$p[h.nodeName.toLowerCase()]);){for(var p=d.length-1;p>=0;p--){for(var v=l.createElement(d[p]);u.firstChild;)v.appendChild(u.firstChild);u.appendChild(v),f++}h=u.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice","".concat(o," ").concat(a).concat(f?" -".concat(f):""," ").concat(JSON.stringify(n)));var m=e.someProp("clipboardTextSerializer",function(n){return n(t,e)})||t.content.textBetween(0,t.content.size,"\n\n");return{dom:u,text:m,slice:t}}function zp(e,t,n,i,r){var o,a,s=r.parent.type.spec.code;if(!n&&!t)return null;var c=!!t&&(i||s||!n);if(c){if(e.someProp("transformPastedText",function(n){t=n(t,s||i,e)}),s)return a=new pu(cu.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",function(t){a=t(a,e,!0)}),a;var l=e.someProp("clipboardTextParser",function(n){return n(t,r,i,e)});if(l)a=l;else{var u=r.marks(),d=e.state.schema,h=ud.fromSchema(d);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(function(e){var t=o.appendChild(document.createElement("p"));e&&t.appendChild(h.serializeNode(d.text(e,u)))})}}else e.someProp("transformPastedHTML",function(t){n=t(n,e)}),o=function(e){var t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var n,i=qp().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e);(n=r&&$p[r[1].toLowerCase()])&&(e=n.map(function(e){return"<"+e+">"}).join("")+e+n.map(function(e){return"</"+e+">"}).reverse().join(""));if(i.innerHTML=function(e){var t=window.trustedTypes;if(!t)return e;Kp||(Kp=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:function(e){return e}}));return Kp.createHTML(e)}(e),n)for(var o=0;o<n.length;o++)i=i.querySelector(n[o])||i;return i}(n),kf&&function(e){for(var t=e.querySelectorAll(hf?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<t.length;n++){var i=t[n];1==i.childNodes.length&&" "==i.textContent&&i.parentNode&&i.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),i)}}(o);var f=o&&o.querySelector("[data-pm-slice]"),p=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(p&&p[3])for(var v=+p[3];v>0;v--){for(var m=o.firstChild;m&&1!=m.nodeType;)m=m.nextSibling;if(!m)break;o=m}if(!a){var g=e.someProp("clipboardParser")||e.someProp("domParser")||ed.fromSchema(e.state.schema);a=g.parseSlice(o,{preserveWhitespace:!(!c&&!p),context:r,ruleFromNode:function(e){return"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Bp.test(e.parentNode.nodeName)?null:{ignore:!0}}})}if(p)a=function(e,t){if(!e.size)return e;var n,i=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(vs){return e}for(var r=e.content,o=e.openStart,a=e.openEnd,s=n.length-2;s>=0;s-=2){var c=i.nodes[n[s]];if(!c||c.hasRequiredAttrs())break;r=cu.from(c.create(n[s+1],r)),o++,a++}return new pu(r,o,a)}(Wp(a,+p[1],+p[2]),p[4]);else if(a=pu.maxOpen(function(e,t){if(e.childCount<2)return e;for(var n,i=function(){var n,i=t.node(r).contentMatchAt(t.index(r)),o=[];if(e.forEach(function(e){if(o){var t,r=i.findWrapping(e.type);if(!r)return o=null;if(t=o.length&&n.length&&Fp(r,n,e,o[o.length-1],0))o[o.length-1]=t;else{o.length&&(o[o.length-1]=jp(o[o.length-1],n.length));var a=Hp(e,r);o.push(a),i=i.matchType(a.type),n=r}}}),o)return{v:cu.from(o)}},r=t.depth;r>=0;r--)if(n=i())return n.v;return e}(a.content,r),!0),a.openStart||a.openEnd){for(var y=0,k=0,w=a.content.firstChild;y<a.openStart&&!w.type.spec.isolating;y++,w=w.firstChild);for(var b=a.content.lastChild;k<a.openEnd&&!b.type.spec.isolating;k++,b=b.lastChild);a=Wp(a,y,k)}return e.someProp("transformPasted",function(t){a=t(a,e,c)}),a}var Bp=/^(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 Hp(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=t.length-1;i>=n;i--)e=t[i].create(null,cu.from(e));return e}function Fp(e,t,n,i,r){if(r<e.length&&r<t.length&&e[r]==t[r]){var o=Fp(e,t,n,i.lastChild,r+1);if(o)return i.copy(i.content.replaceChild(i.childCount-1,o));if(i.contentMatchAt(i.childCount).matchType(r==e.length-1?n.type:e[r+1]))return i.copy(i.content.append(cu.from(Hp(n,e,r+1))))}}function jp(e,t){if(0==t)return e;var n=e.content.replaceChild(e.childCount-1,jp(e.lastChild,t-1)),i=e.contentMatchAt(e.childCount).fillBefore(cu.empty,!0);return e.copy(n.append(i))}function Vp(e,t,n,i,r,o){var a=t<0?e.firstChild:e.lastChild,s=a.content;return e.childCount>1&&(o=0),r<i-1&&(s=Vp(s,t,n,i,r+1,o)),r>=n&&(s=t<0?a.contentMatchAt(0).fillBefore(s,o<=r).append(s):s.append(a.contentMatchAt(a.childCount).fillBefore(cu.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(s))}function Wp(e,t,n){return t<e.openStart&&(e=new pu(Vp(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new pu(Vp(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var $p={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Up=null;function qp(){return Up||(Up=document.implementation.createHTMLDocument("title"))}var Kp=null;var Jp={},Gp={},Yp={touchstart:!0,touchmove:!0},Xp=x(function e(){C(this,e),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 Qp(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Zp(e){e.someProp("handleDOMEvents",function(t){for(var n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=function(t){return ev(e,t)})})}function ev(e,t){return e.someProp("handleDOMEvents",function(n){var i=n[t.type];return!!i&&(i(e,t)||t.defaultPrevented)})}function tv(e){return{left:e.clientX,top:e.clientY}}function nv(e,t,n,i,r){if(-1==i)return!1;for(var o,a=e.state.doc.resolve(i),s=function(i){if(e.someProp(t,function(t){return i>a.depth?t(e,n,a.nodeAfter,a.before(i),r,!0):t(e,n,a.node(i),a.before(i),r,!1)}))return{v:!0}},c=a.depth+1;c>0;c--)if(o=s(c))return o.v;return!1}function iv(e,t,n){if(e.focused||e.focus(),!e.state.selection.eq(t)){var i=e.state.tr.setSelection(t);"pointer"==n&&i.setMeta("pointer",!0),e.dispatch(i)}}function rv(e,t,n,i,r){return nv(e,"handleClickOn",t,n,i)||e.someProp("handleClick",function(n){return n(e,t,i)})||(r?function(e,t){if(-1==t)return!1;var n,i,r=e.state.selection;r instanceof fh&&(n=r.node);for(var o=e.state.doc.resolve(t),a=o.depth+1;a>0;a--){var s=a>o.depth?o.nodeAfter:o.node(a);if(fh.isSelectable(s)){i=n&&r.$from.depth>0&&a>=r.$from.depth&&o.before(r.$from.depth+1)==r.$from.pos?o.before(r.$from.depth):o.before(a);break}}return null!=i&&(iv(e,fh.create(e.state.doc,i),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;var n=e.state.doc.resolve(t),i=n.nodeAfter;return!!(i&&i.isAtom&&fh.isSelectable(i))&&(iv(e,new fh(n),"pointer"),!0)}(e,n))}function ov(e,t,n,i){return nv(e,"handleDoubleClickOn",t,n,i)||e.someProp("handleDoubleClick",function(n){return n(e,t,i)})}function av(e,t,n,i){return nv(e,"handleTripleClickOn",t,n,i)||e.someProp("handleTripleClick",function(n){return n(e,t,i)})||function(e,t,n){if(0!=n.button)return!1;var i=e.state.doc;if(-1==t)return!!i.inlineContent&&(iv(e,dh.create(i,0,i.content.size),"pointer"),!0);for(var r=i.resolve(t),o=r.depth+1;o>0;o--){var a=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(a.inlineContent)iv(e,dh.create(i,s+1,s+1+a.content.size),"pointer");else{if(!fh.isSelectable(a))continue;iv(e,fh.create(i,s),"pointer")}return!0}}(e,n,i)}function sv(e){return vv(e)}Gp.keydown=function(e,t){var n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!uv(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!yf||!hf||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!vf||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",function(t){return t(e,n)})||Rp(e,n)?n.preventDefault():Qp(e,"key");else{var i=Date.now();e.input.lastIOSEnter=i,e.input.lastIOSEnterFallbackTimeout=setTimeout(function(){e.input.lastIOSEnter==i&&(e.someProp("handleKeyDown",function(t){return t(e,ef(13,"Enter"))}),e.input.lastIOSEnter=0)},200)}},Gp.keyup=function(e,t){16==t.keyCode&&(e.input.shiftKey=!1)},Gp.keypress=function(e,t){var n=t;if(!(uv(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||mf&&n.metaKey))if(e.someProp("handleKeyPress",function(t){return t(e,n)}))n.preventDefault();else{var i=e.state.selection;if(!(i instanceof dh&&i.$from.sameParent(i.$to))){var r=String.fromCharCode(n.charCode),o=function(){return e.state.tr.insertText(r).scrollIntoView()};/[\r\n]/.test(r)||e.someProp("handleTextInput",function(t){return t(e,i.$from.pos,i.$to.pos,r,o)})||e.dispatch(o()),n.preventDefault()}}};var cv=mf?"metaKey":"ctrlKey";Jp.mousedown=function(e,t){var n=t;e.input.shiftKey=n.shiftKey;var i=sv(e),r=Date.now(),o="singleClick";r-e.input.lastClick.time<500&&function(e,t){var n=t.x-e.clientX,i=t.y-e.clientY;return n*n+i*i<100}(n,e.input.lastClick)&&!n[cv]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?o="doubleClick":"doubleClick"==e.input.lastClick.type&&(o="tripleClick")),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:o,button:n.button};var a=e.posAtCoords(tv(n));a&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new lv(e,a,n,!!i)):("doubleClick"==o?ov:av)(e,a.pos,a.inside,n)?n.preventDefault():Qp(e,"pointer"))};var lv=function(){return x(function e(t,n,i,r){var o,a,s=this;if(C(this,e),this.view=t,this.pos=n,this.event=i,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!i[cv],this.allowDefault=i.shiftKey,n.inside>-1)o=t.state.doc.nodeAt(n.inside),a=n.inside;else{var c=t.state.doc.resolve(n.pos);o=c.parent,a=c.depth?c.before():0}var l=r?null:i.target,u=l?t.docView.nearestDesc(l,!0):null;this.target=u&&1==u.nodeDOM.nodeType?u.nodeDOM:null;var d=t.state.selection;(0==i.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||d instanceof fh&&d.from<=a&&d.to>a)&&(this.mightDrag={node:o,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!uf||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(function(){s.view.input.mouseDown==s&&s.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Qp(t,"pointer")},[{key:"done",value:function(){var e=this;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(function(){return fp(e.view)}),this.view.input.mouseDown=null}},{key:"up",value:function(e){if(this.done(),this.view.dom.contains(e.target)){var t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(tv(e))),this.updateAllowDefault(e),this.allowDefault||!t?Qp(this.view,"pointer"):rv(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||pf&&this.mightDrag&&!this.mightDrag.node.isAtom||hf&&!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)?(iv(this.view,sh.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Qp(this.view,"pointer")}}},{key:"move",value:function(e){this.updateAllowDefault(e),Qp(this.view,"pointer"),0==e.buttons&&this.done()}},{key:"updateAllowDefault",value:function(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}])}();function uv(e,t){return!!e.composing||!!(pf&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Jp.touchstart=function(e){e.input.lastTouch=Date.now(),sv(e),Qp(e,"pointer")},Jp.touchmove=function(e){e.input.lastTouch=Date.now(),Qp(e,"pointer")},Jp.contextmenu=function(e){return sv(e)};var dv=yf?5e3:-1;function hv(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(function(){return vv(e)},t))}function fv(e){var t;for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function pv(e){var t=e.domSelectionRange();if(!t.focusNode)return null;var n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Xh(e=e.childNodes[t-1])}else{if(!e.parentNode||Qh(e))return null;t=$h(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),i=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Qh(e))return null;t=$h(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&i&&n!=i){var r=i.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||i==o)return o;if(!r||!r.isText(i.nodeValue))return i;if(e.input.compositionNode==i){var a=n.pmViewDesc;if(a&&a.isText(n.nodeValue))return i}}return n||i}function vv(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(yf&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),fv(e),t||e.docView&&e.docView.dirty){var n=dp(e),i=e.state.selection;return n&&!n.eq(i)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Gp.compositionstart=Gp.compositionupdate=function(e){if(!e.composing){e.domObserver.flush();var t=e.state,n=t.selection.$to;if(t.selection instanceof dh&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(function(e){return!1===e.type.spec.inclusive})||hf&&gf&&function(e){var t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n||1!=n.nodeType||i>=n.childNodes.length)return!1;var r=n.childNodes[i];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),vv(e,!0),e.markCursor=null;else if(vv(e,!t.selection.empty),uf&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var i=e.domSelectionRange(),r=i.focusNode,o=i.focusOffset;r&&1==r.nodeType&&0!=o;){var a=o<0?r.lastChild:r.childNodes[o-1];if(!a)break;if(3==a.nodeType){var s=e.domSelection();s&&s.collapse(a,a.nodeValue.length);break}r=a,o=-1}e.input.composing=!0}hv(e,dv)},Gp.compositionend=function(e,t){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(function(){return e.domObserver.flush()}),e.input.compositionID++,hv(e,20))};var mv=cf&&lf<15||vf&&wf<604;function gv(e,t,n,i,r){var o=zp(e,t,n,i,e.state.selection.$from);if(e.someProp("handlePaste",function(t){return t(e,r,o||pu.empty)}))return!0;if(!o)return!1;var a=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(o),s=a?e.state.tr.replaceSelectionWith(a,i):e.state.tr.replaceSelection(o);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function yv(e){var t=e.getData("text/plain")||e.getData("Text");if(t)return t;var n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Jp.copy=Gp.cut=function(e,t){var n=t,i=e.state.selection,r="cut"==n.type;if(!i.empty){var o=mv?null:n.clipboardData,a=Pp(e,i.content()),s=a.dom,c=a.text;o?(n.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",c)):function(e,t){if(e.dom.parentNode){var n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";var i=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(function(){n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}}(e,s),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},Gp.paste=function(e,t){var n=t;if(!e.composing||yf){var i=mv?null:n.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;i&&gv(e,yv(i),i.getData("text/html"),r,n)?n.preventDefault():function(e,t){if(e.dom.parentNode){var n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,i=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();var r=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(function(){e.focus(),i.parentNode&&i.parentNode.removeChild(i),n?gv(e,i.value,null,r,t):gv(e,i.textContent,i.innerHTML,r,t)},50)}}(e,n)}};var kv=x(function e(t,n,i){C(this,e),this.slice=t,this.move=n,this.node=i}),wv=mf?"altKey":"ctrlKey";function bv(e,t){var n=e.someProp("dragCopies",function(e){return!e(t)});return null!=n?n:!t[wv]}for(var Cv in Jp.dragstart=function(e,t){var n=t,i=e.input.mouseDown;if(i&&i.done(),n.dataTransfer){var r,o=e.state.selection,a=o.empty?null:e.posAtCoords(tv(n));if(a&&a.pos>=o.from&&a.pos<=(o instanceof fh?o.to-1:o.to));else if(i&&i.mightDrag)r=fh.create(e.state.doc,i.mightDrag.pos);else if(n.target&&1==n.target.nodeType){var s=e.docView.nearestDesc(n.target,!0);s&&s.node.type.spec.draggable&&s!=e.docView&&(r=fh.create(e.state.doc,s.posBefore))}var c=Pp(e,(r||e.state.selection).content()),l=c.dom,u=c.text,d=c.slice;(!n.dataTransfer.files.length||!hf||ff>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(mv?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",mv||n.dataTransfer.setData("text/plain",u),e.dragging=new kv(d,bv(e,n),r)}},Jp.dragend=function(e){var t=e.dragging;window.setTimeout(function(){e.dragging==t&&(e.dragging=null)},50)},Gp.dragover=Gp.dragenter=function(e,t){return t.preventDefault()},Gp.drop=function(e,t){try{!function(e,t,n){if(!t.dataTransfer)return;var i=e.posAtCoords(tv(t));if(!i)return;var r=e.state.doc.resolve(i.pos),o=n&&n.slice;o?e.someProp("transformPasted",function(t){o=t(o,e,!1)}):o=zp(e,yv(t.dataTransfer),mv?null:t.dataTransfer.getData("text/html"),!1,r);var a=!(!n||!bv(e,t));if(e.someProp("handleDrop",function(n){return n(e,t,o||pu.empty,a)}))return void t.preventDefault();if(!o)return;t.preventDefault();var s=o?$d(e.state.doc,r.pos,o):r.pos;null==s&&(s=r.pos);var c=e.state.tr;if(a){var l=n.node;l?l.replace(c):c.deleteSelection()}var u=c.mapping.map(s),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,h=c.doc;d?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o);if(c.doc.eq(h))return;var f=c.doc.resolve(u);if(d&&fh.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new fh(f));else{var p=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach(function(e,t,n,i){return p=i}),c.setSelection(wp(e,f,c.doc.resolve(p)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Jp.focus=function(e){e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(function(){e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&fp(e)},20))},Jp.blur=function(e,t){var n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Jp.beforeinput=function(e,t){if(hf&&yf&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();var n=e.input.domChangeCount;setTimeout(function(){if(e.input.domChangeCount==n&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",function(t){return t(e,ef(8,"Backspace"))}))){var t=e.state.selection.$cursor;t&&t.pos>0&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView())}},50)}},Gp)Jp[Cv]=Gp[Cv];function Sv(e,t){if(e==t)return!0;for(var n in e)if(e[n]!==t[n])return!1;for(var i in t)if(!(i in e))return!1;return!0}var xv=function(){function e(t,n){C(this,e),this.toDOM=t,this.spec=n||Ov,this.side=this.spec.side||0}return x(e,[{key:"map",value:function(e,t,n,i){var r=e.mapResult(t.from+i,this.side<0?-1:1),o=r.pos;return r.deleted?null:new _v(o-n,o-n,this)}},{key:"valid",value:function(){return!0}},{key:"eq",value:function(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Sv(this.spec,t.spec))}},{key:"destroy",value:function(e){this.spec.destroy&&this.spec.destroy(e)}}])}(),Tv=function(){function e(t,n){C(this,e),this.attrs=t,this.spec=n||Ov}return x(e,[{key:"map",value:function(e,t,n,i){var r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return r>=o?null:new _v(r,o,this)}},{key:"valid",value:function(e,t){return t.from<t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&Sv(this.attrs,t.attrs)&&Sv(this.spec,t.spec)}},{key:"destroy",value:function(){}}],[{key:"is",value:function(t){return t.type instanceof e}}])}(),Mv=function(){function e(t,n){C(this,e),this.attrs=t,this.spec=n||Ov}return x(e,[{key:"map",value:function(e,t,n,i){var r=e.mapResult(t.from+i,1);if(r.deleted)return null;var o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=r.pos?null:new _v(r.pos-n,o.pos-n,this)}},{key:"valid",value:function(e,t){var n,i=e.content.findIndex(t.from),r=i.index,o=i.offset;return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&Sv(this.attrs,t.attrs)&&Sv(this.spec,t.spec)}},{key:"destroy",value:function(){}}])}(),_v=function(){function e(t,n,i){C(this,e),this.from=t,this.to=n,this.type=i}return x(e,[{key:"copy",value:function(t,n){return new e(t,n,this.type)}},{key:"eq",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}},{key:"map",value:function(e,t,n){return this.type.map(e,this,t,n)}},{key:"spec",get:function(){return this.type.spec}},{key:"inline",get:function(){return this.type instanceof Tv}},{key:"widget",get:function(){return this.type instanceof xv}}],[{key:"widget",value:function(t,n,i){return new e(t,t,new xv(n,i))}},{key:"inline",value:function(t,n,i,r){return new e(t,n,new Tv(i,r))}},{key:"node",value:function(t,n,i,r){return new e(t,n,new Mv(i,r))}}])}(),Nv=[],Ov={},Ev=function(){function e(t,n){C(this,e),this.local=t.length?t:Nv,this.children=n.length?n:Nv}return x(e,[{key:"find",value:function(e,t,n){var i=[];return this.findInner(null==e?0:e,null==t?1e9:t,i,0,n),i}},{key:"findInner",value:function(e,t,n,i,r){for(var o=0;o<this.local.length;o++){var a=this.local[o];a.from<=t&&a.to>=e&&(!r||r(a.spec))&&n.push(a.copy(a.from+i,a.to+i))}for(var s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){var c=this.children[s]+1;this.children[s+2].findInner(e-c,t-c,n,i+c,r)}}},{key:"map",value:function(e,t,n){return this==Av||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Ov)}},{key:"mapInner",value:function(t,n,i,r,o){for(var a,s=0;s<this.local.length;s++){var c=this.local[s].map(t,i,r);c&&c.type.valid(n,c)?(a||(a=[])).push(c):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?Iv(this.children,a||[],t,n,i,r,o):a?new e(a.sort(Bv),Nv):Av}},{key:"add",value:function(t,n){return n.length?this==Av?e.create(t,n):this.addInner(t,n,0):this}},{key:"addInner",value:function(t,n,i){var r,o=this,a=0;t.forEach(function(e,t){var s,c=t+i;if(s=Rv(n,e,c)){for(r||(r=o.children.slice());a<r.length&&r[a]<t;)a+=3;r[a]==t?r[a+2]=r[a+2].addInner(e,s,c+1):r.splice(a,0,t,t+e.nodeSize,zv(s,e,c+1,Ov)),a+=3}});for(var s=Lv(a?Pv(n):n,-i),c=0;c<s.length;c++)s[c].type.valid(t,s[c])||s.splice(c--,1);return new e(s.length?this.local.concat(s).sort(Bv):this.local,r||this.children)}},{key:"remove",value:function(e){return 0==e.length||this==Av?this:this.removeInner(e,0)}},{key:"removeInner",value:function(t,n){for(var i=this.children,r=this.local,o=0;o<i.length;o+=3){for(var a,s=void 0,c=i[o]+n,l=i[o+1]+n,u=0;u<t.length;u++)(a=t[u])&&a.from>c&&a.to<l&&(t[u]=null,(s||(s=[])).push(a));if(s){i==this.children&&(i=this.children.slice());var d=i[o+2].removeInner(s,c+1);d!=Av?i[o+2]=d:(i.splice(o,3),o-=3)}}if(r.length)for(var h,f=0;f<t.length;f++)if(h=t[f])for(var p=0;p<r.length;p++)r[p].eq(h,n)&&(r==this.local&&(r=this.local.slice()),r.splice(p--,1));return i==this.children&&r==this.local?this:r.length||i.length?new e(r,i):Av}},{key:"forChild",value:function(t,n){if(this==Av)return this;if(n.isLeaf)return e.empty;for(var i,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(i=this.children[o+2]);break}for(var a=t+1,s=a+n.content.size,c=0;c<this.local.length;c++){var l=this.local[c];if(l.from<s&&l.to>a&&l.type instanceof Tv){var u=Math.max(a,l.from)-a,d=Math.min(s,l.to)-a;u<d&&(r||(r=[])).push(l.copy(u,d))}}if(r){var h=new e(r.sort(Bv),Nv);return i?new Dv([h,i]):h}return i||Av}},{key:"eq",value:function(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(var i=0;i<this.children.length;i+=3)if(this.children[i]!=t.children[i]||this.children[i+1]!=t.children[i+1]||!this.children[i+2].eq(t.children[i+2]))return!1;return!0}},{key:"locals",value:function(e){return Hv(this.localsInner(e))}},{key:"localsInner",value:function(e){if(this==Av)return Nv;if(e.inlineContent||!this.local.some(Tv.is))return this.local;for(var t=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Tv||t.push(this.local[n]);return t}},{key:"forEachSet",value:function(e){e(this)}}],[{key:"create",value:function(e,t){return t.length?zv(t,e,0,Ov):Av}}])}();Ev.empty=new Ev([],[]),Ev.removeOverlap=Hv;var Av=Ev.empty,Dv=function(){function e(t){C(this,e),this.members=t}return x(e,[{key:"map",value:function(t,n){var i=this.members.map(function(e){return e.map(t,n,Ov)});return e.from(i)}},{key:"forChild",value:function(t,n){if(n.isLeaf)return Ev.empty;for(var i=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,n);o!=Av&&(o instanceof e?i=i.concat(o.members):i.push(o))}return e.from(i)}},{key:"eq",value:function(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(var n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}},{key:"locals",value:function(e){for(var t,n=!0,i=0;i<this.members.length;i++){var r=this.members[i].localsInner(e);if(r.length)if(t){n&&(t=t.slice(),n=!1);for(var o=0;o<r.length;o++)t.push(r[o])}else t=r}return t?Hv(n?t:t.sort(Bv)):Nv}},{key:"forEachSet",value:function(e){for(var t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}],[{key:"from",value:function(t){switch(t.length){case 0:return Av;case 1:return t[0];default:return new e(t.every(function(e){return e instanceof Ev})?t:t.reduce(function(e,t){return e.concat(t instanceof Ev?t:t.members)},[]))}}}])}();function Iv(e,t,n,i,r,o,a){for(var s=e.slice(),c=function(e){var t=0;n.maps[l].forEach(function(n,i,r,o){for(var a=o-r-(i-n),c=0;c<s.length;c+=3){var l=s[c+1];if(!(l<0||n>l+e-t)){var u=s[c]+e-t;i>=u?s[c+1]=n<=u?-2:-1:n>=e&&a&&(s[c]+=a,s[c+1]+=a)}}t+=a}),e=n.maps[l].map(e,-1),u=e},l=0,u=o;l<n.maps.length;l++)c(u);for(var d=!1,h=0;h<s.length;h+=3)if(s[h+1]<0){if(-2==s[h+1]){d=!0,s[h+1]=-1;continue}var f=n.map(e[h]+o),p=f-r;if(p<0||p>=i.content.size){d=!0;continue}var v=n.map(e[h+1]+o,-1)-r,m=i.content.findIndex(p),g=m.index,y=m.offset,k=i.maybeChild(g);if(k&&y==p&&y+k.nodeSize==v){var w=s[h+2].mapInner(n,k,f+1,e[h]+o+1,a);w!=Av?(s[h]=p,s[h+1]=v,s[h+2]=w):(s[h+1]=-2,d=!0)}else d=!0}if(d){var b=function(e,t,n,i,r,o,a){function s(e,t){for(var o=0;o<e.local.length;o++){var c=e.local[o].map(i,r,t);c?n.push(c):a.onRemove&&a.onRemove(e.local[o].spec)}for(var l=0;l<e.children.length;l+=3)s(e.children[l+2],e.children[l]+t+1)}for(var c=0;c<e.length;c+=3)-1==e[c+1]&&s(e[c+2],t[c]+o+1);return n}(s,e,t,n,r,o,a),C=zv(b,i,0,a);t=C.local;for(var S=0;S<s.length;S+=3)s[S+1]<0&&(s.splice(S,3),S-=3);for(var x=0,T=0;x<C.children.length;x+=3){for(var M=C.children[x];T<s.length&&s[T]<M;)T+=3;s.splice(T,0,C.children[x],C.children[x+1],C.children[x+2])}}return new Ev(t.sort(Bv),s)}function Lv(e,t){if(!t||!e.length)return e;for(var n=[],i=0;i<e.length;i++){var r=e[i];n.push(new _v(r.from+t,r.to+t,r.type))}return n}function Rv(e,t,n){if(t.isLeaf)return null;for(var i,r=n+t.nodeSize,o=null,a=0;a<e.length;a++)(i=e[a])&&i.from>n&&i.to<r&&((o||(o=[])).push(i),e[a]=null);return o}function Pv(e){for(var t=[],n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function zv(e,t,n,i){var r=[],o=!1;t.forEach(function(t,a){var s=Rv(e,t,a+n);if(s){o=!0;var c=zv(s,t,n+a+1,i);c!=Av&&r.push(a,a+t.nodeSize,c)}});for(var a=Lv(o?Pv(e):e,-n).sort(Bv),s=0;s<a.length;s++)a[s].type.valid(t,a[s])||(i.onRemove&&i.onRemove(a[s].spec),a.splice(s--,1));return a.length||r.length?new Ev(a,r):Av}function Bv(e,t){return e.from-t.from||e.to-t.to}function Hv(e){for(var t=e,n=0;n<t.length-1;n++){var i=t[n];if(i.from!=i.to)for(var r=n+1;r<t.length;r++){var o=t[r];if(o.from!=i.from){o.from<i.to&&(t==e&&(t=e.slice()),t[n]=i.copy(i.from,o.from),Fv(t,r,i.copy(o.from,i.to)));break}o.to!=i.to&&(t==e&&(t=e.slice()),t[r]=o.copy(o.from,i.to),Fv(t,r+1,o.copy(i.to,o.to)))}}return t}function Fv(e,t,n){for(;t<e.length&&Bv(n,e[t])>0;)t++;e.splice(t,0,n)}function jv(e){var t=[];return e.someProp("decorations",function(n){var i=n(e.state);i&&i!=Av&&t.push(i)}),e.cursorWrapper&&t.push(Ev.create(e.state.doc,[e.cursorWrapper.deco])),Dv.from(t)}var Vv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Wv=cf&&lf<=11,$v=function(){return x(function e(){C(this,e),this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0},[{key:"set",value:function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}},{key:"clear",value:function(){this.anchorNode=this.focusNode=null}},{key:"eq",value:function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}])}(),Uv=function(){return x(function e(t,n){var i=this;C(this,e),this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $v,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(function(e){for(var t=0;t<e.length;t++)i.queue.push(e[t]);cf&&lf<=11&&e.some(function(e){return"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length})?i.flushSoon():i.flush()}),Wv&&(this.onCharData=function(e){i.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),i.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)},[{key:"flushSoon",value:function(){var e=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(function(){e.flushingSoon=-1,e.flush()},20))}},{key:"forceFlush",value:function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}},{key:"start",value:function(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Vv)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}},{key:"stop",value:function(){var e=this;if(this.observer){var t=this.observer.takeRecords();if(t.length){for(var n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout(function(){return e.flush()},20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}},{key:"connectSelection",value:function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}},{key:"disconnectSelection",value:function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"suppressSelectionUpdates",value:function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout(function(){return e.suppressingSelectionUpdates=!1},50)}},{key:"onSelectionChange",value:function(){if(bp(this.view)){if(this.suppressingSelectionUpdates)return fp(this.view);if(cf&&lf<=11&&!this.view.state.selection.empty){var e=this.view.domSelectionRange();if(e.focusNode&&Jh(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}},{key:"setCurSelection",value:function(){this.currentSelection.set(this.view.domSelectionRange())}},{key:"ignoreSelectionChange",value:function(e){if(!e.focusNode)return!0;for(var t,n=new Set,i=e.focusNode;i;i=Uh(i))n.add(i);for(var r=e.anchorNode;r;r=Uh(r))if(n.has(r)){t=r;break}var o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}},{key:"pendingRecords",value:function(){if(this.observer){var e,t=m(this.observer.takeRecords());try{for(t.s();!(e=t.n()).done;){var n=e.value;this.queue.push(n)}}catch(i){t.e(i)}finally{t.f()}}return this.queue}},{key:"flush",value:function(){var e=this.view;if(e.docView&&!(this.flushingSoon>-1)){var t=this.pendingRecords();t.length&&(this.queue=[]);var n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&bp(e)&&!this.ignoreSelectionChange(n),r=-1,o=-1,a=!1,s=[];if(e.editable)for(var c=0;c<t.length;c++){var l=this.registerMutation(t[c],s);l&&(r=r<0?l.from:Math.min(l.from,r),o=o<0?l.to:Math.max(l.to,o),l.typeOver&&(a=!0))}if(uf&&s.length){var u=s.filter(function(e){return"BR"==e.nodeName});if(2==u.length){var d=g(u,2),h=d[0],f=d[1];h.parentNode&&h.parentNode.parentNode==f.parentNode?f.remove():h.remove()}else{var p,v=this.currentSelection.focusNode,y=m(u);try{for(y.s();!(p=y.n()).done;){var k=p.value,w=k.parentNode;!w||"LI"!=w.nodeName||v&&Gv(e,v)==w||k.remove()}}catch(M){y.e(M)}finally{y.f()}}}else if((hf||pf)&&s.some(function(e){return"BR"==e.nodeName})&&(8==e.input.lastKeyCode||46==e.input.lastKeyCode)){var b,C=m(s);try{for(C.s();!(b=C.n()).done;){var S=b.value;if("BR"==S.nodeName&&S.parentNode){var x=S.nextSibling;x&&1==x.nodeType&&"false"==x.contentEditable&&S.parentNode.removeChild(S)}}}catch(M){C.e(M)}finally{C.f()}}var T=null;r<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Zh(n)&&(T=dp(e))&&T.eq(sh.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,fp(e),this.currentSelection.set(n),e.scrollToSelection()):(r>-1||i)&&(r>-1&&(e.docView.markDirty(r,o),function(e){if(qv.has(e))return;if(qv.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=uf,Kv)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."),Kv=!0}}(e)),this.handleDOMChange(r,o,a,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||fp(e),this.currentSelection.set(n))}}},{key:"registerMutation",value:function(e,t){if(t.indexOf(e.target)>-1)return null;var n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(var i=0;i<e.addedNodes.length;i++){var r=e.addedNodes[i];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};var o=e.previousSibling,a=e.nextSibling;if(cf&&lf<=11&&e.addedNodes.length)for(var s=0;s<e.addedNodes.length;s++){var c=e.addedNodes[s],l=c.previousSibling,u=c.nextSibling;(!l||Array.prototype.indexOf.call(e.addedNodes,l)<0)&&(o=l),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(a=u)}var d=o&&o.parentNode==e.target?$h(o)+1:0,h=n.localPosFromDOM(e.target,d,-1),f=a&&a.parentNode==e.target?$h(a):e.target.childNodes.length;return{from:h,to:n.localPosFromDOM(e.target,f,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}])}(),qv=new WeakMap,Kv=!1;function Jv(e,t){var n=t.startContainer,i=t.startOffset,r=t.endContainer,o=t.endOffset,a=e.domAtPos(e.state.selection.anchor);if(Jh(a.node,a.offset,r,o)){var s=[r,o,n,i];n=s[0],i=s[1],r=s[2],o=s[3]}return{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}}function Gv(e,t){for(var n=t.parentNode;n&&n!=e.dom;n=n.parentNode){var i=e.docView.nearestDesc(n,!0);if(i&&i.node.isBlock)return n}return null}function Yv(e){var t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(pf&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(e.parentNode.lastChild==e||pf&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Xv=/^(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 Qv(e,t,n,i,r){var o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){var a=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,s=dp(e,a);if(s&&!e.state.selection.eq(s)){if(hf&&yf&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",function(t){return t(e,ef(13,"Enter"))}))return;var c=e.state.tr.setSelection(s);"pointer"==a?c.setMeta("pointer",!0):"key"==a&&c.scrollIntoView(),o&&c.setMeta("composition",o),e.dispatch(c)}}else{var l=e.state.doc.resolve(t),u=l.sharedDepth(n);t=l.before(u+1),n=e.state.doc.resolve(n).after(u+1);var d,h,f=e.state.selection,p=function(e,t,n){var i,r=e.docView.parseRange(t,n),o=r.node,a=r.fromOffset,s=r.toOffset,c=r.from,l=r.to,u=e.domSelectionRange(),d=u.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(i=[{node:d,offset:u.anchorOffset}],Zh(u)||i.push({node:u.focusNode,offset:u.focusOffset})),hf&&8===e.input.lastKeyCode)for(var h=s;h>a;h--){var f=o.childNodes[h-1],p=f.pmViewDesc;if("BR"==f.nodeName&&!p){s=h;break}if(!p||p.size)break}var v=e.state.doc,m=e.someProp("domParser")||ed.fromSchema(e.state.schema),g=v.resolve(c),y=null,k=m.parse(o,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:a,to:s,preserveWhitespace:"pre"!=g.parent.type.whitespace||"full",findPositions:i,ruleFromNode:Yv,context:g});if(i&&null!=i[0].pos){var w=i[0].pos,b=i[1]&&i[1].pos;null==b&&(b=w),y={anchor:w+c,head:b+c}}return{doc:k,sel:y,from:c,to:l}}(e,t,n),v=e.state.doc,m=v.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(d=e.state.selection.to,h="end"):(d=e.state.selection.from,h="start"),e.input.lastKeyCode=null;var g=function(e,t,n,i,r){var o=e.findDiffStart(t,n);if(null==o)return null;var a=e.findDiffEnd(t,n+e.size,n+t.size),s=a.a,c=a.b;if("end"==r){i-=s+Math.max(0,o-Math.min(s,c))-o}if(s<o&&e.size<t.size){var l=i<=o&&i>=s?o-i:0;(o-=l)&&o<t.size&&tm(t.textBetween(o-1,o+1))&&(o+=l?1:-1),c=o+(c-s),s=o}else if(c<o){var u=i<=o&&i>=c?o-i:0;(o-=u)&&o<e.size&&tm(e.textBetween(o-1,o+1))&&(o+=u?1:-1),s=o+(s-c),c=o}return{start:o,endA:s,endB:c}}(m.content,p.doc.content,p.from,d,h);if(g&&e.input.domChangeCount++,(vf&&e.input.lastIOSEnter>Date.now()-225||yf)&&r.some(function(e){return 1==e.nodeType&&!Xv.test(e.nodeName)})&&(!g||g.endA>=g.endB)&&e.someProp("handleKeyDown",function(t){return t(e,ef(13,"Enter"))}))e.input.lastIOSEnter=0;else{if(!g){if(!(i&&f instanceof dh&&!f.empty&&f.$head.sameParent(f.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){var y=Zv(e,e.state.doc,p.sel);if(y&&!y.eq(e.state.selection)){var k=e.state.tr.setSelection(y);o&&k.setMeta("composition",o),e.dispatch(k)}}return}g={start:f.from,endA:f.to,endB:f.to}}e.state.selection.from<e.state.selection.to&&g.start==g.endB&&e.state.selection instanceof dh&&(g.start>e.state.selection.from&&g.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?g.start=e.state.selection.from:g.endA<e.state.selection.to&&g.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(g.endB+=e.state.selection.to-g.endA,g.endA=e.state.selection.to)),cf&&lf<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>p.from&&"  "==p.doc.textBetween(g.start-p.from-1,g.start-p.from+1)&&(g.start--,g.endA--,g.endB--);var w=p.doc.resolveNoCache(g.start-p.from),b=p.doc.resolveNoCache(g.endB-p.from),C=v.resolve(g.start),S=w.sameParent(b)&&w.parent.inlineContent&&C.end()>=g.endA;if((vf&&e.input.lastIOSEnter>Date.now()-225&&(!S||r.some(function(e){return"DIV"==e.nodeName||"P"==e.nodeName}))||!S&&w.pos<p.doc.content.size&&(!w.sameParent(b)||!w.parent.inlineContent)&&w.pos<b.pos&&!/\S/.test(p.doc.textBetween(w.pos,b.pos,"","")))&&e.someProp("handleKeyDown",function(t){return t(e,ef(13,"Enter"))}))e.input.lastIOSEnter=0;else if(e.state.selection.anchor>g.start&&function(e,t,n,i,r){if(n-t<=r.pos-i.pos||em(i,!0,!1)<r.pos)return!1;var o=e.resolve(t);if(!i.parent.isTextblock){var a=o.nodeAfter;return null!=a&&n==t+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;var s=e.resolve(em(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||em(s,!0,!1)<n)&&i.parent.content.cut(i.parentOffset).eq(s.parent.content)}(v,g.start,g.endA,w,b)&&e.someProp("handleKeyDown",function(t){return t(e,ef(8,"Backspace"))}))yf&&hf&&e.domObserver.suppressSelectionUpdates();else{hf&&g.endB==g.start&&(e.input.lastChromeDelete=Date.now()),yf&&!S&&w.start()!=b.start()&&0==b.parentOffset&&w.depth==b.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==g.endA&&(g.endB-=2,b=p.doc.resolveNoCache(g.endB-p.from),setTimeout(function(){e.someProp("handleKeyDown",function(t){return t(e,ef(13,"Enter"))})},20));var x,T=g.start,M=g.endA,_=function(t){var n=t||e.state.tr.replace(T,M,p.doc.slice(g.start-p.from,g.endB-p.from));if(p.sel){var i=Zv(e,n.doc,p.sel);i&&!(hf&&e.composing&&i.empty&&(g.start!=g.endB||e.input.lastChromeDelete<Date.now()-100)&&(i.head==T||i.head==n.mapping.map(M)-1)||cf&&i.empty&&i.head==T)&&n.setSelection(i)}return o&&n.setMeta("composition",o),n.scrollIntoView()};if(S)if(w.pos==b.pos){cf&&lf<=11&&0==w.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(function(){return fp(e)},20));var N=_(e.state.tr.delete(T,M)),O=v.resolve(g.start).marksAcross(v.resolve(g.endA));O&&N.ensureMarks(O),e.dispatch(N)}else if(g.endA==g.endB&&(x=function(e,t){for(var n,i,r,o=e.firstChild.marks,a=t.firstChild.marks,s=o,c=a,l=0;l<a.length;l++)s=a[l].removeFromSet(s);for(var u=0;u<o.length;u++)c=o[u].removeFromSet(c);if(1==s.length&&0==c.length)i=s[0],n="add",r=function(e){return e.mark(i.addToSet(e.marks))};else{if(0!=s.length||1!=c.length)return null;i=c[0],n="remove",r=function(e){return e.mark(i.removeFromSet(e.marks))}}for(var d=[],h=0;h<t.childCount;h++)d.push(r(t.child(h)));if(cu.from(d).eq(e))return{mark:i,type:n}}(w.parent.content.cut(w.parentOffset,b.parentOffset),C.parent.content.cut(C.parentOffset,g.endA-C.start())))){var E=_(e.state.tr);"add"==x.type?E.addMark(T,M,x.mark):E.removeMark(T,M,x.mark),e.dispatch(E)}else if(w.parent.child(w.index()).isText&&w.index()==b.index()-(b.textOffset?0:1)){var A=w.parent.textBetween(w.parentOffset,b.parentOffset),D=function(){return _(e.state.tr.insertText(A,T,M))};e.someProp("handleTextInput",function(t){return t(e,T,M,A,D)})||e.dispatch(D())}else e.dispatch(_());else e.dispatch(_())}}}}function Zv(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:wp(e,t.resolve(n.anchor),t.resolve(n.head))}function em(e,t,n){for(var i=e.depth,r=t?e.end():e.pos;i>0&&(t||e.indexAfter(i)==e.node(i).childCount);)i--,r++,t=!1;if(n)for(var o=e.node(i).maybeChild(e.indexAfter(i));o&&!o.isLeaf;)o=o.firstChild,r++;return r}function tm(e){if(2!=e.length)return!1;var t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var nm=function(){return x(function e(t,n){var i=this;C(this,e),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 Xp,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(sm),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=om(this),rm(this),this.nodeViews=am(this),this.docView=Gf(this.state.doc,im(this),jv(this),this.dom,this),this.domObserver=new Uv(this,function(e,t,n,r){return Qv(i,e,t,n,r)}),this.domObserver.start(),function(e){var t=function(){var t=Jp[n];e.dom.addEventListener(n,e.input.eventHandlers[n]=function(n){!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,n)||ev(e,n)||!e.editable&&n.type in Gp||t(e,n)},Yp[n]?{passive:!0}:void 0)};for(var n in Jp)t();pf&&e.dom.addEventListener("input",function(){return null}),Zp(e)}(this),this.updatePluginViews()},[{key:"composing",get:function(){return this.input.composing}},{key:"props",get:function(){if(this._props.state!=this.state){var e=this._props;for(var t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}},{key:"update",value:function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Zp(this);var t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(sm),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}},{key:"setProps",value:function(e){var t={};for(var n in this._props)t[n]=this._props[n];for(var i in t.state=this.state,e)t[i]=e[i];this.update(t)}},{key:"updateState",value:function(e){this.updateStateInner(e,this._props)}},{key:"updateStateInner",value:function(e,t){var n,i=this.state,r=!1,o=!1;e.storedMarks&&this.composing&&(fv(this),o=!0),this.state=e;var a=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){var s=am(this);(function(e,t){var n=0,i=0;for(var r in e){if(e[r]!=t[r])return!0;n++}for(var o in t)i++;return n!=i})(s,this.nodeViews)&&(this.nodeViews=s,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Zp(this),this.editable=om(this),rm(this);var c=jv(this),l=im(this),u=i.plugins==e.plugins||i.doc.eq(e.doc)?e.scrollToSelection>i.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(e.doc,l,c);!d&&e.selection.eq(i.selection)||(o=!0);var h,f,p,v,m,g,y,k,w,b,C,S="preserve"==u&&o&&null==this.dom.style.overflowAnchor&&function(e){for(var t,n,i=e.dom.getBoundingClientRect(),r=Math.max(0,i.top),o=(i.left+i.right)/2,a=r+1;a<Math.min(innerHeight,i.bottom);a+=5){var s=e.root.elementFromPoint(o,a);if(s&&s!=e.dom&&e.dom.contains(s)){var c=s.getBoundingClientRect();if(c.top>=r-20){t=s,n=c.top;break}}}return{refDOM:t,refTop:n,stack:Tf(e.dom)}}(this);if(o){this.domObserver.stop();var x=d&&(cf||hf)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&(v=i.selection,m=e.selection,g=Math.min(v.$anchor.sharedDepth(v.head),m.$anchor.sharedDepth(m.head)),v.$anchor.start(g)!=m.$anchor.start(g));if(d){var T=hf?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=pv(this)),!r&&this.docView.update(e.doc,l,c,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=Gf(e.doc,l,c,this.dom,this)),T&&!this.trackWrites&&(x=!0)}x||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(h=this,f=h.docView.domFromPos(h.state.selection.anchor,0),p=h.domSelectionRange(),Jh(f.node,f.offset,p.anchorNode,p.anchorOffset)))?fp(this,x):(yp(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),"reset"==u?this.dom.scrollTop=0:"to selection"==u?this.scrollToSelection():S&&(k=(y=S).refDOM,w=y.refTop,b=y.stack,C=k?k.getBoundingClientRect().top:0,Mf(b,0==C?0:C-w))}},{key:"scrollToSelection",value:function(){var e=this,t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",function(t){return t(e)}));else if(this.state.selection instanceof fh){var n=this.docView.domAfterPos(this.state.selection.from);1==n.nodeType&&xf(this,n.getBoundingClientRect(),t)}else xf(this,this.coordsAtPos(this.state.selection.head,1),t);else;}},{key:"destroyPluginViews",value:function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()}},{key:"updatePluginViews",value:function(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var t=0;t<this.pluginViews.length;t++){var n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(var i=0;i<this.directPlugins.length;i++){var r=this.directPlugins[i];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(var o=0;o<this.state.plugins.length;o++){var a=this.state.plugins[o];a.spec.view&&this.pluginViews.push(a.spec.view(this))}}}},{key:"updateDraggedNode",value:function(e,t){var n=e.node,i=-1;if(this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{var r=n.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&this.state.doc.nodeAt(r))==n.node&&(i=r)}this.dragging=new kv(e.slice,e.move,i<0?void 0:fh.create(this.state.doc,i))}},{key:"someProp",value:function(e,t){var n,i=this._props&&this._props[e];if(null!=i&&(n=t?t(i):i))return n;for(var r=0;r<this.directPlugins.length;r++){var o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}var a=this.state.plugins;if(a)for(var s=0;s<a.length;s++){var c=a[s].props[e];if(null!=c&&(n=t?t(c):c))return n}}},{key:"hasFocus",value:function(){if(cf){var 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("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}},{key:"focus",value:function(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(_f)return e.focus(_f);var t=Tf(e);e.focus(null==_f?{get preventScroll(){return _f={preventScroll:!0},!0}}:void 0),_f||(_f=!1,Mf(t,0))}(this.dom),fp(this),this.domObserver.start()}},{key:"root",get:function(){var e=this,t=this._root;if(null==t)for(var n,i=function(t){if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=function(){return t.ownerDocument.getSelection()}),{v:e._root=t}},r=this.dom.parentNode;r;r=r.parentNode)if(n=i(r))return n.v;return t||document}},{key:"updateRoot",value:function(){this._root=null}},{key:"posAtCoords",value:function(e){return Af(this,e)}},{key:"coordsAtPos",value:function(e){return Rf(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)}},{key:"domAtPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.docView.domFromPos(e,t)}},{key:"nodeDOM",value:function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null}},{key:"posAtDOM",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=this.docView.posFromDOM(e,t,n);if(null==i)throw new RangeError("DOM position not inside the editor");return i}},{key:"endOfTextblock",value:function(e,t){return Wf(this,t||this.state,e)}},{key:"pasteHTML",value:function(e,t){return gv(this,"",e,!1,t||new ClipboardEvent("paste"))}},{key:"pasteText",value:function(e,t){return gv(this,e,null,!0,t||new ClipboardEvent("paste"))}},{key:"serializeForClipboard",value:function(e){return Pp(this,e)}},{key:"destroy",value:function(){this.docView&&(!function(e){for(var t in e.domObserver.stop(),e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],jv(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,qh=null)}},{key:"isDestroyed",get:function(){return null==this.docView}},{key:"dispatchEvent",value:function(e){return function(e,t){ev(e,t)||!Jp[t.type]||!e.editable&&t.type in Gp||Jp[t.type](e,t)}(this,e)}},{key:"domSelectionRange",value:function(){var e=this.domSelection();return e?pf&&11===this.root.nodeType&&function(e){for(var t=e.activeElement;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){var n=t.getComposedRanges(e.root)[0];if(n)return Jv(e,n)}var i;function r(e){e.preventDefault(),e.stopImmediatePropagation(),i=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),i?Jv(e,i):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}},{key:"domSelection",value:function(){return this.root.getSelection()}}])}();function im(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",function(n){if("function"==typeof n&&(n=n(e.state)),n)for(var i in n)"class"==i?t.class+=" "+n[i]:"style"==i?t.style=(t.style?t.style+";":"")+n[i]:t[i]||"contenteditable"==i||"nodeName"==i||(t[i]=String(n[i]))}),t.translate||(t.translate="no"),[_v.node(0,e.state.doc.content.size,t)]}function rm(e){if(e.markCursor){var t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:_v.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function om(e){return!e.someProp("editable",function(t){return!1===t(e.state)})}function am(e){var t=Object.create(null);function n(e){for(var n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function sm(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}nm.prototype.dispatch=function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var cm={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:"'"},lm={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},um="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),dm="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),hm=0;hm<10;hm++)cm[48+hm]=cm[96+hm]=String(hm);for(hm=1;hm<=24;hm++)cm[hm+111]="F"+hm;for(hm=65;hm<=90;hm++)cm[hm]=String.fromCharCode(hm+32),lm[hm]=String.fromCharCode(hm);for(var fm in cm)lm.hasOwnProperty(fm)||(lm[fm]=cm[fm]);var pm="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),vm="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function mm(e){var t,n,i,r,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"==a&&(a=" ");for(var s=0;s<o.length-1;s++){var c=o[s];if(/^(cmd|meta|m)$/i.test(c))r=!0;else if(/^a(lt)?$/i.test(c))t=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))i=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: "+c);pm?r=!0:n=!0}}return t&&(a="Alt-"+a),n&&(a="Ctrl-"+a),r&&(a="Meta-"+a),i&&(a="Shift-"+a),a}function gm(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function ym(e){var t=function(e){var t=Object.create(null);for(var n in e)t[mm(n)]=e[n];return t}(e);return function(e,n){var i,r=function(e){var t=!(um&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||dm&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?lm:cm)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),o=t[gm(r,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){var a=t[gm(r,n,!1)];if(a&&a(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(vm&&n.ctrlKey&&n.altKey)&&(i=cm[n.keyCode])&&i!=r){var s=t[gm(i,n)];if(s&&s(e.state,e.dispatch,e))return!0}}return!1}}var km=Object.defineProperty,wm=function(e,t){for(var n in t)km(e,n,{get:t[n],enumerable:!0})};function bm(e){var t=e.state,n=e.transaction,i=n.selection,r=n.doc,o=n.storedMarks;return d(d({},t),{},{apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return i},get doc(){return r},get tr(){return i=n.selection,r=n.doc,o=n.storedMarks,n}})}var Cm=function(){return x(function e(t){C(this,e),this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state},[{key:"hasCustomState",get:function(){return!!this.customState}},{key:"state",get:function(){return this.customState||this.editor.state}},{key:"commands",get:function(){var e=this,t=this.rawCommands,n=this.editor,i=this.state,r=n.view,o=i.tr,a=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(function(t){var n=g(t,2),i=n[0],s=n[1];return[i,function(){var t=s.apply(void 0,arguments)(a);return o.getMeta("preventDispatch")||e.hasCustomState||r.dispatch(o),t}]}))}},{key:"chain",get:function(){var e=this;return function(){return e.createChain()}}},{key:"can",get:function(){var e=this;return function(){return e.createCan()}}},{key:"createChain",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.rawCommands,r=this.editor,o=this.state,a=r.view,s=[],c=!!e,l=e||o.tr,u=d(d({},Object.fromEntries(Object.entries(i).map(function(e){var i=g(e,2),r=i[0],o=i[1];return[r,function(){var e=t.buildProps(l,n),i=o.apply(void 0,arguments)(e);return s.push(i),u}]}))),{},{run:function(){return c||!n||l.getMeta("preventDispatch")||t.hasCustomState||a.dispatch(l),s.every(function(e){return!0===e})}});return u}},{key:"createCan",value:function(e){var t=this,n=this.rawCommands,i=this.state,r=!1,o=e||i.tr,a=this.buildProps(o,r),s=Object.fromEntries(Object.entries(n).map(function(e){var t=g(e,2),n=t[0],i=t[1];return[n,function(){return i.apply(void 0,arguments)(d(d({},a),{},{dispatch:void 0}))}]}));return d(d({},s),{},{chain:function(){return t.createChain(o,r)}})}},{key:"buildProps",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.rawCommands,r=this.editor,o=this.state,a=r.view,s={tr:e,editor:r,view:a,state:bm({state:o,transaction:e}),dispatch:n?function(){}:void 0,chain:function(){return t.createChain(e,n)},can:function(){return t.createCan(e)},get commands(){return Object.fromEntries(Object.entries(i).map(function(e){var t=g(e,2),n=t[0],i=t[1];return[n,function(){return i.apply(void 0,arguments)(s)}]}))}};return s}}])}(),Sm={};wm(Sm,{blur:function(){return xm},clearContent:function(){return Tm},clearNodes:function(){return Mm},command:function(){return _m},createParagraphNear:function(){return Nm},cut:function(){return Om},deleteCurrentNode:function(){return Em},deleteNode:function(){return Dm},deleteRange:function(){return Im},deleteSelection:function(){return Lm},enter:function(){return Rm},exitCode:function(){return Pm},extendMarkRange:function(){return Wm},first:function(){return $m},focus:function(){return Gm},forEach:function(){return Ym},insertContent:function(){return Xm},insertContentAt:function(){return tg},joinBackward:function(){return rg},joinDown:function(){return ig},joinForward:function(){return og},joinItemBackward:function(){return ag},joinItemForward:function(){return sg},joinTextblockBackward:function(){return cg},joinTextblockForward:function(){return lg},joinUp:function(){return ng},keyboardShortcut:function(){return dg},lift:function(){return fg},liftEmptyBlock:function(){return pg},liftListItem:function(){return vg},newlineInCode:function(){return mg},resetAttributes:function(){return kg},scrollIntoView:function(){return wg},selectAll:function(){return bg},selectNodeBackward:function(){return Cg},selectNodeForward:function(){return Sg},selectParentNode:function(){return xg},selectTextblockEnd:function(){return Tg},selectTextblockStart:function(){return Mg},setContent:function(){return Ng},setMark:function(){return ry},setMeta:function(){return oy},setNode:function(){return ay},setNodeSelection:function(){return sy},setTextDirection:function(){return cy},setTextSelection:function(){return ly},sinkListItem:function(){return uy},splitBlock:function(){return hy},splitListItem:function(){return fy},toggleList:function(){return my},toggleMark:function(){return gy},toggleNode:function(){return yy},toggleWrap:function(){return ky},undoInputRule:function(){return wy},unsetAllMarks:function(){return by},unsetMark:function(){return Cy},unsetTextDirection:function(){return Sy},updateAttributes:function(){return xy},wrapIn:function(){return Ty},wrapInList:function(){return My}});var xm=function(){return function(e){var t=e.editor,n=e.view;return requestAnimationFrame(function(){var e;t.isDestroyed||(n.dom.blur(),null==(e=null==window?void 0:window.getSelection())||e.removeAllRanges())}),!0}},Tm=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return function(t){return t.commands.setContent("",{emitUpdate:e})}},Mm=function(){return function(e){var t=e.state,n=e.tr,i=e.dispatch,r=n.selection.ranges;return!i||(r.forEach(function(e){var i=e.$from,r=e.$to;t.doc.nodesBetween(i.pos,r.pos,function(e,t){if(!e.type.isText){var i=n.doc,r=n.mapping,o=i.resolve(r.map(t)),a=i.resolve(r.map(t+e.nodeSize)),s=o.blockRange(a);if(s){var c=Rd(s);if(e.type.isTextblock){var l=o.parent.contentMatchAt(o.index()).defaultType;n.setNodeMarkup(s.start,l)}(c||0===c)&&n.lift(s,c)}}})}),!0)}},_m=function(e){return function(t){return e(t)}},Nm=function(){return function(e){return function(e,t){var n=e.selection,i=n.$from,r=n.$to;if(n instanceof vh||i.parent.inlineContent||r.parent.inlineContent)return!1;var o=Ph(r.parent.contentMatchAt(r.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){var a=(!i.parentOffset&&r.index()<r.parent.childCount?i:r).pos,s=e.tr.insert(a,o.createAndFill());s.setSelection(dh.create(s.doc,a+1)),t(s.scrollIntoView())}return!0}(e.state,e.dispatch)}},Om=function(e,t){return function(n){var i=n.editor,r=n.tr,o=i.state.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);var a=r.mapping.map(t);return r.insert(a,o.content),r.setSelection(new dh(r.doc.resolve(Math.max(a-1,0)))),!0}},Em=function(){return function(e){var t=e.tr,n=e.dispatch,i=t.selection.$anchor.node();if(i.content.size>0)return!1;for(var r=t.selection.$anchor,o=r.depth;o>0;o-=1){if(r.node(o).type===i.type){if(n){var a=r.before(o),s=r.after(o);t.delete(a,s).scrollIntoView()}return!0}}return!1}};function Am(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error("There is no node type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.nodes[e]}return e}var Dm=function(e){return function(t){for(var n=t.tr,i=t.state,r=t.dispatch,o=Am(e,i.schema),a=n.selection.$anchor,s=a.depth;s>0;s-=1){if(a.node(s).type===o){if(r){var c=a.before(s),l=a.after(s);n.delete(c,l).scrollIntoView()}return!0}}return!1}},Im=function(e){return function(t){var n=t.tr,i=t.dispatch,r=e.from,o=e.to;return i&&n.delete(r,o),!0}},Lm=function(){return function(e){return function(e,t){return!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0)}(e.state,e.dispatch)}},Rm=function(){return function(e){return e.commands.keyboardShortcut("Enter")}},Pm=function(){return function(e){return function(e,t){var n=e.selection,i=n.$head,r=n.$anchor;if(!i.parent.type.spec.code||!i.sameParent(r))return!1;var o=i.node(-1),a=i.indexAfter(-1),s=Ph(o.contentMatchAt(a));if(!s||!o.canReplaceWith(a,a,s))return!1;if(t){var c=i.after(),l=e.tr.replaceWith(c,c,s.createAndFill());l.setSelection(sh.near(l.doc.resolve(c),1)),t(l.scrollIntoView())}return!0}(e.state,e.dispatch)}};function zm(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function Bm(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{strict:!0},i=Object.keys(t);return!i.length||i.every(function(i){return n.strict?t[i]===e[i]:zm(t[i])?t[i].test(e[i]):t[i]===e[i]})}function Hm(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.find(function(e){return e.type===t&&Bm(Object.fromEntries(Object.keys(n).map(function(t){return[t,e.attrs[t]]})),n)})}function Fm(e,t){return!!Hm(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function jm(e,t,n){var i;if(e&&t){var r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(function(e){return e.type===t})||(r=e.parent.childBefore(e.parentOffset)),r.node&&r.node.marks.some(function(e){return e.type===t}))if(n=n||(null==(i=r.node.marks[0])?void 0:i.attrs),Hm(c(r.node.marks),t,n)){for(var o=r.index,a=e.start()+r.offset,s=o+1,l=a+r.node.nodeSize;o>0&&Fm(c(e.parent.child(o-1).marks),t,n);)o-=1,a-=e.parent.child(o).nodeSize;for(;s<e.parent.childCount&&Fm(c(e.parent.child(s).marks),t,n);)l+=e.parent.child(s).nodeSize,s+=1;return{from:a,to:l}}}}function Vm(e,t){if("string"==typeof e){if(!t.marks[e])throw Error("There is no mark type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.marks[e]}return e}var Wm=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.tr,r=n.state,o=n.dispatch,a=Vm(e,r.schema),s=i.doc,c=i.selection,l=c.$from,u=c.from,d=c.to;if(o){var h=jm(l,a,t);if(h&&h.from<=u&&h.to>=d){var f=dh.create(s,h.from,h.to);i.setSelection(f)}}return!0}},$m=function(e){return function(t){for(var n="function"==typeof e?e(t):e,i=0;i<n.length;i+=1)if(n[i](t))return!0;return!1}};function Um(e){return e instanceof dh}function qm(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Math.min(Math.max(e,t),n)}function Km(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t)return null;var n=sh.atStart(e),i=sh.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return i;var r=n.from,o=i.to;return"all"===t?dh.create(e,qm(0,r,o),qm(e.content.size,r,o)):dh.create(e,qm(t,r,o),qm(t,r,o))}function Jm(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Gm=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.editor,r=n.view,o=n.tr,a=n.dispatch;t=d({scrollIntoView:!0},t);var s=function(){(Jm()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&r.dom.focus(),requestAnimationFrame(function(){i.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&i.commands.scrollIntoView())})};if(r.hasFocus()&&null===e||!1===e)return!0;if(a&&null===e&&!Um(i.state.selection))return s(),!0;var c=Km(o.doc,e)||i.state.selection,l=i.state.selection.eq(c);return a&&(l||o.setSelection(c),l&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0}},Ym=function(e,t){return function(n){return e.every(function(e,i){return t(e,d(d({},n),{},{index:i}))})}},Xm=function(e,t){return function(n){var i=n.tr;return n.commands.insertContentAt({from:i.selection.from,to:i.selection.to},e,t)}},Qm=function(e){for(var t=e.childNodes,n=t.length-1;n>=0;n-=1){var i=t[n];3===i.nodeType&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)?e.removeChild(i):1===i.nodeType&&Qm(i)}return e};function Zm(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");var t="<body>".concat(e,"</body>"),n=(new window.DOMParser).parseFromString(t,"text/html").body;return Qm(n)}function eg(e,t,n){if(e instanceof Du||e instanceof cu)return e;n=d({slice:!0,parseOptions:{}},n);var i="string"==typeof e;if("object"===_(e)&&null!==e)try{if(Array.isArray(e)&&e.length>0)return cu.fromArray(e.map(function(e){return t.nodeFromJSON(e)}));var r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(l){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:l});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",l),eg("",t,n)}if(i){if(n.errorOnInvalidContent){var o=!1,a="",s=new Qu({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:function(e){return o=!0,a="string"==typeof e?e:e.outerHTML,null}}]}})});if(n.slice?ed.fromSchema(s).parseSlice(Zm(e),n.parseOptions):ed.fromSchema(s).parse(Zm(e),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error("Invalid element found: ".concat(a))})}var c=ed.fromSchema(t);return n.slice?c.parseSlice(Zm(e),n.parseOptions).content:c.parse(Zm(e),n.parseOptions)}return eg("",t,n)}var tg=function(e,t,n){return function(i){var r,o=i.tr,a=i.dispatch,s=i.editor;if(a){var c;n=d({parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1},n);var l=function(e){s.emit("contentError",{editor:s,error:e,disableCollaboration:function(){"collaboration"in s.storage&&"object"===_(s.storage.collaboration)&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},u=d({preserveWhitespace:"full"},n.parseOptions);if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{eg(t,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(vs){l(vs)}try{c=eg(t,s.schema,{parseOptions:u,errorOnInvalidContent:null!=(r=n.errorOnInvalidContent)?r:s.options.enableContentCheck})}catch(vs){return l(vs),!1}var h,f="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},p=f.from,v=f.to,m=!0,g=!0;if(("type"in c?[c]:c).forEach(function(e){e.check(),m=!!m&&(e.isText&&0===e.marks.length),g=!!g&&e.isBlock}),p===v&&g){var y=o.doc.resolve(p).parent;y.isTextblock&&!y.type.spec.code&&!y.childCount&&(p-=1,v+=1)}if(m){if(Array.isArray(t))h=t.map(function(e){return e.text||""}).join("");else if(t instanceof cu){var k="";t.forEach(function(e){e.text&&(k+=e.text)}),h=k}else h="object"===_(t)&&t&&t.text?t.text:t;o.insertText(h,p,v)}else{h=c;var w=o.doc.resolve(p),b=w.node(),C=0===w.parentOffset,S=b.isText||b.isTextblock,x=b.content.size>0;C&&S&&x&&(p=Math.max(0,p-1)),o.replaceWith(p,v,h)}n.updateSelection&&function(e,t,n){var i=e.steps.length-1;if(!(i<t)){var r=e.steps[i];if(r instanceof Ed||r instanceof Ad){var o=e.mapping.maps[i],a=0;o.forEach(function(e,t,n,i){0===a&&(a=i)}),e.setSelection(sh.near(e.doc.resolve(a),n))}}}(o,o.steps.length-1,-1),n.applyInputRules&&o.setMeta("applyInputRules",{from:p,text:h}),n.applyPasteRules&&o.setMeta("applyPasteRules",{from:p,text:h})}return!0}},ng=function(){return function(e){return function(e,t){var n,i=e.selection,r=i instanceof fh;if(r){if(i.node.isTextblock||!jd(e.doc,i.from))return!1;n=i.from}else if(null==(n=Wd(e.doc,i.from,-1)))return!1;if(t){var o=e.tr.join(n);r&&o.setSelection(fh.create(o.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0}(e.state,e.dispatch)}},ig=function(){return function(e){return function(e,t){var n,i=e.selection;if(i instanceof fh){if(i.node.isTextblock||!jd(e.doc,i.to))return!1;n=i.to}else if(null==(n=Wd(e.doc,i.to,1)))return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0}(e.state,e.dispatch)}},rg=function(){return function(e){return function(e,t,n){var i=Eh(e,n);if(!i)return!1;var r=Ih(i);if(!r){var o=i.blockRange(),a=o&&Rd(o);return null!=a&&(t&&t(e.tr.lift(o,a).scrollIntoView()),!0)}var s=r.nodeBefore;if(zh(e,r,t,-1))return!0;if(0==i.parent.content.size&&(Dh(s,"end")||fh.isSelectable(s)))for(var c=i.depth;;c--){var l=Ud(e.doc,i.before(c),i.after(c),pu.empty);if(l&&l.slice.size<l.to-l.from){if(t){var u=e.tr.step(l);u.setSelection(Dh(s,"end")?sh.findFrom(u.doc.resolve(u.mapping.map(r.pos,-1)),-1):fh.create(u.doc,r.pos-s.nodeSize)),t(u.scrollIntoView())}return!0}if(1==c||i.node(c-1).childCount>1)break}return!(!s.isAtom||r.depth!=i.depth-1||(t&&t(e.tr.delete(r.pos-s.nodeSize,r.pos).scrollIntoView()),0))}(e.state,e.dispatch)}},og=function(){return function(e){return function(e,t,n){var i=Lh(e,n);if(!i)return!1;var r=Rh(i);if(!r)return!1;var o=r.nodeAfter;if(zh(e,r,t,1))return!0;if(0==i.parent.content.size&&(Dh(o,"start")||fh.isSelectable(o))){var a=Ud(e.doc,i.before(),i.after(),pu.empty);if(a&&a.slice.size<a.to-a.from){if(t){var s=e.tr.step(a);s.setSelection(Dh(o,"start")?sh.findFrom(s.doc.resolve(s.mapping.map(r.pos)),1):fh.create(s.doc,s.mapping.map(r.pos))),t(s.scrollIntoView())}return!0}}return!(!o.isAtom||r.depth!=i.depth-1||(t&&t(e.tr.delete(r.pos,r.pos+o.nodeSize).scrollIntoView()),0))}(e.state,e.dispatch)}},ag=function(){return function(e){var t=e.state,n=e.dispatch,i=e.tr;try{var r=Wd(t.doc,t.selection.$from.pos,-1);return null!=r&&(i.join(r,2),n&&n(i),!0)}catch(o){return!1}}},sg=function(){return function(e){var t=e.state,n=e.dispatch,i=e.tr;try{var r=Wd(t.doc,t.selection.$from.pos,1);return null!=r&&(i.join(r,2),n&&n(i),!0)}catch(o){return!1}}},cg=function(){return function(e){return function(e,t,n){var i=Eh(e,n);if(!i)return!1;var r=Ih(i);return!!r&&Ah(e,r,t)}(e.state,e.dispatch)}},lg=function(){return function(e){return function(e,t,n){var i=Lh(e,n);if(!i)return!1;var r=Rh(i);return!!r&&Ah(e,r,t)}(e.state,e.dispatch)}};function ug(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var dg=function(e){return function(t){var n=t.editor,i=t.view,r=t.tr,o=t.dispatch,a=function(e){var t,n,i,r,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"===a&&(a=" ");for(var s=0;s<o.length-1;s+=1){var c=o[s];if(/^(cmd|meta|m)$/i.test(c))r=!0;else if(/^a(lt)?$/i.test(c))t=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))i=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: ".concat(c));Jm()||ug()?r=!0:n=!0}}return t&&(a="Alt-".concat(a)),n&&(a="Ctrl-".concat(a)),r&&(a="Meta-".concat(a)),i&&(a="Shift-".concat(a)),a}(e).split(/-(?!$)/),s=a.find(function(e){return!["Alt","Ctrl","Meta","Shift"].includes(e)}),c=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),l=n.captureTransaction(function(){i.someProp("handleKeyDown",function(e){return e(i,c)})});return null==l||l.steps.forEach(function(e){var t=e.map(r.mapping);t&&o&&r.maybeStep(t)}),!0}};function hg(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=e.selection,r=i.from,o=i.to,a=i.empty,s=t?Am(t,e.schema):null,c=[];e.doc.nodesBetween(r,o,function(e,t){if(!e.isText){var n=Math.max(r,t),i=Math.min(o,t+e.nodeSize);c.push({node:e,from:n,to:i})}});var l=o-r,u=c.filter(function(e){return!s||s.name===e.node.type.name}).filter(function(e){return Bm(e.node.attrs,n,{strict:!1})});return a?!!u.length:u.reduce(function(e,t){return e+t.to-t.from},0)>=l}var fg=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.state,r=n.dispatch;return!!hg(i,Am(e,i.schema),t)&&function(e,t){var n=e.selection,i=n.$from,r=n.$to,o=i.blockRange(r),a=o&&Rd(o);return null!=a&&(t&&t(e.tr.lift(o,a).scrollIntoView()),!0)}(i,r)}},pg=function(){return function(e){return function(e,t){var n=e.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var i=n.before();if(Fd(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}var r=n.blockRange(),o=r&&Rd(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)}(e.state,e.dispatch)}},vg=function(e){return function(t){var n=t.state,i=t.dispatch;return Wh(Am(e,n.schema))(n,i)}},mg=function(){return function(e){return function(e,t){var n=e.selection,i=n.$head,r=n.$anchor;return!(!i.parent.type.spec.code||!i.sameParent(r)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))}(e.state,e.dispatch)}};function gg(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function yg(e,t){var n="string"==typeof t?[t]:t;return Object.keys(e).reduce(function(t,i){return n.includes(i)||(t[i]=e[i]),t},{})}var kg=function(e,t){return function(n){var i=n.tr,r=n.state,o=n.dispatch,a=null,s=null,c=gg("string"==typeof e?e:e.name,r.schema);if(!c)return!1;"node"===c&&(a=Am(e,r.schema)),"mark"===c&&(s=Vm(e,r.schema));var l=!1;return i.selection.ranges.forEach(function(e){r.doc.nodesBetween(e.$from.pos,e.$to.pos,function(e,n){a&&a===e.type&&(l=!0,o&&i.setNodeMarkup(n,void 0,yg(e.attrs,t))),s&&e.marks.length&&e.marks.forEach(function(r){s===r.type&&(l=!0,o&&i.addMark(n,n+e.nodeSize,s.create(yg(r.attrs,t))))})})}),l}},wg=function(){return function(e){var t=e.tr;return e.dispatch&&t.scrollIntoView(),!0}},bg=function(){return function(e){var t=e.tr;if(e.dispatch){var n=new vh(t.doc);t.setSelection(n)}return!0}},Cg=function(){return function(e){return function(e,t,n){var i=e.selection,r=i.$head,o=r;if(!i.empty)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=Ih(r)}var a=o&&o.nodeBefore;return!(!a||!fh.isSelectable(a)||(t&&t(e.tr.setSelection(fh.create(e.doc,o.pos-a.nodeSize)).scrollIntoView()),0))}(e.state,e.dispatch)}},Sg=function(){return function(e){return function(e,t,n){var i=e.selection,r=i.$head,o=r;if(!i.empty)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=Rh(r)}var a=o&&o.nodeAfter;return!(!a||!fh.isSelectable(a)||(t&&t(e.tr.setSelection(fh.create(e.doc,o.pos)).scrollIntoView()),0))}(e.state,e.dispatch)}},xg=function(){return function(e){return function(e,t){var n,i=e.selection,r=i.$from,o=i.to,a=r.sharedDepth(o);return 0!=a&&(n=r.before(a),t&&t(e.tr.setSelection(fh.create(e.doc,n))),!0)}(e.state,e.dispatch)}},Tg=function(){return function(e){var t=e.state,n=e.dispatch;return Fh(t,n)}},Mg=function(){return function(e){var t=e.state,n=e.dispatch;return Hh(t,n)}};function _g(e,t){return eg(e,t,{slice:!1,parseOptions:arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},errorOnInvalidContent:(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).errorOnInvalidContent})}var Ng=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errorOnInvalidContent,i=t.emitUpdate,r=void 0===i||i,o=t.parseOptions,a=void 0===o?{}:o;return function(t){var i=t.editor,o=t.tr,s=t.dispatch,c=t.commands,l=o.doc;if("full"!==a.preserveWhitespace){var u=_g(e,i.schema,a,{errorOnInvalidContent:null!=n?n:i.options.enableContentCheck});return s&&o.replaceWith(0,l.content.size,u).setMeta("preventUpdate",!r),!0}return s&&o.setMeta("preventUpdate",!r),c.insertContentAt({from:0,to:l.content.size},e,{parseOptions:a,errorOnInvalidContent:null!=n?n:i.options.enableContentCheck})}};function Og(e,t){var n=Vm(t,e.schema),i=e.selection,r=i.from,o=i.to,a=i.empty,s=[];a?(e.storedMarks&&s.push.apply(s,c(e.storedMarks)),s.push.apply(s,c(e.selection.$head.marks()))):e.doc.nodesBetween(r,o,function(e){s.push.apply(s,c(e.marks))});var l=s.find(function(e){return e.type.name===n.name});return l?d({},l.attrs):{}}function Eg(e){return function(t){return function(e,t){for(var n=e.depth;n>0;n-=1){var i=e.node(n);if(t(i))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:i}}}(t.$from,e)}}function Ag(e,t,n){return void 0===e.config[t]&&e.parent?Ag(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind(d(d({},n),{},{parent:e.parent?Ag(e.parent,t,n):null})):e.config[t]}function Dg(e){return e.map(function(e){var t=Ag(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e].concat(c(Dg(t()))):e}).flat(10)}function Ig(e,t){var n=ud.fromSchema(t).serializeFragment(e),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Lg(e){return"function"==typeof e}function Rg(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;if(Lg(e)){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return t?e.bind(t).apply(void 0,i):e.apply(void 0,i)}return e}function Pg(e){return{baseExtensions:e.filter(function(e){return"extension"===e.type}),nodeExtensions:e.filter(function(e){return"node"===e.type}),markExtensions:e.filter(function(e){return"mark"===e.type})}}function zg(e){var t=[],n=Pg(e),i=n.nodeExtensions,r=n.markExtensions,o=[].concat(c(i),c(r)),a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(function(e){var n=Ag(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage,extensions:o});n&&n().forEach(function(e){e.types.forEach(function(n){Object.entries(e.attributes).forEach(function(e){var i=g(e,2),r=i[0],o=i[1];t.push({type:n,name:r,attribute:d(d({},a),o)})})})})}),o.forEach(function(e){var n={name:e.name,options:e.options,storage:e.storage},i=Ag(e,"addAttributes",n);if(i){var r=i();Object.entries(r).forEach(function(n){var i=g(n,2),r=i[0],o=i[1],s=d(d({},a),o);"function"==typeof(null==s?void 0:s.default)&&(s.default=s.default()),(null==s?void 0:s.isRequired)&&void 0===(null==s?void 0:s.default)&&delete s.default,t.push({type:e.name,name:r,attribute:s})})}}),t}function Bg(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter(function(e){return!!e}).reduce(function(e,t){var n=d({},e);return Object.entries(t).forEach(function(e){var t=g(e,2),i=t[0],r=t[1];if(n[i])if("class"===i){var o=r?String(r).split(" "):[],a=n[i]?n[i].split(" "):[],s=o.filter(function(e){return!a.includes(e)});n[i]=[].concat(c(a),c(s)).join(" ")}else if("style"===i){var l=r?r.split(";").map(function(e){return e.trim()}).filter(Boolean):[],u=n[i]?n[i].split(";").map(function(e){return e.trim()}).filter(Boolean):[],d=new Map;u.forEach(function(e){var t=g(e.split(":").map(function(e){return e.trim()}),2),n=t[0],i=t[1];d.set(n,i)}),l.forEach(function(e){var t=g(e.split(":").map(function(e){return e.trim()}),2),n=t[0],i=t[1];d.set(n,i)}),n[i]=Array.from(d.entries()).map(function(e){var t=g(e,2),n=t[0],i=t[1];return"".concat(n,": ").concat(i)}).join("; ")}else n[i]=r;else n[i]=r}),n},{})}function Hg(e,t){return t.filter(function(t){return t.type===e.type.name}).filter(function(e){return e.attribute.rendered}).map(function(t){return t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:T({},t.name,e.attrs[t.name])}).reduce(function(e,t){return Bg(e,t)},{})}function Fg(e,t){return"style"in e?e:d(d({},e),{},{getAttrs:function(n){var i=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===i)return!1;var r=t.reduce(function(e,t){var i=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==i?e:d(d({},e),{},T({},t.name,i))},{});return d(d({},i),r)}})}function jg(e){return Object.fromEntries(Object.entries(e).filter(function(e){var t=g(e,2),n=t[0],i=t[1];return("attrs"!==n||!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 0===Object.keys(e).length&&e.constructor===Object}(i))&&null!=i}))}function Vg(e){var t,n,i={};return!(null==(t=null==e?void 0:e.attribute)?void 0:t.isRequired)&&"default"in((null==e?void 0:e.attribute)||{})&&(i.default=e.attribute.default),void 0!==(null==(n=null==e?void 0:e.attribute)?void 0:n.validate)&&(i.validate=e.attribute.validate),[e.name,i]}function Wg(e){return e.sort(function(e,t){var n=Ag(e,"priority")||100,i=Ag(t,"priority")||100;return n>i?-1:n<i?1:0})}function $g(e){var t,n,i=Wg(Dg(e)),r=(t=i.map(function(e){return e.name}),n=t.filter(function(e,n){return t.indexOf(e)!==n}),Array.from(new Set(n)));return r.length&&console.warn("[tiptap warn]: Duplicate extension names found: [".concat(r.map(function(e){return"'".concat(e,"'")}).join(", "),"]. This can lead to issues.")),i}function Ug(e,t,n){var i=t.from,r=t.to,o=n||{},a=o.blockSeparator,s=void 0===a?"\n\n":a,c=o.textSerializers,l=void 0===c?{}:c,u="";return e.nodesBetween(i,r,function(e,n,o,a){var c;e.isBlock&&n>i&&(u+=s);var d=null==l?void 0:l[e.type.name];if(d)return o&&(u+=d({node:e,pos:n,parent:o,index:a,range:t})),!1;e.isText&&(u+=null==(c=null==e?void 0:e.text)?void 0:c.slice(Math.max(i,n)-n,r-n))}),u}function qg(e){return Object.fromEntries(Object.entries(e.nodes).filter(function(e){return g(e,2)[1].spec.toText}).map(function(e){var t=g(e,2);return[t[0],t[1].spec.toText]}))}function Kg(e,t){var n=gg("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){var n=Am(t,e.schema),i=e.selection,r=i.from,o=i.to,a=[];e.doc.nodesBetween(r,o,function(e){a.push(e)});var s=a.reverse().find(function(e){return e.type.name===n.name});return s?d({},s.attrs):{}}(e,t):"mark"===n?Og(e,t):{}}function Jg(e){var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:JSON.stringify,n={};return e.filter(function(e){var i=t(e);return!Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=!0)})}(e);return 1===t.length?t:t.filter(function(e,n){var i=t.filter(function(e,t){return t!==n});return!i.some(function(t){return e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to})})}function Gg(e,t){return t.nodes[e]||t.marks[e]||null}function Yg(e,t,n){return Object.fromEntries(Object.entries(n).filter(function(n){var i=g(n,1)[0],r=e.find(function(e){return e.type===t&&e.name===i});return!!r&&r.attribute.keepOnSplit}))}function Xg(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=e.selection,r=i.empty,o=i.ranges,a=t?Vm(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(function(e){return!a||a.name===e.type.name}).find(function(e){return Bm(e.attrs,n,{strict:!1})});var s=0,l=[];if(o.forEach(function(t){var n=t.$from,i=t.$to,r=n.pos,o=i.pos;e.doc.nodesBetween(r,o,function(e,t){if(e.isText||e.marks.length){var n=Math.max(r,t),i=Math.min(o,t+e.nodeSize);s+=i-n,l.push.apply(l,c(e.marks.map(function(e){return{mark:e,from:n,to:i}})))}})}),0===s)return!1;var u=l.filter(function(e){return!a||a.name===e.mark.type.name}).filter(function(e){return Bm(e.mark.attrs,n,{strict:!1})}).reduce(function(e,t){return e+t.to-t.from},0),d=l.filter(function(e){return!a||e.mark.type!==a&&e.mark.type.excludes(a)}).reduce(function(e,t){return e+t.to-t.from},0);return(u>0?u+d:u)>=s}function Qg(e,t){return Array.isArray(t)?t.some(function(t){return("string"==typeof t?t:t.name)===e.name}):t}function Zg(e,t){var n=Pg(t).nodeExtensions.find(function(t){return t.name===e});if(!n)return!1;var i=Rg(Ag(n,"group",{name:n.name,options:n.options,storage:n.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function ey(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.checkChildren,r=void 0===i||i,o=n.ignoreWhitespace,a=void 0!==o&&o;if(a){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!=(t=e.text)?t:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(r){var s=!0;return e.content.forEach(function(e){!1!==s&&(ey(e,{ignoreWhitespace:a,checkChildren:r})||(s=!1))}),s}return!1}var ty=function(){function e(t){C(this,e),this.position=t}return x(e,[{key:"toJSON",value:function(){return{position:this.position}}}],[{key:"fromJSON",value:function(t){return new e(t.position)}}])}();function ny(e,t){var n=t.mapping.mapResult(e.position);return{position:new ty(n.pos),mapResult:n}}function iy(e){return new ty(e)}var ry=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.tr,r=n.state,o=n.dispatch,a=i.selection,s=a.empty,c=a.ranges,l=Vm(e,r.schema);if(o)if(s){var u=Og(r,l);i.addStoredMark(l.create(d(d({},u),t)))}else c.forEach(function(e){var n=e.$from.pos,o=e.$to.pos;r.doc.nodesBetween(n,o,function(e,r){var a=Math.max(r,n),s=Math.min(r+e.nodeSize,o);e.marks.find(function(e){return e.type===l})?e.marks.forEach(function(e){l===e.type&&i.addMark(a,s,l.create(d(d({},e.attrs),t)))}):i.addMark(a,s,l.create(t))})});return function(e,t,n){var i,r=t.selection,o=null;if(Um(r)&&(o=r.$cursor),o){var a=null!=(i=e.storedMarks)?i:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(function(e){return e.type.excludes(n)}))}return r.ranges.some(function(t){var i=t.$from,r=t.$to,o=0===i.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(i.pos,r.pos,function(e,t,i){if(o)return!1;if(e.isInline){var r=!i||i.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(function(e){return e.type.excludes(n)});o=r&&a}return!o}),o})}(r,i,l)}},oy=function(e,t){return function(n){return n.tr.setMeta(e,t),!0}},ay=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i,r=n.state,o=n.dispatch,a=n.chain,s=Am(e,r.schema);return r.selection.$anchor.sameParent(r.selection.$head)&&(i=r.selection.$anchor.parent.attrs),s.isTextblock?a().command(function(e){var n=e.commands;return!!jh(s,d(d({},i),t))(r)||n.clearNodes()}).command(function(e){var n=e.state;return jh(s,d(d({},i),t))(n,o)}).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)}},sy=function(e){return function(t){var n=t.tr;if(t.dispatch){var i=n.doc,r=qm(e,0,i.content.size),o=fh.create(i,r);n.setSelection(o)}return!0}},cy=function(e,t){return function(n){var i,r,o=n.tr,a=n.state,s=n.dispatch,c=a.selection;return"number"==typeof t?(i=t,r=t):t&&"from"in t&&"to"in t?(i=t.from,r=t.to):(i=c.from,r=c.to),s&&o.doc.nodesBetween(i,r,function(t,n){t.isText||o.setNodeMarkup(n,void 0,d(d({},t.attrs),{},{dir:e}))}),!0}},ly=function(e){return function(t){var n=t.tr;if(t.dispatch){var i=n.doc,r="number"==typeof e?{from:e,to:e}:e,o=r.from,a=r.to,s=dh.atStart(i).from,c=dh.atEnd(i).to,l=qm(o,s,c),u=qm(a,s,c),d=dh.create(i,l,u);n.setSelection(d)}return!0}},uy=function(e){return function(t){var n,i=t.state,r=t.dispatch,o=Am(e,i.schema);return(n=o,function(e,t){var i=e.selection,r=i.$from,o=i.$to,a=r.blockRange(o,function(e){return e.childCount>0&&e.firstChild.type==n});if(!a)return!1;var s=a.startIndex;if(0==s)return!1;var c=a.parent,l=c.child(s-1);if(l.type!=n)return!1;if(t){var u=l.lastChild&&l.lastChild.type==c.type,d=cu.from(u?n.create():null),h=new pu(cu.from(n.create(null,cu.from(c.type.create(null,d)))),u?3:1,0),f=a.start,p=a.end;t(e.tr.step(new Ad(f-(u?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0})(i,r)}};function dy(e,t){var n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){var i=n.filter(function(e){return null==t?void 0:t.includes(e.type.name)});e.tr.ensureMarks(i)}}var hy=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).keepMarks,t=void 0===e||e;return function(e){var n=e.tr,i=e.state,r=e.dispatch,o=e.editor,a=n.selection,s=n.doc,c=a.$from,l=a.$to,u=Yg(o.extensionManager.attributes,c.node().type.name,c.node().attrs);if(a instanceof fh&&a.node.isBlock)return!(!c.parentOffset||!Fd(s,c.pos))&&(r&&(t&&dy(i,o.extensionManager.splittableMarks),n.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;var d=l.parentOffset===l.parent.content.size,h=0===c.depth?void 0:function(e){for(var t=0;t<e.edgeCount;t+=1){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(c.node(-1).contentMatchAt(c.indexAfter(-1))),f=d&&h?[{type:h,attrs:u}]:void 0,p=Fd(n.doc,n.mapping.map(c.pos),1,f);if(f||p||!Fd(n.doc,n.mapping.map(c.pos),1,h?[{type:h}]:void 0)||(p=!0,f=h?[{type:h,attrs:u}]:void 0),r){if(p&&(a instanceof dh&&n.deleteSelection(),n.split(n.mapping.map(c.pos),1,f),h&&!d&&!c.parentOffset&&c.parent.type!==h)){var v=n.mapping.map(c.before()),m=n.doc.resolve(v);c.node(-1).canReplaceWith(m.index(),m.index()+1,h)&&n.setNodeMarkup(n.mapping.map(c.before()),h)}t&&dy(i,o.extensionManager.splittableMarks),n.scrollIntoView()}return p}},fy=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i,r=n.tr,o=n.state,a=n.dispatch,s=n.editor,c=Am(e,o.schema),l=o.selection,u=l.$from,h=l.$to,f=o.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(h))return!1;var p=u.node(-1);if(p.type!==c)return!1;var v=s.extensionManager.attributes;if(0===u.parent.content.size&&u.node(-1).childCount===u.indexAfter(-1)){if(2===u.depth||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(a){for(var m=cu.empty,g=u.index(-1)?1:u.index(-2)?2:3,y=u.depth-g;y>=u.depth-3;y-=1)m=cu.from(u.node(y).copy(m));var k=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,w=d(d({},Yg(v,u.node().type.name,u.node().attrs)),t),b=(null==(i=c.contentMatch.defaultType)?void 0:i.createAndFill(w))||void 0;m=m.append(cu.from(c.createAndFill(null,b)||void 0));var C=u.before(u.depth-(g-1));r.replace(C,u.after(-k),new pu(m,4-g,0));var S=-1;r.doc.nodesBetween(C,r.doc.content.size,function(e,t){if(S>-1)return!1;e.isTextblock&&0===e.content.size&&(S=t+1)}),S>-1&&r.setSelection(dh.near(r.doc.resolve(S))),r.scrollIntoView()}return!0}var x=h.pos===u.end()?p.contentMatchAt(0).defaultType:null,T=d(d({},Yg(v,p.type.name,p.attrs)),t),M=d(d({},Yg(v,u.node().type.name,u.node().attrs)),t);r.delete(u.pos,h.pos);var _=x?[{type:c,attrs:T},{type:x,attrs:M}]:[{type:c,attrs:T}];if(!Fd(r.doc,u.pos,2))return!1;if(a){var N=o.selection,O=o.storedMarks,E=s.extensionManager.splittableMarks,A=O||N.$to.parentOffset&&N.$from.marks();if(r.split(u.pos,2,_).scrollIntoView(),!A||!a)return!0;var D=A.filter(function(e){return E.includes(e.type.name)});r.ensureMarks(D)}return!0}},py=function(e,t){var n=Eg(function(e){return e.type===t})(e.selection);if(!n)return!0;var i=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===i)return!0;var r=e.doc.nodeAt(i);return n.node.type!==(null==r?void 0:r.type)||!jd(e.doc,n.pos)||(e.join(n.pos),!0)},vy=function(e,t){var n=Eg(function(e){return e.type===t})(e.selection);if(!n)return!0;var i=e.doc.resolve(n.start).after(n.depth);if(void 0===i)return!0;var r=e.doc.nodeAt(i);return n.node.type!==(null==r?void 0:r.type)||!jd(e.doc,i)||(e.join(i),!0)},my=function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return function(r){var o=r.editor,a=r.tr,s=r.state,c=r.dispatch,l=r.chain,u=r.commands,d=r.can,h=o.extensionManager,f=h.extensions,p=h.splittableMarks,v=Am(e,s.schema),m=Am(t,s.schema),g=s.selection,y=s.storedMarks,k=g.$from,w=g.$to,b=k.blockRange(w),C=y||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;var S=Eg(function(e){return Zg(e.type.name,f)})(g);if(b.depth>=1&&S&&b.depth-S.depth<=1){if(S.node.type===v)return u.liftListItem(m);if(Zg(S.node.type.name,f)&&v.validContent(S.node.content)&&c)return l().command(function(){return a.setNodeMarkup(S.pos,v),!0}).command(function(){return py(a,v)}).command(function(){return vy(a,v)}).run()}return n&&C&&c?l().command(function(){var e=d().wrapInList(v,i),t=C.filter(function(e){return p.includes(e.type.name)});return a.ensureMarks(t),!!e||u.clearNodes()}).wrapInList(v,i).command(function(){return py(a,v)}).command(function(){return vy(a,v)}).run():l().command(function(){return!!d().wrapInList(v,i)||u.clearNodes()}).wrapInList(v,i).command(function(){return py(a,v)}).command(function(){return vy(a,v)}).run()}},gy=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(i){var r=i.state,o=i.commands,a=n.extendEmptyMarkRange,s=void 0!==a&&a,c=Vm(e,r.schema);return Xg(r,c,t)?o.unsetMark(c,{extendEmptyMarkRange:s}):o.setMark(c,t)}},yy=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(i){var r,o=i.state,a=i.commands,s=Am(e,o.schema),c=Am(t,o.schema),l=hg(o,s,n);return o.selection.$anchor.sameParent(o.selection.$head)&&(r=o.selection.$anchor.parent.attrs),l?a.setNode(c,r):a.setNode(s,d(d({},r),n))}},ky=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.state,r=n.commands,o=Am(e,i.schema);return hg(i,o,t)?r.lift(o):r.wrapIn(o,t)}},wy=function(){return function(e){for(var t=e.state,n=e.dispatch,i=t.plugins,r=0;r<i.length;r+=1){var o=i[r],a=void 0;if(o.spec.isInputRules&&(a=o.getState(t))){if(n){for(var s=t.tr,c=a.transform,l=c.steps.length-1;l>=0;l-=1)s.step(c.steps[l].invert(c.docs[l]));if(a.text){var u=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,u))}else s.delete(a.from,a.to)}return!0}}return!1}},by=function(){return function(e){var t=e.tr,n=e.dispatch,i=t.selection,r=i.empty,o=i.ranges;return r||n&&o.forEach(function(e){t.removeMark(e.$from.pos,e.$to.pos)}),!0}},Cy=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i,r=n.tr,o=n.state,a=n.dispatch,s=t.extendEmptyMarkRange,c=void 0!==s&&s,l=r.selection,u=Vm(e,o.schema),d=l.$from,h=l.empty,f=l.ranges;if(!a)return!0;if(h&&c){var p=l.from,v=l.to,m=null==(i=d.marks().find(function(e){return e.type===u}))?void 0:i.attrs,g=jm(d,u,m);g&&(p=g.from,v=g.to),r.removeMark(p,v,u)}else f.forEach(function(e){r.removeMark(e.$from.pos,e.$to.pos,u)});return r.removeStoredMark(u),!0}},Sy=function(e){return function(t){var n,i,r=t.tr,o=t.state,a=t.dispatch,s=o.selection;return"number"==typeof e?(n=e,i=e):e&&"from"in e&&"to"in e?(n=e.from,i=e.to):(n=s.from,i=s.to),a&&r.doc.nodesBetween(n,i,function(e,t){if(!e.isText){var n=d({},e.attrs);delete n.dir,r.setNodeMarkup(t,void 0,n)}}),!0}},xy=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.tr,r=n.state,o=n.dispatch,a=null,s=null,c=gg("string"==typeof e?e:e.name,r.schema);if(!c)return!1;"node"===c&&(a=Am(e,r.schema)),"mark"===c&&(s=Vm(e,r.schema));var l=!1;return i.selection.ranges.forEach(function(e){var n,c,u,h,f=e.$from.pos,p=e.$to.pos;i.selection.empty?r.doc.nodesBetween(f,p,function(e,t){a&&a===e.type&&(l=!0,u=Math.max(t,f),h=Math.min(t+e.nodeSize,p),n=t,c=e)}):r.doc.nodesBetween(f,p,function(e,r){r<f&&a&&a===e.type&&(l=!0,u=Math.max(r,f),h=Math.min(r+e.nodeSize,p),n=r,c=e),r>=f&&r<=p&&(a&&a===e.type&&(l=!0,o&&i.setNodeMarkup(r,void 0,d(d({},e.attrs),t))),s&&e.marks.length&&e.marks.forEach(function(n){if(s===n.type&&(l=!0,o)){var a=Math.max(r,f),c=Math.min(r+e.nodeSize,p);i.addMark(a,c,s.create(d(d({},n.attrs),t)))}}))}),c&&(void 0!==n&&o&&i.setNodeMarkup(n,void 0,d(d({},c.attrs),t)),s&&c.marks.length&&c.marks.forEach(function(e){s===e.type&&o&&i.addMark(u,h,s.create(d(d({},e.attrs),t)))}))}),l}},Ty=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.state,r=n.dispatch;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,i){var r=n.selection,o=r.$from,a=r.$to,s=o.blockRange(a),c=s&&Pd(s,e,t);return!!c&&(i&&i(n.tr.wrap(s,c).scrollIntoView()),!0)}}(Am(e,i.schema),t)(i,r)}},My=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=n.state,r=n.dispatch;return Vh(Am(e,i.schema),t)(i,r)}},_y=function(){return x(function e(){C(this,e),this.callbacks={}},[{key:"on",value:function(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}},{key:"emit",value:function(e){for(var t=this,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];var o=this.callbacks[e];return o&&o.forEach(function(e){return e.apply(t,i)}),this}},{key:"off",value:function(e,t){var n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(function(e){return e!==t}):delete this.callbacks[e]),this}},{key:"once",value:function(e,t){var n=this,i=function(){n.off(e,i);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];t.apply(n,o)};return this.on(e,i)}},{key:"removeAllListeners",value:function(){this.callbacks={}}}])}(),Ny=x(function e(t){var n;C(this,e),this.find=t.find,this.handler=t.handler,this.undoable=null==(n=t.undoable)||n});function Oy(e){var t,n=e.editor,i=e.from,r=e.to,o=e.text,a=e.rules,s=e.plugin,c=n.view;if(c.composing)return!1;var l=c.state.doc.resolve(i);if(l.parent.type.spec.code||(null==(t=l.nodeBefore||l.nodeAfter)?void 0:t.marks.find(function(e){return e.type.spec.code})))return!1;var u=!1,d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n="",i=e.parentOffset;return e.parent.nodesBetween(Math.max(0,i-t),i,function(e,t,r,o){var a,s,c=(null==(s=(a=e.type.spec).toText)?void 0:s.call(a,{node:e,pos:t,parent:r,index:o}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?c:c.slice(0,Math.max(0,i-t))}),n}(l)+o;return a.forEach(function(e){if(!u){var t=function(e,t){if(zm(t))return t.exec(e);var n=t(e);if(!n)return null;var i=[n.text];return i.index=n.index,i.input=e,i.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(n.replaceWith)),i}(d,e.find);if(t){var a=c.state.tr,l=bm({state:c.state,transaction:a}),h={from:i-(t[0].length-o.length),to:r},f=new Cm({editor:n,state:l}),p=f.commands,v=f.chain,m=f.can;null!==e.handler({state:l,range:h,match:t,commands:p,chain:v,can:m})&&a.steps.length&&(e.undoable&&a.setMeta(s,{transform:a,from:i,to:r,text:o}),c.dispatch(a),u=!0)}}}),u}function Ey(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function Ay(e,t){var n=d({},e);return Ey(e)&&Ey(t)&&Object.keys(t).forEach(function(i){Ey(t[i])&&Ey(e[i])?n[i]=Ay(e[i],t[i]):n[i]=t[i]}),n}var Dy=function(){return x(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};C(this,e),this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config=d(d({},this.config),t),this.name=this.config.name},[{key:"options",get:function(){return d({},Rg(Ag(this,"addOptions",{name:this.name}))||{})}},{key:"storage",get:function(){return d({},Rg(Ag(this,"addStorage",{name:this.name,options:this.options}))||{})}},{key:"configure",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.extend(d(d({},this.config),{},{addOptions:function(){return Ay(e.options,t)}}));return n.name=this.name,n.parent=this.parent,n}},{key:"extend",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new this.constructor(d(d({},this.config),e));return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}}])}(),Iy=function(t){function r(){var e;return C(this,r),(e=n(this,r,arguments)).type="mark",e}return i(r,t),x(r,[{key:"configure",value:function(t){return e(r,"configure",this,3)([t])}},{key:"extend",value:function(t){var n="function"==typeof t?t():t;return e(r,"extend",this,3)([n])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r("function"==typeof e?e():e)}},{key:"handleExit",value:function(e){var t=e.editor,n=e.mark,i=t.state.tr,r=t.state.selection.$from;if(r.pos===r.end()){var o=r.marks(),a=!!o.find(function(e){return(null==e?void 0:e.type.name)===n.name});if(!a)return!1;var s=o.find(function(e){return(null==e?void 0:e.type.name)===n.name});return s&&i.removeStoredMark(s),i.insertText(" ",r.pos),t.view.dispatch(i),!0}return!1}}])}(Dy);function Ly(e){var t=e.editor,n=e.state,i=e.from,r=e.to,o=e.rule,a=e.pasteEvent,s=e.dropEvent,l=new Cm({editor:t,state:n}),u=l.commands,d=l.chain,h=l.can,f=[];return n.doc.nodesBetween(i,r,function(e,t){var l,p,v,m,g;if(!(null==(p=null==(l=e.type)?void 0:l.spec)?void 0:p.code)&&(e.isText||e.isTextblock||e.isInline)){var y=null!=(g=null!=(m=null==(v=e.content)?void 0:v.size)?m:e.nodeSize)?g:0,k=Math.max(i,t),w=Math.min(r,t+y);if(!(k>=w))(function(e,t,n){if(zm(t))return c(e.matchAll(t));var i=t(e,n);return i?i.map(function(t){var n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n}):[]})(e.isText?e.text||"":e.textBetween(k-t,w-t,void 0,""),o.find,a).forEach(function(e){if(void 0!==e.index){var t=k+e.index+1,i=t+e[0].length,r={from:n.tr.mapping.map(t),to:n.tr.mapping.map(i)},c=o.handler({state:n,range:r,match:e,commands:u,chain:d,can:h,pasteEvent:a,dropEvent:s});f.push(c)}})}}),f.every(function(e){return null!==e})}var Ry=null;function Py(e){var t,n=e.editor,i=e.rules,r=null,o=!1,a=!1,s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(u){t=null}var c=function(e){var i=e.state,r=e.from,o=e.to,a=e.rule,c=e.pasteEvt,l=i.tr,u=bm({state:i,transaction:l});if(Ly({editor:n,state:u,from:Math.max(r-1,0),to:o.b-1,rule:a,pasteEvent:c,dropEvent:t})&&l.steps.length){try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(d){t=null}return s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,l}},l=i.map(function(e){return new Mh({view:function(e){var t=function(t){var i;(r=(null==(i=e.dom.parentElement)?void 0:i.contains(t.target))?e.dom.parentElement:null)&&(Ry=n)},i=function(){Ry&&(Ry=null)};return window.addEventListener("dragstart",t),window.addEventListener("dragend",i),{destroy:function(){window.removeEventListener("dragstart",t),window.removeEventListener("dragend",i)}}},props:{handleDOMEvents:{drop:function(e,n){if(a=r===e.dom.parentElement,t=n,!a){var i=Ry;(null==i?void 0:i.isEditable)&&setTimeout(function(){var e=i.state.selection;e&&i.commands.deleteRange({from:e.from,to:e.to})},10)}return!1},paste:function(e,t){var n,i=null==(n=t.clipboardData)?void 0:n.getData("text/html");return s=t,o=!!(null==i?void 0:i.includes("data-pm-slice")),!1}}},appendTransaction:function(t,n,i){var r=t[0],l="paste"===r.getMeta("uiEvent")&&!o,u="drop"===r.getMeta("uiEvent")&&!a,d=r.getMeta("applyPasteRules"),h=!!d;if(l||u||h){if(h){var f=d.text;"string"==typeof f||(f=Ig(cu.from(f),i.schema));var p=d.from,v=p+f.length,m=function(e){var t,n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(t=n.clipboardData)||t.setData("text/html",e),n}(f);return c({rule:e,state:i,from:p,to:{b:v},pasteEvt:m})}var g=n.doc.content.findDiffStart(i.doc.content),y=n.doc.content.findDiffEnd(i.doc.content);if("number"==typeof g&&y&&g!==y.b)return c({rule:e,state:i,from:g,to:y,pasteEvt:s})}}})});return l}var zy=function(){return x(function e(t,n){C(this,e),this.splittableMarks=[],this.editor=n,this.baseExtensions=t,this.extensions=$g(t),this.schema=function(e,t){var n,i=zg(e),r=Pg(e),o=r.nodeExtensions,a=r.markExtensions,s=null==(n=o.find(function(e){return Ag(e,"topNode")}))?void 0:n.name,c=Object.fromEntries(o.map(function(n){var r=i.filter(function(e){return e.type===n.name}),o={name:n.name,options:n.options,storage:n.storage,editor:t},a=e.reduce(function(e,t){var i=Ag(t,"extendNodeSchema",o);return d(d({},e),i?i(n):{})},{}),s=jg(d(d({},a),{},{content:Rg(Ag(n,"content",o)),marks:Rg(Ag(n,"marks",o)),group:Rg(Ag(n,"group",o)),inline:Rg(Ag(n,"inline",o)),atom:Rg(Ag(n,"atom",o)),selectable:Rg(Ag(n,"selectable",o)),draggable:Rg(Ag(n,"draggable",o)),code:Rg(Ag(n,"code",o)),whitespace:Rg(Ag(n,"whitespace",o)),linebreakReplacement:Rg(Ag(n,"linebreakReplacement",o)),defining:Rg(Ag(n,"defining",o)),isolating:Rg(Ag(n,"isolating",o)),attrs:Object.fromEntries(r.map(Vg))})),c=Rg(Ag(n,"parseHTML",o));c&&(s.parseDOM=c.map(function(e){return Fg(e,r)}));var l=Ag(n,"renderHTML",o);l&&(s.toDOM=function(e){return l({node:e,HTMLAttributes:Hg(e,r)})});var u=Ag(n,"renderText",o);return u&&(s.toText=u),[n.name,s]})),l=Object.fromEntries(a.map(function(n){var r=i.filter(function(e){return e.type===n.name}),o={name:n.name,options:n.options,storage:n.storage,editor:t},a=e.reduce(function(e,t){var i=Ag(t,"extendMarkSchema",o);return d(d({},e),i?i(n):{})},{}),s=jg(d(d({},a),{},{inclusive:Rg(Ag(n,"inclusive",o)),excludes:Rg(Ag(n,"excludes",o)),group:Rg(Ag(n,"group",o)),spanning:Rg(Ag(n,"spanning",o)),code:Rg(Ag(n,"code",o)),attrs:Object.fromEntries(r.map(Vg))})),c=Rg(Ag(n,"parseHTML",o));c&&(s.parseDOM=c.map(function(e){return Fg(e,r)}));var l=Ag(n,"renderHTML",o);return l&&(s.toDOM=function(e){return l({mark:e,HTMLAttributes:Hg(e,r)})}),[n.name,s]}));return new Qu({topNode:s,nodes:c,marks:l})}(this.extensions,n),this.setupExtensions()},[{key:"commands",get:function(){var e=this;return this.extensions.reduce(function(t,n){var i=Ag(n,"addCommands",{name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:e.editor,type:Gg(n.name,e.schema)});return i?d(d({},t),i()):t},{})}},{key:"plugins",get:function(){var e=this,t=this.editor;return Wg(c(this.extensions).reverse()).flatMap(function(n){var i={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:Gg(n.name,e.schema)},r=[],o=Ag(n,"addKeyboardShortcuts",i),a={};if("mark"===n.type&&Ag(n,"exitable",i)&&(a.ArrowRight=function(){return Iy.handleExit({editor:t,mark:n})}),o){var s=Object.fromEntries(Object.entries(o()).map(function(e){var n=g(e,2),i=n[0],r=n[1];return[i,function(){return r({editor:t})}]}));a=d(d({},a),s)}var l=function(e){return new Mh({props:{handleKeyDown:ym(e)}})}(a);r.push(l);var u=Ag(n,"addInputRules",i);if(Qg(n,t.options.enableInputRules)&&u){var h=u();if(h&&h.length){var f=function(e){var t=e.editor,n=e.rules,i=new Mh({state:{init:function(){return null},apply:function(e,r,o){var a=e.getMeta(i);if(a)return a;var s=e.getMeta("applyInputRules");return!!s&&setTimeout(function(){var e=s.text;"string"==typeof e||(e=Ig(cu.from(e),o.schema));var r=s.from,a=r+e.length;Oy({editor:t,from:r,to:a,text:e,rules:n,plugin:i})}),e.selectionSet||e.docChanged?null:r}},props:{handleTextInput:function(e,r,o,a){return Oy({editor:t,from:r,to:o,text:a,rules:n,plugin:i})},handleDOMEvents:{compositionend:function(e){return setTimeout(function(){var r=e.state.selection.$cursor;r&&Oy({editor:t,from:r.pos,to:r.pos,text:"",rules:n,plugin:i})}),!1}},handleKeyDown:function(e,r){if("Enter"!==r.key)return!1;var o=e.state.selection.$cursor;return!!o&&Oy({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:i})}},isInputRules:!0});return i}({editor:t,rules:h}),p=Array.isArray(f)?f:[f];r.push.apply(r,c(p))}}var v=Ag(n,"addPasteRules",i);if(Qg(n,t.options.enablePasteRules)&&v){var m=v();if(m&&m.length){var y=Py({editor:t,rules:m});r.push.apply(r,c(y))}}var k=Ag(n,"addProseMirrorPlugins",i);if(k){var w=k();r.push.apply(r,c(w))}return r})}},{key:"attributes",get:function(){return zg(this.extensions)}},{key:"nodeViews",get:function(){var e=this,t=this.editor,n=Pg(this.extensions).nodeExtensions;return Object.fromEntries(n.filter(function(e){return!!Ag(e,"addNodeView")}).map(function(n){var i=e.attributes.filter(function(e){return e.type===n.name}),r={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:Am(n.name,e.schema)},o=Ag(n,"addNodeView",r);if(!o)return[];var a=o();if(!a)return[];return[n.name,function(e,r,o,s,c){var l=Hg(e,i);return a({node:e,view:r,getPos:o,decorations:s,innerDecorations:c,editor:t,extension:n,HTMLAttributes:l})}]}))}},{key:"markViews",get:function(){var e=this,t=this.editor,n=Pg(this.extensions).markExtensions;return Object.fromEntries(n.filter(function(e){return!!Ag(e,"addMarkView")}).map(function(n){var i=e.attributes.filter(function(e){return e.type===n.name}),r={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:Vm(n.name,e.schema)},o=Ag(n,"addMarkView",r);if(!o)return[];return[n.name,function(e,r,a){var s=Hg(e,i);return o()({mark:e,view:r,inline:a,editor:t,extension:n,HTMLAttributes:s,updateAttributes:function(n){!function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.state,r=i.doc,o=i.tr,a=e;r.descendants(function(t,i){var r=o.mapping.map(i),s=o.mapping.map(i)+t.nodeSize,c=null;if(t.marks.forEach(function(e){if(e!==a)return!1;c=e}),c){var l=!1;if(Object.keys(n).forEach(function(e){n[e]!==c.attrs[e]&&(l=!0)}),l){var u=e.type.create(d(d({},e.attrs),n));o.removeMark(r,s,e.type),o.addMark(r,s,u)}}}),o.docChanged&&t.view.dispatch(o)}(e,t,n)}})}]}))}},{key:"setupExtensions",value:function(){var e=this,t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(function(e){return[e.name,e.storage]})),t.forEach(function(t){var n,i={name:t.name,options:t.options,storage:e.editor.extensionStorage[t.name],editor:e.editor,type:Gg(t.name,e.schema)};"mark"===t.type&&((null==(n=Rg(Ag(t,"keepOnSplit",i)))||n)&&e.splittableMarks.push(t.name));var r=Ag(t,"onBeforeCreate",i),o=Ag(t,"onCreate",i),a=Ag(t,"onUpdate",i),s=Ag(t,"onSelectionUpdate",i),c=Ag(t,"onTransaction",i),l=Ag(t,"onFocus",i),u=Ag(t,"onBlur",i),d=Ag(t,"onDestroy",i);r&&e.editor.on("beforeCreate",r),o&&e.editor.on("create",o),a&&e.editor.on("update",a),s&&e.editor.on("selectionUpdate",s),c&&e.editor.on("transaction",c),l&&e.editor.on("focus",l),u&&e.editor.on("blur",u),d&&e.editor.on("destroy",d)})}}])}();zy.resolve=$g,zy.sort=Wg,zy.flatten=Dg;wm({},{ClipboardTextSerializer:function(){return Hy},Commands:function(){return Fy},Delete:function(){return jy},Drop:function(){return Vy},Editable:function(){return Wy},FocusEvents:function(){return Uy},Keymap:function(){return qy},Paste:function(){return Ky},Tabindex:function(){return Jy},TextDirection:function(){return Gy},focusEventsPluginKey:function(){return $y}});var By=function(t){function r(){var e;return C(this,r),(e=n(this,r,arguments)).type="extension",e}return i(r,t),x(r,[{key:"configure",value:function(t){return e(r,"configure",this,3)([t])}},{key:"extend",value:function(t){var n="function"==typeof t?t():t;return e(r,"extend",this,3)([n])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r("function"==typeof e?e():e)}}])}(Dy),Hy=By.create({name:"clipboardTextSerializer",addOptions:function(){return{blockSeparator:void 0}},addProseMirrorPlugins:function(){var e=this;return[new Mh({key:new Oh("clipboardTextSerializer"),props:{clipboardTextSerializer:function(){var t=e.editor,n=t.state,i=t.schema,r=n.doc,o=n.selection.ranges,a=Math.min.apply(Math,c(o.map(function(e){return e.$from.pos}))),s=Math.max.apply(Math,c(o.map(function(e){return e.$to.pos}))),l=qg(i);return Ug(r,{from:a,to:s},d(d({},void 0!==e.options.blockSeparator?{blockSeparator:e.options.blockSeparator}:{}),{},{textSerializers:l}))}}})]}}),Fy=By.create({name:"commands",addCommands:function(){return d({},Sm)}}),jy=By.create({name:"delete",onUpdate:function(e){var t,n,i,r=this,o=e.transaction,a=e.appendedTransactions,s=function(){var e,t,n,i;if(!(null!=(i=null==(n=null==(t=null==(e=r.editor.options.coreExtensionOptions)?void 0:e.delete)?void 0:t.filterTransaction)?void 0:n.call(t,o))?i:o.getMeta("y-sync$"))){var s,l,u,d=(s=o.before,l=[o].concat(c(a)),u=new oh(s),l.forEach(function(e){e.steps.forEach(function(e){u.step(e)})}),u),h=function(e){var t=e.mapping,n=e.steps,i=[];return t.maps.forEach(function(e,r){var o=[];if(e.ranges.length)e.forEach(function(e,t){o.push({from:e,to:t})});else{var a=n[r],s=a.from,c=a.to;if(void 0===s||void 0===c)return;o.push({from:s,to:c})}o.forEach(function(e){var n=e.from,o=e.to,a=t.slice(r).map(n,-1),s=t.slice(r).map(o),c=t.invert().map(a,-1),l=t.invert().map(s);i.push({oldRange:{from:c,to:l},newRange:{from:a,to:s}})})}),Jg(i)}(d);h.forEach(function(e){d.mapping.mapResult(e.oldRange.from).deletedAfter&&d.mapping.mapResult(e.oldRange.to).deletedBefore&&d.before.nodesBetween(e.oldRange.from,e.oldRange.to,function(t,n){var i=n+t.nodeSize-2,a=e.oldRange.from<=n&&i<=e.oldRange.to;r.editor.emit("delete",{type:"node",node:t,from:n,to:i,newFrom:d.mapping.map(n),newTo:d.mapping.map(i),deletedRange:e.oldRange,newRange:e.newRange,partial:!a,editor:r.editor,transaction:o,combinedTransform:d})})});var f=d.mapping;d.steps.forEach(function(e,t){var n,i;if(e instanceof _d){var a=f.slice(t).map(e.from,-1),s=f.slice(t).map(e.to),c=f.invert().map(a,-1),l=f.invert().map(s),u=null==(n=d.doc.nodeAt(a-1))?void 0:n.marks.some(function(t){return t.eq(e.mark)}),h=null==(i=d.doc.nodeAt(s))?void 0:i.marks.some(function(t){return t.eq(e.mark)});r.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:c,to:l},newRange:{from:a,to:s},partial:Boolean(h||u),editor:r.editor,transaction:o,combinedTransform:d})}})}};null==(i=null==(n=null==(t=this.editor.options.coreExtensionOptions)?void 0:t.delete)?void 0:n.async)||i?setTimeout(s,0):s()}}),Vy=By.create({name:"drop",addProseMirrorPlugins:function(){var e=this;return[new Mh({key:new Oh("tiptapDrop"),props:{handleDrop:function(t,n,i,r){e.editor.emit("drop",{editor:e.editor,event:n,slice:i,moved:r})}}})]}}),Wy=By.create({name:"editable",addProseMirrorPlugins:function(){var e=this;return[new Mh({key:new Oh("editable"),props:{editable:function(){return e.editor.options.editable}}})]}}),$y=new Oh("focusEvents"),Uy=By.create({name:"focusEvents",addProseMirrorPlugins:function(){var e=this.editor;return[new Mh({key:$y,props:{handleDOMEvents:{focus:function(t,n){e.isFocused=!0;var i=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1},blur:function(t,n){e.isFocused=!1;var i=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1}}}})]}}),qy=By.create({name:"keymap",addKeyboardShortcuts:function(){var e=this,t=function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.undoInputRule()},function(){return t.command(function(e){var n=e.tr,i=n.selection,r=n.doc,o=i.empty,a=i.$anchor,s=a.pos,c=a.parent,l=a.parent.isTextblock&&s>0?n.doc.resolve(s-1):a,u=l.parent.type.spec.isolating,d=a.pos-a.parentOffset,h=u&&1===l.parent.childCount?d===a.pos:sh.atStart(r).from===s;return!(!o||!c.type.isTextblock||c.textContent.length||!h||h&&"paragraph"===a.parent.type.name)&&t.clearNodes()})},function(){return t.deleteSelection()},function(){return t.joinBackward()},function(){return t.selectNodeBackward()}]})},n=function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.deleteSelection()},function(){return t.deleteCurrentNode()},function(){return t.joinForward()},function(){return t.selectNodeForward()}]})},i={Enter:function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.newlineInCode()},function(){return t.createParagraphNear()},function(){return t.liftEmptyBlock()},function(){return t.splitBlock()}]})},"Mod-Enter":function(){return e.editor.commands.exitCode()},Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:n,"Mod-Delete":n,"Mod-a":function(){return e.editor.commands.selectAll()}},r=d({},i),o=d(d({},i),{},{"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":n,"Ctrl-Alt-Backspace":n,"Alt-Delete":n,"Alt-d":n,"Ctrl-a":function(){return e.editor.commands.selectTextblockStart()},"Ctrl-e":function(){return e.editor.commands.selectTextblockEnd()}});return Jm()||ug()?o:r},addProseMirrorPlugins:function(){var e=this;return[new Mh({key:new Oh("clearDocument"),appendTransaction:function(t,n,i){if(!t.some(function(e){return e.getMeta("composition")})){var r=t.some(function(e){return e.docChanged})&&!n.doc.eq(i.doc),o=t.some(function(e){return e.getMeta("preventClearDocument")});if(r&&!o){var a=n.selection,s=a.empty,c=a.from,l=a.to,u=sh.atStart(n.doc).from,d=sh.atEnd(n.doc).to;if(!s&&(c===u&&l===d))if(ey(i.doc)){var h=i.tr,f=bm({state:i,transaction:h});if(new Cm({editor:e.editor,state:f}).commands.clearNodes(),h.steps.length)return h}}}}})]}}),Ky=By.create({name:"paste",addProseMirrorPlugins:function(){var e=this;return[new Mh({key:new Oh("tiptapPaste"),props:{handlePaste:function(t,n,i){e.editor.emit("paste",{editor:e.editor,event:n,slice:i})}}})]}}),Jy=By.create({name:"tabindex",addProseMirrorPlugins:function(){var e=this;return[new Mh({key:new Oh("tabindex"),props:{attributes:function(){return e.editor.isEditable?{tabindex:"0"}:{}}}})]}}),Gy=By.create({name:"textDirection",addOptions:function(){return{direction:void 0}},addGlobalAttributes:function(){var e=this;return this.options.direction?[{types:Pg(this.extensions).nodeExtensions.filter(function(e){return"text"!==e.name}).map(function(e){return e.name}),attributes:{dir:{default:this.options.direction,parseHTML:function(t){var n=t.getAttribute("dir");return!n||"ltr"!==n&&"rtl"!==n&&"auto"!==n?e.options.direction:n},renderHTML:function(e){return e.dir?{dir:e.dir}:{}}}}}]:[]},addProseMirrorPlugins:function(){var e=this;return[new Mh({key:new Oh("textDirection"),props:{attributes:function(){var t=e.options.direction;return t?{dir:t}:{}}}})]}}),Yy=function(){function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;C(this,e),this.currentNode=null,this.actualDepth=null,this.isBlock=i,this.resolvedPos=t,this.editor=n,this.currentNode=r}return x(e,[{key:"name",get:function(){return this.node.type.name}},{key:"node",get:function(){return this.currentNode||this.resolvedPos.node()}},{key:"element",get:function(){return this.editor.view.domAtPos(this.pos).node}},{key:"depth",get:function(){var e;return null!=(e=this.actualDepth)?e:this.resolvedPos.depth}},{key:"pos",get:function(){return this.resolvedPos.pos}},{key:"content",get:function(){return this.node.content},set:function(e){var t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error("You can’t set content on a block node. Tried to set content on ".concat(this.name," at ").concat(this.pos));t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}},{key:"attributes",get:function(){return this.node.attrs}},{key:"textContent",get:function(){return this.node.textContent}},{key:"size",get:function(){return this.node.nodeSize}},{key:"from",get:function(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}},{key:"range",get:function(){return{from:this.from,to:this.to}}},{key:"to",get:function(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}},{key:"parent",get:function(){if(0===this.depth)return null;var t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}},{key:"before",get:function(){var t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}},{key:"after",get:function(){var t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}},{key:"children",get:function(){var t=this,n=[];return this.node.content.forEach(function(i,r){var o=i.isBlock&&!i.isTextblock,a=i.isAtom&&!i.isText,s=t.pos+r+(a?0:1);if(!(s<0||s>t.resolvedPos.doc.nodeSize-2)){var c=t.resolvedPos.doc.resolve(s);if(o||!(c.depth<=t.depth)){var l=new e(c,t.editor,o,o?i:null);o&&(l.actualDepth=t.depth+1),n.push(new e(c,t.editor,o,o?i:null))}}}),n}},{key:"firstChild",get:function(){return this.children[0]||null}},{key:"lastChild",get:function(){var e=this.children;return e[e.length-1]||null}},{key:"closest",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,i=this.parent;i&&!n;){if(i.node.type.name===e)if(Object.keys(t).length>0)for(var r=i.node.attrs,o=Object.keys(t),a=0;a<o.length;a+=1){var s=o[a];if(r[s]!==t[s])break}else n=i;i=i.parent}return n}},{key:"querySelector",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.querySelectorAll(e,t,!0)[0]||null}},{key:"querySelectorAll",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[];if(!this.children||0===this.children.length)return i;var r=Object.keys(t);return this.children.forEach(function(o){if(!(n&&i.length>0)){if(o.node.type.name===e)r.every(function(e){return t[e]===o.node.attrs[e]})&&i.push(o);n&&i.length>0||(i=i.concat(o.querySelectorAll(e,t,n)))}}),i}},{key:"setAttribute",value:function(e){var t=this.editor.state.tr;t.setNodeMarkup(this.from,void 0,d(d({},this.node.attrs),e)),this.editor.view.dispatch(t)}}])}();var Xy=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};C(this,t),(e=n(this,t)).css=null,e.className="tiptap",e.editorView=null,e.isFocused=!1,e.isInitialized=!1,e.extensionStorage={},e.instanceId=Math.random().toString(36).slice(2,9),e.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:function(){return null},onCreate:function(){return null},onMount:function(){return null},onUnmount:function(){return null},onUpdate:function(){return null},onSelectionUpdate:function(){return null},onTransaction:function(){return null},onFocus:function(){return null},onBlur:function(){return null},onDestroy:function(){return null},onContentError:function(e){throw e.error},onPaste:function(){return null},onDrop:function(){return null},onDelete:function(){return null}},e.isCapturingTransaction=!1,e.capturedTransaction=null,e.utils={getUpdatedPosition:ny,createMappablePosition:iy},e.setOptions(i),e.createExtensionManager(),e.createCommandManager(),e.createSchema(),e.on("beforeCreate",e.options.onBeforeCreate),e.emit("beforeCreate",{editor:e}),e.on("mount",e.options.onMount),e.on("unmount",e.options.onUnmount),e.on("contentError",e.options.onContentError),e.on("create",e.options.onCreate),e.on("update",e.options.onUpdate),e.on("selectionUpdate",e.options.onSelectionUpdate),e.on("transaction",e.options.onTransaction),e.on("focus",e.options.onFocus),e.on("blur",e.options.onBlur),e.on("destroy",e.options.onDestroy),e.on("drop",function(t){var n=t.event,i=t.slice,r=t.moved;return e.options.onDrop(n,i,r)}),e.on("paste",function(t){var n=t.event,i=t.slice;return e.options.onPaste(n,i)}),e.on("delete",e.options.onDelete);var r=e.createDoc(),o=Km(r,e.options.autofocus);return e.editorState=xh.create({doc:r,schema:e.schema,selection:o||void 0}),e.options.element&&e.mount(e.options.element),e}return i(t,e),x(t,[{key:"mount",value:function(e){var t=this;if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(function(){t.isDestroyed||(!1!==t.options.autofocus&&null!==t.options.autofocus&&t.commands.focus(t.options.autofocus),t.emit("create",{editor:t}),t.isInitialized=!0)},0)}},{key:"unmount",value:function(){if(this.editorView){var e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(".".concat(this.className)).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}},{key:"storage",get:function(){return this.extensionStorage}},{key:"commands",get:function(){return this.commandManager.commands}},{key:"chain",value:function(){return this.commandManager.chain()}},{key:"can",value:function(){return this.commandManager.can()}},{key:"injectCSS",value:function(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=function(e,t,n){var i=document.querySelector("style[data-tiptap-style".concat(n?"-".concat(n):"","]"));if(null!==i)return i;var r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute("data-tiptap-style".concat(n?"-".concat(n):""),""),r.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(r),r}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}',this.options.injectNonce))}},{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=d(d({},this.options),e),this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}},{key:"setEditable",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}},{key:"isEditable",get:function(){return this.options.editable&&this.view&&this.view.editable}},{key:"view",get:function(){var e=this;return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:function(t){e.editorState=t},dispatch:function(t){e.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:function(t,n){if(e.editorView)return e.editorView[n];if("state"===n)return e.editorState;if(n in t)return Reflect.get(t,n);throw new Error("[tiptap error]: The editor view is not available. Cannot access view['".concat(n,"']. The editor may not be mounted yet."))}})}},{key:"state",get:function(){return this.editorView&&(this.editorState=this.view.state),this.editorState}},{key:"registerPlugin",value:function(e,t){var n=Lg(t)?t(e,c(this.state.plugins)):[].concat(c(this.state.plugins),[e]),i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}},{key:"unregisterPlugin",value:function(e){if(!this.isDestroyed){var t=this.state.plugins,n=t;if([].concat(e).forEach(function(e){var t="string"==typeof e?"".concat(e,"$"):e.key;n=n.filter(function(e){return!e.key.startsWith(t)})}),t.length!==n.length){var i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}}}},{key:"createExtensionManager",value:function(){var e,t,n=this,i=this.options.enableCoreExtensions?[Wy,Hy.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),Fy,Uy,qy,Jy,Vy,Ky,jy,Gy.configure({direction:this.options.textDirection})].filter(function(e){return"object"!==_(n.options.enableCoreExtensions)||!1!==n.options.enableCoreExtensions[e.name]}):[],r=[].concat(c(i),c(this.options.extensions)).filter(function(e){return["extension","node","mark"].includes(null==e?void 0:e.type)});this.extensionManager=new zy(r,this)}},{key:"createCommandManager",value:function(){this.commandManager=new Cm({editor:this})}},{key:"createSchema",value:function(){this.schema=this.extensionManager.schema}},{key:"createDoc",value:function(){var e,t=this;try{e=_g(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(vs){if(!(vs instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(vs.message)))throw vs;this.emit("contentError",{editor:this,error:vs,disableCollaboration:function(){"collaboration"in t.storage&&"object"===_(t.storage.collaboration)&&t.storage.collaboration&&(t.storage.collaboration.isDisabled=!0),t.options.extensions=t.options.extensions.filter(function(e){return"collaboration"!==e.name}),t.createExtensionManager()}}),e=_g(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}},{key:"createView",value:function(e){var t;this.editorView=new nm(e,d(d({},this.options.editorProps),{},{attributes:d({role:"textbox"},null==(t=this.options.editorProps)?void 0:t.attributes),dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews}));var n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}},{key:"createNodeViews",value:function(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}},{key:"prependClass",value:function(){this.view.dom.className="".concat(this.className," ").concat(this.view.dom.className)}},{key:"captureTransaction",value:function(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;var t=this.capturedTransaction;return this.capturedTransaction=null,t}},{key:"dispatchTransaction",value:function(e){var t=this;if(!this.view.isDestroyed){if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach(function(e){var n;return null==(n=t.capturedTransaction)?void 0:n.step(e)}):void(this.capturedTransaction=e);var n=this.state.applyTransaction(e),i=n.state,r=n.transactions,o=!this.state.selection.eq(i.selection),a=r.includes(e),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:i}),a){this.view.updateState(i),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:r.slice(1)}),o&&this.emit("selectionUpdate",{editor:this,transaction:e});var c=r.findLast(function(e){return e.getMeta("focus")||e.getMeta("blur")}),l=null==c?void 0:c.getMeta("focus"),u=null==c?void 0:c.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:c}),u&&this.emit("blur",{editor:this,event:u.event,transaction:c}),e.getMeta("preventUpdate")||!r.some(function(e){return e.docChanged})||s.doc.eq(i.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:r.slice(1)})}}}},{key:"getAttributes",value:function(e){return Kg(this.state,e)}},{key:"isActive",value:function(e,t){var n="string"==typeof e?e:null,i="string"==typeof e?t:e;return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return hg(e,null,n)||Xg(e,null,n);var i=gg(t,e.schema);return"node"===i?hg(e,t,n):"mark"===i&&Xg(e,t,n)}(this.state,n,i)}},{key:"getJSON",value:function(){return this.state.doc.toJSON()}},{key:"getHTML",value:function(){return Ig(this.state.doc.content,this.schema)}},{key:"getText",value:function(e){var t=e||{},n=t.blockSeparator,i=void 0===n?"\n\n":n,r=t.textSerializers,o=void 0===r?{}:r;return function(e,t){return Ug(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:i,textSerializers:d(d({},qg(this.schema)),o)})}},{key:"isEmpty",get:function(){return ey(this.state.doc)}},{key:"destroy",value:function(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}},{key:"isDestroyed",get:function(){var e,t;return null==(t=null==(e=this.editorView)?void 0:e.isDestroyed)||t}},{key:"$node",value:function(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelector(e,t))||null}},{key:"$nodes",value:function(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(e,t))||null}},{key:"$pos",value:function(e){var t=this.state.doc.resolve(e);return new Yy(t,this)}},{key:"$doc",get:function(){return this.$pos(0)}}])}(_y);var Qy=function(){return x(function e(t){var n,i,r,o,a,s=this;C(this,e),this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=function(e){if(s.isResizing&&s.activeHandle){var t=e.clientX-s.startX,n=e.clientY-s.startY;s.handleResize(t,n)}},this.handleTouchMove=function(e){if(s.isResizing&&s.activeHandle){var t=e.touches[0];if(t){var n=t.clientX-s.startX,i=t.clientY-s.startY;s.handleResize(n,i)}}},this.handleMouseUp=function(){if(s.isResizing){var e=s.element.offsetWidth,t=s.element.offsetHeight;s.onCommit(e,t),s.isResizing=!1,s.activeHandle=null,s.container.dataset.resizeState="false",s.classNames.resizing&&s.container.classList.remove(s.classNames.resizing),document.removeEventListener("mousemove",s.handleMouseMove),document.removeEventListener("mouseup",s.handleMouseUp),document.removeEventListener("keydown",s.handleKeyDown),document.removeEventListener("keyup",s.handleKeyUp)}},this.handleKeyDown=function(e){"Shift"===e.key&&(s.isShiftKeyPressed=!0)},this.handleKeyUp=function(e){"Shift"===e.key&&(s.isShiftKeyPressed=!1)},this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(null==(n=t.options)?void 0:n.min)&&(this.minSize=d(d({},this.minSize),t.options.min)),(null==(i=t.options)?void 0:i.max)&&(this.maxSize=t.options.max),(null==(r=null==t?void 0:t.options)?void 0:r.directions)&&(this.directions=t.options.directions),(null==(o=t.options)?void 0:o.preserveAspectRatio)&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(null==(a=t.options)?void 0:a.className)&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()},[{key:"dom",get:function(){return this.container}},{key:"contentDOM",get:function(){return this.contentElement}},{key:"update",value:function(e,t,n){return e.type===this.node.type&&(this.node=e,!this.onUpdate||this.onUpdate(e,t,n))}},{key:"destroy",value:function(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}},{key:"createContainer",value:function(){var e=document.createElement("div");return e.dataset.resizeContainer="",e.dataset.node=this.node.type.name,e.style.display="flex",e.style.justifyContent="flex-start",e.style.alignItems="flex-start",this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}},{key:"createWrapper",value:function(){var e=document.createElement("div");return e.style.position="relative",e.style.display="block",e.dataset.resizeWrapper="",this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}},{key:"createHandle",value:function(e){var t=document.createElement("div");return t.dataset.resizeHandle=e,t.style.position="absolute",this.classNames.handle&&(t.className=this.classNames.handle),t}},{key:"positionHandle",value:function(e,t){var n=t.includes("top"),i=t.includes("bottom"),r=t.includes("left"),o=t.includes("right");n&&(e.style.top="0"),i&&(e.style.bottom="0"),r&&(e.style.left="0"),o&&(e.style.right="0"),"top"!==t&&"bottom"!==t||(e.style.left="0",e.style.right="0"),"left"!==t&&"right"!==t||(e.style.top="0",e.style.bottom="0")}},{key:"attachHandles",value:function(){var e=this;this.directions.forEach(function(t){var n=e.createHandle(t);e.positionHandle(n,t),n.addEventListener("mousedown",function(n){return e.handleResizeStart(n,t)}),n.addEventListener("touchstart",function(n){return e.handleResizeStart(n,t)}),e.wrapper.appendChild(n)})}},{key:"applyInitialSize",value:function(){var e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width="".concat(e,"px"),this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height="".concat(t,"px"),this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}},{key:"handleResizeStart",value:function(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,!function(e){return"touches"in e}(e)?(this.startX=e.clientX,this.startY=e.clientY):(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}},{key:"handleResize",value:function(e,t){if(this.activeHandle){var n=this.preserveAspectRatio||this.isShiftKeyPressed,i=this.calculateNewDimensions(this.activeHandle,e,t),r=i.width,o=i.height,a=this.applyConstraints(r,o,n);this.element.style.width="".concat(a.width,"px"),this.element.style.height="".concat(a.height,"px"),this.onResize&&this.onResize(a.width,a.height)}}},{key:"calculateNewDimensions",value:function(e,t,n){var i=this.startWidth,r=this.startHeight,o=e.includes("right"),a=e.includes("left"),s=e.includes("bottom"),c=e.includes("top");return o?i=this.startWidth+t:a&&(i=this.startWidth-t),s?r=this.startHeight+n:c&&(r=this.startHeight-n),"right"!==e&&"left"!==e||(i=this.startWidth+(o?t:-t)),"top"!==e&&"bottom"!==e||(r=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(i,r,e):{width:i,height:r}}},{key:"applyConstraints",value:function(e,t,n){var i,r,o,a;if(!n){var s=Math.max(this.minSize.width,e),c=Math.max(this.minSize.height,t);return(null==(i=this.maxSize)?void 0:i.width)&&(s=Math.min(this.maxSize.width,s)),(null==(r=this.maxSize)?void 0:r.height)&&(c=Math.min(this.maxSize.height,c)),{width:s,height:c}}var l=e,u=t;return l<this.minSize.width&&(u=(l=this.minSize.width)/this.aspectRatio),u<this.minSize.height&&(l=(u=this.minSize.height)*this.aspectRatio),(null==(o=this.maxSize)?void 0:o.width)&&l>this.maxSize.width&&(u=(l=this.maxSize.width)/this.aspectRatio),(null==(a=this.maxSize)?void 0:a.height)&&u>this.maxSize.height&&(l=(u=this.maxSize.height)*this.aspectRatio),{width:l,height:u}}},{key:"applyAspectRatio",value:function(e,t,n){var i="top"===n||"bottom"===n;return"left"===n||"right"===n?{width:e,height:e/this.aspectRatio}:i?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}}])}();function Zy(e){if(!(null==e?void 0:e.trim()))return{};var t={},n=[],i=e.replace(/["']([^"']*)["']/g,function(e){return n.push(e),"__QUOTED_".concat(n.length-1,"__")}),r=i.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(r){var o=r.map(function(e){return e.trim().slice(1)});t.class=o.join(" ")}var a=i.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(t.id=a[1]);Array.from(i.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(function(e){var i,r=g(e,3),o=r[1],a=r[2],s=parseInt((null==(i=a.match(/__QUOTED_(\d+)__/))?void 0:i[1])||"0",10),c=n[s];c&&(t[o]=c.slice(1,-1))});var s=i.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();s&&s.split(/\s+/).filter(Boolean).forEach(function(e){e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)});return t}function ek(e){if(!e||0===Object.keys(e).length)return"";var t=[];e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(function(e){return t.push(".".concat(e))});return e.id&&t.push("#".concat(e.id)),Object.entries(e).forEach(function(e){var n=g(e,2),i=n[0],r=n[1];"class"!==i&&"id"!==i&&(!0===r?t.push(i):!1!==r&&null!=r&&t.push("".concat(i,'="').concat(String(r),'"')))}),t.join(" ")}function tk(e){var t=e.nodeName,n=e.name,i=e.parseAttributes,r=void 0===i?Zy:i,o=e.serializeAttributes,a=void 0===o?ek:o,s=e.defaultAttributes,c=void 0===s?{}:s,l=e.requiredAttributes,u=void 0===l?[]:l,h=e.allowedAttributes,f=n||t;return{parseMarkdown:function(e,n){var i=d(d({},c),e.attributes);return n.createNode(t,i,[])},markdownTokenizer:{name:t,level:"block",start:function(e){var t,n=new RegExp("^:::".concat(f,"(?:\\s|$)"),"m"),i=null==(t=e.match(n))?void 0:t.index;return void 0!==i?i:-1},tokenize:function(e,n,i){var o=new RegExp("^:::".concat(f,"(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)")),a=e.match(o);if(a){var s=a[1]||"",c=r(s);if(!u.find(function(e){return!(e in c)}))return{type:t,raw:a[0],attributes:c}}}},renderMarkdown:function(e){var t=function(e){if(!h)return e;var t={};return h.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),n=a(t),i=n?" {".concat(n,"}"):"";return":::".concat(f).concat(i," :::")}}}function nk(e){var t=e.nodeName,n=e.name,i=e.getContent,r=e.parseAttributes,o=void 0===r?Zy:r,a=e.serializeAttributes,s=void 0===a?ek:a,c=e.defaultAttributes,l=void 0===c?{}:c,u=e.content,h=void 0===u?"block":u,f=e.allowedAttributes,p=n||t;return{parseMarkdown:function(e,n){var r;if(i){var o=i(e);r="string"==typeof o?[{type:"text",text:o}]:o}else r="block"===h?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);var a=d(d({},l),e.attributes);return n.createNode(t,a,r)},markdownTokenizer:{name:t,level:"block",start:function(e){var t,n=new RegExp("^:::".concat(p),"m"),i=null==(t=e.match(n))?void 0:t.index;return void 0!==i?i:-1},tokenize:function(e,n,i){var r,a=new RegExp("^:::".concat(p,"(?:\\s+\\{([^}]*)\\})?\\s*\\n")),s=e.match(a);if(s){var c=g(s,2),l=c[0],u=c[1],d=o(void 0===u?"":u),f=1,v=l.length,m="",y=/^:::([\w-]*)(\s.*)?/gm,k=e.slice(v);for(y.lastIndex=0;;){var w=y.exec(k);if(null===w)break;var b=w.index,C=w[1];if(!(null==(r=w[2])?void 0:r.endsWith(":::")))if(C)f+=1;else if(0===(f-=1)){var S=k.slice(0,b);m=S.trim();var x=e.slice(0,v+b+w[0].length),T=[];if(m)if("block"===h)for((T=i.blockTokens(S)).forEach(function(e){!e.text||e.tokens&&0!==e.tokens.length||(e.tokens=i.inlineTokens(e.text))});T.length>0;){var M=T[T.length-1];if("paragraph"!==M.type||M.text&&""!==M.text.trim())break;T.pop()}else T=i.inlineTokens(m);return{type:t,raw:x,attributes:d,content:m,tokens:T}}}}}},renderMarkdown:function(e,t){var n=function(e){if(!f)return e;var t={};return f.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),i=s(n),r=i?" {".concat(i,"}"):"",o=t.renderChildren(e.content||[],"\n\n");return":::".concat(p).concat(r,"\n\n").concat(o,"\n\n:::")}}}function ik(e){if(!e.trim())return{};for(var t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,i=n.exec(e);null!==i;){var r=g(i,4),o=r[1],a=r[2],s=r[3];t[o]=a||s,i=n.exec(e)}return t}function rk(e){return Object.entries(e).filter(function(e){var t=g(e,2)[1];return null!=t}).map(function(e){var t=g(e,2),n=t[0],i=t[1];return"".concat(n,'="').concat(i,'"')}).join(" ")}function ok(e){var t=e.nodeName,n=e.name,i=e.getContent,r=e.parseAttributes,o=void 0===r?ik:r,a=e.serializeAttributes,s=void 0===a?rk:a,c=e.defaultAttributes,l=void 0===c?{}:c,u=e.selfClosing,h=void 0!==u&&u,f=e.allowedAttributes,p=n||t,v=p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:function(e,n){var r=d(d({},l),e.attributes);if(h)return n.createNode(t,r);var o=i?i(e):e.content||"";return o?n.createNode(t,r,[n.createTextNode(o)]):n.createNode(t,r,[])},markdownTokenizer:{name:t,level:"inline",start:function(e){var t=h?new RegExp("\\[".concat(v,"\\s*[^\\]]*\\]")):new RegExp("\\[".concat(v,"\\s*[^\\]]*\\][\\s\\S]*?\\[\\/").concat(v,"\\]")),n=e.match(t),i=null==n?void 0:n.index;return void 0!==i?i:-1},tokenize:function(e,n,i){var r=h?new RegExp("^\\[".concat(v,"\\s*([^\\]]*)\\]")):new RegExp("^\\[".concat(v,"\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/").concat(v,"\\]")),a=e.match(r);if(a){var s="",c="";if(h){c=g(a,2)[1]}else{var l=g(a,3);c=l[1],s=l[2]||""}var u=o(c.trim());return{type:t,raw:a[0],content:s.trim(),attributes:u}}}},renderMarkdown:function(e){var t="";i?t=i(e):e.content&&e.content.length>0&&(t=e.content.filter(function(e){return"text"===e.type}).map(function(e){return e.text}).join(""));var n=function(e){if(!f)return e;var t={};return f.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),r=s(n),o=r?" ".concat(r):"";return h?"[".concat(p).concat(o,"]"):"[".concat(p).concat(o,"]").concat(t,"[/").concat(p,"]")}}}function ak(e,t,n){for(var i,r,o,a,s,c=e.split("\n"),l=[],u="",d=0,h=t.baseIndentSize||2,f=function(){var e=c[d],s=e.match(t.itemPattern);if(!s)return l.length>0?0:""===e.trim()?(d+=1,u="".concat(u).concat(e,"\n"),1):{v:void 0};var f=t.extractItemData(s),p=f.indentLevel,v=f.mainContent;u="".concat(u).concat(e,"\n");var m,g=[v];for(d+=1;d<c.length;){var y=c[d];if(""===y.trim()){var k=c.slice(d+1).findIndex(function(e){return""!==e.trim()});if(-1===k)break;var w=c[d+1+k];if(((null==(r=null==(i=w.match(/^(\s*)/))?void 0:i[1])?void 0:r.length)||0)>p){g.push(y),u="".concat(u).concat(y,"\n"),d+=1;continue}break}if(!(((null==(a=null==(o=y.match(/^(\s*)/))?void 0:o[1])?void 0:a.length)||0)>p))break;g.push(y),u="".concat(u).concat(y,"\n"),d+=1}var b=g.slice(1);if(b.length>0){var C=b.map(function(e){return e.slice(p+h)}).join("\n");C.trim()&&(m=t.customNestedParser?t.customNestedParser(C):n.blockTokens(C))}var S=t.createToken(f,m);l.push(S)};d<c.length&&0!==(s=f());)if(1!==s&&s)return s.v;if(0!==l.length)return{items:l,raw:u}}function sk(e,t,n,i){if(!e||!Array.isArray(e.content))return"";var r="function"==typeof n?n(i):n,o=function(e){return b(e)||l(e)||k(e)||y()}(e.content),a=o[0],s=o.slice(1),c=t.renderChildren([a]),u=["".concat(r).concat(c)];return s&&s.length>0&&s.forEach(function(e){var n=t.renderChildren([e]);if(n){var i=n.split("\n").map(function(e){return e?t.indent(e):""}).join("\n");u.push(i)}}),u.join("\n")}wm({},{createAtomBlockMarkdownSpec:function(){return tk},createBlockMarkdownSpec:function(){return nk},createInlineMarkdownSpec:function(){return ok},parseAttributes:function(){return Zy},parseIndentedBlocks:function(){return ak},renderNestedMarkdownContent:function(){return sk},serializeAttributes:function(){return ek}});var ck=function(t){function r(){var e;return C(this,r),(e=n(this,r,arguments)).type="node",e}return i(r,t),x(r,[{key:"configure",value:function(t){return e(r,"configure",this,3)([t])}},{key:"extend",value:function(t){var n="function"==typeof t?t():t;return e(r,"extend",this,3)([n])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r("function"==typeof e?e():e)}}])}(Dy),lk=ck.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:function(e,t){return e.content?t.renderChildren(e.content,"\n\n"):""}}),uk=lk;function dk(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Mh({view:function(t){return new hk(t,e)}})}var hk=function(){return x(function e(t,n){var i,r=this;C(this,e),this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(i=n.width)&&void 0!==i?i:1,this.color=!1===n.color?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(function(e){var n=function(t){r[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}})},[{key:"destroy",value:function(){var e=this;this.handlers.forEach(function(t){var n=t.name,i=t.handler;return e.editorView.dom.removeEventListener(n,i)})}},{key:"update",value:function(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}},{key:"setCursor",value:function(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}},{key:"updateOverlay",value:function(){var e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,i=this.editorView.dom,r=i.getBoundingClientRect(),o=r.width/i.offsetWidth,a=r.height/i.offsetHeight;if(n){var s=t.nodeBefore,c=t.nodeAfter;if(s||c){var l=this.editorView.nodeDOM(this.cursorPos-(s?s.nodeSize:0));if(l){var u=l.getBoundingClientRect(),d=s?u.bottom:u.top;s&&c&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);var h=this.width/2*a;e={left:u.left,right:u.right,top:d-h,bottom:d+h}}}}if(!e){var f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;e={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}var v,m,g=this.editorView.dom.offsetParent;if(this.element||(this.element=g.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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!g||g==document.body&&"static"==getComputedStyle(g).position)v=-pageXOffset,m=-pageYOffset;else{var y=g.getBoundingClientRect(),k=y.width/g.offsetWidth,w=y.height/g.offsetHeight;v=y.left-g.scrollLeft*k,m=y.top-g.scrollTop*w}this.element.style.left=(e.left-v)/o+"px",this.element.style.top=(e.top-m)/a+"px",this.element.style.width=(e.right-e.left)/o+"px",this.element.style.height=(e.bottom-e.top)/a+"px"}},{key:"scheduleRemoval",value:function(e){var t=this;clearTimeout(this.timeout),this.timeout=setTimeout(function(){return t.setCursor(null)},e)}},{key:"dragover",value:function(e){if(this.editorView.editable){var t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,r="function"==typeof i?i(this.editorView,t,e):i;if(t&&!r){var o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){var a=$d(this.editorView.state.doc,o,this.editorView.dragging.slice);null!=a&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}}},{key:"dragend",value:function(){this.scheduleRemoval(20)}},{key:"drop",value:function(){this.scheduleRemoval(20)}},{key:"dragleave",value:function(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}])}(),fk=function(e){function t(e){return C(this,t),n(this,t,[e,e])}return i(t,e),x(t,[{key:"map",value:function(e,n){var i=e.resolve(n.map(this.head));return t.valid(i)?new t(i):sh.near(i)}},{key:"content",value:function(){return pu.empty}},{key:"eq",value:function(e){return e instanceof t&&e.head==this.head}},{key:"toJSON",value:function(){return{type:"gapcursor",pos:this.head}}},{key:"getBookmark",value:function(){return new pk(this.anchor)}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}},{key:"valid",value:function(e){var t=e.parent;if(t.isTextblock||!function(e){for(var t=e.depth;t>=0;t--){var n=e.index(t),i=e.node(t);if(0!=n)for(var r=i.child(n-1);;r=r.lastChild){if(0==r.childCount&&!r.inlineContent||vk(r.type))return!0;if(r.inlineContent)return!1}else if(i.type.spec.isolating)return!0}return!0}(e)||!function(e){for(var t=e.depth;t>=0;t--){var n=e.indexAfter(t),i=e.node(t);if(n!=i.childCount)for(var r=i.child(n);;r=r.firstChild){if(0==r.childCount&&!r.inlineContent||vk(r.type))return!0;if(r.inlineContent)return!1}else if(i.type.spec.isolating)return!0}return!0}(e))return!1;var n=t.type.spec.allowGapCursor;if(null!=n)return n;var i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}},{key:"findGapCursorFrom",value:function(e,n){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e:for(;;){if(!i&&t.valid(e))return e;for(var r=e.pos,o=null,a=e.depth;;a--){var s=e.node(a);if(n>0?e.indexAfter(a)<s.childCount:e.index(a)>0){o=s.child(n>0?e.indexAfter(a):e.index(a)-1);break}if(0==a)return null;r+=n;var c=e.doc.resolve(r);if(t.valid(c))return c}for(;;){var l=n>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!fh.isSelectable(o)){e=e.doc.resolve(r+o.nodeSize*n),i=!1;continue e}break}o=l,r+=n;var u=e.doc.resolve(r);if(t.valid(u))return u}return null}}}])}(sh);fk.prototype.visible=!1,fk.findFrom=fk.findGapCursorFrom,sh.jsonID("gapcursor",fk);var pk=function(){function e(t){C(this,e),this.pos=t}return x(e,[{key:"map",value:function(t){return new e(t.map(this.pos))}},{key:"resolve",value:function(e){var t=e.resolve(this.pos);return fk.valid(t)?new fk(t):sh.near(t)}}])}();function vk(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}var mk=ym({ArrowLeft:gk("horiz",-1),ArrowRight:gk("horiz",1),ArrowUp:gk("vert",-1),ArrowDown:gk("vert",1)});function gk(e,t){var n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,i,r){var o=e.selection,a=t>0?o.$to:o.$from,s=o.empty;if(o instanceof dh){if(!r.endOfTextblock(n)||0==a.depth)return!1;s=!1,a=e.doc.resolve(t>0?a.after():a.before())}var c=fk.findGapCursorFrom(a,t,s);return!!c&&(i&&i(e.tr.setSelection(new fk(c))),!0)}}function yk(e,t,n){if(!e||!e.editable)return!1;var i=e.state.doc.resolve(t);if(!fk.valid(i))return!1;var r=e.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&fh.isSelectable(e.state.doc.nodeAt(r.inside)))&&(e.dispatch(e.state.tr.setSelection(new fk(i))),!0)}function kk(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof fk))return!1;var n=e.state.selection.$from,i=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!i)return!1;for(var r=cu.empty,o=i.length-1;o>=0;o--)r=cu.from(i[o].createAndFill(null,r));var a=e.state.tr.replace(n.pos,n.pos,new pu(r,0,0));return a.setSelection(dh.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function wk(e){if(!(e.selection instanceof fk))return null;var t=document.createElement("div");return t.className="ProseMirror-gapcursor",Ev.create(e.doc,[_v.widget(e.selection.head,t,{key:"gapcursor"})])}var bk=200,Ck=function(){};Ck.prototype.append=function(e){return e.length?(e=Ck.from(e),!this.length&&e||e.length<bk&&this.leafAppend(e)||this.length<bk&&e.leafPrepend(this)||this.appendInner(e)):this},Ck.prototype.prepend=function(e){return e.length?Ck.from(e).append(this):this},Ck.prototype.appendInner=function(e){return new xk(this,e)},Ck.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Ck.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ck.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ck.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Ck.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var i=[];return this.forEach(function(t,n){return i.push(e(t,n))},t,n),i},Ck.from=function(e){return e instanceof Ck?e:e&&e.length?new Sk(e):Ck.empty};var Sk=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,i){for(var r=t;r<n;r++)if(!1===e(this.values[r],i+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,i){for(var r=t-1;r>=n;r--)if(!1===e(this.values[r],i+r))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=bk)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=bk)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Ck);Ck.empty=new Sk([]);var xk=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,i){var r=this.left.length;return!(t<r&&!1===this.left.forEachInner(e,t,Math.min(n,r),i))&&(!(n>r&&!1===this.right.forEachInner(e,Math.max(t-r,0),Math.min(this.length,n)-r,i+r))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,i){var r=this.left.length;return!(t>r&&!1===this.right.forEachInvertedInner(e,t-r,Math.max(n,r)-r,i+r))&&(!(n<r&&!1===this.left.forEachInvertedInner(e,Math.min(t,r),n,i))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Ck),Tk=function(){function e(t,n){C(this,e),this.items=t,this.eventCount=n}return x(e,[{key:"popEvent",value:function(t,n){var i=this;if(0==this.eventCount)return null;for(var r,o,a=this.items.length;;a--){if(this.items.get(a-1).selection){--a;break}}n&&(r=this.remapping(a,this.items.length),o=r.maps.length);var s,c,l=t.tr,u=[],d=[];return this.items.forEach(function(t,n){if(!t.step)return r||(r=i.remapping(a,n+1),o=r.maps.length),o--,void d.push(t);if(r){d.push(new Mk(t.map));var h,f=t.step.map(r.slice(o));f&&l.maybeStep(f).doc&&(h=l.mapping.maps[l.mapping.maps.length-1],u.push(new Mk(h,void 0,void 0,u.length+d.length))),o--,h&&r.appendMap(h,o)}else l.maybeStep(t.step);return t.selection?(s=r?t.selection.map(r.slice(o)):t.selection,c=new e(i.items.slice(0,a).append(d.reverse().concat(u)),i.eventCount-1),!1):void 0},this.items.length,0),{remaining:c,transform:l,selection:s}}},{key:"addTransform",value:function(t,n,i,r){for(var o=[],a=this.eventCount,s=this.items,c=!r&&s.length?s.get(s.length-1):null,l=0;l<t.steps.length;l++){var u,d=t.steps[l].invert(t.docs[l]),h=new Mk(t.mapping.maps[l],d,n);(u=c&&c.merge(h))&&(h=u,l?o.pop():s=s.slice(0,s.length-1)),o.push(h),n&&(a++,n=void 0),r||(c=h)}var f=a-i.depth;return f>Nk&&(s=function(e,t){var n;return e.forEach(function(e,i){if(e.selection&&0==t--)return n=i,!1}),e.slice(n)}(s,f),a-=f),new e(s.append(o),a)}},{key:"remapping",value:function(e,t){var n=new bd;return this.items.forEach(function(t,i){var r=null!=t.mirrorOffset&&i-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,r)},e,t),n}},{key:"addMaps",value:function(t){return 0==this.eventCount?this:new e(this.items.append(t.map(function(e){return new Mk(e)})),this.eventCount)}},{key:"rebased",value:function(t,n){if(!this.eventCount)return this;var i=[],r=Math.max(0,this.items.length-n),o=t.mapping,a=t.steps.length,s=this.eventCount;this.items.forEach(function(e){e.selection&&s--},r);var c=n;this.items.forEach(function(e){var n=o.getMirror(--c);if(null!=n){a=Math.min(a,n);var r=o.maps[n];if(e.step){var l=t.steps[n].invert(t.docs[n]),u=e.selection&&e.selection.map(o.slice(c+1,n));u&&s++,i.push(new Mk(r,l,u))}else i.push(new Mk(r))}},r);for(var l=[],u=n;u<a;u++)l.push(new Mk(o.maps[u]));var d=new e(this.items.slice(0,r).append(l).append(i),s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-i.length)),d}},{key:"emptyItemCount",value:function(){var e=0;return this.items.forEach(function(t){t.step||e++}),e}},{key:"compress",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items.length,n=this.remapping(0,t),i=n.maps.length,r=[],o=0;return this.items.forEach(function(e,a){if(a>=t)r.push(e),e.selection&&o++;else if(e.step){var s=e.step.map(n.slice(i)),c=s&&s.getMap();if(i--,c&&n.appendMap(c,i),s){var l=e.selection&&e.selection.map(n.slice(i));l&&o++;var u,d=new Mk(c.invert(),s,l),h=r.length-1;(u=r.length&&r[h].merge(d))?r[h]=u:r.push(d)}}else e.map&&i--},this.items.length,0),new e(Ck.from(r.reverse()),o)}}])}();Tk.empty=new Tk(Ck.empty,0);var Mk=function(){function e(t,n,i,r){C(this,e),this.map=t,this.step=n,this.selection=i,this.mirrorOffset=r}return x(e,[{key:"merge",value:function(t){if(this.step&&t.step&&!t.selection){var n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}}])}(),_k=x(function e(t,n,i,r,o){C(this,e),this.done=t,this.undone=n,this.prevRanges=i,this.prevTime=r,this.prevComposition=o}),Nk=20;function Ok(e){for(var t=[],n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(function(e,n,i,r){return t.push(i,r)});return t}function Ek(e,t){if(!e)return null;for(var n=[],i=0;i<e.length;i+=2){var r=t.map(e[i],1),o=t.map(e[i+1],-1);r<=o&&n.push(r,o)}return n}var Ak=!1,Dk=null;function Ik(e){var t=e.plugins;if(Dk!=t){Ak=!1,Dk=t;for(var n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Ak=!0;break}}return Ak}var Lk=new Oh("history"),Rk=new Oh("closeHistory");function Pk(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Mh({key:Lk,state:{init:function(){return new _k(Tk.empty,Tk.empty,null,0,-1)},apply:function(t,n,i){return function(e,t,n,i){var r,o=n.getMeta(Lk);if(o)return o.historyState;n.getMeta(Rk)&&(e=new _k(e.done,e.undone,null,0,-1));var a=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(a&&a.getMeta(Lk))return a.getMeta(Lk).redo?new _k(e.done.addTransform(n,void 0,i,Ik(t)),e.undone,Ok(n.mapping.maps),e.prevTime,e.prevComposition):new _k(e.done,e.undone.addTransform(n,void 0,i,Ik(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||a&&!1===a.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new _k(e.done.rebased(n,r),e.undone.rebased(n,r),Ek(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new _k(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ek(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);var s=n.getMeta("composition"),c=0==e.prevTime||!a&&e.prevComposition!=s&&(e.prevTime<(n.time||0)-i.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;var n=!1;return e.mapping.maps[0].forEach(function(e,i){for(var r=0;r<t.length;r+=2)e<=t[r+1]&&i>=t[r]&&(n=!0)}),n}(n,e.prevRanges)),l=a?Ek(e.prevRanges,n.mapping):Ok(n.mapping.maps);return new _k(e.done.addTransform(n,c?t.selection.getBookmark():void 0,i,Ik(t)),Tk.empty,l,n.time,null==s?e.prevComposition:s)}(n,i,t,e)}},config:e,props:{handleDOMEvents:{beforeinput:function(e,t){var n=t.inputType,i="historyUndo"==n?Bk:"historyRedo"==n?Hk:null;return!(!i||!e.editable)&&(t.preventDefault(),i(e.state,e.dispatch))}}}})}function zk(e,t){return function(n,i){var r=Lk.getState(n);if(!r||0==(e?r.undone:r.done).eventCount)return!1;if(i){var o=function(e,t,n){var i=Ik(t),r=Lk.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,i);if(!o)return null;var a=o.selection.resolve(o.transform.doc),s=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),r,i),c=new _k(n?s:o.remaining,n?o.remaining:s,null,0,-1);return o.transform.setSelection(a).setMeta(Lk,{redo:n,historyState:c})}(r,n,e);o&&i(t?o.scrollIntoView():o)}return!0}}var Bk=zk(!1,!0),Hk=zk(!0,!0);By.create({name:"characterCount",addOptions:function(){return{limit:null,mode:"textSize",textCounter:function(e){return e.length},wordCounter:function(e){return e.split(" ").filter(function(e){return""!==e}).length}}},addStorage:function(){return{characters:function(){return 0},words:function(){return 0}}},onBeforeCreate:function(){var e=this;this.storage.characters=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc;if("textSize"===((null==t?void 0:t.mode)||e.options.mode)){var i=n.textBetween(0,n.content.size,void 0," ");return e.options.textCounter(i)}return n.nodeSize},this.storage.words=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc,i=n.textBetween(0,n.content.size," "," ");return e.options.wordCounter(i)}},addProseMirrorPlugins:function(){var e=this,t=!1;return[new Mh({key:new Oh("characterCount"),appendTransaction:function(n,i,r){if(!t){var o=e.options.limit;if(null!=o&&0!==o){var a=e.storage.characters({node:r.doc});if(a>o){var s=a-o;console.warn("[CharacterCount] Initial content exceeded limit of ".concat(o," characters. Content was automatically trimmed."));var c=r.tr.deleteRange(0,s);return t=!0,c}t=!0}else t=!0}},filterTransaction:function(t,n){var i=e.options.limit;if(!t.docChanged||0===i||null==i)return!0;var r=e.storage.characters({node:n.doc}),o=e.storage.characters({node:t.doc});if(o<=i)return!0;if(r>i&&o>i&&o<=r)return!0;if(r>i&&o>i&&o>r)return!1;if(!t.getMeta("paste"))return!1;var a=t.selection.$head.pos,s=a-(o-i),c=a;return t.deleteRange(s,c),!(e.storage.characters({node:t.doc})>i)}})]}}),By.create({name:"dropCursor",addOptions:function(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins:function(){return[dk(this.options)]}}),By.create({name:"focus",addOptions:function(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins:function(){var e=this;return[new Mh({key:new Oh("focus"),props:{decorations:function(t){var n=t.doc,i=t.selection,r=e.editor,o=r.isEditable,a=r.isFocused,s=i.anchor,c=[];if(!o||!a)return Ev.create(n,[]);var l=0;"deepest"===e.options.mode&&n.descendants(function(e,t){if(!e.isText){if(!(s>=t&&s<=t+e.nodeSize-1))return!1;l+=1}});var u=0;return n.descendants(function(t,n){return!t.isText&&(s>=n&&s<=n+t.nodeSize-1&&(u+=1,"deepest"===e.options.mode&&l-u>0||"shallowest"===e.options.mode&&u>1?"deepest"===e.options.mode:void c.push(_v.node(n,n+t.nodeSize,{class:e.options.className}))))}),Ev.create(n,c)}}})]}}),By.create({name:"gapCursor",addProseMirrorPlugins:function(){return[new Mh({props:{decorations:wk,createSelectionBetween:function(e,t,n){return t.pos==n.pos&&fk.valid(n)?new fk(n):null},handleClick:yk,handleKeyDown:mk,handleDOMEvents:{beforeinput:kk}}})]},extendNodeSchema:function(e){var t;return{allowGapCursor:null!=(t=Rg(Ag(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))?t:null}}});var Fk=By.create({name:"placeholder",addOptions:function(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins:function(){var e=this;return[new Mh({key:new Oh("placeholder"),props:{decorations:function(t){var n=t.doc,i=t.selection,r=e.editor.isEditable||!e.options.showOnlyWhenEditable,o=i.anchor,a=[];if(!r)return null;var s=e.editor.isEmpty;return n.descendants(function(t,n){var i=o>=n&&o<=n+t.nodeSize,r=!t.isLeaf&&ey(t);if((i||!e.options.showOnlyCurrent)&&r){var c=[e.options.emptyNodeClass];s&&c.push(e.options.emptyEditorClass);var l=_v.node(n,n+t.nodeSize,{class:c.join(" "),"data-placeholder":"function"==typeof e.options.placeholder?e.options.placeholder({editor:e.editor,node:t,pos:n,hasAnchor:i}):e.options.placeholder});a.push(l)}return e.options.includeChildren}),Ev.create(n,a)}}})]}});function jk(e){var t=e.types,n=e.node;return n&&Array.isArray(t)&&t.includes(n.type)||(null==n?void 0:n.type)===t}By.create({name:"selection",addOptions:function(){return{className:"selection"}},addProseMirrorPlugins:function(){var e=this.editor,t=this.options;return[new Mh({key:new Oh("selection"),props:{decorations:function(n){return n.selection.empty||e.isFocused||!e.isEditable||n.selection instanceof fh||e.view.dragging?null:Ev.create(n.doc,[_v.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}}),By.create({name:"trailingNode",addOptions:function(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins:function(){var e,t=this,n=new Oh(this.name),i=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(function(e){return g(e,2)[1]}).filter(function(e){return(t.options.notAfter||[]).concat(i).includes(e.name)});return[new Mh({key:n,appendTransaction:function(e,t,r){var o=r.doc,a=r.tr,s=r.schema,c=n.getState(r),l=o.content.size,u=s.nodes[i];if(c)return a.insert(l,u.create())},state:{init:function(e,t){return!jk({node:t.tr.doc.lastChild,types:r})},apply:function(e,t){return e.docChanged?e.getMeta("__uniqueIDTransaction")?t:!jk({node:e.doc.lastChild,types:r}):t}}})]}});var Vk=By.create({name:"undoRedo",addOptions:function(){return{depth:100,newGroupDelay:500}},addCommands:function(){return{undo:function(){return function(e){var t=e.state,n=e.dispatch;return Bk(t,n)}},redo:function(){return function(e){var t=e.state,n=e.dispatch;return Hk(t,n)}}}},addProseMirrorPlugins:function(){return[Pk(this.options)]},addKeyboardShortcuts:function(){var e=this;return{"Mod-z":function(){return e.editor.commands.undo()},"Shift-Mod-z":function(){return e.editor.commands.redo()},"Mod-y":function(){return e.editor.commands.redo()},"Mod-я":function(){return e.editor.commands.undo()},"Shift-Mod-я":function(){return e.editor.commands.redo()}}}}),Wk=Fk,$k=ck.create({name:"text",group:"inline",parseMarkdown:function(e){return{type:"text",text:e.text||""}},renderMarkdown:function(e){return e.text||""}}),Uk=ck.create({name:"paragraph",priority:1e3,addOptions:function(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML:function(){return[{tag:"p"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["p",Bg(this.options.HTMLAttributes,t),0]},parseMarkdown:function(e,t){var n=e.tokens||[];return 1===n.length&&"image"===n[0].type?t.parseChildren([n[0]]):t.createNode("paragraph",void 0,t.parseInline(n))},renderMarkdown:function(e,t){return e&&Array.isArray(e.content)?t.renderChildren(e.content):""},addCommands:function(){var e=this;return{setParagraph:function(){return function(t){return t.commands.setNode(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Alt-0":function(){return e.editor.commands.setParagraph()}}}}),qk=Uk,Kk=ck.create({name:"hardBreak",markdownTokenName:"br",addOptions:function(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:function(){return[{tag:"br"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["br",Bg(this.options.HTMLAttributes,t)]},renderText:function(){return"\n"},renderMarkdown:function(){return" \n"},parseMarkdown:function(){return{type:"hardBreak"}},addCommands:function(){var e=this;return{setHardBreak:function(){return function(t){var n=t.commands,i=t.chain,r=t.state,o=t.editor;return n.first([function(){return n.exitCode()},function(){return n.command(function(){var t=r.selection,n=r.storedMarks;if(t.$from.parent.type.spec.isolating)return!1;var a=e.options.keepMarks,s=o.extensionManager.splittableMarks,c=n||t.$to.parentOffset&&t.$from.marks();return i().insertContent({type:e.name}).command(function(e){var t=e.tr;if(e.dispatch&&c&&a){var n=c.filter(function(e){return s.includes(e.type.name)});t.ensureMarks(n)}return!0}).run()})}])}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Enter":function(){return e.editor.commands.setHardBreak()},"Shift-Enter":function(){return e.editor.commands.setHardBreak()}}}}),Jk=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Gk=ck.create({name:"image",addOptions:function(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline:function(){return this.options.inline},group:function(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:function(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML:function(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML:function(e){var t=e.HTMLAttributes;return["img",Bg(this.options.HTMLAttributes,t)]},parseMarkdown:function(e,t){return t.createNode("image",{src:e.href,title:e.title,alt:e.text})},renderMarkdown:function(e){var t,n,i,r,o,a,s=null!=(n=null==(t=e.attrs)?void 0:t.src)?n:"",c=null!=(r=null==(i=e.attrs)?void 0:i.alt)?r:"",l=null!=(a=null==(o=e.attrs)?void 0:o.title)?a:"";return l?"![".concat(c,"](").concat(s,' "').concat(l,'")'):"![".concat(c,"](").concat(s,")")},addNodeView:function(){var e=this;if(!this.options.resize||!this.options.resize.enabled||"undefined"==typeof document||!this.editor.isEditable)return null;var t=this.options.resize,n=t.directions,i=t.minWidth,r=t.minHeight,o=t.alwaysPreserveAspectRatio;return function(t){var a=t.node,s=t.getPos,c=t.HTMLAttributes,l=document.createElement("img");Object.entries(c).forEach(function(e){var t=g(e,2),n=t[0],i=t[1];if(null!=i)switch(n){case"width":case"height":break;default:l.setAttribute(n,i)}}),l.src=c.src;var u=new Qy({element:l,node:a,getPos:s,onResize:function(e,t){l.style.width="".concat(e,"px"),l.style.height="".concat(t,"px")},onCommit:function(t,n){var i=s();void 0!==i&&e.editor.chain().setNodeSelection(i).updateAttributes(e.name,{width:t,height:n}).run()},onUpdate:function(e,t,n){return e.type===a.type},options:{directions:n,min:{width:i,height:r},preserveAspectRatio:!0===o}}),d=u.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",l.onload=function(){d.style.visibility="",d.style.pointerEvents=""},u}},addCommands:function(){var e=this;return{setImage:function(t){return function(n){return n.commands.insertContent({type:e.name,attrs:t})}}}},addInputRules:function(){return[(e={find:Jk,type:this.type,getAttributes:function(e){var t=g(e,5),n=t[2];return{src:t[3],alt:n,title:t[4]}}},new Ny({find:e.find,handler:function(t){var n=t.state,i=t.range,r=t.match,o=Rg(e.getAttributes,void 0,r)||{},a=n.tr,s=i.from,c=i.to,l=e.type.create(o);if(r[1]){var u=s+r[0].lastIndexOf(r[1]);u>c?u=c:c=u+r[1].length;var d=r[0][r[0].length-1];a.insertText(d,s+r[0].length-1),a.replaceWith(u,c,l)}else if(r[0]){var h=e.type.isInline?s:s-1;a.insert(h,e.type.create(o)).delete(a.mapping.map(s),a.mapping.map(c))}a.scrollIntoView()},undoable:e.undoable}))];var e}}),Yk=Gk,Xk=By.create({name:"fileHandler",addOptions:function(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins:function(){return[(e={key:new Oh(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste},t=e.key,n=e.editor,i=e.onPaste,r=e.onDrop,o=e.allowedMimeTypes,new Mh({key:t||new Oh("fileHandler"),props:{handleDrop:function(e,t){var i;if(!r)return!1;if(!(null==(i=t.dataTransfer)?void 0:i.files.length))return!1;var a=e.posAtCoords({left:t.clientX,top:t.clientY}),s=Array.from(t.dataTransfer.files);return o&&(s=s.filter(function(e){return o.includes(e.type)})),0!==s.length&&(t.preventDefault(),t.stopPropagation(),r(n,s,(null==a?void 0:a.pos)||0),!0)},handlePaste:function(e,t){var r;if(!i)return!1;if(!(null==(r=t.clipboardData)?void 0:r.files.length))return!1;var a=Array.from(t.clipboardData.files),s=t.clipboardData.getData("text/html");return o&&(a=a.filter(function(e){return o.includes(e.type)})),0!==a.length&&(t.preventDefault(),t.stopPropagation(),i(n,a,s),!(s.length>0))}}}))];var e,t,n,i,r,o}}),Qk=new ra("chat-editor"),Zk=hl(function(e,t){var n=e.c,i=e.value,r=e.disabled,o=e.placeholder,a=e.onChange,s=e.onKeyDown,c=e.onCreate,l=qa(null),u=qa(null),d=Ds(!1),f=function(){n.inputExpand.value||requestAnimationFrame(function(){if(l.current){var e=l.current.view.dom;d.value=e.scrollHeight>e.clientHeight}})},p=function(e){n.inputExpand.value=e,e||f()};return $a(function(){var e=function(e){var t;null===(t=l.current)||void 0===t||t.commands.setContent(e)};return n.evt.on("onSetInput",e),function(){n.evt.off("onSetInput",e)}},[]),$a(function(){if(u.current){var e,t,r=function(){var e=v(h().m(function e(t){var i,r;return h().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n.opts.uploader.onUpload(t,function(){},{context:n.context,params:n.params});case 1:if(i=e.v){e.n=2;break}return e.a(2,{name:"",url:""});case 2:return r=n.opts.uploader.getDownLoadUrl(i,{context:n.context,params:n.params}),e.a(2,{name:i.name,url:r})}},e)}));return function(t){return e.apply(this,arguments)}}(),d=new Xy({element:u.current,extensions:[uk,$k.extend({addKeyboardShortcuts:function(){return{"Mod-Enter":function(){var e,t;return null===(e=l.current)||void 0===e||e.commands.enter(),null===(t=l.current)||void 0===t||t.commands.scrollIntoView(),!0},"Shift-Enter":function(){var e,t;return null===(e=l.current)||void 0===e||e.commands.setHardBreak(),null===(t=l.current)||void 0===t||t.commands.scrollIntoView(),!0}}}}),qk,Kk,Vk,Wk.configure({placeholder:o,showOnlyWhenEditable:!0,showOnlyCurrent:!1}),Yk.configure({inline:!0,allowBase64:!0,HTMLAttributes:{draggable:"false"}}).extend({draggable:!1}),Xk.configure({onDrop:(t=v(h().m(function e(t,n){var i;return h().w(function(e){for(;;)switch(e.n){case 0:if((n=n.filter(function(e){return e.type.startsWith("image/")})).length){e.n=1;break}return e.a(2);case 1:return e.n=2,Promise.all(n.map(function(e){return r(e)}));case 2:if(i=e.v,!t.isDestroyed){e.n=3;break}return e.a(2);case 3:t.chain().deleteSelection().insertContentAt(t.state.selection.from,i.map(function(e){return{type:"image",attrs:{src:e.url,alt:e.name}}})).focus().scrollIntoView().run();case 4:return e.a(2)}},e)})),function(e,n){return t.apply(this,arguments)}),onPaste:(e=v(h().m(function e(t,n){var i;return h().w(function(e){for(;;)switch(e.n){case 0:if((n=n.filter(function(e){return e.type.startsWith("image/")})).length){e.n=1;break}return e.a(2);case 1:return e.n=2,Promise.all(n.map(function(e){return r(e)}));case 2:if(i=e.v,!t.isDestroyed){e.n=3;break}return e.a(2);case 3:t.chain().deleteSelection().insertContentAt(t.state.selection.from,i.map(function(e){return{type:"image",attrs:{src:e.url,alt:e.name}}})).focus().scrollIntoView().run();case 4:return e.a(2)}},e)})),function(t,n){return e.apply(this,arguments)})})],content:i||"",editorProps:{handleKeyDown:function(e,t){return s(t)}},onUpdate:function(){!function(e){a(e),f()}(d.getHTML())},onCreate:function(){c(d)}});return l.current=d,function(){l.current&&(l.current.destroy(),l.current=null)}}},[]),Ka(t,function(){return{toggleCollapse:p}}),na("div",{className:"".concat(Qk.b()," ").concat(r?Qk.m("disabled"):""," ").concat(Qk.is("has-scrollbar",d.value)),children:[na("div",{ref:u,className:Qk.e("content")}),n.inputExpand.value?na("div",{title:$c.t.value("exitFullscreen"),className:Qk.e("collapse"),onClick:function(){return p(!1)},children:na(js,{})}):na("div",{title:$c.t.value("fullscreen"),className:Qk.e("collapse"),onClick:function(){return p(!0)},children:na(Fs,{})})]})}),ew=new ra("user-message-question"),tw=function(e){var t=Ds(null),n=Ds(135),i=Ds(!0),r=Ds(!1),o=qa(null),a=Ja(function(){return ba.parseMixedContent(e.message.content)},[e.message.content]),c=Ds({resources:[],remainingText:"",hasResources:!1});c.value=a;var l=g(Wa(!1),2),u=l[0];(0,l[1])(!0===e.message.reeditstate),u&&t.value&&(t.value.destroy(),t.value=null);var d=qa(null);$a(function(){!function(){if(!t.value&&!u){var e=Na.protect(c.value.remainingText||"");t.value=new s({el:o.current,value:e,editor:{defaultModel:"previewOnly",codemirror:{autofocus:!1}},previewer:{enablePreviewerBubble:!1},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}}})}}()},[c.value.remainingText,u]),$a(function(){if(o.current&&window.ResizeObserver){var e=new ResizeObserver(function(){var e,i=null===(e=t.value)||void 0===e?void 0:e.previewer.options.previewerDom;i&&(r.value=i.scrollHeight>n.value)});return e.observe(o.current),function(){e.disconnect()}}},[o.current]);return na("div",{className:ew.b(),children:[na("div",{className:ew.e("user-header"),children:[e.children,na("div",{className:ew.e("user"),children:$c.t.value("me")})]}),na("div",{className:ew.e("content"),children:[40===e.message.state&&na("div",{className:ew.em("content","warning-container"),onClick:function(t){e.message&&e.controller&&e.controller.refreshMessage(e.message,!0)},children:na("div",{className:ew.em("content","warning"),children:[na("div",{className:"warning-icon",title:$c.t.value("retry"),children:na(mc,{})}),na("div",{className:"refresh-icon",title:$c.t.value("retry"),children:na(Bs,{})})]})}),na("div",!0===u?{className:ew.em("content","re-edit-body"),children:[na(Zk,{c:e.controller,value:e.controller.reEditContent.value,disabled:e.controller.isLoading.value,onCreate:function(e){d.current=e,e.commands.focus("end")},onChange:function(t){!function(t){e.controller.reEditContent.value=t,e.controller.reEditContentChanged.value=!0}(t)},onKeyDown:function(t){return function(t){return"Escape"===t.code&&"Escape"===t.key&&!0===e.message.reeditstate?(t.stopPropagation(),e.controller.reEditCancel(e.message),!0):"Enter"===t.code&&"Enter"===t.key&&!1===t.shiftKey?(e.controller.reEditContentChanged.value&&setTimeout(function(){e.controller.reEditSubmit(e.message)},0),t.stopPropagation(),!0):void 0}(t)}}),na("div",{className:ew.em("content","re-edit-btns"),children:[na("div",{className:"".concat(ew.em("content","re-edit-btn")," ").concat(ew.em("content","cancel-btn")),onClick:function(t){!function(t){t.stopPropagation(),e.controller.reEditCancel(e.message)}(t)},children:$c.t.value("cancel")}),na("div",{className:"".concat(ew.em("content","re-edit-btn")," ").concat(ew.em("content","send-btn")," ").concat(ew.is("disabled ",!e.controller.reEditContentChanged.value)),onClick:function(t){!function(t){e.controller.reEditContentChanged.value&&(t.stopPropagation(),e.controller.reEditSubmit(e.message))}(t)},children:$c.t.value("send")})]})]}:{className:ew.em("content","body"),children:[c.value.hasResources&&na("div",{className:ew.em("content","material"),children:c.value.resources.map(function(t){return na(nu,{material:t,disabled:!0,controller:e.controller},t.id)})}),na("div",{className:"pre-wrap-container",children:[na("div",{className:"".concat(ew.e("text-content")," ").concat(ew.is("collapse",i.value)),ref:o,style:{maxHeight:i.value?"".concat(n.value,"px"):""}}),na("div",{className:"".concat(ew.e("collapse-btn")," ").concat(ew.is("visible",r.value)),title:i.value?$c.t.value("expand"):$c.t.value("foldUp"),onClick:function(){i.value=!i.value},children:i.value?na("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",children:na("path",{fill:"currentColor",d:"M104.704 338.752a64 64 0 0 1 90.496 0l316.8 316.8 316.8-316.8a64 64 0 0 1 90.496 90.496L557.248 791.296a64 64 0 0 1-90.496 0L104.704 429.248a64 64 0 0 1 0-90.496"})}):na("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",children:na("path",{fill:"currentColor",d:"M104.704 685.248a64 64 0 0 0 90.496 0l316.8-316.8 316.8 316.8a64 64 0 0 0 90.496-90.496L557.248 232.704a64 64 0 0 0-90.496 0L104.704 594.752a64 64 0 0 0 0 90.496"})})})]})]})]})]})},nw=new ra("error-message"),iw=function(e){var t=e.message,n=e.size,i=g(Wa(!0),2),r=i[0],o=i[1],a=Ds(la()),c=Ds(null),l=Ds({resources:[],remainingText:"",hasResources:!1}),u=function(e){var t=ba.parseMixedContent(e),n=t.resources,i=t.remainingText,r=t.hasResources,o=t.error;l.value={resources:n,remainingText:i,hasResources:r,error:o}};t.think||(t.think={title:"",description:"",collapse:!0});var h=function(e,n){t.think=d(d({},t.think),{},{title:e?$c.t.value("thinkThrough"):!0===t.completed?$c.t.value("stopThinking"):$c.t.value("thinking"),description:n||"",done:e||!0===t.completed}),t.think.done||(t.think.beginTime||(t.think.beginTime=Date.now()),t.think.endTime=void 0),t.think.done&&!t.think.endTime&&(t.think.endTime=Date.now(),t.think.collapse=!0)},f=function(e){var t=e.indexOf("<think>"),n=e.indexOf("</think>"),i="",r="",o=!1;return-1===n?(o=!1,i=e.slice(t+7),r=""):(o=!0,i=e.slice(t+7,n),r=e.slice(n+8)),{isThoughtCompleted:o,thoughtContent:i,answerContent:r}},p=function(t){var n=t.target,i=null==n?void 0:n.closest('a[href^="chunkview://"], a[href^="view://"], a[href^="action://"]');if(i){t.preventDefault();var r=i.getAttribute("href");if(r){var o="";switch(r.startsWith("chunkview://")?o="chunkview":r.startsWith("view://")?o="view":r.startsWith("action://")&&(o="action"),o){case"chunkview":case"view":case"action":e.controller.handlePredefinedClick(o,r,e.message,t);break;default:console.error($c.t.value("protocol",{protocol:o}))}}return!1}};$a(function(){if(n>=0&&c.value){if(t.content&&-1!==t.content.indexOf("<think>")){var e=f(t.content),i=e.isThoughtCompleted,r=e.thoughtContent,o=e.answerContent;h(i,r),u(o)}else u(t.content);c.value.setMarkdown(l.value.remainingText||"")}},[t,n]),$a(function(){var e;if(t.content&&-1!==t.content.indexOf("<think>")){var n=f(t.content),i=n.isThoughtCompleted,r=n.thoughtContent,o=n.answerContent;h(i,r),o&&u(o)}else u(t.content);e=l.value.remainingText,c.value=new s({id:a,value:e||"",editor:{defaultModel:"previewOnly",codemirror:{autofocus:!1}},themeSettings:{mainTheme:"dark",codeBlockTheme:"dark"},previewer:{enablePreviewerBubble:!1},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}},callback:{onClickPreview:p}})},[]);var v=Ja(function(){return t.errorText||$c.t.value("unknownError")},[t.errorText]);return na("div",{className:nw.b(),children:[na("div",{className:nw.b("header"),children:[na("div",{className:nw.be("header","caption"),children:"AI "}),e.children]}),na("div",{className:"".concat(nw.b("content")," pre-wrap-container"),children:[l.value.hasResources&&na("div",{className:"content-material-container",children:l.value.resources.map(function(t){return na(nu,{material:t,disabled:!0,controller:e.controller},t.id)})}),t.chatsteps&&t.chatsteps.length>0&&na(Yl,{items:t.chatsteps||[],controller:e.controller,onLinkClick:p}),na(Qc,{toolcallCompleted:!!t.toolcallcompleted,items:t.toolcalls||[],controller:e.controller,onLinkClick:p}),na(Uc,{item:t.think,controller:e.controller}),na("div",{id:a})]}),r&&v&&na("div",{className:"".concat(nw.b("footer")),children:[na("div",{className:"".concat(nw.be("footer","close")),onClick:function(){o(!1)},children:na(Ls,{})}),na("div",{className:"".concat(nw.be("footer","text")),children:v})]})]})},rw=new ra("unknown-message"),ow=function(e){return na("div",{className:rw.b(),children:na("div",{className:"".concat(rw.e("content")," pre-wrap-container"),children:$c.t.value("unsupportedMessageType",{type:e.message.type})})})},aw=new ra("chat-message-item"),sw=function(e){var t=e.message,n=e.size,i=null;switch(t.type){case"DEFAULT":i="ASSISTANT"===t.role?ru:tw;break;case"ERROR":i=iw;break;default:i=ow}return na("div",{className:aw.b(),children:Eo(i,{size:n,message:t,controller:e.controller,children:e.children})})},cw=function(){return x(function e(t){C(this,e),T(this,"toolcallcompleted",!0),T(this,"toolcalls",[]),T(this,"chatsteps",[]),T(this,"chatuiactions",[]),T(this,"think",void 0),T(this,"usage",void 0),T(this,"reeditstate",!1),T(this,"allcontent",""),this.msg=t,this.toolcalls=t.toolcalls||[],this.chatsteps=t.chatsteps||[],this.chatuiactions=t.chatuiactions||[],this.allcontent=t.content,this.usage=t.usage,this.think=t.think||void 0},[{key:"messageid",get:function(){return this.msg.messageid}},{key:"state",get:function(){return this.msg.state}},{key:"role",get:function(){return this.msg.role}},{key:"type",get:function(){return this.msg.type}},{key:"status",get:function(){return this.msg.status}},{key:"realcontent",get:function(){var e=this.msg.content;if(-1!==e.indexOf("<think>")&&-1===e.indexOf("</think>"))return"";if(-1!==(e=e.replace(/<think>[^]*?<\/think>/g,"").trim()).indexOf("<chatstep>")&&-1===e.indexOf("</chatstep>"))return"";if(-1!==(e=e.replace(/<chatstep>[^]*?<\/chatstep>/g,"").trim()).indexOf("<tool_call>")&&-1===e.indexOf("</tool_call>"))return"";if(-1!==(e=e.replace(/<tool_call>[^]*?<\/tool_call>/g,"").trim()).indexOf("<resources>")&&-1===e.indexOf("</resources>"))return"";var t=(e=e.replace(/<resources>[^]*?<\/resources>/g,"").trim()).indexOf("<suggestions>");-1!==t&&(e=e.substring(0,t).trim());var n=e.indexOf("<chatuiaction>");return-1!==n&&(e=e.substring(0,n).trim()),e}},{key:"errorText",get:function(){return this.msg.errorText}},{key:"content",get:function(){return this.msg.content}},{key:"completed",get:function(){return this.msg.completed}},{key:"suggestions",get:function(){return this.msg.suggestions}},{key:"_origin",get:function(){return this.msg}},{key:"islike",get:function(){return this.msg.islike}},{key:"isdislike",get:function(){return this.msg.isdislike}},{key:"feedbackcontent",get:function(){return this.msg.feedbackcontent}},{key:"realmessageid",get:function(){return this.msg.realmessageid}},{key:"metadata",get:function(){return this.msg.metadata}},{key:"agent_tag",get:function(){return this.msg.agent_tag}},{key:"create_time",get:function(){return this.msg.create_time},set:function(e){this.msg.create_time=e}},{key:"update",value:function(e){var t="USER"===e.role;if(e.content||(e.content=""),this.allcontent+=e.content,e.content&&-1!==e.content.indexOf("<think>")&&this.msg.content&&!t&&(this.msg.content=""),this.msg.content+=e.content,!t){-1===this.msg.content.indexOf("<tool_call>")&&-1===this.msg.content.indexOf("</tool_call>")||(this.msg.content=""),this.computeToolCalls();var n=this.msg.content.indexOf("<chatstep>"),i=this.msg.content.indexOf("</chatstep>");-1===n&&-1===i||(this.msg.content=-1!==n&&-1!==i?this.msg.content.replace(/<chatstep>[^]*?<\/chatstep>/g,""):""),this.computeChatSteps();var r=this.msg.content.indexOf("<chatuiaction>"),o=this.msg.content.indexOf("</chatuiaction>");-1===r&&-1===o||(this.msg.content=-1!==r&&-1!==o?this.msg.content.replace(/<chatuiaction>[^]*?<\/chatuiaction>/g,""):""),this.computeChatUIActions()}}},{key:"replace",value:function(e){this.msg=e}},{key:"updateCompleted",value:function(e){this.msg.completed=e,this.toolcallcompleted=e}},{key:"computeToolCalls",value:function(){var e=Ta.parse(this.allcontent),t=e.completed,n=e.toolCalls;this.toolcallcompleted=t,this.toolcalls=n}},{key:"computeChatSteps",value:function(){this.chatsteps=Ma.parse(this.allcontent)}},{key:"computeChatUIActions",value:function(){this.chatuiactions=_a.parse(this.allcontent)}}])}(),lw=function(){return x(function e(t){C(this,e),this.data=t},[{key:"appid",get:function(){return this.data.appid}},{key:"id",get:function(){return this.data.id}},{key:"type",get:function(){return this.data.type}},{key:"caption",get:function(){return this.data.caption}},{key:"sourceCaption",get:function(){return this.data.sourceCaption}},{key:"url",get:function(){return this.data.url}},{key:"aiChat",get:function(){return this.data.aiChat}},{key:"captionMode",get:function(){return this.data.captionMode}},{key:"realid",get:function(){return this.data.realid}},{key:"sequence",get:function(){return this.data.sequence}},{key:"isTop",get:function(){return this.data.isTop}},{key:"isShow",get:function(){var e;return null===(e=this.data.isShow)||void 0===e||e}},{key:"disableStorage",get:function(){return this.data.disableStorage||!1}},{key:"captionComputed",get:function(){return this.data.captionComputed||!1}},{key:"scope",get:function(){return this.data.scope}},{key:"groupid",get:function(){return this.data.groupid}}])}(),uw=function(){return x(function e(t){C(this,e),this.material=t},[{key:"id",get:function(){return this.material.id}},{key:"type",get:function(){return this.material.type}},{key:"metadata",get:function(){return this.material.metadata}},{key:"data",get:function(){return this.material.data}}])}(),dw=function(){return x(function e(t,n){C(this,e),this.agent=t,this.defaultConfig=n},[{key:"id",get:function(){return this.agent.id}},{key:"caption",get:function(){return this.agent.caption}},{key:"default",get:function(){return this.agent.default}},{key:"order",get:function(){return this.agent.order}},{key:"value",get:function(){return this.agent.id}},{key:"label",get:function(){return this.agent.caption}},{key:"knowledge_bases",get:function(){return this.agent.knowledge_bases}},{key:"allow_any_knowledge_base",get:function(){return this.agent.allow_any_knowledge_base}},{key:"rerank",get:function(){return this.agent.rerank||this.defaultConfig.chunkrerank}},{key:"maxchunks",get:function(){return this.agent.maxchunks||this.defaultConfig.maxchunks}},{key:"chunkthreshold",get:function(){return this.agent.chunkthreshold||this.defaultConfig.chunkthreshold}},{key:"chunkpageindex",get:function(){return this.agent.chunkpageindex||this.defaultConfig.chunkpageindex}},{key:"flow_mode",get:function(){return this.agent.flow_mode}}])}(),hw=function(){return x(function e(t){C(this,e),this.knowledgeBase=t},[{key:"id",get:function(){return this.knowledgeBase.id}},{key:"name",get:function(){return this.knowledgeBase.name}},{key:"value",get:function(){return this.knowledgeBase.id}},{key:"label",get:function(){return this.knowledgeBase.name}}])}(),fw=new ra("chat-toolbar-item"),pw=function(e){var t,n,i,r=e.model,o=e.data,a=e.className,s=e.disabled,c=void 0!==s&&s,l=e.buttonType,u=void 0===l?"default":l,d=e.onClick,h=g(Wa(!1),2),f=h[0],p=h[1],v=qa(null),m=function(e){return"function"==typeof e.hidden?e.hidden(o):!0===e.hidden};if(m(r))return na(Do,{});var y=function(e){return!!c||("function"==typeof e.disabled?e.disabled(o):!0===e.disabled)},k=function(e){var t,n,i,r;return"function"==typeof e.icon?e.icon():null!==(t=e.icon)&&void 0!==t&&t.showIcon&&null!==(n=e.icon)&&void 0!==n&&n.cssClass?na("i",{className:e.icon.cssClass}):null!==(i=e.icon)&&void 0!==i&&i.showIcon&&null!==(r=e.icon)&&void 0!==r&&r.imagePath?ha(e.icon.imagePath)?na("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):na("img",{src:e.icon.imagePath}):void 0},w=function(e,t){y(t)||(p(!1),d(e,t))};return $a(function(){var e=function(e){v.current&&v.current.contains(e.target)||p(!1)};return f&&document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[f]),na("div",{className:"".concat(fw.b()," ").concat(fw.b(u)," ").concat(r.customClass||""," ").concat(a||""," ").concat(fw.is("disabled",y(r))," ").concat(fw.is("more",!(null===(t=r.children)||void 0===t||!t.length))),children:[na("div",{title:r.title,className:fw.e("content"),onClick:function(e){return w(e,r)},children:[na("div",{className:fw.em("content","icon"),children:k(r)}),na("div",{className:fw.em("content","label"),children:r.label})]}),(null===(n=r.children)||void 0===n?void 0:n.length)&&na("div",{title:$c.t.value("more"),className:fw.e("more"),onClick:function(e){y(r)||p(!0)},children:na("i",{"aria-hidden":"true",className:"fa fa-angle-down ".concat(fw.em("more","icon"))})}),f&&na("div",{ref:v,className:fw.b("dropdown"),children:null===(i=r.children)||void 0===i?void 0:i.map(function(e,t){if(!m(e))return na("div",{title:e.title,onClick:function(t){return w(t,e)},className:"".concat(fw.be("dropdown","item")," ").concat(e.customClass||""," ").concat(fw.is("disabled",y(e))),children:[na("div",{className:fw.bem("dropdown","item","icon"),children:k(e)}),na("div",{className:fw.bem("dropdown","item","label"),children:e.label})]},t)})})]})},vw=new ra("chat-toolbar"),mw=function(e){var t=e.controller,n=e.items,i=void 0===n?[]:n,r=e.data,o=e.type,a=e.className,s=e.style,l=Ya(cb),u=[],h=[{label:$c.t.value("resetConversation"),title:$c.t.value("resetConversation"),icon:function(){return na(oc,{})},onClick:function(){t.resetTopicMessage()},children:[{label:$c.t.value("clearConversation"),title:$c.t.value("clearConversation"),icon:function(){return na(rc,{})},onClick:function(){t.clearTopicMessage()}}]}],f=[{label:$c.t.value("refresh"),title:$c.t.value("refresh"),icon:function(){return na(Bs,{})},onClick:function(){t.refreshMessage(r)}},{label:$c.t.value("delete"),title:$c.t.value("delete"),hidden:function(){return!r.realmessageid},icon:function(){return na(zs,{})},onClick:function(){t.deleteMessage(r)}}];l.enableBackFill&&f.unshift.apply(f,[{label:$c.t.value("backfill"),title:$c.t.value("backfill"),icon:function(){return na(Rs,{})},onClick:function(){t.backfill(r)}}]);var p=[{label:$c.t.value("refresh"),title:$c.t.value("refresh"),icon:function(){return na(Bs,{})},hidden:function(){return!!t.reEditContent.value},onClick:function(){t.refreshMessage(r,!0)}},{label:$c.t.value("reedit"),title:$c.t.value("reedit"),icon:function(){return na(Ac,{})},hidden:function(){return!!t.reEditContent.value||r.messageid!==t.lastUserMsgID.value||!!t.isLoading.value},onClick:function(){t.reEditEnter(r)}}];if("content"===o)switch(r.type){case"DEFAULT":u="ASSISTANT"===r.role?[].concat(f,c(i)):[].concat(p);break;case"ERROR":u=[].concat(f,c(i))}else u=[].concat(h,c(i));var v=function(n,i){var o=d({},r);if(r instanceof cw?(Object.assign(o,{topic:t.topic}),o.msg.realcontent=r.realcontent):(o.data||(o.data={}),Object.assign(o.data,{messages:t.messages.value})),i.onClick&&"function"==typeof i.onClick)i.onClick(n,i,t.context,t.params,o);else{var a=e.controller.opts.extendToolbarClick;a&&"function"==typeof a&&a(n,i,t.context,t.params,o)}},m=Ja(function(){return"content"===o&&("ASSISTANT"===(null==r?void 0:r.role)?20===(null==r?void 0:r.state)&&!0!==(null==r?void 0:r.completed)||t.isLoading.value:"USER"===(null==r?void 0:r.role)&&t.isLoading.value)},[null==r?void 0:r.state,null==r?void 0:r.completed,null==r?void 0:r.role,t.isLoading.value]);return na("div",{className:"".concat(vw.b()," ").concat(a||""),style:s,children:u.map(function(e,t){return na(pw,{data:r,model:e,disabled:m,buttonType:"content"===o?"circle":"default",onClick:v.bind(void 0)},t)})})},gw=function(e){var t=Ds(!1),n=Ds({}),i=new ra("chat-back-bottom"),r=Ds(null),o=function(){if(r.value){var n=e.visibilityHeight||200,i=r.value.scrollHeight-r.value.scrollTop-r.value.offsetHeight;t.value=i>=n}},a=function(e,t){var n=null;return function(){for(var i=this,r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];n||(n=setTimeout(function(){e.apply(i,o),n=null},t))}}(o,300);return Ja(function(){n.value={right:"".concat(e.right,"px"),bottom:"".concat(e.bottom,"px")}},[e.right,e.bottom]),$a(function(){if(e.target){var t,n=null!==(t=document.querySelector(e.target))&&void 0!==t?t:void 0;n&&(r.value=n,n.addEventListener("scroll",a),o())}},[]),na("div",{className:"".concat(i.b()," ").concat(i.is("visible",t.value)),style:n.value,onClick:function(){var t;r.value&&(r.value.scrollTo({top:r.value.scrollHeight,behavior:"smooth"}),null===(t=e.onClick)||void 0===t||t.call(e))},children:na(ic,{className:i.e("icon")})})},yw=new ra("chat-scrollbar"),kw=function(e){return Math.max(0,Math.min(1,e))},ww=function(e){var t=e.minThumbSize,n=void 0===t?24:t,i=qa(null),r=Ds(!1),o=Ds(0),a=qa(0),s=qa(function(){}),c=Ds(null);Ua(function(){var t=e.containerRef.current;if(t){var n=function(){var e=t.offsetParent;e&&(c.value={top:t.offsetTop,right:e.clientWidth-t.offsetLeft-t.offsetWidth,height:t.offsetHeight})};n();var i="undefined"!=typeof ResizeObserver?new ResizeObserver(n):null;return null==i||i.observe(t),t.offsetParent&&(null==i||i.observe(t.offsetParent)),function(){null==i||i.disconnect()}}},[]);var l=e.totalSize.value,u=e.clientHeight.value,d=e.scrollTop.value,h=function(){var t,i,r=e.totalSize.value,o=e.clientHeight.value,a=null!==(t=null===(i=c.value)||void 0===i?void 0:i.height)&&void 0!==t?t:o,s=Math.min(a,Math.max(n,o/Math.max(r,1)*a));return{total:r,client:o,scrollable:Math.max(0,r-o),trackH:a,thumbH:s,trackScrollable:Math.max(0,a-s)}},f=function(){var t,n=h(),i=n.total,r=n.client,a=Math.round(o.value*Math.max(0,i-r));(e.setScrollTop(a),a<1)&&(null===(t=e.onNearTop)||void 0===t||t.call(e))};Ua(function(){r.value&&f()},[l,u]);var p=function(){var t;r.value&&(r.value=!1,null===(t=e.onDragStateChange)||void 0===t||t.call(e,!1))};s.current=p,$a(function(){var e=function(){return s.current()};return window.addEventListener("pointerup",e),window.addEventListener("pointercancel",e),window.addEventListener("blur",e),function(){window.removeEventListener("pointerup",e),window.removeEventListener("pointercancel",e),window.removeEventListener("blur",e)}},[]);if(!c.value||u<=0||l<=u)return null;var v=h(),m=v.thumbH,g=v.trackScrollable,y=v.scrollable,k=0;return r.value?k=o.value*g:y>0&&(k=kw(d/y)*g),na("div",{ref:i,className:"".concat(yw.b()," ").concat(yw.is("dragging",r.value)),style:{top:"".concat(c.value.top,"px"),right:"".concat(c.value.right,"px"),height:"".concat(c.value.height,"px")},onPointerDown:function(t){if(0===t.button){var n=e.containerRef.current,r=i.current;if(n&&r){var o=h(),a=o.scrollable,s=o.trackScrollable,c=r.getBoundingClientRect(),l=(a>0?kw(e.scrollTop.value/a):0)*s,u=t.clientY<c.top+l?-1:1;e.setScrollTop(n.scrollTop+u*n.clientHeight*.9)}}},children:na("div",{className:yw.e("thumb"),style:{top:"".concat(k,"px"),height:"".concat(m,"px")},onPointerDown:function(t){var n;if(0===t.button){t.preventDefault(),t.stopPropagation();var s=i.current;if(s){t.currentTarget.setPointerCapture(t.pointerId);var c=h(),l=c.scrollable,u=c.trackScrollable,d=s.getBoundingClientRect(),f=l>0?kw(e.scrollTop.value/l):0;o.value=f,a.current=t.clientY-(d.top+f*u),r.value=!0,null===(n=e.onDragStateChange)||void 0===n||n.call(e,!0)}}},onPointerMove:function(e){if(r.value){var t=i.current;if(t){var n=h().trackScrollable,s=t.getBoundingClientRect(),c=(e.clientY-s.top-a.current)/Math.max(n,1);o.value=kw(c),f()}}},onPointerUp:p,onLostPointerCapture:p})})},bw=new ra("chat-messages"),Cw=function(e){var t,n=e.controller.messages,i=e.controller.isLoadingHistory,r=g(Wa(!0),2),o=r[0],a=r[1],s=qa(!1),c=qa(null),l=qa(n.value),u=qa(n.value.length),d=qa(null===(t=n.value[0])||void 0===t?void 0:t.messageid),h=function(e){var t=e.count,n=e.getItemKey,i=e.estimateSize,r=e.overscan,o=void 0===r?5:r,a=qa(null),s=Ds(Number.MAX_SAFE_INTEGER),c=Ds(0),l=Ds(0),u=Ds(!1),d=qa(new Map),h=qa(new Map),f=qa(new Map),p=s.value,v=c.value,m=l.value;$a(function(){var e=a.current;if(e){var t=function(){s.value=e.scrollTop};e.addEventListener("scroll",t,{passive:!0}),s.value=e.scrollTop,c.value=e.clientHeight;var n="undefined"!=typeof ResizeObserver?new ResizeObserver(function(){c.value=e.clientHeight}):null;return null==n||n.observe(e),function(){e.removeEventListener("scroll",t),null==n||n.disconnect()}}},[]);var g=function(e){var t=f.current.get(e);return t||(t=function(t){var n=h.current.get(e);if(n&&(n.disconnect(),h.current.delete(e)),t&&"undefined"!=typeof ResizeObserver){var i=new ResizeObserver(function(){var n=Math.round(t.offsetHeight);n>0&&d.current.get(e)!==n&&(d.current.set(e,n),l.value+=1)});i.observe(t),h.current.set(e,i)}},f.current.set(e,t)),t},y=Ja(function(){var e=new Array(t+1);e[0]=0;for(var r=0;r<t;r+=1){var a=d.current.get(n(r));e[r+1]=e[r]+(null!=a?a:i(r))}for(var s=e[t]||0,c=p+v,l=0,u=0,h=t-1;u<=h;){var f=Math.floor((u+h)/2);e[f]<=p?(l=f,u=f+1):h=f-1}for(var m=l=Math.max(0,l-o);m<t&&e[m]<c;)m+=1;m=Math.min(t,m+o);for(var y=[],k=l;k<m;k+=1){var w=n(k);y.push({index:k,key:w,start:e[k],size:e[k+1]-e[k],measureRef:g(w)})}return{offsets:e,totalSize:s,virtualItems:y}},[t,p,v,m]),k=Is(function(){l.value;for(var e=0,r=0;r<t;r+=1){var o;e+=null!==(o=d.current.get(n(r)))&&void 0!==o?o:i(r)}return e}),w=qa(t),b=qa(t>0?n(0):void 0),C=t>0?n(0):void 0;return Ua(function(){var e,i=a.current,r=w.current,o=b.current,c=t>r&&void 0!==o&&o!==C;if(w.current=t,b.current=C,i&&c&&!u.value){for(var l=-1,d=0;d<t;d+=1)if(n(d)===o){l=d;break}if(!(l<=0)){var h=null!==(e=y.offsets[l])&&void 0!==e?e:0;if(h>0){var f=i.scrollTop+h;s.value=f,i.scrollTop=f}}}},[t,C]),{containerRef:a,virtualItems:y.virtualItems,totalSize:y.totalSize,offsets:y.offsets,getOffset:function(e){var t;return null!==(t=y.offsets[e])&&void 0!==t?t:0},restoreScrollPosition:function(){var e=a.current;e&&(e.scrollTop=s.value)},totalSizeSignal:k,scrollTopSignal:s,clientHeightSignal:c,isDragging:u,setScrollTop:function(e){var t=a.current;if(t){var n=Math.max(0,t.scrollHeight-t.clientHeight),i=Math.max(0,Math.min(e,n));s.value=i,t.scrollTop=i}}}}({count:n.value.length,getItemKey:function(e){var t;return(null===(t=n.value[e])||void 0===t?void 0:t.messageid)||String(e)},estimateSize:function(e){var t=n.value[e];if(!t||"SYSTEM"===t.role)return 0;var i=t.content||"";return Math.max(200,Math.min(550,200+i.length/20*43))},overscan:3}),f=h.containerRef,p=h.virtualItems,v=h.totalSize,m=h.offsets,y=h.restoreScrollPosition,k=h.totalSizeSignal,w=h.scrollTopSignal,b=h.clientHeightSignal,C=h.isDragging,S=h.setScrollTop,x=function(){var e=f.current;e&&(s.current=!0,e.scrollTo({top:Number.MAX_SAFE_INTEGER,behavior:"auto"}),setTimeout(function(){s.current=!1},500))},T=function(){e.controller.hasMoreHistory.value&&!e.controller.isLoadingHistory.value&&e.controller.loadHistoryMore()};$a(function(){return e.controller.evt.on("onActivated",y),function(){e.controller.evt.off("onActivated",y)}},[]),Ua(function(){var e,t=f.current;if(t){var i=n.value.length,r=u.current,s=null===(e=n.value[0])||void 0===e?void 0:e.messageid,h=i>r&&s===d.current,p=i>r&&s!==d.current,v=l.current!==n.value;u.current=i,d.current=s,l.current=n.value;var g=C.value;if(h&&!g){var y=n.value.slice(r).some(function(e){return"USER"===e.role});if(y)return a(!0),void x()}if(!o||g){if(v&&!p&&c.current){var k,w=c.current,b=w.messageid,S=w.offsetWithin,T=n.value.findIndex(function(e){return e.messageid===b});if(T>=0)t.scrollTop=(null!==(k=m[T])&&void 0!==k?k:0)+S}}else x()}},[n.value,v,o]);return na("div",{className:bw.e("wrap"),children:[na("div",{ref:f,className:bw.b(),onScroll:function(){if(!s.current){var e=f.current;if(e){var t=e.scrollTop,n=e.scrollHeight-(t+e.clientHeight)<50;if(a(n),t<1&&T(),n)c.current=null;else{var i=p[0];i&&(c.current={messageid:i.key,offsetWithin:t-i.start})}}}},children:[na("div",{style:{position:"relative",height:"".concat(v,"px")},children:[p.map(function(t){var i,r=n.value[t.index];if(!r||"SYSTEM"===r.role)return null;var o=(null===(i=r.content)||void 0===i?void 0:i.length)||0;return na("div",{ref:t.measureRef,style:{position:"absolute",top:0,left:0,width:"100%",transform:"translateY(".concat(t.start,"px)")},children:na(sw,{size:o,message:r,controller:e.controller,children:na(mw,{type:"content",mode:"DEFAULT",hideTopicSidebar:!1,data:r,items:e.toolbarItems,controller:e.controller})})},t.key)}),i.value&&na("div",{className:bw.e("history-loading"),children:na(nl,{size:20})})]}),na(gw,{right:20,bottom:14,target:".".concat(bw.b()),onClick:function(){s.current=!0,a(!0)}})]}),na(ww,{containerRef:f,scrollTop:w,clientHeight:b,totalSize:k,setScrollTop:S,onNearTop:T,onDragStateChange:function(e){C.value=e}}),e.children?na("div",{className:bw.e("footer-toolbar"),children:e.children}):null]})},Sw=new ra("chat-splitter"),xw=function(e){var t=e.direction,n=e.onDragStart,i=e.onMove,r=e.onDragEnd,o=e.className,a=void 0===o?"":o,s=Ds(!1),c=qa({x:0,y:0}),l=qa(i),u=qa(r);l.current=i,u.current=r;return na("div",{className:"".concat(Sw.b()," ").concat(Sw.is(t,!0)," ").concat(Sw.is("dragging",s.value)," ").concat(a),onMouseDown:function(e){e.preventDefault(),s.value=!0,document.body.style.userSelect="none",c.current={x:e.clientX,y:e.clientY},null==n||n();var i=function(e){var n,i="vertical"===t?e.clientX-c.current.x:e.clientY-c.current.y;null===(n=l.current)||void 0===n||n.call(l,i)},r=function(){var e;s.value=!1,document.body.style.userSelect="",window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",r),null===(e=u.current)||void 0===e||e.call(u)};window.addEventListener("mousemove",i),window.addEventListener("mouseup",r)},children:na("div",{className:Sw.e("line")})})},Tw=function(e){return e.STYLE_CACHE="ai-chat-style-cache",e.MINIMIZE_STYLY_CHCHE="ai-chat-minimize-style-cache",e.TOPIC_SIDEBAR_WIDTH="ai-chat-topic-sidebar-width",e.INPUT_HEIGHT="ai-chat-input-height",e.DATA_BASE_NAME="ibiz-chat",e.DATA_TABLE_NAME="history-message",e.DATA_TABLE_KEY_NAME="id",e}(Tw||{}),Mw=function(e){return e.NONE_SCOPE_ID="__NONE__",e.NONE_SCOPE_KEY="scope:__NONE__",e}(Mw||{});function _w(e){switch(e){case"user":default:return"USER";case"agent":return"ASSISTANT";case"system":return"SYSTEM"}}function Nw(e){switch(e){case"pending":return 20;case"sent":case"canceled":default:return 30;case"failed":return 40}}function Ow(e){switch(e){case"pending":case"sent":case"canceled":default:return"DEFAULT";case"failed":return"ERROR"}}function Ew(e){var t;if(e.metadata)try{t=JSON.parse(e.metadata)}catch(vs){console.warn("解析消息 metadata 失败,已做容错处理",{value:e.metadata,error:vs})}return{messageid:e.id,state:Nw(e.status),type:Ow(e.status),role:_w(e.sender_type),content:e.content,completed:!0,islike:e.is_like,isdislike:e.is_dislike,feedbackcontent:e.feedback_content,realmessageid:e.id,status:e.status,metadata:t,agent_tag:e.agent_tag,create_time:e.create_time}}var Aw=function(){return x(function e(t,n,i){C(this,e),T(this,"evt",new p),T(this,"messages",gs([])),T(this,"isLoadingHistory",gs(!1)),T(this,"hasMoreHistory",gs(!1)),T(this,"loadedHistoryCount",0),T(this,"nextHistoryPage",0),T(this,"materials",gs([])),T(this,"input",gs("")),T(this,"inputExpand",gs(!1)),T(this,"reEditContent",gs("")),T(this,"reEditContentChanged",gs(!1)),T(this,"lastUserMsgID",gs(void 0)),T(this,"isLoading",gs(!1)),T(this,"enableKnowledgeBaseSelect",gs(!1)),T(this,"enableRecallConfigSetting",gs(!1)),T(this,"enableChatProject",gs(!1)),T(this,"enableAIAgentChange",!0),T(this,"activeAIAgentID",void 0),T(this,"agentList",gs([])),T(this,"context",void 0),T(this,"params",void 0),T(this,"appDataEntityId",void 0),T(this,"topicId",void 0),T(this,"topic",void 0),T(this,"aiTopic",void 0),T(this,"chatSessionid",""),T(this,"chatMode",void 0),T(this,"chatScope",void 0),T(this,"isDigestProcessed",!1),T(this,"needUpdateMetaData",!0),T(this,"knowledgeBasesList",[]),T(this,"selectionKnowledgeBases",gs([])),T(this,"selectionProject",void 0),T(this,"knowledgeBases",gs([])),T(this,"placeholder",gs("")),T(this,"reCallConfig",gs({chunkrerank:2,maxchunks:void 0,chunkthreshold:void 0,chunkpageindex:void 0})),T(this,"streamingMsgID",void 0),T(this,"inited",gs(!1)),T(this,"steerQuesCfg",gs({enable:!1,message:""})),T(this,"activeAsyncacitonid",""),this.opts=t,this.resourceOptions=n,this.topicOptions=i,this.context=t.context,this.params=t.params,this.appDataEntityId=t.appDataEntityId,this.aiTopic=t.aiTopic,this.topicId=t.topicId,this.topic=t.topic,this.activeAIAgentID=t.activeAIAgentID,this.enableAIAgentChange=!!t.enableAIAgentChange,this.chatMode=t.srfMode,this.chatScope=t.srfScope,this.chatSessionid=t.sessionid,this.enableKnowledgeBaseSelect.value=!!t.enableKnowledgeBaseSelect,this.enableRecallConfigSetting.value=!!t.enableRecallConfigSetting,this.placeholder.value=t.placeholder||$c.t.value("chatInputPlaceholder"),this.initAIChat()},[{key:"resourceMode",get:function(){var e;return(null===(e=this.resourceOptions)||void 0===e?void 0:e.resourceMode)||"LOCAL"}},{key:"currentTopicDisableStorage",get:function(){if(this.topicId&&this.aiTopic){var e=this.aiTopic.getCurrentTopicByID(this.topicId);if(e&&e.disableStorage)return!0}return!1}},{key:"sessionCaptionMode",get:function(){if(this.aiTopic&&this.topicId){var e=this.aiTopic.getCurrentTopicByID(this.topicId);if(e&&e.captionMode)return e.captionMode}return this.topicOptions&&this.topicOptions.captionMode?this.topicOptions.captionMode:"default"}},{key:"sessionDefaultCaption",get:function(){if(this.aiTopic&&this.topicId){var e=this.aiTopic.getCurrentTopicByID(this.topicId);if(e&&e.caption)return e.caption}return this.opts.caption||$c.t.value("newConversation")}},{key:"sessionMeta",get:function(){if(this.aiTopic&&this.topicId){var e=this.aiTopic.getCurrentTopicByID(this.topicId);if(e&&!e.disableStorage)return{appid:e.appid,id:e.id,type:e.type,captionMode:e.captionMode,captionComputed:!!e.captionComputed,caption:e.caption||e.sourceCaption,sourceCaption:e.sourceCaption,url:e.url,aiChat:e.aiChat?d(d({},e.aiChat),{},{activeAIAgentID:this.activeAIAgentID,selectAIKnowledgeBaseId:this.getQueryKnowledgeBases()}):e.aiChat,isTop:e.isTop,sequence:e.sequence,scope:e.scope,groupid:e.groupid}}}},{key:"updateAIChat",value:function(e){this.streamingMsgID||(this.opts=e,this.initAIChat())}},{key:"initAIChat",value:(U=v(h().m(function e(){return h().w(function(e){for(;;)switch(e.n){case 0:return this.inited.value=!1,this.messages.value=[],this.needUpdateMetaData=!0,e.n=1,this.initAIChatAgent();case 1:return e.n=2,this.initAIChatKnowledge();case 2:return e.n=3,this.fecthHistory();case 3:return e.a(2)}},e,this)})),function(){return U.apply(this,arguments)})},{key:"initAIChatAgent",value:($=v(h().m(function e(){var t,n=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.opts.aiAgentlist&&this.opts.aiAgentlist.length>0&&this.opts.aiAgentlist.forEach(function(e){n.agentList.value=[].concat(c(n.agentList.value),[new dw(e,{chunkrerank:n.opts.reRankDefaultValue,maxchunks:n.opts.maxChunksDefaultValue,chunkthreshold:n.opts.chunkThresholdDefaultValue,chunkpageindex:n.opts.chunkPageIndexDefaultValue})])}),this.computeEnableChatProject(),this.enableRecallConfigSetting.value){e.n=1;break}return e.a(2);case 1:t=this.agentList.value.find(function(e){return e.id===n.activeAIAgentID}),t&&(this.reCallConfig.value={chunkrerank:t.rerank,maxchunks:t.maxchunks,chunkthreshold:t.chunkthreshold,chunkpageindex:t.chunkpageindex});case 2:return e.a(2)}},e,this)})),function(){return $.apply(this,arguments)})},{key:"initAIChatKnowledge",value:(W=v(h().m(function e(){var t;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.enableKnowledgeBaseSelect.value){e.n=1;break}return e.a(2);case 1:null!==(t=this.opts.aiknowledgeBasesList)&&void 0!==t&&t.length&&(this.knowledgeBasesList=this.opts.aiknowledgeBasesList.map(function(e){return new hw(e)})),this.computeSelectedKnowledge();case 2:return e.a(2)}},e,this)})),function(){return W.apply(this,arguments)})},{key:"computeEnableChatProject",value:function(){var e=this,t=this.agentList.value.find(function(t){return t.id===e.activeAIAgentID});this.enableChatProject.value=!!this.opts.enableAIProject&&"SKILL"===(null==t?void 0:t.flow_mode),this.enableChatProject.value||(this.selectionProject=void 0)}},{key:"computeSelectedKnowledge",value:function(){var e,t=this;if(this.enableKnowledgeBaseSelect.value){var n=this.agentList.value.find(function(e){return e.id===t.activeAIAgentID});if(this.knowledgeBases.value=!n||n.allow_any_knowledge_base?c(this.knowledgeBasesList):(null===(e=n.knowledge_bases)||void 0===e?void 0:e.map(function(e){return new hw({id:e.ai_knowledge_base_id,name:e.ai_knowledge_base_name})}))||[],this.opts.selectAIKnowledgeBaseId)this.selectionKnowledgeBases.value=this.knowledgeBases.value.filter(function(e){var n;return null===(n=t.opts.selectAIKnowledgeBaseId)||void 0===n?void 0:n.includes(e.id)}).map(function(e){return e.id});else if(n){var i;this.selectionKnowledgeBases.value=(null===(i=n.knowledge_bases)||void 0===i?void 0:i.map(function(e){return e.ai_knowledge_base_id}))||[]}}}},{key:"knowledgeRemoteSearch",value:(V=v(h().m(function e(t){var n,i,r,o=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.enableKnowledgeBaseSelect.value){e.n=1;break}return e.a(2,[]);case 1:if(n=this.agentList.value.find(function(e){return e.id===o.activeAIAgentID}),n&&!n.allow_any_knowledge_base){e.n=4;break}if(!this.opts.fetchKnowledgeBaseList){e.n=3;break}return e.n=2,this.opts.fetchKnowledgeBaseList({query:t,knowledgebases:this.getQueryKnowledgeBases()});case 2:if(!((i=e.v)&&i.length>0)){e.n=3;break}return r=new Map(i.map(function(e){return[e.id,e]})),e.a(2,Array.from(r.values()).map(function(e){return{value:e.id,label:e.name}}));case 3:e.n=5;break;case 4:if(!(n&&n.knowledge_bases&&n.knowledge_bases.length>0)){e.n=5;break}return e.a(2,n.knowledge_bases.map(function(e){return{value:e.ai_knowledge_base_id,label:e.ai_knowledge_base_name}}).filter(function(e){return e.label.toLowerCase().includes(t.toLowerCase())}));case 5:return e.a(2,[])}},e,this)})),function(e){return V.apply(this,arguments)})},{key:"getHistoryStoreKey",value:function(e){return"".concat(e)}},{key:"getQueryKnowledgeBases",value:function(){return this.enableKnowledgeBaseSelect.value?this.selectionKnowledgeBases.value.join(","):void 0}},{key:"getQueryRecallConfig",value:function(){return this.enableRecallConfigSetting.value?this.reCallConfig.value:void 0}},{key:"fecthHistory",value:(j=v(h().m(function e(){var t,n,i,r=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(!this.opts.isSimple){e.n=1;break}return this.inited.value=!0,e.a(2,!0);case 1:if(this.hasMoreHistory.value=!1,!this.topicId){e.n=8;break}if(t={},!this.currentTopicDisableStorage){e.n=2;break}t.data=[],e.n=6;break;case 2:if("LOCAL"!==this.resourceMode){e.n=4;break}return e.n=3,ka.getData(Tw.DATA_BASE_NAME,Tw.DATA_TABLE_NAME,this.getHistoryStoreKey(this.topicId));case 3:t=e.v,e.n=6;break;case 4:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=6;break}return e.n=5,this.fetchRemoteHistoryPage(!0);case 5:(n=e.v)&&n.length>0&&(t.data=n);case 6:if(!(t&&t.data&&t.data.length>0)){e.n=8;break}return i=t.data.map(function(e){return r.addMessage(r.buildHistoryMessage(e),!0)}),this.onMessageChange("historymsg",i),this.inited.value=!0,e.n=7,this.markLastUserMessage();case 7:return e.a(2,!0);case 8:return e.n=9,this.opts.history(this.context,this.params,{appDataEntityId:this.appDataEntityId,appendCurData:this.opts.appendCurData,sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,srfmode:this.chatMode,srfscope:this.chatScope});case 9:if(!e.v){e.n=10;break}return e.n=10,this.afterFecthHistory();case 10:return e.a(2,!0)}},e,this)})),function(){return j.apply(this,arguments)})},{key:"fetchRemoteHistoryPage",value:(F=v(h().m(function e(t){var n,i,r,o,a;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.resourceOptions){e.n=1;break}return e.a(2,[]);case 1:return t&&(this.nextHistoryPage=0,this.loadedHistoryCount=0),e.n=2,this.resourceOptions.getMessages({n_session_id_eq:this.chatSessionid,page:this.nextHistoryPage,size:this.opts.chatMessagePageSize||100});case 2:if(i=e.v,r=i.data||[],o=null!==(n=i.total)&&void 0!==n?n:0,0!==(a=r.map(function(e){return Ew(e)})).length){e.n=3;break}return this.hasMoreHistory.value=!1,e.a(2,a);case 3:return this.loadedHistoryCount+=a.length,this.hasMoreHistory.value=this.loadedHistoryCount<o,this.hasMoreHistory.value&&(this.nextHistoryPage+=1),e.a(2,a)}},e,this)})),function(e){return F.apply(this,arguments)})},{key:"buildHistoryMessage",value:function(e){return{messageid:e.messageid,state:e.state,type:e.type,role:e.role,islike:e.islike,isdislike:e.isdislike,metadata:e.metadata,feedbackcontent:e.feedbackcontent,content:e.content,suggestions:e.suggestions,completed:!0,toolcalls:e.toolcalls,realmessageid:e.realmessageid,status:e.status,chatsteps:e.chatsteps,chatuiactions:e.chatuiactions,agent_tag:e.agent_tag,create_time:e.create_time}}},{key:"loadHistoryMore",value:(H=v(h().m(function e(){var t,n,i=this;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this.isLoadingHistory.value&&this.hasMoreHistory.value){e.n=1;break}return e.a(2);case 1:if("REMOTE"===this.resourceMode&&this.resourceOptions){e.n=2;break}return e.a(2);case 2:if(!this.currentTopicDisableStorage){e.n=3;break}return e.a(2);case 3:return this.isLoadingHistory.value=!0,e.p=4,e.n=5,this.fetchRemoteHistoryPage(!1);case 5:if(0!==(t=e.v).length){e.n=6;break}return e.a(2);case 6:n=t.map(function(e){var t=i.buildHistoryMessage(e);i.attachMessageAgentID(t);var n=new cw(t);return n.update(d(d({},t),{},{content:""})),n}),this.messages.value=[].concat(c(n),c(this.messages.value)),this.onMessageChange("historymsg",n);case 7:return e.p=7,this.isLoadingHistory.value=!1,e.f(7);case 8:return e.a(2)}},e,this,[[4,,7,8]])})),function(){return H.apply(this,arguments)})},{key:"afterFecthHistory",value:(B=v(h().m(function e(){var t,n,i,r,o,a,s,l,u,f=this;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.inited.value=!0,!this.opts.appendCurContent){e.n=1;break}return this.addMessage({state:30,messageid:la(),role:"USER",type:"DEFAULT",content:this.opts.appendCurContent,completed:!0,status:"sent"}),e.n=1,this.markLastUserMessage();case 1:if(this.opts.appendCurResource&&(t=ba.parseMixedContent(this.opts.appendCurResource),n=t.hasResources,i=t.resources,n&&i&&i.length>0&&i.forEach(function(e){f.replaceMaterial(e.id,e)})),!1===this.opts.autoQuestion){e.n=6;break}if(r=this.messages.value.length-1,!(o=this.messages.value[r])||"USER"!==o.role){e.n=6;break}return(a=this.stringlyMaterialResource(!1))&&(s=a+o.content,l=d(d({},o._origin),{},{messageid:la(),content:s}),u=new cw(l),this.messages.value[r]=u,this.messages.value=c(this.messages.value),this.onMessageChange("updatemsg",u)),e.p=2,this.isLoading.value=!0,e.n=3,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode,this.chatScope,this.getQueryKnowledgeBases(),this.getQueryRecallConfig(),this.opts.appendCurData,this.opts.srfMcpservers,this.sessionMeta,this.selectionProject);case 3:if(!this.opts.action){e.n=4;break}return e.n=4,this.opts.action("question",o.content);case 4:return e.p=4,this.isLoading.value=!1,this.resetSteerQuesCfg(),e.f(4);case 5:return e.n=6,this.updateTopic("history"===this.opts.captionComputedMode);case 6:return e.n=7,this.markLastUserMessage();case 7:return e.a(2)}},e,this,[[2,,4,5]])})),function(){return B.apply(this,arguments)})},{key:"asyncToIndexDB",value:(z=v(h().m(function e(){var t;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.topicId&&"LOCAL"===this.resourceMode){e.n=1;break}return e.a(2);case 1:if(!this.currentTopicDisableStorage){e.n=2;break}return e.a(2);case 2:return t={id:this.getHistoryStoreKey(this.topicId),data:this.messages.value.map(function(e){return d(d({},e._origin),{},{toolcalls:e.toolcalls,chatsteps:e.chatsteps,chatuiactions:e.chatuiactions})}),timestamp:(new Date).getTime()},e.n=3,ka.updateData(Tw.DATA_BASE_NAME,Tw.DATA_TABLE_NAME,t);case 3:return e.a(2)}},e,this)})),function(){return z.apply(this,arguments)})},{key:"setInput",value:function(e){this.evt.emit("onSetInput",e||"")}},{key:"attachMessageAgentID",value:function(e){"ASSISTANT"===e.role&&!e.hasOwnProperty("agent_tag")&&this.activeAIAgentID&&(e.agent_tag=this.activeAIAgentID)}},{key:"addMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.attachMessageAgentID(e),20===e.state&&"pending"===e.status&&e.messageid&&(this.streamingMsgID=e.messageid);var n=this.messages.value.find(function(t){return t.messageid===e.messageid}),i=n?"updatemsg":"createmsg";return n?(n.update(e),this.messages.value=c(this.messages.value)):((n=new cw(e)).update(d(d({},e),{},{content:""})),this.messages.value=[].concat(c(this.messages.value),[n])),t||this.onMessageChange(i,n),this.asyncToIndexDB(),n}},{key:"completeMessage",value:(P=v(h().m(function e(t,n){var i,r;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.streamingMsgID===t&&n&&(this.streamingMsgID=void 0),!(i=this.messages.value.find(function(e){return e.messageid===t}))){e.n=1;break}return i.updateCompleted(n),this.messages.value=c(this.messages.value),this.onMessageChange("updatemsg",i),e.n=1,this.asyncToIndexDB();case 1:!0===this.opts.autoFill&&"ASSISTANT"===(r=i||this.messages.value[this.messages.value.length-1]).role&&30===r.state&&this.backfill(r),this.evt.emit("onCompleteMessage",{messageid:t,completed:n});case 2:return e.a(2)}},e,this)})),function(e,t){return P.apply(this,arguments)})},{key:"replaceMessage",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.attachMessageAgentID(e);var i=[];if(e.content){var r=e.content,o=r.indexOf("<chatuiaction>"),a=r.indexOf("</chatuiaction>");-1!==o&&-1!==a&&o<a&&(e.content=r.replace(/<chatuiaction>[^]*?<\/chatuiaction>/g,""));var s=r.indexOf("<chatstep>"),l=r.indexOf("</chatstep>");-1!==s&&-1!==l&&s<l&&(i=Ma.parse(e.content),e.content=r.replace(/<chatstep>[^]*?<\/chatstep>/g,""))}var u=d({},e),h=this.messages.value.findIndex(function(t){return t.messageid===e.messageid});if(-1!==h){if("ERROR"===e.type){var f=this.messages.value[h].content;try{var p=JSON.parse(f);p&&p.choices&&p.choices.length>0&&(f=p.choices[0].content||f)}catch(vs){console.warn("解析错误消息内容失败,已做容错处理",{value:f,error:vs})}finally{e.content=f}}var v;if(i.length>0)null===(v=this.messages.value[h].chatsteps)||void 0===v||v.push.apply(v,c(i));u.toolcalls=this.messages.value[h].toolcalls,u.chatsteps=this.messages.value[h].chatsteps,u.chatuiactions=this.messages.value[h].chatuiactions,u.think=this.messages.value[h].think,u.usage=this.messages.value[h].usage,this.messages.value[h].replace(e),this.messages.value=c(this.messages.value),this.onMessageChange("updatemsg",this.messages.value[h])}else{var m;if(i.length>0)e.chatsteps||(e.chatsteps=[]),(m=e.chatsteps).push.apply(m,c(i));var g=new cw(e);this.messages.value=[].concat(c(this.messages.value),[g]),this.onMessageChange("updatemsg",g)}this.asyncToIndexDB(),"DEFAULT"===e.type&&this.opts.recommendPrompt&&n&&this.opts.recommendPrompt(this.context,this.params,{appDataEntityId:this.appDataEntityId,message:{messages:[d(d({},e),{},{content:e.content.replace(/<think>[^]*?<\/think>/g,"")})],sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID}}).then(function(e){e&&e.content&&t.updateRecommendPrompt(u,e.content)})}},{key:"updateMsgUsage",value:function(e,t){var n=this.messages.value.findIndex(function(t){return t.messageid===e});-1!==n&&(this.messages.value[n].usage=t,this.messages.value=c(this.messages.value),this.onMessageChange("updatemsg",this.messages.value[n]))}},{key:"stopMessage",value:(R=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:return this.attachMessageAgentID(t),n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}),t.content=t.content||$c.t.value("userInterrupt"),-1!==n?(delete this.messages.value[n].think,this.messages.value[n].replace(t),this.messages.value=c(this.messages.value),this.onMessageChange("updatemsg",this.messages.value[n])):(i=new cw(t),this.messages.value=[].concat(c(this.messages.value),[i]),this.onMessageChange("createmsg",i)),e.n=1,this.markLastUserMessage();case 1:return e.n=2,this.asyncToIndexDB();case 2:return e.a(2)}},e,this)})),function(e){return R.apply(this,arguments)})},{key:"stringlyMaterialResource",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t="",n=[];return this.materials.value&&this.materials.value.length>0&&(this.materials.value.forEach(function(e){if("ossfile"===e.type){var t=e.metadata;t.state&&"successed"===t.state&&n.push(e)}else n.push(e)}),e&&(this.materials.value=[])),n&&n.length>0&&(t=ba.stringify(n)),t}},{key:"cloneMessage",value:function(e){var t=new cw(e._origin);return delete t.think,t}},{key:"getMessages",value:function(){var e=this.messages.value.filter(function(e){return"ERROR"!==e.type&&"canceled"!==e.status}).map(function(e){return f(e._origin)});return e.forEach(function(e){"ASSISTANT"===e.role&&(e.content=e.content.replace(/<tool_call>[^]*?<\/tool_call>/g,"").replace(/<think>[^]*?<\/think>/g,"").trim(),delete e.toolcalls,delete e.chatsteps,delete e.chatuiactions,delete e.think,delete e.metadata,delete e.agent_tag)}),e}},{key:"getAllMessages",value:function(){return this.messages.value.map(function(e){return e._origin})}},{key:"question",value:(L=v(h().m(function e(t){var n,i=this;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,this.isLoading.value=!0,this.reEditExit(),this.messages.value.forEach(function(e,t){var n=e._origin;n.suggestions&&(n.suggestions=void 0,i.messages.value[t].replace(n))}),this.messages.value=c(this.messages.value),this.asyncToIndexDB(),(n=this.stringlyMaterialResource(!0))?n+="\n".concat(t):n=t,this.addMessage({state:30,messageid:la(),role:"USER",type:"DEFAULT",content:n,status:"sent"}),e.n=1,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode,this.chatScope,this.getQueryKnowledgeBases(),this.getQueryRecallConfig(),this.opts.appendCurData,this.opts.srfMcpservers,this.sessionMeta,this.selectionProject);case 1:return this.opts.action&&this.opts.action("question",t),this.isLoading.value=!1,this.resetSteerQuesCfg(),e.n=2,this.markLastUserMessage();case 2:return e.n=3,this.updateTopic(!(!this.opts.captionComputedMode||"history"!==this.opts.captionComputedMode&&"question"!==this.opts.captionComputedMode));case 3:e.n=5;break;case 4:e.p=4,e.v,this.isLoading.value=!1,this.resetSteerQuesCfg();case 5:return e.a(2)}},e,this,[[0,4]])})),function(e){return L.apply(this,arguments)})},{key:"abortQuestion",value:(I=v(h().m(function e(){return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this.opts.abortQuestion(this,this.context,this.params,{appDataEntityId:this.appDataEntityId,sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,srfmode:this.chatMode,srfscope:this.chatScope,srfproject:this.selectionProject});case 1:return e.p=1,this.isLoading.value=!1,this.resetSteerQuesCfg(),e.f(1);case 2:return e.a(2)}},e,this,[[0,,1,2]])})),function(){return I.apply(this,arguments)})},{key:"supplementQuestion",value:(D=v(h().m(function e(){var t;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.steerQuesCfg.value.message){e.n=1;break}return e.a(2);case 1:return e.p=1,t={state:30,messageid:la(),role:"USER",type:"DEFAULT",content:this.steerQuesCfg.value.message,status:"sent"},e.n=2,this.opts.supplementQuestion(this,this.context,this.params,{appDataEntityId:this.appDataEntityId,sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,srfmode:this.chatMode,srfscope:this.chatScope,srfproject:this.selectionProject,messages:[t]});case 2:return e.p=2,this.resetSteerQuesCfg(),e.f(2);case 3:return e.a(2)}},e,this,[[1,,2,3]])})),function(){return D.apply(this,arguments)})},{key:"setSteerQuesCfg",value:function(e){this.steerQuesCfg.value={enable:!0,message:e}}},{key:"resetSteerQuesCfg",value:function(){this.steerQuesCfg.value={enable:!1,message:""}}},{key:"backfill",value:function(e){if(this.opts.action){var t=this.cloneMessage(e);this.opts.action("backfill",t)}}},{key:"deleteMessage",value:(A=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:if(-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&(this.messages.value.splice(n,1),this.messages.value=c(this.messages.value)),this.asyncToIndexDB(),"REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=1;break}if(!t.realmessageid){e.n=1;break}return e.n=1,this.resourceOptions.deleteMessage(t.realmessageid);case 1:i=this.cloneMessage(t),this.onMessageChange("deletemsg",i);case 2:return e.a(2)}},e,this)})),function(e){return A.apply(this,arguments)})},{key:"refreshMessage",value:(E=v(h().m(function e(t){var n,i,r,o,a,s,l,u,f=arguments;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=f.length>1&&void 0!==f[1]&&f[1],this.isLoading.value=!0,e.p=1,i=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}),r=[],!n){e.n=3;break}return 40===t.state&&(a=d(d({},t._origin),{},{state:30}),this.replaceMessage(a,!1)),o=this.messages.value[i],r=this.messages.value.splice(i,this.messages.value.length-i),this.addMessage(d(d({},o._origin),{},{messageid:la()})),e.n=2,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode,this.chatScope,this.getQueryKnowledgeBases(),this.getQueryRecallConfig(),this.opts.appendCurData,this.opts.srfMcpservers,this.sessionMeta,this.selectionProject);case 2:e.n=6;break;case 3:if(i!==this.messages.value.length-1){e.n=5;break}return(s=this.messages.value.pop())&&r.push(s),(o=this.messages.value[this.messages.value.length-1])&&(r.push(o),this.messages.value.pop(),this.addMessage(d(d({},o._origin),{},{messageid:la()}))),this.messages.value=c(this.messages.value),e.n=4,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode,this.chatScope,this.getQueryKnowledgeBases(),this.getQueryRecallConfig(),this.opts.appendCurData,this.opts.srfMcpservers,this.sessionMeta,this.selectionProject);case 4:e.n=6;break;case 5:return i>=1&&(i-=1,o=this.messages.value[i]),r=this.messages.value.splice(i,this.messages.value.length-i),o&&this.addMessage(d(d({},o._origin),{},{messageid:la()})),e.n=6,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode,this.chatScope,this.getQueryKnowledgeBases(),this.getQueryRecallConfig(),this.opts.appendCurData,this.opts.srfMcpservers,this.sessionMeta,this.selectionProject);case 6:if(this.asyncToIndexDB(),!("REMOTE"===this.resourceMode&&this.resourceOptions&&r&&r.length>0)){e.n=7;break}if(!(l=r.filter(function(e){return e.realmessageid}).map(function(e){return e.realmessageid}).join(","))){e.n=7;break}return e.n=7,this.resourceOptions.deleteMessage(l);case 7:this.opts.action&&(u=this.cloneMessage(t),this.opts.action("refreshmsg",u));case 8:return e.p=8,this.isLoading.value=!1,this.resetSteerQuesCfg(),e.n=9,this.markLastUserMessage();case 9:return e.f(8);case 10:return e.a(2)}},e,this,[[1,,8,10]])})),function(e){return E.apply(this,arguments)})},{key:"copyMessage",value:function(e,t){var n;if(ya.copy(e),null===(n=this.opts.utils)||void 0===n||n.message.success($c.t.value("copied")),this.opts.action){var i=this.cloneMessage(t);this.opts.action("copymsg",i)}}},{key:"reEditEnter",value:(O=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&(this.messages.value[n].reeditstate=!0,this.reEditContent.value=ma(t.content),this.messages.value=c(this.messages.value));case 1:return e.a(2)}},e,this)})),function(e){return O.apply(this,arguments)})},{key:"reEditExit",value:(N=v(h().m(function e(){var t;return h().w(function(e){for(;;)switch(e.n){case 0:-1!==(t=this.messages.value.findIndex(function(e){return!0===e.reeditstate}))&&(this.messages.value[t].reeditstate=!1,this.reEditContent.value="",this.reEditContentChanged.value=!1,this.messages.value=c(this.messages.value));case 1:return e.a(2)}},e,this)})),function(){return N.apply(this,arguments)})},{key:"reEditSubmit",value:(_=v(h().m(function e(t){var n,i,r;return h().w(function(e){for(;;)switch(e.n){case 0:if(-1===(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))){e.n=1;break}return i=va(this.reEditContent.value),r=d(d({},t._origin),{},{content:i,realcontent:i}),this.replaceMessage(r,!1),this.messages.value[n].reeditstate=!1,this.reEditContent.value="",this.reEditContentChanged.value=!1,e.n=1,this.refreshMessage(t,!0);case 1:return e.a(2)}},e,this)})),function(e){return _.apply(this,arguments)})},{key:"reEditCancel",value:(M=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&(this.messages.value[n].reeditstate=!1,this.reEditContent.value="",this.reEditContentChanged.value=!1,this.messages.value=c(this.messages.value));case 1:return e.a(2)}},e,this)})),function(e){return M.apply(this,arguments)})},{key:"markLastUserMessage",value:(S=v(h().m(function e(){var t,n;return h().w(function(e){for(;;)switch(e.n){case 0:if(0!==this.messages.value.length){e.n=1;break}return e.a(2);case 1:t=c(this.messages.value).reverse(),n=t.find(function(e){return"USER"===e.role}),this.lastUserMsgID.value=null==n?void 0:n.messageid;case 2:return e.a(2)}},e,this)})),function(){return S.apply(this,arguments)})},{key:"resetTopicMessage",value:(b=v(h().m(function e(){var t,n;return h().w(function(e){for(;;)switch(e.n){case 0:if(null===(t=this.opts.utils)||void 0===t||!t.confirm){e.n=2;break}return e.n=1,this.opts.utils.confirm.warning({title:$c.t.value("resetConversation"),desc:$c.t.value("resetTopicConfirmTip")});case 1:if(e.v){e.n=2;break}return e.a(2,!1);case 2:return n=!0,e.n=3,this.clearTopicMessage(!1);case 3:if(n=e.v){e.n=4;break}return e.a(2,n);case 4:return e.n=5,this.fecthHistory();case 5:return e.a(2,n)}},e,this)})),function(){return b.apply(this,arguments)})},{key:"clearTopicMessage",value:(w=v(h().m(function e(){var t,n,i,r,o=arguments;return h().w(function(e){for(;;)switch(e.n){case 0:if(o.length>0&&void 0!==o[0]&&!o[0]||null===(t=this.opts.utils)||void 0===t||!t.confirm){e.n=2;break}return e.n=1,this.opts.utils.confirm.warning({title:$c.t.value("clearConversation"),desc:$c.t.value("clearTopicConfirmTip")});case 1:if(e.v){e.n=2;break}return e.a(2,!1);case 2:return n=!0,e.n=3,this.abortQuestion();case 3:if(!this.topicId){e.n=10;break}if(!this.topicId||!this.aiTopic){e.n=9;break}if(!this.currentTopicDisableStorage){e.n=4;break}n=!0,e.n=9;break;case 4:if("LOCAL"!==this.resourceMode){e.n=6;break}return e.n=5,ka.deleteData(Tw.DATA_BASE_NAME,Tw.DATA_TABLE_NAME,this.getHistoryStoreKey(this.topicId));case 5:n=e.v,e.n=9;break;case 6:if("REMOTE"!==this.resourceMode){e.n=9;break}if(!this.resourceOptions){e.n=9;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:this.chatSessionid});case 7:if(!((i=e.v)&&i.length>0)){e.n=9;break}return e.n=8,this.resourceOptions.clearAllMessageBySessionId(i[0].realid);case 8:n=e.v;case 9:e.n=13;break;case 10:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=13;break}return e.n=11,this.resourceOptions.getSessionList({n_session_id_eq:this.chatSessionid});case 11:if(!((r=e.v)&&r.length>0)){e.n=13;break}return e.n=12,this.resourceOptions.clearAllMessageBySessionId(r[0].realid);case 12:n=e.v;case 13:if(n){e.n=14;break}return e.a(2,n);case 14:return this.messages.value=[],e.a(2,n)}},e,this)})),function(){return w.apply(this,arguments)})},{key:"addMaterial",value:function(e){var t=this.materials.value.find(function(t){return t.id===e.id});this.materials.value=t?c(this.materials.value):[].concat(c(this.materials.value),[new uw(e)])}},{key:"replaceMaterial",value:function(e,t){var n=this.materials.value.findIndex(function(t){return t.id===e});-1!==n?(this.materials.value[n]=new uw(t),this.materials.value=c(this.materials.value)):this.materials.value=[].concat(c(this.materials.value),[new uw(t)])}},{key:"deleteMaterial",value:function(e){var t=this.materials.value.findIndex(function(t){return t.id===e.id});-1!==t&&(this.materials.value.splice(t,1),this.materials.value=c(this.materials.value))}},{key:"updateRecommendPrompt",value:function(e,t){if(t){var n=this.messages.value.findIndex(function(t){return t.messageid===e.messageid}),i=Ca.parseMixedContent(t).suggestions;if(i&&i.length>0){e.suggestions=i;var r=new cw(e);-1!==n?(this.messages.value[n]=r,this.messages.value=c(this.messages.value)):this.messages.value=[].concat(c(this.messages.value),[r]),this.onMessageChange("updatemsg",r),this.asyncToIndexDB()}}}},{key:"clearUIActions",value:(k=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&((i=this.messages.value[n]._origin).suggestions=void 0,this.messages.value[n].replace(i),this.messages.value=c(this.messages.value)),this.asyncToIndexDB();case 1:return e.a(2)}},e,this)})),function(e){return k.apply(this,arguments)})},{key:"handleSuggestionClick",value:(y=v(h().m(function e(t,n,i){var r,o,a,s,c,l,u,f,p,v,m,y;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.n=1,this.clearUIActions(t);case 1:r=n.type,o=n.metadata,y=r,e.n="action"===y?2:"raw"===y?9:11;break;case 2:if(!this.opts.extendToolbarClick){e.n=8;break}if(s=n.data.actionid,c=n.data.appid,s){e.n=3;break}throw new Error($c.t.value("actionIdCannotEmpty"));case 3:if(this.addMessage({messageid:la(),state:30,type:"DEFAULT",role:"USER",content:o.content_name,status:"sent"}),l=this.cloneMessage(t),Object.assign(l,{topic:this.topic}),l.msg.realcontent=t.realcontent,u=d({},this.context),!o.action_context){e.n=6;break}e.p=4,f=o.action_context.split(";"),(p=f.reduce(function(e,t){if(t.trim()){var n=g(t.split(":"),2),i=n[0],r=n[1];i&&r&&(e[i.trim()]=r.trim())}return e},{}))&&Object.keys(p).length>0&&Object.assign(u,d({},p)),e.n=6;break;case 5:throw e.p=5,e.v,new Error($c.t.value("actionExContext"));case 6:return e.n=7,this.opts.extendToolbarClick(i,{id:s,isPluginApp:!!c,appId:c||this.context.srfappid},u,this.params,l);case 7:v=e.v,(m=null==v||null===(a=v.data)||void 0===a?void 0:a[0])&&m.content&&this.addMessage({messageid:la(),state:30,type:m.type||"DEFAULT",role:m.role||"ASSISTANT",content:m.content,status:"sent"});case 8:return e.a(3,12);case 9:return e.n=10,this.question(n.data.content);case 10:return e.a(3,12);case 11:throw new Error($c.t.value("notSupportingType",{type:r}));case 12:return e.a(2)}},e,this,[[4,5]])})),function(e,t,n){return y.apply(this,arguments)})},{key:"handleUIActionClick",value:(m=v(h().m(function e(t,n,i){var r,o,a,s,c,l,u,f,p,v,m,y,k;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.n=1,this.clearUIActions(t);case 1:r=n.type,o=n.data,a=n.metadata,k=r,e.n="action"===k?2:"raw"===k?9:11;break;case 2:if(!this.opts.extendToolbarClick){e.n=8;break}if(c=o.actionid,l=o.appid,c){e.n=3;break}throw new Error($c.t.value("actionIdCannotEmpty"));case 3:if(u=this.cloneMessage(t),Object.assign(u,{topic:this.topic}),u.msg.realcontent=t.realcontent,f=d({},this.context),!a.action_context){e.n=6;break}e.p=4,p=a.action_context.split(";"),(v=p.reduce(function(e,t){if(t.trim()){var n=g(t.split(":"),2),i=n[0],r=n[1];i&&r&&(e[i.trim()]=r.trim())}return e},{}))&&Object.keys(v).length>0&&Object.assign(f,d({},v)),e.n=6;break;case 5:throw e.p=5,e.v,new Error($c.t.value("actionExContext"));case 6:return e.n=7,this.opts.extendToolbarClick(i,{id:c,isPluginApp:!!l,appId:l||this.context.srfappid},f,this.params,u);case 7:m=e.v,(y=null==m||null===(s=m.data)||void 0===s?void 0:s[0])&&y.content&&this.addMessage({messageid:la(),state:30,type:y.type||"DEFAULT",role:y.role||"ASSISTANT",content:y.content,status:"sent"});case 8:return e.a(3,12);case 9:return e.n=10,this.question(o.content);case 10:return e.a(3,12);case 11:throw new Error($c.t.value("notSupportingType",{type:r}));case 12:return e.a(2)}},e,this,[[4,5]])})),function(e,t,n){return m.apply(this,arguments)})},{key:"setActiveAIAgentID",value:(u=v(h().m(function e(t){var n,i=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.activeAIAgentID!==t){e.n=1;break}return e.a(2);case 1:this.activeAIAgentID=t,this.computeEnableChatProject(),this.topicId&&this.aiTopic&&this.aiTopic.updateTopicChatByID(this.topicId,{activeAIAgentID:t}),this.enableRecallConfigSetting.value&&(n=this.agentList.value.find(function(e){return e.id===i.activeAIAgentID}),n&&(this.reCallConfig.value={chunkrerank:n.rerank,maxchunks:n.maxchunks,chunkthreshold:n.chunkthreshold,chunkpageindex:n.chunkpageindex})),this.enableKnowledgeBaseSelect.value&&this.computeSelectedKnowledge();case 2:return e.a(2)}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"setAIAgentConfig",value:function(e){this.reCallConfig.value=d(d({},this.reCallConfig.value),e)}},{key:"searchAIAgent",value:(l=v(h().m(function e(t){var n,i,r=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(n=[],!this.opts.fetchAgentList){e.n=3;break}return e.n=1,this.opts.fetchAgentList({query:t,agentid:this.activeAIAgentID||this.opts.activeAIAgentID});case 1:if(i=e.v){e.n=2;break}i=[];case 2:n=i.map(function(e){return new dw(e,{chunkrerank:r.opts.reRankDefaultValue,maxchunks:r.opts.maxChunksDefaultValue,chunkthreshold:r.opts.chunkThresholdDefaultValue,chunkpageindex:r.opts.chunkPageIndexDefaultValue})}),e.n=4;break;case 3:n=this.agentList.value;case 4:return e.a(2,n)}},e,this)})),function(e){return l.apply(this,arguments)})},{key:"searchProject",value:(s=v(h().m(function e(){var t,n,i,r,o=arguments;return h().w(function(e){for(;;)switch(e.n){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:"",n=o.length>1&&void 0!==o[1]?o[1]:"",i=[],!this.opts.fetchProject){e.n=2;break}return e.n=1,this.opts.fetchProject(this.context,d(d({},this.params),{},{appDataEntityId:this.appDataEntityId}),{file_path:t,pattern:n,srfaiagent:this.activeAIAgentID||"",sessionid:this.chatSessionid,max_depth:1,only_dirs:!0});case 1:r=e.v,i=r.map(function(e){return{id:e.name,label:e.name,isLeaf:"dir"!==e.type}});case 2:return e.a(2,i)}},e,this)})),function(){return s.apply(this,arguments)})},{key:"setSelectionKnowledge",value:function(e){this.selectionKnowledgeBases.value=c(e);var t=this.getQueryKnowledgeBases();this.topicId&&this.aiTopic&&t&&this.aiTopic.updateTopicChatByID(this.topicId,{selectAIKnowledgeBaseId:t})}},{key:"updateTopic",value:(a=v(h().m(function e(){var t,n,i,r,o,a,s,c,l,u,f,p,v,m,g,y,k=arguments;return h().w(function(e){for(;;)switch(e.n){case 0:if(t=!(k.length>0&&void 0!==k[0])||k[0],!this.chatSessionid||!this.chatSessionid.startsWith("temp")){e.n=1;break}return e.a(2);case 1:if((n=t)&&this.topicId&&this.aiTopic&&(i=this.aiTopic.getCurrentTopicByID(this.topicId))&&i.captionComputed&&(n=!1),n&&!0===this.isDigestProcessed&&(n=!1),r="",o=!1,!n){e.n=6;break}if(!(a=this.messages.value.find(function(e){return"USER"===e.role}))){e.n=6;break}if(o=!0,!this.sessionCaptionMode){e.n=6;break}y=this.sessionCaptionMode,e.n="snippet"===y?2:"summary"===y?3:5;break;case 2:return s=a.content,c=ba.parseMixedContent(s),l=c.remainingText,r=l.substring(0,15),e.a(3,6);case 3:return e.n=4,this.opts.chatDigest(this.context,this.params,{appDataEntityId:this.appDataEntityId,message:{messages:this.getMessages(),sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,mode:"title",maxtokens:this.opts.summaryMaxTokens||30}});case 4:return(u=e.v)&&u.content&&(r=u.content),e.a(3,6);case 5:return r=this.sessionDefaultCaption,e.a(3,6);case 6:if(f={},!o||"REMOTE"!==this.resourceMode||!this.resourceOptions||this.currentTopicDisableStorage){e.n=8;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:this.chatSessionid});case 7:if(!((p=e.v)&&p.length>0)){e.n=8;break}if(v=p[0],m={},v.ui_meta&&(m=ga(v.ui_meta)),!r||!v||v.caption===r||!0===m.captionComputed){e.n=8;break}if(f.caption=r,f.ui_meta=d(d({},this.sessionMeta),{},{captionComputed:!0}),!(Object.keys(f).length>0)){e.n=8;break}return e.n=8,this.resourceOptions.updateSession(p[0].realid,f);case 8:if(!this.topicId||!this.aiTopic){e.n=11;break}if(g=this.needUpdateMetaData?this.sessionMeta:void 0,!o||!r){e.n=10;break}return e.n=9,this.aiTopic.updateTopicCaption(this.topicId,r);case 9:this.isDigestProcessed=!0,e.n=11;break;case 10:if(!g||!this.aiTopic.backupOptions){e.n=11;break}return e.n=11,this.aiTopic.updateTopicConfig(this.aiTopic.backupOptions);case 11:this.needUpdateMetaData=!1;case 12:return e.a(2)}},e,this)})),function(){return a.apply(this,arguments)})},{key:"messageLike",value:(o=v(h().m(function e(t){var n,i,r;return h().w(function(e){for(;;)switch(e.n){case 0:if(n="1"===t.islike,(i=t.realmessageid)&&this.resourceOptions){e.n=1;break}return e.a(2);case 1:if(!n){e.n=3;break}return e.n=2,this.resourceOptions.cancelFeedback(i);case 2:r=e.v,e.n=5;break;case 3:return e.n=4,this.resourceOptions.likeMessage(i);case 4:r=e.v;case 5:r&&(t.islike=n?"0":"1",n||"1"!==t.isdislike||(t.isdislike="0"),this.replaceMessage(t,!1));case 6:return e.a(2)}},e,this)})),function(e){return o.apply(this,arguments)})},{key:"messageDisLike",value:(r=v(h().m(function e(t){var n,i,r,o;return h().w(function(e){for(;;)switch(e.n){case 0:if(n="1"===t.isdislike,i=t.realmessageid,r=t.feedbackcontent,i&&this.resourceOptions){e.n=1;break}return e.a(2);case 1:if(!n){e.n=3;break}return e.n=2,this.resourceOptions.cancelFeedback(i);case 2:o=e.v,e.n=5;break;case 3:return e.n=4,this.resourceOptions.dislikeMessage(i,r);case 4:o=e.v;case 5:o&&(t.isdislike=n?"0":"1",n||"1"!==t.islike||(t.islike="0"),this.replaceMessage(t,!1));case 6:return e.a(2)}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"handlePredefinedClick",value:(i=v(h().m(function e(t,n,i,r){var o,a,s;return h().w(function(e){for(;;)switch(e.n){case 0:s=t,e.n="chunkview"===s?1:"view"===s?5:"action"===s?7:9;break;case 1:if(o=n.replace("chunkview://",""),this.opts.chunkView){e.n=2;break}return console.error($c.t.value("chunkView")),e.a(2);case 2:if(this.opts.chunkEntity){e.n=3;break}return console.error($c.t.value("chunkEntity")),e.a(2);case 3:return a="view://".concat(this.opts.chunkView,'?srfnavctx={"').concat(this.opts.chunkEntity,'":"').concat(o,'"}'),e.n=4,this.handlePredefViewClick(a,i,r);case 4:case 6:case 8:return e.a(3,9);case 5:return e.n=6,this.handlePredefViewClick(n,i,r);case 7:return e.n=8,this.handlePredefActionClick(n,i,r);case 9:return e.a(2)}},e,this)})),function(e,t,n,r){return i.apply(this,arguments)})},{key:"handlePredefViewClick",value:(n=v(h().m(function e(t,n,i){return h().w(function(e){for(;;)switch(e.n){case 0:if(this.opts.openLinkView){e.n=1;break}return e.a(2);case 1:return e.n=2,this.opts.openLinkView(t,n,i);case 2:return e.a(2)}},e,this)})),function(e,t,i){return n.apply(this,arguments)})},{key:"handlePredefActionClick",value:(t=v(h().m(function e(t,n,i){var r,o,a,s,c,l,u,f,p,v,m,g;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.opts.extendToolbarClick){e.n=1;break}return e.a(2);case 1:if(o=pa(t),a=o.typeId,s=o.context,c=o.params,l=a,u=s.appid,l){e.n=2;break}throw new Error($c.t.value("actionIdCannotEmpty"));case 2:return f=this.cloneMessage(n),Object.assign(f,{topic:this.topic}),f.msg.realcontent=n.realcontent,p=d({},this.context),s&&Object.keys(s).length>0&&Object.assign(p,d({},s)),v=d({},this.params),c&&Object.keys(c).length>0&&Object.assign(v,d({},c)),e.n=3,this.opts.extendToolbarClick(i,{id:l,isPluginApp:!!u,appId:u||this.context.srfappid},p,v,f);case 3:m=e.v,(g=null==m||null===(r=m.data)||void 0===r?void 0:r[0])&&g.content&&this.addMessage({messageid:la(),state:30,type:g.type||"DEFAULT",role:g.role||"ASSISTANT",content:g.content,status:"sent"});case 4:return e.a(2)}},e,this)})),function(e,n,i){return t.apply(this,arguments)})},{key:"onMessageChange",value:function(e,t){var n,i;null===(n=(i=this.opts).action)||void 0===n||n.call(i,e,t)}},{key:"destroyed",value:(e=v(h().m(function e(){return h().w(function(e){for(;;)switch(e.n){case 0:this.evt.reset();case 1:return e.a(2)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"setActiveAsyncacitonId",value:function(e){this.activeAsyncacitonid=e}},{key:"getActiveAsyncacitonId",value:function(){return this.activeAsyncacitonid}}]);var e,t,n,i,r,o,a,s,l,u,m,y,k,w,b,S,M,_,N,O,E,A,D,I,L,R,P,z,B,H,F,j,V,W,$,U}(),Dw=function(){return x(function e(t){C(this,e),T(this,"topics",gs([])),T(this,"activedTopic",gs(void 0)),T(this,"topicSidebarCollapse",gs(!1)),T(this,"topicSidebarWidth",gs(0)),T(this,"isTempChat",gs(!1)),T(this,"isSelectMode",gs(!1)),T(this,"selectedTopicIds",gs(new Set)),T(this,"backupOptions",void 0),T(this,"preActivedTopic",void 0),T(this,"remoteSessionList",[]),T(this,"resourceMode","LOCAL"),T(this,"resourceOptions",void 0),T(this,"configList",[]),T(this,"storageMode","DEFAULT"),T(this,"compWrapperId","DEFAULT"),T(this,"workMode","DEFAULT"),T(this,"disableSelectScope",!1),T(this,"scopeList",[]),T(this,"groups",gs([])),T(this,"groupConfig",void 0),this.chat=t},[{key:"isTopicGenerating",value:function(e){var t,n;return null!==(t=null===(n=this.chat.getAiChatControllerByTopicId(e))||void 0===n?void 0:n.isLoading.value)&&void 0!==t&&t}},{key:"setActivedTopic",value:function(e){this.preActivedTopic=this.activedTopic.value,this.activedTopic.value=e,this.handleAction("active",e)}},{key:"injectBasicResources",value:function(e,t,n,i){this.compWrapperId=e||"DEFAULT",this.workMode=t,this.disableSelectScope=n||!1,this.scopeList=null!=i?i:[],this.computeTopicSidebarWidth()}},{key:"injectResourceOptions",value:function(e){this.resourceMode=(null==e?void 0:e.resourceMode)||"LOCAL",this.resourceOptions=e}},{key:"fetchHistory",value:(I=v(h().m(function e(t){var n,i,r,o,a=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.topics.value=[],this.storageMode=t.storageMode||"DEFAULT","WORKSPACE"!==this.workMode){e.n=1;break}return e.n=1,this.fetchGroups(t);case 1:if("REMOTESESSION"!==this.storageMode){e.n=3;break}if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=3;break}return e.n=2,this.resourceOptions.getSessionList();case 2:return this.remoteSessionList=e.v,e.n=3,this.asyncRemoteSession();case 3:if("DEFAULT"!==this.storageMode){e.n=8;break}return i=t.configService(t.appid,"aitopics",t.type),e.n=4,i.load();case 4:if(r=e.v,this.configList=Array.isArray(r)?r:[],!(this.configList&&this.configList.length>0)){e.n=8;break}if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=7;break}return e.n=5,this.resourceOptions.getSessionList();case 5:return this.remoteSessionList=e.v,e.n=6,this.asyncRemoteSession();case 6:e.n=8;break;case 7:o=1,this.configList.forEach(function(e,t){e.captionComputed||(e.caption=$c.t.value("historySession",{count:o}),o+=1),Object.prototype.hasOwnProperty.call(e,"sequence")||(e.sequence=t),Object.prototype.hasOwnProperty.call(e,"isTop")||(e.isTop=0),a.topics.value=[].concat(c(a.topics.value),[new lw(e)])});case 8:null===(n=t.action)||void 0===n||n.call(t,"history",{topics:this.topics.value});case 9:return e.a(2)}},e,this)})),function(e){return I.apply(this,arguments)})},{key:"asyncRemoteSession",value:(D=v(h().m(function e(){var t,n=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.remoteSessionList&&0!==this.remoteSessionList.length&&("DEFAULT"!==this.storageMode||0!==this.configList.length)){e.n=1;break}return e.a(2);case 1:t=1,this.remoteSessionList.forEach(function(e){var i;if("DEFAULT"===n.storageMode&&(i=n.configList.find(function(t){var n;return(null===(n=t.aiChat)||void 0===n?void 0:n.sessionid)===e.session_id})),"REMOTESESSION"===n.storageMode&&e.ui_meta&&(i=ga(e.ui_meta)),i&&!i.captionComputed&&(i.caption=$c.t.value("historySession",{count:t}),t+=1),i&&i.id){i.realid=e.realid,i.sequence=e.sequence,i.isTop=e.is_top?e.is_top:0,e.caption&&(i.caption=e.caption),e.scope&&(i.scope=e.scope);var r=n.topics.value.findIndex(function(t){var n;return(null===(n=t.aiChat)||void 0===n?void 0:n.sessionid)===e.session_id});-1===r?n.topics.value=[].concat(c(n.topics.value),[new lw(i)]):(n.topics.value.splice(r,1,new lw(i)),n.topics.value=c(n.topics.value))}});case 2:return e.a(2)}},e,this)})),function(){return D.apply(this,arguments)})},{key:"asyncTopic",value:(A=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:this.backupOptions=t,n=this.topics.value.findIndex(function(e){return e.id===t.id}),i=new lw(t),-1!==n?this.topics.value.splice(n,1,i):this.topics.value=[].concat(c(this.topics.value),[i]),this.setActivedTopic(i);case 1:return e.a(2)}},e,this)})),function(e){return A.apply(this,arguments)})},{key:"getCurrentTopicByID",value:function(e){var t=this.topics.value.find(function(t){return t.id===e});return t&&t.data?new lw(d({},t.data)):void 0}},{key:"updateTopicChatByID",value:(E=v(h().m(function e(t,n){var i,r,o,a;return h().w(function(e){for(;;)switch(e.n){case 0:if(t&&n&&this.backupOptions){e.n=1;break}return e.a(2);case 1:if(-1!==(i=this.topics.value.findIndex(function(e){return e.id===t}))&&this.topics.value[i].data.aiChat){e.n=2;break}return e.a(2);case 2:if(r=this.topics.value[i]){e.n=3;break}return e.a(2);case 3:if(r.data.aiChat=d(d({},r.data.aiChat),n),!1!==r.captionComputed){e.n=4;break}return e.a(2);case 4:if("REMOTESESSION"!==this.storageMode||!this.resourceOptions){e.n=8;break}if(o={ui_meta:this.buildTopicUiMeta(r,n)},!r.realid){e.n=6;break}return e.n=5,this.resourceOptions.updateSession(r.realid,o);case 5:e.n=8;break;case 6:if(!r.aiChat||!r.aiChat.sessionid){e.n=8;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:r.aiChat.sessionid});case 7:if(!((a=e.v)&&a.length>0)){e.n=8;break}return e.n=8,this.resourceOptions.updateSession(a[0].realid,o);case 8:if("DEFAULT"!==this.storageMode){e.n=9;break}return e.n=9,this.updateTopicConfig(this.backupOptions);case 9:this.handleAction("update",r);case 10:return e.a(2)}},e,this)})),function(e,t){return E.apply(this,arguments)})},{key:"buildTopicUiMeta",value:function(e,t){return{appid:e.appid,id:e.id,type:e.type,captionMode:e.captionMode,captionComputed:!!e.captionComputed,caption:e.caption||e.sourceCaption,sourceCaption:e.sourceCaption,url:e.url,aiChat:d(d({},e.aiChat),t),isTop:e.isTop,sequence:e.sequence,scope:e.scope,groupid:e.groupid}}},{key:"updateTopicRemoteMeta",value:(O=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:if("REMOTESESSION"===this.storageMode||"DEFAULT"===this.storageMode&&"REMOTE"===this.resourceMode){e.n=1;break}return e.a(2);case 1:if(this.resourceOptions){e.n=2;break}return e.a(2);case 2:if(n={ui_meta:this.buildTopicUiMeta(t)},(t.scope||void 0===t.scope)&&Object.assign(n,{scope:t.scope||null}),!t.realid){e.n=4;break}return e.n=3,this.resourceOptions.updateSession(t.realid,n);case 3:e.n=6;break;case 4:if(!t.aiChat||!t.aiChat.sessionid){e.n=6;break}return e.n=5,this.resourceOptions.getSessionList({n_session_id_eq:t.aiChat.sessionid});case 5:if(!((i=e.v)&&i.length>0)){e.n=6;break}return e.n=6,this.resourceOptions.updateSession(i[0].realid,n);case 6:return e.a(2)}},e,this)})),function(e){return O.apply(this,arguments)})},{key:"removeTopic",value:(N=v(h().m(function e(t,n,i,r,o){var a,s,l,u,d;return h().w(function(e){for(;;)switch(e.n){case 0:if(s=!0,!t.beforeDelete){e.n=2;break}return e.n=1,t.beforeDelete($c.t.value("deleteConversation"),$c.t.value("deleteConversationConfirmTip"));case 1:s=e.v;case 2:if(s){e.n=3;break}return e.a(2);case 3:if(l=!1,!r||!r.disableStorage){e.n=4;break}l=!0,e.n=11;break;case 4:if("DEFAULT"!==this.storageMode){e.n=9;break}if("LOCAL"!==this.resourceMode){e.n=6;break}return e.n=5,ka.deleteData(Tw.DATA_BASE_NAME,Tw.DATA_TABLE_NAME,r.id);case 5:l=e.v,e.n=8;break;case 6:return e.n=7,this.deleteRemoteSession(r);case 7:l=e.v;case 8:e.n=11;break;case 9:if("REMOTESESSION"!==this.storageMode){e.n=11;break}return e.n=10,this.deleteRemoteSession(r);case 10:l=e.v;case 11:if(l){e.n=12;break}return e.a(2);case 12:return-1!==(u=this.topics.value.findIndex(function(e){return e.id===r.id}))&&(this.topics.value.splice(u,1),this.topics.value=c(this.topics.value)),"DEFAULT"===this.storageMode&&-1!==(d=this.configList.findIndex(function(e){return e.id===r.id}))&&this.configList.splice(d,1),e.n=13,this.updateTopicConfig(t);case 13:this.handleAction("remove",r),this.topics.value.length>0&&r.id===(null===(a=this.activedTopic.value)||void 0===a?void 0:a.id)&&this.handleTopicChange(this.topics.value[0]);case 14:return e.a(2)}},e,this)})),function(e,t,n,i,r){return N.apply(this,arguments)})},{key:"deleteRemoteSession",value:(_=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:if("REMOTE"===this.resourceMode&&this.resourceOptions){e.n=1;break}return e.a(2,!1);case 1:if(!t.realid){e.n=2;break}return e.a(2,this.resourceOptions.deleteSession(t.realid));case 2:if(null===(n=t.aiChat)||void 0===n||!n.sessionid){e.n=5;break}return e.n=3,this.resourceOptions.getSessionList({n_session_id_eq:t.aiChat.sessionid});case 3:if(!((i=e.v)&&i.length>0)){e.n=4;break}return e.a(2,this.resourceOptions.deleteSession(i[0].realid));case 4:return e.a(2,!0);case 5:return e.a(2,!1)}},e,this)})),function(e){return _.apply(this,arguments)})},{key:"handleTopicChange",value:function(e){var t;(null===(t=this.activedTopic.value)||void 0===t?void 0:t.id)!==e.id&&(this.setActivedTopic(e),this.chat.switchAiChatController(e))}},{key:"handleTopicAction",value:(M=v(h().m(function e(t,n,i){var r,o,a,s,l,u;return h().w(function(e){for(;;)switch(e.n){case 0:if(r=this.topics.value.find(function(e){return e.id===n.id}),!(this.backupOptions&&r&&r.aiChat)){e.n=10;break}o=r.aiChat,a=o.context,s=o.params,u=t,e.n="DELETE"===u?1:"RENAME"===u||"PINNED"===u?3:9;break;case 1:return e.n=2,this.removeTopic(this.backupOptions,a,s,r,i);case 2:return e.a(3,9);case 3:if("PINNED"===t&&(n.data.isTop=0===n.data.isTop?1:0,this.topics.value=c(this.topics.value)),!n||n.disableStorage){e.n=8;break}if(!n||"REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=7;break}if(!n.realid){e.n=5;break}return e.n=4,this.resourceOptions.updateSession(n.realid,{caption:n.caption,is_top:n.isTop});case 4:e.n=7;break;case 5:if(!n.aiChat||!n.aiChat.sessionid){e.n=7;break}return e.n=6,this.resourceOptions.getSessionList({n_session_id_eq:n.aiChat.sessionid});case 6:if(!((l=e.v)&&l.length>0)){e.n=7;break}return e.n=7,this.resourceOptions.updateSession(l[0].realid,{caption:n.caption,is_top:n.isTop});case 7:if("DEFAULT"!==this.storageMode){e.n=8;break}return e.n=8,this.updateTopicConfig(this.backupOptions);case 8:return e.a(3,9);case 9:this.handleAction(t,n);case 10:return e.a(2)}},e,this)})),function(e,t,n){return M.apply(this,arguments)})},{key:"newTopic",value:(S=v(h().m(function e(t,n,i){var r,o,a,s,l,u,f,p;return h().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:if(r=this.getCurrentTopicByID(t)){e.n=2;break}return e.a(2);case 2:o=ua(r.id),a="".concat(o,"@").concat(Date.now()),s=fa("TOPIC",a),n&&r.aiChat&&(r.data.aiChat=d(d(d({},r.aiChat),n),{},{sessionid:s})),l=$c.t.value("newConversation"),u=Math.max.apply(Math,c(this.topics.value.map(function(e){return e.sequence}))),f=d({appid:r.appid,id:a,type:r.type,captionMode:r.captionMode,caption:l,sourceCaption:r.sourceCaption,url:r.url,aiChat:r.aiChat,sequence:u+1,isTop:0,disableStorage:r.disableStorage},i),p=new lw(f),this.topics.value=[p].concat(c(this.topics.value)),this.handleAction("create",p),this.handleTopicChange(p);case 3:return e.a(2)}},e,this)})),function(e,t,n){return S.apply(this,arguments)})},{key:"clearTopic",value:(b=v(h().m(function e(){var t,n,i,r,o=this,a=arguments;return h().w(function(e){for(;;)switch(e.n){case 0:if(t=a.length>0&&void 0!==a[0]&&a[0],n=this.topics.value.find(function(e){var t;return e.id===(null===(t=o.activedTopic.value)||void 0===t?void 0:t.id)}),this.backupOptions&&n){e.n=1;break}return e.a(2);case 1:if(!this.backupOptions.beforeDelete){e.n=3;break}return e.n=2,this.backupOptions.beforeDelete($c.t.value("clearSession"),$c.t.value(t?"clearSessionWithGroupConfirmTip":"clearSessionConfirmTip"));case 2:if(e.v){e.n=3;break}return e.a(2);case 3:if(i=!1,"DEFAULT"!==this.storageMode){e.n=8;break}if("LOCAL"!==this.resourceMode){e.n=5;break}return e.n=4,Promise.all(this.topics.value.filter(function(e){return e.id!==n.id&&!e.disableStorage}).map(function(e){return ka.deleteData(Tw.DATA_BASE_NAME,Tw.DATA_TABLE_NAME,e.id)}));case 4:i=!0,e.n=7;break;case 5:return e.n=6,this.clearRemoteSession(n);case 6:i=e.v;case 7:e.n=10;break;case 8:if("REMOTESESSION"!==this.storageMode){e.n=10;break}return e.n=9,this.clearRemoteSession(n);case 9:i=e.v;case 10:if(i){e.n=11;break}return e.a(2);case 11:return r=t?new Set(this.computeGroupTree().flatMap(function(e){return e.groups.map(function(e){return e.id})})):void 0,"DEFAULT"===this.storageMode&&(this.configList=[]),this.handleAction("clear",n),this.topics.value=n?[n]:[],e.n=12,this.updateTopicConfig(this.backupOptions);case 12:if(!r){e.n=13;break}return this.groups.value=this.groups.value.filter(function(e){return!r.has(e.id)}),e.n=13,this.saveGroups();case 13:return e.a(2)}},e,this)})),function(){return b.apply(this,arguments)})},{key:"clearRemoteSession",value:(w=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.resourceOptions){e.n=1;break}return e.a(2,!0);case 1:if(i=null===(n=t.aiChat)||void 0===n?void 0:n.sessionid){e.n=2;break}return e.a(2,!0);case 2:return e.a(2,this.resourceOptions.clearAllSession(i))}},e,this)})),function(e){return w.apply(this,arguments)})},{key:"enterSelectMode",value:function(e){this.isSelectMode.value=!0,e&&(this.selectedTopicIds.value=new Set([e]))}},{key:"exitSelectMode",value:function(){this.isSelectMode.value=!1,this.selectedTopicIds.value=new Set}},{key:"toggleTopicSelected",value:function(e){var t=new Set(this.selectedTopicIds.value);t.has(e)?t.delete(e):t.add(e),this.selectedTopicIds.value=t}},{key:"getSelectedTopics",value:function(){var e=this;return this.topics.value.filter(function(t){return e.selectedTopicIds.value.has(t.id)})}},{key:"updateTopicCaption",value:(k=v(h().m(function e(t,n){var i;return h().w(function(e){for(;;)switch(e.n){case 0:if(!(i=this.topics.value.find(function(e){return e.id===t}))||i.caption===n){e.n=1;break}if(i.data.caption=n,i.data.captionComputed=!0,this.topics.value=c(this.topics.value),this.handleAction("update",i),!this.backupOptions){e.n=1;break}return e.n=1,this.updateTopicConfig(this.backupOptions);case 1:return e.a(2)}},e,this)})),function(e,t){return k.apply(this,arguments)})},{key:"updateTopicConfig",value:(y=v(h().m(function e(t){var n,i,r;return h().w(function(e){for(;;)switch(e.n){case 0:if(t&&"DEFAULT"===this.storageMode&&!0!==this.isTempChat.value){e.n=1;break}return e.a(2);case 1:return n=[],i=new Set,this.topics.value.forEach(function(e){i.add(e.id),!e.disableStorage&&e.captionComputed&&n.push({appid:e.appid,id:e.id,type:e.type,captionMode:e.captionMode,captionComputed:!!e.captionComputed,caption:e.caption||e.sourceCaption,sourceCaption:e.sourceCaption,url:e.url,aiChat:e.aiChat,isTop:e.isTop,sequence:e.sequence,scope:e.scope,groupid:e.groupid})}),this.configList.forEach(function(e){i.has(e.id)||n.push({appid:e.appid,id:e.id,type:e.type,captionMode:e.captionMode,captionComputed:!!e.captionComputed,caption:e.caption,sourceCaption:e.sourceCaption,url:e.url,aiChat:e.aiChat,isTop:e.isTop,sequence:e.sequence,scope:e.scope,groupid:e.groupid})}),r=t.configService(t.appid,"aitopics",t.type),e.n=2,null==r?void 0:r.save(n);case 2:return e.a(2)}},e,this)})),function(e){return y.apply(this,arguments)})},{key:"computeTopicSidebarWidth",value:function(){var e,t="WORKSPACE"===this.workMode?320:200;this.topicSidebarWidth.value=!0===this.topicSidebarCollapse.value?42:null!==(e=this.getTopicSidebarWidthCache())&&void 0!==e?e:t}},{key:"getTopicSidebarWidthCacheKey",value:function(){return"".concat(this.compWrapperId,"__").concat(Tw.TOPIC_SIDEBAR_WIDTH)}},{key:"getTopicSidebarWidthCache",value:function(){var e=this.getTopicSidebarWidthCacheKey(),t=localStorage.getItem(e);if(null!==t){var n=Number(t);return Number.isFinite(n)&&n>0?n:void 0}}},{key:"updateTopicSidebarWidth",value:function(){var e=this.getTopicSidebarWidthCacheKey();localStorage.setItem(e,String(this.topicSidebarWidth.value))}},{key:"switchTopicSidebarCollapse",value:function(){this.topicSidebarCollapse.value=!this.topicSidebarCollapse.value,this.computeTopicSidebarWidth()}},{key:"globalNewTopic",value:function(e,t){if(this.activedTopic.value)if(this.isTempChat.value){if(!this.backupOptions)return;this.exitTempChat();var n=this.backupOptions.aiChat;this.newTopic(this.backupOptions.id,{activeAIAgentID:n.activeAIAgentID},{scope:e,groupid:t})}else{var i=this.activedTopic.value.aiChat;this.newTopic(this.activedTopic.value.id,{activeAIAgentID:i.activeAIAgentID},{scope:e,groupid:t})}}},{key:"enterTempChat",value:function(){if(this.isTempChat.value=!0,this.backupOptions){var e=ua(this.backupOptions.id),t=fa("TEMP"),n=Math.max.apply(Math,c(this.topics.value.map(function(e){return e.sequence}))),i=d(d({},this.backupOptions.aiChat),{},{sessionid:t}),r={appid:this.backupOptions.appid,id:"".concat(e,"@").concat(Date.now()),type:this.backupOptions.type,captionMode:this.backupOptions.captionMode,caption:$c.t.value("temporarySession"),sourceCaption:$c.t.value("temporarySession"),url:this.backupOptions.url,aiChat:i,sequence:n+1,isTop:0,disableStorage:!0,isShow:!1},o=new lw(r);this.topics.value=[].concat(c(this.topics.value),[o]),this.handleAction("createTemp",o),this.handleTopicChange(o)}else console.error($c.t.value("temporarySessionFailed"))}},{key:"exitTempChat",value:function(){this.isTempChat.value=!1;var e=this.topics.value.findIndex(function(e){return!0===e.disableStorage&&!1===e.isShow});if(-1!==e){var t=this.topics.value[e];this.topics.value.splice(e,1),this.topics.value=c(this.topics.value),this.handleAction("removeTemp",t)}}},{key:"handleAction",value:function(e,t){var n,i,r,o;null===(n=this.backupOptions)||void 0===n||null===(i=n.action)||void 0===i||i.call(n,e,{topic:t,params:null==t||null===(r=t.aiChat)||void 0===r?void 0:r.params,context:null==t||null===(o=t.aiChat)||void 0===o?void 0:o.context,topics:this.topics.value})}},{key:"resolveTopicRealIds",value:(g=v(h().m(function e(t){var n,i=this;return h().w(function(e){for(;;)switch(e.n){case 0:return n=[],e.n=1,Promise.all(t.map(function(){var e=v(h().m(function e(t){var r,o;return h().w(function(e){for(;;)switch(e.n){case 0:if(!t.realid){e.n=1;break}return n.push(t.realid),e.a(2);case 1:if(null===(r=t.aiChat)||void 0===r||!r.sessionid){e.n=3;break}return e.n=2,i.resourceOptions.getSessionList({n_session_id_eq:t.aiChat.sessionid});case 2:(o=e.v)&&o.length>0&&n.push(o[0].realid);case 3:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}()));case 1:return e.a(2,n)}},e)})),function(e){return g.apply(this,arguments)})},{key:"batchDeleteRemoteSession",value:(m=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.resourceOptions&&0!==t.length){e.n=1;break}return e.a(2,!0);case 1:return e.n=2,this.resolveTopicRealIds(t);case 2:if(0!==(n=e.v).length){e.n=3;break}return e.a(2,!0);case 3:return e.a(2,this.resourceOptions.batchDeleteSession(n))}},e,this)})),function(e){return m.apply(this,arguments)})},{key:"batchPinTop",value:(p=v(h().m(function e(){var t,n;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.backupOptions){e.n=1;break}return e.a(2);case 1:if(0!==(t=this.getSelectedTopics()).length){e.n=2;break}return e.a(2);case 2:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=5;break}return e.n=3,this.resolveTopicRealIds(t);case 3:if(!((n=e.v).length>0)){e.n=5;break}return e.n=4,this.resourceOptions.batchTopSession(n);case 4:if(e.v){e.n=5;break}return e.a(2);case 5:if(t.forEach(function(e){e.data.isTop=1}),this.topics.value=c(this.topics.value),"DEFAULT"!==this.storageMode){e.n=6;break}return e.n=6,this.updateTopicConfig(this.backupOptions);case 6:this.exitSelectMode();case 7:return e.a(2)}},e,this)})),function(){return p.apply(this,arguments)})},{key:"batchUnPinTop",value:(f=v(h().m(function e(){var t,n;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.backupOptions){e.n=1;break}return e.a(2);case 1:if(0!==(t=this.getSelectedTopics()).length){e.n=2;break}return e.a(2);case 2:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=5;break}return e.n=3,this.resolveTopicRealIds(t);case 3:if(!((n=e.v).length>0)){e.n=5;break}return e.n=4,this.resourceOptions.batchUnTopSession(n);case 4:if(e.v){e.n=5;break}return e.a(2);case 5:if(t.forEach(function(e){e.data.isTop=0}),this.topics.value=c(this.topics.value),"DEFAULT"!==this.storageMode){e.n=6;break}return e.n=6,this.updateTopicConfig(this.backupOptions);case 6:this.exitSelectMode();case 7:return e.a(2)}},e,this)})),function(){return f.apply(this,arguments)})},{key:"batchDeleteTopics",value:(u=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.backupOptions){e.n=1;break}return e.a(2);case 1:if(!(n=this.getSelectedTopics())||0!==n.length){e.n=2;break}return e.a(2);case 2:return e.n=3,this.deleteTopicsCore(n);case 3:this.exitSelectMode();case 4:return e.a(2)}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"deleteTopicsCore",value:(l=v(h().m(function e(t,n,i){var r,o;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.backupOptions){e.n=1;break}return e.a(2,!1);case 1:if(!this.backupOptions.beforeDelete){e.n=3;break}return e.n=2,this.backupOptions.beforeDelete(null!=n?n:0===t.length?$c.t.value("batchDeleteSession"):$c.t.value("batchDeleteConversation",{count:t.length}),null!=i?i:$c.t.value("batchDeleteConversationConfirmTip"));case 2:if(e.v){e.n=3;break}return e.a(2,!1);case 3:if(t&&0!==t.length){e.n=4;break}return e.a(2,!0);case 4:if(r=!1,"DEFAULT"!==this.storageMode){e.n=9;break}if("LOCAL"!==this.resourceMode){e.n=6;break}return e.n=5,Promise.all(t.filter(function(e){return!e.disableStorage}).map(function(e){return ka.deleteData(Tw.DATA_BASE_NAME,Tw.DATA_TABLE_NAME,e.id)}));case 5:r=!0,e.n=8;break;case 6:return e.n=7,this.batchDeleteRemoteSession(t);case 7:r=e.v;case 8:e.n=11;break;case 9:if("REMOTESESSION"!==this.storageMode){e.n=11;break}return e.n=10,this.batchDeleteRemoteSession(t);case 10:r=e.v;case 11:if(r){e.n=12;break}return e.a(2,!1);case 12:return o=new Set(t.map(function(e){return e.id})),this.topics.value=this.topics.value.filter(function(e){return!o.has(e.id)}),"DEFAULT"===this.storageMode&&(this.configList=this.configList.filter(function(e){return!o.has(e.id)})),e.n=13,this.updateTopicConfig(this.backupOptions);case 13:return this.activedTopic.value&&o.has(this.activedTopic.value.id)&&this.topics.value.length>0&&this.handleTopicChange(this.topics.value[0]),e.a(2,!0)}},e,this)})),function(e,t,n){return l.apply(this,arguments)})},{key:"getGroupConfig",value:function(e){return this.groupConfig||(this.groupConfig=e.configService(e.appid,"aigroups",e.type)),this.groupConfig}},{key:"fetchGroups",value:(s=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.n){case 0:return n=this.getGroupConfig(t),e.n=1,n.load();case 1:i=e.v,this.groups.value=Array.isArray(i)?i:[];case 2:return e.a(2)}},e,this)})),function(e){return s.apply(this,arguments)})},{key:"saveGroups",value:(a=v(h().m(function e(){var t;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.backupOptions){e.n=1;break}return e.a(2);case 1:return t=this.getGroupConfig(this.backupOptions),e.n=2,null==t?void 0:t.save(this.groups.value);case 2:return e.a(2)}},e,this)})),function(){return a.apply(this,arguments)})},{key:"computeGroupTree",value:function(e){var t=this,n=null==e?void 0:e.trim().toLowerCase(),i=c(this.topics.value).sort(function(e,t){return e.isTop!==t.isTop?t.isTop?1:-1:t.sequence-e.sequence}).filter(function(e){var t,i;return!1!==e.isShow&&(!n||null!==(t=null===(i=e.caption)||void 0===i?void 0:i.toLowerCase().includes(n))&&void 0!==t&&t)}),r=[];this.scopeList.forEach(function(e){var n=i.filter(function(t){return String(t.scope)===String(e.id)});if(0!==n.length){var o=t.groups.value.filter(function(t){return String(t.scopeid)===String(e.id)}),a=new Set(o.map(function(e){return e.id}));r.push({key:"scope:".concat(String(e.id)),scopeid:e.id,text:e.text,groups:o.map(function(e){return{id:e.id,text:e.text,collapsed:e.collapsed,topics:n.filter(function(t){return t.groupid===e.id})}}),ungroupedTopics:n.filter(function(e){return!e.groupid||!a.has(e.groupid)})})}});var o=i.filter(function(e){return t.isUnclassifiedTopic(e)}),a=this.groups.value.filter(function(e){return e.scopeid===Mw.NONE_SCOPE_ID});if(o.length>0){var s=new Set(a.map(function(e){return e.id}));r.push({key:Mw.NONE_SCOPE_KEY,scopeid:void 0,text:$c.t.value("unclassifiedTopic"),groups:a.map(function(e){return{id:e.id,text:e.text,collapsed:e.collapsed,topics:o.filter(function(t){return t.groupid===e.id})}}),ungroupedTopics:o.filter(function(e){return!e.groupid||!s.has(e.groupid)})})}return r}},{key:"isUnclassifiedTopic",value:function(e){return!e.scope||!this.scopeList.some(function(t){return String(t.id)===String(e.scope)})}},{key:"addGroup",value:(o=v(h().m(function e(t){var n,i;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return n={id:"group_".concat(Date.now(),"_").concat(Math.random().toString(36).slice(2,8)),text:$c.t.value("newGroup"),scopeid:null!=t?t:Mw.NONE_SCOPE_ID,collapsed:!0},this.groups.value=[].concat(c(this.groups.value),[n]),e.p=1,e.n=2,this.saveGroups();case 2:return e.a(2,n);case 3:return e.p=3,i=e.v,this.groups.value=this.groups.value.filter(function(e){return e.id!==n.id}),this.groups.value=c(this.groups.value),console.error("[AiTopicController] addGroup 持久化失败",i),e.a(2,void 0)}},e,this,[[1,3]])})),function(e){return o.apply(this,arguments)})},{key:"renameGroup",value:(r=v(h().m(function e(t,n){var i,r,o;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if((i=this.groups.value.find(function(e){return e.id===t}))&&n&&i.text!==n){e.n=1;break}return e.a(2,void 0);case 1:return r=i.text,i.text=n,this.groups.value=c(this.groups.value),e.p=2,e.n=3,this.saveGroups();case 3:return e.a(2,i);case 4:return e.p=4,o=e.v,i.text=r,this.groups.value=c(this.groups.value),console.error("[AiTopicController] renameGroup 持久化失败",o),e.a(2,void 0)}},e,this,[[2,4]])})),function(e,t){return r.apply(this,arguments)})},{key:"toggleGroupCollapse",value:(i=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:if(n=this.groups.value.find(function(e){return e.id===t})){e.n=1;break}return e.a(2);case 1:return n.collapsed=!0!==n.collapsed,this.groups.value=c(this.groups.value),e.n=2,this.saveGroups();case 2:return e.a(2)}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"removeScope",value:(n=v(h().m(function e(t){var n,i,r,o=this;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(void 0!==t){e.n=1;break}n=this.topics.value.filter(function(e){return o.isUnclassifiedTopic(e)}),e.n=3;break;case 1:if(this.scopeList.some(function(e){return String(e.id)===String(t)})){e.n=2;break}return e.a(2,!1);case 2:n=this.topics.value.filter(function(e){return String(e.scope)===String(t)});case 3:return e.n=4,this.deleteTopicsCore(n,$c.t.value("deleteScope"),$c.t.value("deleteScopeConfirmTip"));case 4:if(e.v){e.n=5;break}return e.a(2,!1);case 5:return i=this.groups.value,this.groups.value=this.groups.value.filter(function(e){return String(e.scopeid)!==String(void 0===t?Mw.NONE_SCOPE_ID:t)}),e.p=6,e.n=7,this.saveGroups();case 7:return e.a(2,!0);case 8:return e.p=8,r=e.v,this.groups.value=i,console.error("[AiTopicController] removeScope 持久化失败",r),e.a(2,!1)}},e,this,[[6,8]])})),function(e){return n.apply(this,arguments)})},{key:"removeGroup",value:(t=v(h().m(function e(t){var n,i,r;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.groups.value.some(function(e){return e.id===t})){e.n=1;break}return e.a(2,!1);case 1:return n=this.topics.value.filter(function(e){return e.groupid===t}),e.n=2,this.deleteTopicsCore(n,$c.t.value("deleteGroup"),$c.t.value("deleteGroupConfirmTip"));case 2:if(e.v){e.n=3;break}return e.a(2,!1);case 3:return i=this.groups.value,this.groups.value=this.groups.value.filter(function(e){return e.id!==t}),e.p=4,e.n=5,this.saveGroups();case 5:return e.a(2,!0);case 6:return e.p=6,r=e.v,this.groups.value=i,console.error("[AiTopicController] removeGroup 持久化失败",r),e.a(2,!1)}},e,this,[[4,6]])})),function(e){return t.apply(this,arguments)})},{key:"moveTopic",value:(e=v(h().m(function e(t,n,i){var r,o,a,s,l;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if((r=this.topics.value.find(function(e){return e.id===t}))&&this.backupOptions){e.n=1;break}return e.a(2,!1);case 1:if(o=r.data.scope,a=r.data.groupid,s=void 0===n?void 0:this.getOriginScopeId(n),(void 0===o?void 0:String(o))!==(void 0===s?void 0:String(s))||a!==i){e.n=2;break}return e.a(2,!0);case 2:if(r.data.scope=s,r.data.groupid=i,this.topics.value=c(this.topics.value),this.handleAction("update",r),e.p=3,"DEFAULT"!==this.storageMode){e.n=4;break}return e.n=4,this.updateTopicConfig(this.backupOptions);case 4:return e.n=5,this.updateTopicRemoteMeta(r);case 5:e.n=7;break;case 6:return e.p=6,l=e.v,r.data.scope=o,r.data.groupid=a,this.topics.value=c(this.topics.value),this.handleAction("update",r),console.error("[AiTopicController] moveTopic 持久化失败,已还原归属",l),e.a(2,!1);case 7:return e.a(2,!0)}},e,this,[[3,6]])})),function(t,n,i){return e.apply(this,arguments)})},{key:"getOriginScopeId",value:function(e){var t=this.scopeList.find(function(t){return String(t.id)===String(e)});return t?t.id:e}},{key:"getAiChat",value:function(){return this.chat.aiChat}}]);var e,t,n,i,r,o,a,s,l,u,f,p,m,g,y,k,w,b,S,M,_,N,O,E,A,D,I}(),Iw=x(function e(t){C(this,e),this.aiChat=t}),Lw=function(e){function t(){return C(this,t),n(this,t,arguments)}return i(t,e),x(t,[{key:"excuteAction",value:(r=v(h().m(function e(t,n){var i,r,o=this;return h().w(function(e){for(;;)switch(e.n){case 0:if(!n||!n.onClick||"function"!=typeof n.onClick){e.n=2;break}return e.n=1,n.onClick(t,n,this.aiChat.context,this.aiChat.params);case 1:i=e.v,e.n=5;break;case 2:if(!(r=this.aiChat.opts.extendToolbarClick)){e.n=4;break}return e.n=3,r(t,n,this.aiChat.context,this.aiChat.params,{});case 3:i=e.v,e.n=5;break;case 4:console.error($c.t.value("extensionToolbarClick"));case 5:i&&i.data&&i.data.length>0&&i.data.forEach(function(e){var t={id:e.id,type:e.type,data:e.data||{},metadata:e.metadata||{}};n.id&&Object.assign(t.metadata,{actionId:n.id}),o.aiChat.addMaterial(t)});case 6:return e.a(2)}},e,this)})),function(e,t){return r.apply(this,arguments)})}]);var r}(Iw),Rw=function(e){function t(){return C(this,t),n(this,t,arguments)}return i(t,e),x(t,[{key:"excuteAction",value:(r=v(h().m(function e(t,n){var i,r,o,a,s,c,l,u,d,f,p,m,g,y,k=this;return h().w(function(e){for(;;)switch(e.n){case 0:i=this.aiChat.opts.uploader,r=i.folder,o=i.accept,a=i.maxSize,s=i.multiple,c=i.onError,l=i.onSelect,u=i.onUpload,d=i.onSuccess,f=i.onDownLoad,p=i.getDownLoadUrl,m=i.onProgress,g=i.globalDownloadPrifix,y={folder:r,globalDownloadPrifix:g,multiple:s||!0,accept:o||"*/*",maxSize:a||5242880,onSelect:function(e){null==l||l(e),e.length>0&&e.forEach(function(e){var t=k.buildMaterialObject(r,e);Object.assign(t.metadata,{state:"uploading"}),k.aiChat.addMaterial(t)})},onUpload:function(){var e=v(h().m(function e(t,n){return h().w(function(e){for(;;)if(0===e.n)return e.a(2,u(t,n,{context:k.aiChat.context,params:k.aiChat.params}))},e)}));return function(t,n){return e.apply(this,arguments)}}(),onDownLoad:f,getDownLoadUrl:p,onSuccess:function(e,t){var n={id:e.id,type:"ossfile",data:{id:e.id,name:e.name,folder:r},metadata:{ext:e.ext,fileext:e.fileext,fileid:e.fileid,filename:e.filename,size:e.size,filesize:e.filesize,state:"successed",folder:r}};k.aiChat.replaceMaterial(t.name,n),null==d||d(e,t)},onError:function(e,t){var n=k.buildMaterialObject(r,t);Object.assign(n.metadata,{state:"failed"}),k.aiChat.replaceMaterial(t.name,n),null==c||c(e,t)},onProgress:function(e,t){null==m||m(e,t)}},new wa(y).openFilePicker();case 1:return e.a(2)}},e,this)})),function(e,t){return r.apply(this,arguments)})},{key:"buildMaterialObject",value:function(e,t){return{id:t.name,type:"ossfile",data:{name:t.name,id:t.name,folder:e},metadata:{size:t.size,type:t.type,lastModified:t.lastModified,folder:e}}}}]);var r}(Iw),Pw=function(){return x(function e(){C(this,e)},null,[{key:"getMaterialHelper",value:function(e,t){return"ossfile"===e?new Rw(t):new Lw(t)}}])}(),zw=function(){return x(function e(){C(this,e),T(this,"mode","DEFAULT"),T(this,"backupChatOptions",void 0),T(this,"resourceOptions",void 0),T(this,"aiTopic",void 0),T(this,"aiTopicMap",new Map),this.aiTopic=new Dw(this)},[{key:"aiChat",get:function(){var e,t=this.aiTopicMap.get("".concat(null===(e=this.aiTopic.activedTopic.value)||void 0===e?void 0:e.id));if(!t&&this.backupChatOptions&&this.backupChatOptions.topicOptions&&this.backupChatOptions.topicOptions.ingnoreAsyncTopic){var n=this.aiTopicMap.entries().next().value;t=n?n[1]:void 0}return t}},{key:"getAiChatControllerByTopicId",value:function(e){return this.aiTopicMap.get("".concat(e))}},{key:"initIndexDB",value:(t=v(h().m(function e(){return h().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ka.checkTableExists(Tw.DATA_BASE_NAME,Tw.DATA_TABLE_NAME);case 1:if(e.v){e.n=2;break}return e.n=2,ka.createTable(Tw.DATA_BASE_NAME,Tw.DATA_TABLE_NAME,Tw.DATA_TABLE_KEY_NAME,!1);case 2:return e.a(2)}},e)})),function(){return t.apply(this,arguments)})},{key:"create",value:(e=v(h().m(function e(t){var n,i,r,o,a,s,c,l,u,d;return h().w(function(e){for(;;)switch(e.n){case 0:if(this.aiTopic.injectBasicResources((null===(n=t.containerOptions)||void 0===n?void 0:n.compWrapperId)||"DEFAULT",(null===(i=t.topicOptions)||void 0===i?void 0:i.workMode)||"DEFAULT",(null===(r=t.topicOptions)||void 0===r?void 0:r.disableSelectScope)||!1,null===(o=t.topicOptions)||void 0===o?void 0:o.scopeList),t.chatOptions.language&&$c.setLanguage(t.chatOptions.language),t.chatOptions.locale&&$c.setLocale(t.chatOptions.locale),this.resourceOptions=t.resourceOptions,"LOCAL"!==((null===(a=t.resourceOptions)||void 0===a?void 0:a.resourceMode)||"LOCAL")){e.n=1;break}return e.n=1,this.initIndexDB();case 1:if(this.backupChatOptions=t,l=t.chatOptions,this.setupContainer(t,l),l.aiAgentlist||!l.fetchAgentList){e.n=3;break}return e.n=2,l.fetchAgentList({agentid:l.activeAIAgentID});case 2:l.aiAgentlist=e.v;case 3:if(l.aiknowledgeBasesList||!l.fetchKnowledgeBaseList||!l.enableKnowledgeBaseSelect){e.n=5;break}return e.n=4,l.fetchKnowledgeBaseList();case 4:l.aiknowledgeBasesList=e.v,e.n=6;break;case 5:l.aiknowledgeBasesList=[];case 6:if(t.chatOptions.isSimple||!t.mode||"TOPIC"!==t.mode){e.n=11;break}return this.aiTopic.injectResourceOptions(t.resourceOptions),u=t.topicOptions,Object.assign(u,{aiChat:{caption:l.caption,context:l.context,params:l.params,appDataEntityId:l.appDataEntityId,sessionid:l.sessionid,contentToolbarItems:l.contentToolbarItems,footerToolbarItems:l.footerToolbarItems,questionToolbarItems:l.questionToolbarItems,otherToolbarItems:l.otherToolbarItems,appendCurData:l.appendCurData,appendCurContent:l.appendCurContent,enableAIAgentChange:l.enableAIAgentChange,activeAIAgentID:l.activeAIAgentID,selectAIKnowledgeBaseId:l.selectAIKnowledgeBaseId,srfMode:l.srfMode,srfScope:l.srfScope,appendCurResource:l.appendCurResource}}),e.n=7,this.aiTopic.fetchHistory(u);case 7:if(u.ingnoreAsyncTopic){e.n=9;break}return this.syncHistoryOptions(u,l,t.resourceOptions),e.n=8,this.aiTopic.asyncTopic(u);case 8:e.n=10;break;case 9:this.aiTopic.setActivedTopic(void 0);case 10:e.n=12;break;case 11:this.aiTopic.setActivedTopic(void 0);case 12:return Object.assign(l,{topicId:null===(s=u)||void 0===s?void 0:s.id,topic:u,aiTopic:this.aiTopic}),d=new Aw(l,this.resourceOptions,t.topicOptions),this.aiTopicMap.set("".concat(null===(c=u)||void 0===c?void 0:c.id),d),t.mode&&"TOPIC"===t.mode&&this.aiTopic.isTempChat.value?this.aiTopic.enterTempChat():this.renderChatContent(t,l,d),e.a(2,d)}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"syncHistoryOptions",value:function(e,t,n){if("WORKSPACE"===e.workMode&&!e.scope&&t.srfScope&&(e.scope=t.srfScope),e.disableStorage){var i=fa("TEMP");return t.sessionid=i,e.aiChat.sessionid=i,e.caption=$c.t.value("temporarySession"),void(e.sourceCaption=$c.t.value("temporarySession"))}var r=this.aiTopic.getCurrentTopicByID(e.id);if(r&&(e.sequence=r.sequence,e.isTop=r.isTop,e.scope=r.scope,e.groupid=r.groupid),!t.activeAIAgentID)if(r&&r.aiChat&&r.aiChat.activeAIAgentID)t.activeAIAgentID=r.aiChat.activeAIAgentID,e.aiChat.activeAIAgentID=r.aiChat.activeAIAgentID;else if(t.aiAgentlist&&t.aiAgentlist.length>0&&!t.activeAIAgentID){var o=t.aiAgentlist.find(function(e){return 1===e.default});o?(t.activeAIAgentID=o.id,e.aiChat.activeAIAgentID=o.id):(t.activeAIAgentID=t.aiAgentlist[0].id,e.aiChat.activeAIAgentID=t.aiAgentlist[0].id)}t.selectAIKnowledgeBaseId||r&&r.aiChat&&r.aiChat.selectAIKnowledgeBaseId&&(t.selectAIKnowledgeBaseId=r.aiChat.selectAIKnowledgeBaseId,e.aiChat.selectAIKnowledgeBaseId=r.aiChat.selectAIKnowledgeBaseId),r&&r.aiChat&&r.aiChat.sessionid&&(t.sessionid=r.aiChat.sessionid,e.aiChat.sessionid=r.aiChat.sessionid);var a=n.resourceMode;"LOCAL"===a?"default"!==e.captionMode?(e.sourceCaption=$c.t.value("newConversation"),r&&r.caption?e.caption=r.caption:e.caption=$c.t.value("newConversation")):e.sourceCaption=e.caption:"REMOTE"===a&&(e.sourceCaption=e.caption,r&&r.caption&&(e.caption=r.caption)),r&&(e.captionComputed=!!r.captionComputed),"REMOTE"===a&&r&&r.realid&&(e.realid=r.realid)}},{key:"switchAiChatController",value:function(e){var t,n,i,r=d({},this.backupChatOptions.chatOptions);e.aiChat&&Object.assign(r,{caption:e.aiChat.caption,context:e.aiChat.context,params:e.aiChat.params,sessionid:e.aiChat.sessionid,contentToolbarItems:e.aiChat.contentToolbarItems,footerToolbarItems:e.aiChat.footerToolbarItems,questionToolbarItems:e.aiChat.questionToolbarItems,otherToolbarItems:e.aiChat.otherToolbarItems,appendCurData:e.aiChat.appendCurData,appendCurContent:void 0,activeAIAgentID:e.aiChat.activeAIAgentID,enableAIAgentChange:e.aiChat.enableAIAgentChange,selectAIKnowledgeBaseId:e.aiChat.selectAIKnowledgeBaseId,srfMode:e.aiChat.srfMode,srfScope:null!==(t=e.scope)&&void 0!==t?t:e.aiChat.srfScope,appendCurResource:e.aiChat.appendCurResource,appDataEntityId:e.aiChat.appDataEntityId,topicId:e.id,topic:e,aiTopic:this.aiTopic,extendToolbarClick:this.backupChatOptions.chatOptions.extendToolbarClick,recommendPrompt:this.backupChatOptions.chatOptions.recommendPrompt,chatDigest:this.backupChatOptions.chatOptions.chatDigest,openLinkView:this.backupChatOptions.chatOptions.openLinkView});this.aiTopicMap.has("".concat(e.id))?(n=this.aiTopicMap.get("".concat(e.id))).updateAIChat(r):(n=new Aw(r,this.resourceOptions,null===(i=this.backupChatOptions)||void 0===i?void 0:i.topicOptions),this.aiTopicMap.set("".concat(e.id),n));this.renderSwitchedContent(r,n)}},{key:"close",value:function(){this.aiTopicMap.forEach(function(e){e.destroyed()})}},{key:"onDeactivated",value:function(){var e;null===(e=this.aiChat)||void 0===e||e.evt.emit("onDeactivated")}},{key:"onActivated",value:function(){var e;null===(e=this.aiChat)||void 0===e||e.evt.emit("onActivated")}}]);var e,t}(),Bw=function(t){function r(){var e;C(this,r);for(var t=arguments.length,i=new Array(t),o=0;o<t;o++)i[o]=arguments[o];return T(e=n(this,r,[].concat(i)),"container",void 0),T(e,"minimize",void 0),e}return i(r,t),x(r,[{key:"create",value:(o=v(h().m(function t(n){var i,o,a,s;return h().w(function(t){for(;;)if(0===t.n)return o=(null===(i=n.containerOptions)||void 0===i?void 0:i.minimizeOptions)||{},a=o.enable,s=o.openMode,this.minimize=a&&("minimize"===s||"autoexpand"===s),t.a(2,e(r,"create",this,3)([n]))},t,this)})),function(e){return o.apply(this,arguments)})},{key:"setupContainer",value:function(e,t){var n,i,r,o=this;this.close(),this.container=document.createElement("div"),this.container.classList.add("ibiz-ai-chat"),document.body.appendChild(this.container),Zo(Eo(lb,{mode:e.mode?e.mode:"DEFAULT",containerOptions:e.containerOptions,caption:t.caption,autoClose:null===(n=e.containerOptions)||void 0===n?void 0:n.autoClose,compWrapperId:(null===(i=e.containerOptions)||void 0===i?void 0:i.compWrapperId)||"DEFAULT",hideTopicSidebar:(null===(r=e.topicOptions)||void 0===r?void 0:r.hideTopicSidebar)||!1,close:function(){o.close(),t&&t.closed&&t.closed(t.context,t.params,[])},fullscreen:function(e){t&&t.fullscreen&&t.fullscreen(e,t.context,t.params)},minimize:function(e){o.minimize=e,t&&t.minimize&&t.minimize(e,t.context,t.params)},isLoading:!0}),this.container)}},{key:"renderChatContent",value:function(e,t,n){var i,r,o,a,s=this;Zo(Eo(lb,{aiChat:n,aiTopic:this.aiTopic,mode:e.mode?e.mode:"DEFAULT",containerOptions:e.containerOptions,caption:t.caption,enableBackFill:null===(i=e.containerOptions)||void 0===i?void 0:i.enableBackFill,compWrapperId:(null===(r=e.containerOptions)||void 0===r?void 0:r.compWrapperId)||"DEFAULT",contentToolbarItems:t.contentToolbarItems,footerToolbarItems:t.footerToolbarItems,questionToolbarItems:t.questionToolbarItems,autoClose:null===(o=e.containerOptions)||void 0===o?void 0:o.autoClose,hideTopicSidebar:(null===(a=e.topicOptions)||void 0===a?void 0:a.hideTopicSidebar)||!1,close:function(){s.close(),t.closed&&t.closed(t.context,t.params,n.getAllMessages())},fullscreen:function(e){t.fullscreen&&t.fullscreen(e,t.context,t.params)},minimize:function(e){s.minimize=e,t.minimize&&t.minimize(e,t.context,t.params)},isLoading:!1}),this.container)}},{key:"renderSwitchedContent",value:function(e,t){var n,i,r,o,a,s,c=this;this.container&&Zo(Eo(lb,{aiChat:t,aiTopic:this.aiTopic,mode:null!==(n=this.backupChatOptions)&&void 0!==n&&n.mode?this.backupChatOptions.mode:"DEFAULT",containerOptions:null===(i=this.backupChatOptions)||void 0===i?void 0:i.containerOptions,caption:e.caption,enableBackFill:null===(r=this.backupChatOptions)||void 0===r||null===(r=r.containerOptions)||void 0===r?void 0:r.enableBackFill,compWrapperId:(null===(o=this.backupChatOptions)||void 0===o||null===(o=o.containerOptions)||void 0===o?void 0:o.compWrapperId)||"DEFAULT",contentToolbarItems:e.contentToolbarItems,footerToolbarItems:e.footerToolbarItems,questionToolbarItems:e.questionToolbarItems,autoClose:null===(a=this.backupChatOptions)||void 0===a||null===(a=a.containerOptions)||void 0===a?void 0:a.autoClose,hideTopicSidebar:(null===(s=this.backupChatOptions)||void 0===s||null===(s=s.topicOptions)||void 0===s?void 0:s.hideTopicSidebar)||!1,close:function(){c.close(),e.closed&&e.closed(e.context,e.params,t.getAllMessages())},fullscreen:function(t){e.fullscreen&&e.fullscreen(t,e.context,e.params)},minimize:function(t){c.minimize=t,e.minimize&&e.minimize(t,e.context,e.params)},isLoading:!1}),this.container)}},{key:"hidden",value:function(){this.container&&(this.container.style.display="none")}},{key:"show",value:function(){this.container&&(this.container.style.display="flex")}},{key:"close",value:function(){e(r,"close",this,3)([]),this.container&&(Zo(null,this.container),this.container.remove(),this.container=void 0)}},{key:"onMinimizeChange",value:function(e){var t;null===(t=this.aiChat)||void 0===t||t.evt.emit("onMinimizeChange",e)}}]);var o}(zw),Hw=(t("chat",new Bw),function(t){function r(){var e;C(this,r);for(var t=arguments.length,i=new Array(t),o=0;o<t;o++)i[o]=arguments[o];return T(e=n(this,r,[].concat(i)),"container",void 0),e}return i(r,t),x(r,[{key:"create",value:(o=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:if(this.container=null===(i=n.containerOptions)||void 0===i?void 0:i.container,this.container){t.n=1;break}throw new Error("container is required");case 1:return n.chatOptions.isSimple&&(n.chatOptions.autoQuestion=!1),t.a(2,e(r,"create",this,3)([n]))}},t,this)})),function(e){return o.apply(this,arguments)})},{key:"setupContainer",value:function(e,t){var n,i,r;if(e.chatOptions.isSimple)return Zo(Eo(vb,{isLoading:!0}),this.container);Zo(Eo(db,{mode:e.mode?e.mode:"DEFAULT",caption:t.caption,extension:e.extensionOptions,enableBackFill:null===(n=e.containerOptions)||void 0===n?void 0:n.enableBackFill,compWrapperId:(null===(i=e.containerOptions)||void 0===i?void 0:i.compWrapperId)||"DEFAULT",hideTopicSidebar:(null===(r=e.topicOptions)||void 0===r?void 0:r.hideTopicSidebar)||!1,isLoading:!0}),this.container)}},{key:"renderChatContent",value:function(e,t,n){var i,r,o;if(e.chatOptions.isSimple)return Zo(Eo(vb,{aiChat:n,isLoading:!1,questionToolbarItems:t.questionToolbarItems}),this.container);Zo(Eo(db,{aiChat:n,aiTopic:this.aiTopic,mode:e.mode?e.mode:"DEFAULT",caption:t.caption,extension:e.extensionOptions,enableBackFill:null===(i=e.containerOptions)||void 0===i?void 0:i.enableBackFill,compWrapperId:(null===(r=e.containerOptions)||void 0===r?void 0:r.compWrapperId)||"DEFAULT",contentToolbarItems:t.contentToolbarItems,footerToolbarItems:t.footerToolbarItems,questionToolbarItems:t.questionToolbarItems,hideTopicSidebar:(null===(o=e.topicOptions)||void 0===o?void 0:o.hideTopicSidebar)||!1,isLoading:!1}),this.container)}},{key:"renderSwitchedContent",value:function(e,t){var n,i,r,o;this.container&&Zo(Eo(db,{aiChat:t,aiTopic:this.aiTopic,mode:null!==(n=this.backupChatOptions)&&void 0!==n&&n.mode?this.backupChatOptions.mode:"DEFAULT",caption:e.caption,enableBackFill:null===(i=this.backupChatOptions)||void 0===i||null===(i=i.containerOptions)||void 0===i?void 0:i.enableBackFill,compWrapperId:(null===(r=this.backupChatOptions)||void 0===r||null===(r=r.containerOptions)||void 0===r?void 0:r.compWrapperId)||"DEFAULT",contentToolbarItems:e.contentToolbarItems,footerToolbarItems:e.footerToolbarItems,questionToolbarItems:e.questionToolbarItems,hideTopicSidebar:(null===(o=this.backupChatOptions)||void 0===o||null===(o=o.topicOptions)||void 0===o?void 0:o.hideTopicSidebar)||!1,extension:e.extensionOptions,isLoading:!1}),this.container)}},{key:"close",value:function(){e(r,"close",this,3)([]),this.container&&Zo(null,this.container)}}]);var o}(zw));var Fw=new ra("chat-input-material"),jw=function(e){var t=e.controller.materials;return na("div",{className:Fw.b(),children:t.value.map(function(t){return na(nu,{material:t,disabled:!1,controller:e.controller},t.id)})})},Vw=new ra("chat-agent-setting"),Ww=function(e){var t=e.controller,n=[{label:$c.t.value("disabled"),value:0},{label:$c.t.value("enable"),value:1},{label:$c.t.value("automatic"),value:2}],i=[{label:$c.t.value("chunkRerank"),value:"chunkrerank"},{label:$c.t.value("chunkPageIndex"),value:"chunkpageindex"},{label:$c.t.value("maxChunks"),value:"maxchunks"},{label:$c.t.value("chunkThreshold"),value:"chunkthreshold"}],r=Ds({chunkrerank:!1,maxchunks:!1,chunkthreshold:!1,chunkpageindex:!1});$a(function(){var e=t.reCallConfig.value;r.value={chunkrerank:2!==e.chunkrerank,maxchunks:void 0!==e.maxchunks,chunkthreshold:void 0!==e.chunkthreshold,chunkpageindex:void 0!==e.chunkpageindex}},[t.activeAIAgentID]);var o=qa(null),a=qa(null),s=g(Wa(!1),2),c=s[0],l=s[1];$a(function(){var e=function(e){var t,n;e.target&&null!==(t=a.current)&&void 0!==t&&t.contains(e.target)||(null!==(n=o.current)&&void 0!==n&&n.contains(e.target)?l(function(e){return!e}):l(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var u=function(e,n){t.setAIAgentConfig(T({},e,n))},h=function(e){switch(e){case"chunkrerank":return na(rl,{popperStyle:{width:"100%",bottom:"inherit",top:"calc(100% + 4px)"},options:n,className:Vw.e("select"),value:t.reCallConfig.value[e],onChange:function(t){return u(e,t)}});case"chunkpageindex":return na(ql,{showText:!0,className:Vw.e("switch"),value:t.reCallConfig.value[e],onChange:function(t){return u(e,t)}});case"maxchunks":return na($l,{min:0,max:20,step:1,showText:!0,onChange:function(t){return u(e,t)},value:t.reCallConfig.value[e]});case"chunkthreshold":return na($l,{min:0,max:1,step:.01,showText:!0,onChange:function(t){return u(e,t)},value:t.reCallConfig.value[e]})}},f=function(e){return na("li",{className:"".concat(Vw.em("dropdown","item")),children:[na("div",{className:Vw.em("dropdown","label"),children:[na("div",{className:Vw.em("dropdown","label-left"),children:e.label}),na("div",{className:Vw.em("dropdown","label-right"),onClick:function(){return t=e.value,n=!r.value[t],r.value=d(d({},r.value),{},T({},t,n)),void(n?["maxchunks","chunkthreshold"].includes(t)&&u(t,0):u(t,"chunkrerank"===t?2:void 0));var t,n},children:r.value[e.value]?$c.t.value("customize"):$c.t.value("default")})]}),r.value[e.value]?na("div",{className:Vw.em("dropdown","config"),children:h(e.value)}):void 0]})};return na("div",{className:"".concat(Vw.b()," ").concat(e.className?e.className:""),children:[na("div",{className:Vw.e("button"),ref:o,children:na("span",{title:$c.t.value("settings"),className:"".concat(Vw.em("button","icon")," ").concat(Vw.em("button","prefix")),children:na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",children:[na("path",{d:"M512 721.67619c-117.028571 0-209.67619-92.647619-209.67619-209.67619s92.647619-209.67619 209.67619-209.67619 209.67619 92.647619 209.67619 209.67619-92.647619 209.67619-209.67619 209.67619z m0-321.828571c-63.390476 0-112.152381 48.761905-112.152381 112.152381 0 63.390476 48.761905 112.152381 112.152381 112.152381s112.152381-48.761905 112.152381-112.152381c0-63.390476-48.761905-112.152381-112.152381-112.152381z"}),na("path",{d:"M604.647619 1009.371429l-14.628571-48.761905c-9.752381-34.133333-43.885714-58.514286-78.019048-58.514286s-68.266667 24.380952-78.019048 58.514286l-14.628571 48.761905-48.761905-14.628572C292.571429 975.238095 219.428571 931.352381 160.914286 877.714286l-34.133334-34.133334 34.133334-34.133333c24.380952-29.257143 29.257143-68.266667 9.752381-97.523809-19.504762-34.133333-53.638095-48.761905-92.647619-39.009524l-48.761905 9.752381-9.752381-48.761905c-9.752381-39.009524-14.628571-82.895238-14.628572-121.904762S9.752381 429.104762 19.504762 390.095238l9.752381-48.761905 48.761905 9.752381c34.133333 9.752381 73.142857-4.87619 92.647619-39.009524 19.504762-34.133333 14.628571-73.142857-9.752381-97.523809l-34.133334-34.133333 34.133334-34.133334C219.428571 92.647619 292.571429 48.761905 370.590476 24.380952l48.761905-14.628571 14.628571 43.885714c9.752381 34.133333 43.885714 58.514286 78.019048 58.514286s68.266667-24.380952 78.019048-58.514286l14.628571-43.885714 48.761905 14.628571C731.428571 48.761905 804.571429 92.647619 863.085714 146.285714l34.133334 34.133334-34.133334 34.133333c-24.380952 29.257143-29.257143 68.266667-9.752381 97.523809 19.504762 34.133333 53.638095 48.761905 92.647619 39.009524l48.761905-9.752381 9.752381 48.761905c9.752381 39.009524 14.628571 82.895238 14.628572 121.904762s-4.87619 82.895238-14.628572 121.904762l-9.752381 48.761905-48.761905-9.752381c-34.133333-9.752381-73.142857 4.87619-92.647619 39.009524-19.504762 34.133333-14.628571 73.142857 9.752381 97.523809l34.133334 34.133333-34.133334 34.133334c-58.514286 58.514286-131.657143 97.52381-209.67619 121.904762l-48.761905 9.752381z m-346.209524-175.542858c34.133333 24.380952 68.266667 43.885714 102.4 58.514286 34.133333-48.761905 87.771429-82.895238 151.161905-82.895238s117.028571 34.133333 151.161905 82.895238c34.133333-14.628571 68.266667-34.133333 102.4-58.514286-29.257143-53.638095-29.257143-117.028571 4.87619-170.666666 29.257143-53.638095 87.771429-87.771429 146.285715-87.771429 4.87619-19.504762 4.87619-39.009524 4.87619-58.514286s0-39.009524-4.87619-58.514285c-58.514286-4.87619-117.028571-34.133333-146.285715-87.771429-29.257143-53.638095-34.133333-117.028571-4.87619-170.666666-34.133333-34.133333-68.266667-53.638095-102.4-68.266667-34.133333 48.761905-87.771429 82.895238-151.161905 82.895238s-117.028571-29.257143-151.161905-82.895238c-34.133333 14.628571-68.266667 34.133333-102.4 58.514286 29.257143 53.638095 29.257143 117.028571-4.87619 175.542857-29.257143 53.638095-87.771429 87.771429-146.285715 87.771428-4.87619 19.504762-4.87619 39.009524-4.87619 58.514286s0 39.009524 4.87619 58.514286c58.514286 4.87619 117.028571 34.133333 146.285715 87.771428s34.133333 121.904762 4.87619 175.542857z"})]})})}),c?na("div",{className:Vw.e("dropdown"),ref:a,children:na("ul",{className:Vw.em("dropdown","list"),children:i.map(function(e){return f(e)})})}):null]})},$w=function(){return na("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"icon-2xs text-text-tertiary/70",children:na("path",{d:"M2.66797 11V3.33301C2.66797 2.96574 2.96574 2.66797 3.33301 2.66797C3.70028 2.66797 3.99805 2.96574 3.99805 3.33301V11C3.99805 11.7109 3.99894 12.2044 4.03027 12.5879C4.06098 12.9634 4.11776 13.175 4.19824 13.333L4.26856 13.459C4.44487 13.7465 4.69781 13.9808 5 14.1348L5.12988 14.1904C5.27366 14.2419 5.46311 14.2797 5.74512 14.3027C6.12864 14.3341 6.62197 14.335 7.33301 14.335H15L15.0674 14.3418L14.1123 13.3867L14.0273 13.2822C13.8571 13.0242 13.8854 12.6735 14.1123 12.4463C14.3397 12.2189 14.6911 12.1906 14.9492 12.3613L15.0537 12.4463L17.1367 14.5293C17.3964 14.7889 17.3963 15.21 17.1367 15.4697L15.0537 17.5537C14.794 17.8134 14.372 17.8134 14.1123 17.5537C13.8526 17.294 13.8526 16.872 14.1123 16.6123L15.0664 15.6582L15 15.665H7.33301C6.64392 15.665 6.08696 15.6647 5.63672 15.6279C5.23614 15.5952 4.87531 15.5309 4.53906 15.3867L4.39649 15.3193C3.87528 15.0538 3.43887 14.6502 3.13477 14.1543L3.0127 13.9365C2.82084 13.5599 2.74153 13.1541 2.7041 12.6963C2.66732 12.2461 2.66797 11.6889 2.66797 11ZM15.665 15C15.665 15.0226 15.6594 15.0444 15.6572 15.0664L15.7256 14.999L15.6572 14.9316C15.6595 14.9541 15.665 14.9769 15.665 15ZM11.666 8.91797L11.8008 8.93164C12.1036 8.99381 12.3311 9.2618 12.3311 9.58301C12.3311 9.90422 12.1036 10.1722 11.8008 10.2344L11.666 10.248H7.5C7.13273 10.248 6.83496 9.95028 6.83496 9.58301C6.83496 9.21574 7.13273 8.91797 7.5 8.91797H11.666ZM14.166 4.33496L14.3008 4.34863C14.6036 4.41083 14.8311 4.67881 14.8311 5C14.8309 5.32109 14.6035 5.58924 14.3008 5.65137L14.166 5.66504H7.5C7.13284 5.66504 6.83514 5.36712 6.83496 5C6.83496 4.63273 7.13273 4.33496 7.5 4.33496H14.166Z",fill:"currentColor"})})},Uw=function(){return na("svg",{width:"21",height:"21",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"icon-2xs shrink-0",children:na("path",{d:"M13.1293 7.34753C13.3565 7.12027 13.7081 7.09207 13.9662 7.26257L14.0707 7.34753L18.0707 11.3475C18.3304 11.6072 18.3304 12.0292 18.0707 12.2889L14.0707 16.2889C13.811 16.5486 13.389 16.5486 13.1293 16.2889C12.8696 16.0292 12.8696 15.6072 13.1293 15.3475L15.9935 12.4833H6.59998C4.57585 12.4833 2.93494 10.8424 2.93494 8.81824V5.31824C2.93494 4.95097 3.23271 4.6532 3.59998 4.6532C3.96724 4.6532 4.26501 4.95097 4.26501 5.31824V8.81824C4.26501 10.1078 5.31039 11.1532 6.59998 11.1532H15.9935L13.1293 8.28894L13.0443 8.18445C12.8738 7.92632 12.902 7.5748 13.1293 7.34753Z",fill:"currentColor"})})},qw=new ra("lazy-tree"),Kw=function(e){var t=e.nodes,n=e.lazyLoad,i=e.onNodeClick,r=e.onNodeExpand,o=e.onNodeCheck,a=e.separator,s=void 0===a?"/":a,l=e.defaultCheckedKeys,u=e.showSearch,d=void 0===u||u,f=e.highlight,p=void 0===f||f,g=e.expandOnClickNode,y=void 0===g||g,k=Ds(c(t)),w=Ds(),b=Ds(new Set),C=Ds(l||[]),S=Cs(function(){var e,t=new Set,n=m(C.value);try{for(n.s();!(e=n.n()).done;)for(var i=e.value.split(s),r=1;r<i.length;r++)t.add(i.slice(0,r).join("\0"))}catch(o){n.e(o)}finally{n.f()}return t}),x=function(e){return S.value.has(e.id.split(s).join("\0"))};$a(function(){k.value=c(t),w.value=""},[t]);var T,M,_=function(e,t){if(!t)return e;var n,i=t.toLowerCase().trim(),r=[],o=m(e);try{for(o.s();!(n=o.n()).done;){var a=n.value,s=a.label.toLowerCase().includes(i),c=a.children&&a.children.length>0?_(a.children,t):[];(s||c.length>0)&&r.push(a)}}catch(l){o.e(l)}finally{o.f()}return r},N=function(e){var t;return w.value?function(e){var t,n=w.value;if(!n||e.isLeaf)return!1;if(b.value.has(e.id))return!1;if(!e.loaded)return!1;var i=n.toLowerCase().trim();return!!e.label.toLowerCase().includes(i)||!(null===(t=e.children)||void 0===t||!t.length)&&_(e.children,n).length>0}(e):null!==(t=e.expanded)&&void 0!==t&&t},O=function(e,t){if(e.expanded=t,w.value){var n=new Set(b.value);t?n.delete(e.id):n.add(e.id),b.value=n}k.value=c(k.value)},E=function(){var e=v(h().m(function e(t){var i,r;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!t.loaded&&!t.isLeaf&&n){e.n=1;break}return e.a(2);case 1:return t.loading=!0,k.value=c(k.value),e.p=2,e.n=3,n(t);case 3:i=e.v,t.children=i,t.loaded=!0,t.children.forEach(function(e){var n,i="".concat(t.id).concat(s);(s&&!e.id.startsWith(i)&&(e.id="".concat(i).concat(e.id)),e.parentId||(e.parentId=t.id),void 0===e.depth)&&(e.depth=(null!==(n=t.depth)&&void 0!==n?n:0)+1)}),e.n=5;break;case 4:e.p=4,r=e.v,console.error("加载子节点失败",r),O(t,!1);case 5:return e.p=5,t.loading=!1,k.value=c(k.value),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),A=function(){var e=v(h().m(function e(t){var n;return h().w(function(e){for(;;)switch(e.n){case 0:if(!t.loading&&!t.isLeaf){e.n=1;break}return e.a(2);case 1:if(n=!N(t),O(t,n),!n){e.n=2;break}return e.n=2,E(t);case 2:null==r||r(t,n);case 3:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),D=function(e){e.isLeaf||A(e)},I=function(e,t){!function(e){var t=C.value.findIndex(function(t){return t===e.id});C.value=-1===t?[e.id]:[],null==o||o(e,-1===t)}(e),null==i||i(e,t),y&&D(e)},L=function(e){var t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.id,o=null!==(t=e.loading)&&void 0!==t&&t,a=null!==(n=e.isLeaf)&&void 0!==n&&n,s=N(e),c=!!w.value?e.children?_(e.children,w.value):[]:e.children;return na("div",{className:"".concat(qw.e("node")," ").concat(qw.is("active",p&&C.value.includes(e.id))," ").concat(qw.is("check",p&&x(e))),"data-node-id":r,children:[na("div",{className:"".concat(qw.e("node-content")," ").concat(qw.is("expanded",s)),onClick:function(t){return I(e,t)},children:[na("span",{className:"".concat(qw.e("node-toggle")," ").concat(qw.is("loading",o)),onClick:function(t){y||(t.stopPropagation(),D(e))},children:a?na("span",{className:qw.e("node-toggle-placeholder")}):o?na("i",{className:"fa fa-spinner fa-pulse"}):na(uc,{className:s?"":"rotate--90"})}),na("span",{className:qw.e("node-icon"),children:e.icon?na("i",{className:e.icon}):na("i",a?{className:"fa fa-file-text-o"}:{className:"fa ".concat(s?"fa-folder-open":"fa-folder")})}),na("span",{className:qw.e("node-label"),title:e.label,children:e.label})]}),s&&!a&&na("div",{className:qw.e("node-children"),children:o?na("div",{className:qw.e("node-loading"),children:[na("i",{className:"fa fa-spinner fa-pulse",style:{marginRight:"6px"}}),$c.t.value("loading")]}):c&&c.length>0?c.map(function(e){return L(e,i+1)}):e.loaded&&0===(null==c?void 0:c.length)?na("div",{className:qw.e("node-empty"),children:$c.t.value("noData")}):null})]},r)};return na("div",{className:qw.b(),children:[d&&na("div",{className:qw.e("search"),children:na(el,{autoFocus:!0,value:w.value,onChange:function(e){w.value=e,b.value=new Set},placeholder:$c.t.value("search")})}),na("div",{className:qw.e("main"),children:(M=(T=w.value)?_(k.value,T):k.value,M&&0!==M.length?M.map(function(e){return L(e,0)}):na("div",{className:qw.e("empty"),children:[na("i",{className:"fa fa-folder-open",style:{marginRight:"8px"}}),$c.t.value("noData")]}))})]})},Jw=new ra("chat-project"),Gw=function(e){var t=e.controller,n=qa(null),i=qa(null),r=g(Wa([]),2),o=r[0],a=r[1],s=g(Wa(!1),2),c=s[0],l=s[1],u=g(Wa(!1),2),d=u[0],f=u[1],p=Ds($c.t.value("projectPlaceholder")),m=function(){var e=v(h().m(function e(n){var i;return h().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.searchProject(n.id);case 1:return i=e.v,e.a(2,i)}},e)}));return function(t){return e.apply(this,arguments)}}(),y=function(){var e=v(h().m(function e(){var n;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,f(!0),e.n=1,t.searchProject("");case 1:n=e.v,a(n),e.n=3;break;case 2:e.p=2,e.v,a([]);case 3:return e.p=3,f(!1),e.f(3);case 4:return e.a(2)}},e,null,[[0,2,3,4]])}));return function(){return e.apply(this,arguments)}}();$a(function(){!1===c?a([]):y()},[c]),$a(function(){var e=function(e){var t,r;null!==(t=i.current)&&void 0!==t&&t.contains(e.target)||(null!==(r=n.current)&&void 0!==r&&r.contains(e.target)?l(function(e){return!e}):l(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);return na("div",{className:"".concat(Jw.b()),children:[na("div",{ref:n,className:Jw.e("button"),children:[na("span",{className:"".concat(Jw.em("button","icon")," ").concat(Jw.em("button","prefix")),children:na("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:na("path",{d:"M95.085714 292.571429L512 504.685714 928.914286 292.571429 512 87.771429 95.085714 292.571429z m58.514286 329.142857L65.828571 577.828571C36.571429 563.2 21.942857 541.257143 21.942857 512s14.628571-51.2 43.885714-65.828571l87.771429-43.885715-87.771429-43.885714C29.257143 343.771429 14.628571 299.885714 29.257143 263.314286c7.314286-14.628571 21.942857-29.257143 29.257143-29.257143L475.428571 29.257143c21.942857-7.314286 43.885714-7.314286 65.828572 0l416.914286 204.8c36.571429 14.628571 51.2 58.514286 29.257142 95.085714-7.314286 14.628571-21.942857 29.257143-29.257142 29.257143l-87.771429 43.885714L950.857143 438.857143c36.571429 14.628571 51.2 36.571429 51.2 73.142857 0 29.257143-14.628571 58.514286-51.2 73.142857l-80.457143 36.571429L950.857143 658.285714c36.571429 14.628571 51.2 36.571429 51.2 73.142857 0 29.257143-14.628571 58.514286-51.2 73.142858l-402.285714 197.485714c-7.314286 7.314286-21.942857 7.314286-36.571429 7.314286s-21.942857 0-36.571429-7.314286L58.514286 797.257143c-29.257143-14.628571-36.571429-36.571429-36.571429-65.828572s14.628571-51.2 43.885714-65.828571l87.771429-43.885714z m80.457143 43.885714l-138.971429 65.828571L512 943.542857l416.914286-204.8-138.971429-65.828571-241.371428 117.028571c-7.314286 7.314286-21.942857 7.314286-36.571429 7.314286s-21.942857 0-36.571429-7.314286L234.057143 665.6z m555.885714-219.428571L548.571429 563.2c-21.942857 7.314286-43.885714 7.314286-65.828572 0L234.057143 446.171429 95.085714 512 512 724.114286 928.914286 512l-138.971429-65.828571z"})})}),na("span",{title:p,className:Jw.em("button","caption"),children:p}),na("span",{className:"".concat(Jw.em("button","icon")," ").concat(Jw.em("button","suffix")),children:c?Oc():uc()})]}),c?na("div",{className:Jw.e("popup"),ref:i,children:na("div",{className:Jw.em("popup","tree"),children:d?na(nl,{}):na(Kw,{nodes:o,lazyLoad:m,expandOnClickNode:!1,onNodeCheck:function(e,n){n?(p.value=e.label,t.selectionProject=e.id):(p.value=$c.t.value("projectPlaceholder"),t.selectionProject=void 0)},defaultCheckedKeys:[t.selectionProject||""]})})}):null]})},Yw=new ra("chat-input"),Xw=window.SpeechRecognition||window.webkitSpeechRecognition,Qw=function(e){var t,n=g(Wa(!1),2),i=n[0],r=n[1];Ya(cb);var o=e.controller.input,a=Ds(!1),s=qa(),c=qa(null),l=qa(null);$a(function(){var t=e.controller.opts.speechRecognition;if(!t&&Xw&&(t=new Xw),t)return t.onstart=function(){a.value=!0},t.onend=function(){a.value=!1},t.onresult=function(e){var t,n,i=null===(t=e.results)||void 0===t||null===(t=t[0])||void 0===t||null===(t=t[0])||void 0===t?void 0:t.transcript;i&&(null===(n=c.current)||void 0===n||n.commands.insertContent(i))},s.current=t,function(){try{t.stop(),t.abort()}catch(e){}t.onstart=null,t.onend=null,t.onresult=null,s.current=void 0,a.value=!1}},[]);var u=Is(function(){return va(o.value).length>0}),d=Ga(v(h().m(function t(){var n,i,r,a;return h().w(function(t){for(;;)switch(t.p=t.n){case 0:if(t.p=0,r=va(o.value)){t.n=1;break}return t.a(2);case 1:if(o.value="",null===(n=c.current)||void 0===n||n.chain().clearContent().run(),null===(i=l.current)||void 0===i||i.toggleCollapse(!1),!e.controller.isLoading.value){t.n=2;break}e.controller.setSteerQuesCfg(r),t.n=3;break;case 2:return t.n=3,e.controller.question(r);case 3:t.n=5;break;case 4:t.p=4,a=t.v,console.error(a);case 5:return t.p=5,setTimeout(function(){c.current&&!c.current.isDestroyed&&c.current.chain().focus().run()},100),t.f(5);case 6:return t.a(2)}},t,null,[[0,4,5,6]])})),[o]),f=Ga(v(h().m(function t(){return h().w(function(t){for(;;)switch(t.n){case 0:try{e.controller.abortQuestion()}catch(n){console.error(n)}case 1:return t.a(2)}},t)})),[o]),p=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return i=Pw.getMaterialHelper("ossfile",e.controller),t.n=1,i.excuteAction(n);case 1:r(!1);case 2:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),m=function(){var t=v(h().m(function t(n,i){var o;return h().w(function(t){for(;;)switch(t.n){case 0:return o=Pw.getMaterialHelper("common",e.controller),t.n=1,o.excuteAction(n,i);case 1:r(!1);case 2:return t.a(2)}},t)}));return function(e,n){return t.apply(this,arguments)}}(),y=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.controller.knowledgeRemoteSearch(n);case 1:return i=t.v,t.a(2,i)}},t)}));return function(e){return t.apply(this,arguments)}}(),k=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.controller.searchAIAgent(n);case 1:return i=t.v,t.a(2,i)}},t)}));return function(e){return t.apply(this,arguments)}}();return na("div",{className:"".concat(Yw.b("wrapper")," ").concat(Yw.is("expand",e.controller.inputExpand.value)),children:[na("div",{className:"".concat(Yw.b("steer-wrapper")," ").concat(Yw.is("enable",e.controller.steerQuesCfg.value.enable)),children:[na("div",{className:"".concat(Yw.b("left-steer-wrapper")," ").concat(Yw.b("flex-both-center")),children:[na($w,{}),na("div",{className:Yw.be("left-steer-wrapper","quesition"),children:e.controller.steerQuesCfg.value.message})]}),na("div",{className:"".concat(Yw.b("right-steer-wrapper")," ").concat(Yw.b("flex-both-center")),children:[na("div",{className:"".concat(Yw.be("right-steer-wrapper","steer")," ").concat(Yw.b("cursor-with-pointer")),onClick:function(){e.controller.supplementQuestion()},title:$c.t.value("instantSteerTip"),children:[na(Uw,{}),na("span",{children:$c.t.value("instantSteer")})]}),na("div",{className:"".concat(Yw.be("right-steer-wrapper","remove")," ").concat(Yw.b("cursor-with-pointer")),onClick:function(){e.controller.resetSteerQuesCfg()},children:na(Gs,{})})]})]}),na("div",{className:Yw.b("material-wrapper"),children:na(jw,{controller:e.controller})}),na("div",{className:Yw.b("main-wrapper"),children:[na(Zk,{ref:l,c:e.controller,value:o.value,disabled:!1,placeholder:e.controller.placeholder.value,onCreate:function(e){c.current=e},onChange:function(e){o.value=e},onKeyDown:function(t){if(!1===t.shiftKey&&"Enter"===t.code&&"Enter"===t.key)return e.controller.steerQuesCfg.value.enable?(e.controller.supplementQuestion(),!0):(d(),!0)}}),na("div",{className:Yw.b("action-wrapper"),children:[na("div",{className:Yw.b("left-action-wrapper"),children:[na(rl,{showBorder:!1,enableSearch:!0,placeholder:"Auto",className:Yw.b("agent-select"),popperStyle:{height:"220px"},value:e.controller.activeAIAgentID,options:e.controller.agentList.value,icon:function(){return na("div",{title:$c.t.value("agent"),children:lc()})},disabled:!e.controller.enableAIAgentChange,onSearch:k,onChange:function(t){return n=t,void e.controller.setActiveAIAgentID(n);var n}}),e.controller.enableKnowledgeBaseSelect.value&&na(al,{className:"".concat(Yw.b("setting-wrapper")," ").concat(Yw.is("disabled",!e.controller.selectionKnowledgeBases.value.length)),enableSearch:!0,popperStyle:{height:"220px"},options:e.controller.knowledgeBases.value,icon:function(){return na("div",{title:$c.t.value("knowledge"),children:bc})},placeholder:$c.t.value("knowledgeSearch"),value:e.controller.selectionKnowledgeBases.value,onSearch:function(e){return y(e)},onChange:function(t){e.controller.setSelectionKnowledge(t)}}),e.controller.opts.enableAIProject&&e.controller.enableChatProject.value?na(Gw,{controller:e.controller}):null,e.controller.enableRecallConfigSetting.value&&e.controller.agentList.value.length>0?na(Ww,{controller:e.controller}):null]}),na("div",{className:Yw.b("right-action-wrapper"),children:[na("div",{className:"".concat(Yw.be("right-action-wrapper","action-item")," ").concat(Yw.is("disabled",e.controller.isLoading.value)),title:$c.t.value("uploadDocument"),children:na(Bl,{triggerMode:"hover",content:na("div",{className:Yw.b("pop-actions"),children:[na("div",{className:Yw.b("pop-action-item"),onClick:function(e){p(e)},children:[na("span",{className:Yw.b("pop-action-item-icon"),children:na(Zs,{})}),na("span",{className:Yw.b("pop-action-item-title"),children:$c.t.value("documentation")})]}),null===(t=e.questionToolbarItems)||void 0===t?void 0:t.map(function(e){var t,n,i;return na("div",{className:Yw.b("pop-action-item"),onClick:function(t){m(t,e)},children:[na("span",{className:Yw.b("pop-action-item-icon"),children:"function"==typeof e.icon?e.icon():(null===(t=e.icon)||void 0===t?void 0:t.showIcon)&&na(Do,{children:null!==(n=e.icon)&&void 0!==n&&n.cssClass?na("i",{className:e.icon.cssClass}):null!==(i=e.icon)&&void 0!==i&&i.imagePath?ha(e.icon.imagePath)?na("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):na("img",{src:e.icon.imagePath}):null})}),na("span",{className:Yw.b("pop-action-item-title"),children:e.label})]},e.id)})]}),position:"top-left",isOpen:i,onToggleOpen:r,children:na(Qs,{})})}),na("div",{title:a.value?$c.t.value("voiceInputProgress"):$c.t.value("voiceInput"),className:"".concat(Yw.be("right-action-wrapper","action-item")," ").concat(Yw.is("disabled",e.controller.isLoading.value)),onClick:function(){s.current&&(a.value?s.current.stop():s.current.start())},children:a.value?na(qs,{}):na(Us,{})}),u.value?na("div",{title:$c.t.value("sendMessage"),className:"".concat(Yw.be("right-action-wrapper","action-item")," ").concat(Yw.is("send",!0)),onClick:d,children:na(Ps,{className:Yw.e("send-icon")})}):e.controller.isLoading.value?na("div",{title:$c.t.value("stopGenerating"),className:"".concat(Yw.be("right-action-wrapper","action-item")," ").concat(Yw.is("send",!0)),onClick:f,children:na(nc,{})}):na("div",{title:$c.t.value("sendMessage"),className:"".concat(Yw.be("right-action-wrapper","action-item")," ").concat(Yw.is("disabled",!0)," ").concat(Yw.is("send",!0)),children:na(Ps,{className:Yw.e("send-icon")})})]})]})]})]})},Zw=new ra("chat-topic-item"),eb="",tb=hl(function(e,t){var n,i=e.hasMoreThanOne,r=e.controller,o=e.topic,a=e.isSelectMode,s=e.isSelected,c=e.onClick,l=e.onAction,u=qa(null),d=qa(!1),h=Is(function(){var e;return(null===(e=r.activedTopic.value)||void 0===e?void 0:e.id)===o.id}),f=Is(function(){return!!r.activedTopic.value&&r.isTopicGenerating(o.id)}),p=Math.min(16,Math.max(6,Math.round(.35*((null===(n=o.caption)||void 0===n?void 0:n.length)||0)))),v=g(Wa(!1),2),m=v[0],y=v[1],k=Ds([]);k.value=i?[{id:"RENAME",caption:$c.t.value("rename"),icon:na(ac,{})},{id:"PINNED",caption:o.isTop?$c.t.value("unpin"):$c.t.value("pinTop"),icon:o.isTop?na(pc,{}):na(fc,{})},{id:"MULTISELECT",caption:$c.t.value("multiSelect"),icon:na(zc,{})},{id:"DELETE",caption:$c.t.value("delete"),icon:na(Gs,{})}]:[{id:"RENAME",caption:$c.t.value("rename"),icon:na(ac,{})},{id:"PINNED",caption:o.isTop?$c.t.value("unpin"):$c.t.value("pinTop"),icon:o.isTop?na(pc,{}):na(fc,{})}];var w=Ds(!1),b=function(){w.value||(eb=o.caption||$c.t.value("newConversation"),d.current=!1,w.value=!0,setTimeout(function(){var e;null===(e=u.current)||void 0===e||e.focus()},100))};Ka(t,function(){return{enterEditMode:b}});return na("div",{className:"".concat(Zw.b()," ").concat(Zw.is("show-popup",m)," ").concat(Zw.is("active",h.value)," ").concat(Zw.is("edit",w.value)," ").concat(Zw.is("marquee",f.value)," ").concat(Zw.is("select-mode",a)),onClick:function(){a?r.toggleTopicSelected(o.id):c()}.bind(void 0),children:[na("input",{type:"checkbox",className:Zw.e("checkbox"),readOnly:!0,checked:!!a&&!!s}),na("div",{className:Zw.e("caption"),title:o.caption,children:w.value?na("input",{ref:u,value:o.caption,onBlur:function(e){e.stopPropagation(),w.value=!1,d.current?d.current=!1:l("RENAME",e)},onKeyDown:function(e){e.stopPropagation(),"Enter"===e.key?w.value=!1:"Escape"===e.key&&(d.current=!0,o.data.caption=eb,w.value=!1)},onClick:function(e){return e.stopPropagation()},onChange:function(e){return(t=e).stopPropagation(),void(o.data.caption=null===(n=t.target)||void 0===n?void 0:n.value);var t,n},className:Zw.em("caption","editor")}):na("div",{className:Zw.em("caption","readonly"),children:[na("span",{className:Zw.em("caption","text"),children:f.value?na("span",{className:Zw.em("caption","marquee"),style:{animationDuration:"".concat(p,"s")},children:[na("span",{children:o.caption}),na("span",{"aria-hidden":"true",children:o.caption})]}):o.caption}),o.isTop?na("span",{className:Zw.em("caption","icon"),children:na(fc,{})}):null]})}),!w.value&&!a&&na("div",{className:Zw.e("icon"),children:[na("span",{title:$c.t.value("jumpMainView"),className:Zw.em("icon","item"),onClick:function(e){e.stopPropagation(),l("LINK",e)}.bind(void 0),children:na(Js,{className:Zw.b("link-icon")})}),na(Bl,{triggerMode:"click",actions:k.value,position:"bottom",isOpen:m,onToggleOpen:y,onAction:function(e,t){"RENAME"===e?b():l(e,t),y(!1)}.bind(void 0),children:na("span",{className:Zw.em("icon","item"),title:$c.t.value("more"),children:na(Ks,{className:Zw.e("more-icon")})})})]})]})}),nb=new ra("chat-topics"),ib=function(e){var t=e.controller.topics.value.filter(function(t){return e.controller.selectedTopicIds.value.has(t.id)}),n=t.length>0&&t.every(function(e){return 1===e.isTop}),i=qa(null),r=qa({}),o=Ds(void 0),a=Ds([]),s=Ds(0);$a(function(){var t=c(e.controller.topics.value).sort(function(e,t){return e.isTop!==t.isTop?t.isTop?1:-1:t.sequence-e.sequence});a.value=t.filter(function(e){var t,n;return null===(t=e.caption)||void 0===t?void 0:t.toLowerCase().includes((null===(n=o.value)||void 0===n?void 0:n.trim().toLowerCase())||"")})},[e.controller.topics.value]),$a(function(){var t=function(t){var n;if("F2"===t.key){var i=t.target;if(!(i&&("INPUT"===i.tagName||"TEXTAREA"===i.tagName||i.isContentEditable)||e.controller.topicSidebarCollapse.value||e.controller.isTempChat.value||e.controller.isSelectMode.value)){var o=e.controller.activedTopic.value;o&&(t.preventDefault(),t.stopPropagation(),null===(n=r.current[o.id])||void 0===n||n.enterEditMode())}}};return window.addEventListener("keydown",t),function(){window.removeEventListener("keydown",t)}},[]);var l=Is(function(){return a.value.length>1});$a(function(){var e=i.current;if(e){var t=function(){s.value=e.scrollTop};return e.addEventListener("scroll",t,{passive:!0}),function(){e.removeEventListener("scroll",t)}}},[]);var u=function(){var e=i.current;e&&0!==s.value&&(e.scrollTop=s.value)};$a(function(){var t=i.current;if(t){var n=setTimeout(function(){var e=t.querySelector(".ibiz-chat-topic-item.is-active");null==e||e.scrollIntoView({behavior:"smooth",block:"nearest"})},0),r=e.controller.getAiChat();return r&&r.evt.on("onActivated",u),function(){clearTimeout(n),r&&r.evt.off("onActivated",u)}}},[e.controller.activedTopic.value,a.value]);var d=function(){e.controller.switchTopicSidebarCollapse()},h=function(t){if(t)e.controller.enterTempChat();else{e.controller.exitTempChat();var n=e.controller.preActivedTopic;if(n||(n=e.controller.topics.value[0]),!n)return;e.controller.handleTopicChange(n)}};return na("div",{className:"".concat(nb.b()," ").concat(nb.is("collapsed",!0===e.controller.topicSidebarCollapse.value)),children:!0===e.controller.topicSidebarCollapse.value?na("div",{className:nb.e("collapse-container"),children:[na("div",{className:nb.e("icon-item"),title:$c.t.value("openSidebar"),onClick:function(){return d()},children:na(Mc,{})}),!1===e.controller.isSelectMode.value&&(!1===e.controller.isTempChat.value?na("div",{className:nb.e("icon-item"),title:$c.t.value("enterSession"),onClick:function(){return h(!0)},children:na(_c,{})}):na("div",{className:nb.e("icon-item"),title:$c.t.value("exitSession"),onClick:function(){return h(!1)},children:na(Nc,{})}))]}):na(Do,{children:[na("div",{className:nb.e("header"),children:[na("div",{className:nb.e("icon-container"),children:[na("div",{className:nb.e("icon-item"),title:$c.t.value("collapseSidebar"),onClick:function(){return d()},children:na(Mc,{})}),!1===e.controller.isSelectMode.value&&na(Do,{children:[na("div",{className:nb.e("icon-item"),title:$c.t.value("newCreateConversation"),onClick:function(){e.controller.globalNewTopic()},children:na($s,{})}),!1===e.controller.isTempChat.value?na("div",{className:nb.e("icon-item"),title:$c.t.value("enterSession"),onClick:function(){return h(!0)},children:na(_c,{})}):na("div",{className:nb.e("icon-item"),title:$c.t.value("exitSession"),onClick:function(){return h(!1)},children:na(Nc,{})})]})]}),e.controller.isSelectMode.value?na("div",{className:nb.e("select-bar"),children:[na("span",{className:nb.e("select-info"),children:$c.t.value("selectedCount",{count:e.controller.selectedTopicIds.value.size})}),na("div",{className:"".concat(nb.e("cancel-select")),title:$c.t.value("cancelMultiSelect"),onClick:function(){return e.controller.exitSelectMode()},children:na(Ls,{})})]}):na(el,{value:o.value,placeholder:$c.t.value("searchTopics"),onChange:function(t){o.value=t,a.value=e.controller.topics.value.filter(function(e){var t,n;return null===(t=e.caption)||void 0===t?void 0:t.toLowerCase().includes((null===(n=o.value)||void 0===n?void 0:n.trim().toLowerCase())||"")})}.bind(void 0)})]}),na("div",{ref:i,className:nb.e("main"),children:a.value&&a.value.length>0?a.value.map(function(t){return!1===t.isShow?null:na(tb,{ref:function(e){r.current[t.id]=e},hasMoreThanOne:l.value,topic:t,controller:e.controller,isSelectMode:e.controller.isSelectMode.value,isSelected:e.controller.selectedTopicIds.value.has(t.id),onClick:function(){return function(t){e.controller.isTempChat.value&&e.controller.exitTempChat(),e.controller.handleTopicChange(t)}(t)},onAction:function(n,i){return function(t,n,i){"MULTISELECT"!==t?e.controller.handleTopicAction(t,n,i):e.controller.enterSelectMode(n.id)}(n,t,i)}},t.id)}):na("div",{className:nb.e("empty"),children:$c.t.value("noTopic")})}),e.controller.isSelectMode.value?na("div",{className:"".concat(nb.e("footer")," ").concat(nb.is("select-mode",e.controller.isSelectMode.value)),children:[na("div",{title:$c.t.value(n?"unpin":"pinTop"),className:"".concat(nb.e("action")," ").concat(nb.is("disabled",0===e.controller.selectedTopicIds.value.size)),onClick:function(){return n?e.controller.batchUnPinTop():e.controller.batchPinTop()},children:[na(n?Bc:fc,{}),na("span",{children:$c.t.value(n?"unpin":"pinTop")})]}),na("div",{title:$c.t.value("delete"),className:"".concat(nb.e("action")," ").concat(nb.is("disabled",0===e.controller.selectedTopicIds.value.size)),onClick:function(t){return e.controller.batchDeleteTopics(t)},children:[na(Gs,{}),na("span",{children:$c.t.value("delete")})]})]}):!0===l.value&&na("div",{className:nb.e("footer"),children:na("div",{title:$c.t.value("clearSession"),className:nb.e("action"),onClick:function(){return e.controller.clearTopic()},children:[na(Gs,{}),na("span",{children:$c.t.value("clearSession")})]})})]})})},rb=new ra("chat-group-topics"),ob=function(e){var t,n,i,r,o,a=e.controller.topics.value.filter(function(t){return e.controller.selectedTopicIds.value.has(t.id)}),s=a.length>0&&a.every(function(e){return 1===e.isTop}),c=qa(null),l=qa({}),u=Ds(void 0),d=Is(function(){return e.controller.computeGroupTree(u.value)}),f=Is(function(){return e.controller.topics.value.length>1}),p=Ds(new Set),m=qa(!1),g=qa(void 0),y=Ds(void 0),k=Ds(void 0),w=Ds(void 0),b=qa(null),C=qa(!1),S=Ds(!1),x=Ds(void 0),T=Ds(""),M=Ds(!1),_=Ds(void 0),N=qa(null),O=Ya(cb),E="number"==typeof(null==O?void 0:O.zIndex)?O.zIndex+10:999,A=function(){return e.controller.isSelectMode.value},D=function(e){var t=new Set(p.value);t.has(e)?t.delete(e):t.add(e),p.value=t};$a(function(){var t=function(t){if(t){var n=t.scope;return n&&e.controller.scopeList.some(function(e){return String(e.id)===String(n)})?"scope:".concat(String(n)):Mw.NONE_SCOPE_KEY}}(e.controller.activedTopic.value);if(g.current!==t)if(g.current=t,m.current){if(t&&p.value.has(t)){var n=new Set(p.value);n.delete(t),p.value=n}}else{if(0===e.controller.topics.value.length)return;if(m.current=!0,!t)return;p.value=new Set(d.value.map(function(e){return e.key}).filter(function(e){return e!==t}))}},[e.controller.activedTopic.value,d.value]),$a(function(){var t=function(t){var n;if("F2"===t.key){var i=t.target;if(!(i&&("INPUT"===i.tagName||"TEXTAREA"===i.tagName||i.isContentEditable)||e.controller.topicSidebarCollapse.value||e.controller.isTempChat.value||e.controller.isSelectMode.value)){var r=e.controller.activedTopic.value;r&&(t.preventDefault(),t.stopPropagation(),null===(n=l.current[r.id])||void 0===n||n.enterEditMode())}}};return window.addEventListener("keydown",t),function(){window.removeEventListener("keydown",t)}},[]),$a(function(){if(w.value){C.current=!1;var e=setTimeout(function(){var e=b.current;if(e){e.focus();var t=e.value.length;e.setSelectionRange(t,t)}},0);return function(){return clearTimeout(e)}}},[w.value]);$a(function(){var e=c.current;if(e){var t=setTimeout(function(){var t=e.querySelector(".ibiz-chat-topic-item.is-active");null==t||t.scrollIntoView({behavior:"smooth",block:"nearest"})},0);return function(){return clearTimeout(t)}}},[e.controller.activedTopic.value,e.controller.topics.value]);var I=function(){e.controller.switchTopicSidebarCollapse()},L=function(t){if(t)e.controller.enterTempChat();else{e.controller.exitTempChat();var n=e.controller.preActivedTopic;if(n||(n=e.controller.topics.value[0]),!n)return;e.controller.handleTopicChange(n)}},R=function(){S.value=!1,M.value=!1,T.value=""},P=Is(function(){var t=T.value.trim().toLowerCase();return t?e.controller.scopeList.filter(function(e){var n;return String(null!==(n=e.text)&&void 0!==n?n:"").toLowerCase().includes(t)}):e.controller.scopeList}),z=Is(function(){if(x.value){var t=e.controller.scopeList.find(function(e){return String(e.id)===String(x.value)});return null==t?void 0:t.text}}),B=function(t){return!1===t.isShow?null:na("div",{draggable:!A(),onDragStart:function(){y.value=t.id},onDragEnd:function(){y.value=void 0,k.value=void 0},children:na(tb,{ref:function(e){l.current[t.id]=e},hasMoreThanOne:f.value,topic:t,controller:e.controller,isSelectMode:e.controller.isSelectMode.value,isSelected:e.controller.selectedTopicIds.value.has(t.id),onClick:function(){return function(t){e.controller.isTempChat.value&&e.controller.exitTempChat(),e.controller.handleTopicChange(t)}(t)},onAction:function(n,i){return function(t,n,i){"MULTISELECT"!==t?e.controller.handleTopicAction(t,n,i):e.controller.enterSelectMode(n.id)}(n,t,i)}})},t.id)},H=function(e,t){t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),k.value=e},F=function(){var t=v(h().m(function t(n,i){return h().w(function(t){for(;;)switch(t.n){case 0:if(!y.value){t.n=1;break}return t.n=1,e.controller.moveTopic(y.value,n,i);case 1:y.value=void 0,k.value=void 0;case 2:return t.a(2)}},t)}));return function(e,n){return t.apply(this,arguments)}}(),j=function(t){var n,i=t.key===Mw.NONE_SCOPE_KEY,r=p.value.has(t.key);return na("div",{className:rb.e("scope-node"),children:[na("div",{className:"".concat(rb.em("scope-node","header")," ").concat(rb.is("none",i)," ").concat(rb.is("dragover",k.value===t.key)),onDragOver:function(e){return H(t.key,e)},onDragLeave:function(){k.value===t.key&&(k.value=void 0)},onDrop:function(){return F(t.scopeid)},children:[na("span",{className:"".concat(rb.em("scope-node","arrow")," ").concat(rb.is("collapsed",r)),onClick:function(e){e.stopPropagation(),D(t.key)},children:na(uc,{})}),na("span",{className:rb.em("scope-node","text"),title:t.text,children:t.text}),!A()&&na("div",{className:rb.em("scope-node","icons"),children:[na("span",{className:rb.em("scope-node","icon-item"),title:$c.t.value("newGroup"),onClick:(n=v(h().m(function n(r){var o;return h().w(function(n){for(;;)switch(n.n){case 0:return r.stopPropagation(),p.value.has(t.key)&&D(t.key),n.n=1,e.controller.addGroup(i?void 0:t.scopeid);case 1:if(o=n.v){n.n=2;break}return n.a(2);case 2:w.value=o.id;case 3:return n.a(2)}},n)})),function(e){return n.apply(this,arguments)}),children:na(Hc,{})}),na("span",{className:"".concat(rb.em("scope-node","icon-item")," ").concat(rb.is("danger",!0)),title:$c.t.value("deleteScope"),onClick:function(n){n.stopPropagation(),e.controller.removeScope(i?void 0:t.scopeid)},children:na(Gs,{})})]})]}),!r&&na("div",{className:rb.em("scope-node","children"),children:[t.groups.map(function(n){return function(t,n,i){var r=!0===n.collapsed,o=w.value===n.id;return na("div",{className:rb.e("group-node"),children:[na("div",{className:"".concat(rb.em("group-node","header")," ").concat(rb.is("renaming",o)," ").concat(rb.is("dragover",k.value==="".concat(i,">group:").concat(n.id))),onDragOver:function(e){return H("".concat(i,">group:").concat(n.id),e)},onDragLeave:function(){k.value==="".concat(i,">group:").concat(n.id)&&(k.value=void 0)},onDrop:function(){return F(t,n.id)},children:[!o&&na("span",{className:"".concat(rb.em("group-node","arrow")," ").concat(rb.is("collapsed",r)),onClick:function(t){t.stopPropagation(),e.controller.toggleGroupCollapse(n.id)},children:na(uc,{})}),o?na("input",{ref:b,className:rb.em("group-node","editor"),defaultValue:n.text,onClick:function(e){return e.stopPropagation()},onKeyDown:function(t){t.stopPropagation(),"Enter"===t.key?(e.controller.renameGroup(n.id,t.target.value.trim()),w.value=void 0):"Escape"===t.key&&(C.current=!0,w.value=void 0)},onBlur:function(t){if(C.current)return C.current=!1,void(w.value=void 0);e.controller.renameGroup(n.id,t.target.value.trim()),w.value=void 0}}):na("span",{className:rb.em("group-node","text"),title:n.text,children:n.text}),!A()&&!o&&na("div",{className:rb.em("group-node","icons"),children:[na("span",{className:rb.em("group-node","icon-item"),title:$c.t.value("newCreateConversation"),onClick:function(i){i.stopPropagation(),!0===n.collapsed&&e.controller.toggleGroupCollapse(n.id),e.controller.globalNewTopic(t,n.id)},children:na(Hc,{})}),na("span",{className:rb.em("group-node","icon-item"),title:$c.t.value("rename"),onClick:function(e){e.stopPropagation(),w.value=n.id},children:na(ac,{})}),na("span",{className:"".concat(rb.em("group-node","icon-item")," ").concat(rb.is("danger",!0)),title:$c.t.value("deleteGroup"),onClick:function(t){t.stopPropagation(),e.controller.removeGroup(n.id)},children:na(Gs,{})})]})]}),!r&&na("div",{className:rb.em("group-node","topics"),children:n.topics.some(function(e){return!1!==e.isShow})?n.topics.map(function(e){return B(e)}):na("div",{className:rb.em("group-node","empty"),children:$c.t.value("noData")})})]},n.id)}(t.scopeid,n,t.key)}),t.ungroupedTopics.map(function(e){return B(e)})]})]},t.key)};return na("div",{className:"".concat(rb.b()," ").concat(rb.is("collapsed",!0===e.controller.topicSidebarCollapse.value)),children:[!0===e.controller.topicSidebarCollapse.value?na("div",{className:rb.e("collapse-container"),children:[na("div",{className:rb.e("icon-item"),title:$c.t.value("openSidebar"),onClick:function(){return I()},children:na(Mc,{})}),!1===e.controller.isSelectMode.value&&(!1===e.controller.isTempChat.value?na("div",{className:rb.e("icon-item"),title:$c.t.value("enterSession"),onClick:function(){return L(!0)},children:na(_c,{})}):na("div",{className:rb.e("icon-item"),title:$c.t.value("exitSession"),onClick:function(){return L(!1)},children:na(Nc,{})}))]}):na(Do,{children:[na("div",{className:rb.e("header"),children:[na("div",{className:rb.e("icon-container"),children:[na("div",{className:rb.e("icon-item"),title:$c.t.value("collapseSidebar"),onClick:function(){return I()},children:na(Mc,{})}),!1===e.controller.isSelectMode.value&&na(Do,{children:[na("div",{ref:N,className:rb.e("icon-item"),title:$c.t.value("newCreateConversation"),onClick:function(){return function(){var t,n;if(e.controller.disableSelectScope){var i,r;e.controller.globalNewTopic((null===(i=e.controller.activedTopic.value)||void 0===i?void 0:i.scope)||(null===(r=e.controller.backupOptions)||void 0===r?void 0:r.scope))}else{var o=null===(t=N.current)||void 0===t?void 0:t.getBoundingClientRect();if(o){var a=Math.min(o.right,window.innerWidth-400-8);_.value={left:Math.max(8,a),top:o.bottom+4}}var s=null===(n=e.controller.activedTopic.value)||void 0===n?void 0:n.scope,c=null!=s&&""!==s&&e.controller.scopeList.some(function(e){return String(e.id)===String(s)});x.value=c?s:void 0,T.value="",M.value=!1,S.value=!0}}()},children:na($s,{})}),!1===e.controller.isTempChat.value?na("div",{className:rb.e("icon-item"),title:$c.t.value("enterSession"),onClick:function(){return L(!0)},children:na(_c,{})}):na("div",{className:rb.e("icon-item"),title:$c.t.value("exitSession"),onClick:function(){return L(!1)},children:na(Nc,{})})]})]}),e.controller.isSelectMode.value?na("div",{className:rb.e("select-bar"),children:[na("span",{className:rb.e("select-info"),children:$c.t.value("selectedCount",{count:e.controller.selectedTopicIds.value.size})}),na("div",{className:"".concat(rb.e("cancel-select")),title:$c.t.value("cancelMultiSelect"),onClick:function(){return e.controller.exitSelectMode()},children:na(Ls,{})})]}):na(el,{value:u.value,placeholder:$c.t.value("searchTopics"),onChange:function(e){u.value=e}.bind(void 0)})]}),na("div",{ref:c,className:rb.e("main"),children:e.controller.topics.value.length>0?d.value.map(function(e){return j(e)}):na("div",{className:rb.e("empty"),children:$c.t.value("noTopic")})}),e.controller.isSelectMode.value?na("div",{className:"".concat(rb.e("footer")," ").concat(rb.is("select-mode",e.controller.isSelectMode.value)),children:[na("div",{title:$c.t.value(s?"unpin":"pinTop"),className:"".concat(rb.e("action")," ").concat(rb.is("disabled",0===e.controller.selectedTopicIds.value.size)),onClick:function(){return s?e.controller.batchUnPinTop():e.controller.batchPinTop()},children:[na(s?Bc:fc,{}),na("span",{children:$c.t.value(s?"unpin":"pinTop")})]}),na("div",{title:$c.t.value("delete"),className:"".concat(rb.e("action")," ").concat(rb.is("disabled",0===e.controller.selectedTopicIds.value.size)),onClick:function(t){return e.controller.batchDeleteTopics(t)},children:[na(Gs,{}),na("span",{children:$c.t.value("delete")})]})]}):!0===f.value&&na("div",{className:rb.e("footer"),children:na("div",{title:$c.t.value("clearSession"),className:rb.e("action"),onClick:function(){return e.controller.clearTopic(!0)},children:[na(Gs,{}),na("span",{children:$c.t.value("clearSession")})]})})]}),S.value&&na("div",{className:rb.e("modal-mask"),style:{zIndex:E},onClick:function(){return R()},children:na("div",{className:rb.e("modal"),style:{left:"".concat(null!==(t=null===(n=_.value)||void 0===n?void 0:n.left)&&void 0!==t?t:0,"px"),top:"".concat(null!==(i=null===(r=_.value)||void 0===r?void 0:r.top)&&void 0!==i?i:0,"px")},onClick:function(e){return e.stopPropagation()},children:[na("div",{className:rb.em("modal","header"),children:[na("span",{children:$c.t.value("newCreateConversation")}),na("span",{className:rb.em("modal","close"),title:$c.t.value("close"),onClick:function(){R()},children:na(Ls,{})})]}),na("div",{className:rb.em("modal","body"),children:[na("label",{className:rb.em("modal","label"),children:[$c.t.value("selectScope"),na("span",{className:rb.em("modal","required"),children:"*"})]}),na("div",{className:rb.em("modal","select-wrapper"),children:[na("div",{className:"".concat(rb.em("modal","select-trigger")," ").concat(rb.is("focus",M.value)),onClick:function(){M.value=!M.value},children:[na("span",{className:"".concat(rb.em("modal","select-value")," ").concat(rb.is("placeholder",!z.value)),children:null!==(o=z.value)&&void 0!==o?o:$c.t.value("selectScopePlaceholder")}),na("span",{className:"".concat(rb.em("modal","select-arrow")," ").concat(rb.is("open",M.value)),children:na(uc,{})})]}),M.value&&na("div",{className:rb.em("modal","dropdown"),children:[na("div",{className:rb.em("modal","dropdown-search"),children:na(el,{value:T.value,placeholder:$c.t.value("searchScopePlaceholder"),autoFocus:!0,onChange:function(e){T.value=e}})}),na("ul",{className:rb.em("modal","options"),children:P.value.length>0?P.value.map(function(e){return na("li",{className:"".concat(rb.em("modal","option")," ").concat(rb.is("selected",String(e.id)===String(x.value))),title:e.text,onClick:function(){x.value=e.id,M.value=!1,T.value=""},children:e.text},String(e.id))}):na("li",{className:"el-empty ".concat(rb.em("modal","option-empty")),children:[Sc,na("div",{className:rb.em("modal","option-empty-text"),children:$c.t.value("noData")})]})})]})]}),na("div",{className:rb.em("modal","tip"),children:$c.t.value("selectScopeTip")})]}),na("div",{className:rb.em("modal","footer"),children:[na("div",{className:rb.em("modal","btn"),onClick:function(){R()},children:$c.t.value("cancel")}),na("div",{className:"".concat(rb.em("modal","btn")," ").concat(rb.is("primary",!0)," ").concat(rb.is("disabled",void 0===x.value||""===x.value)),onClick:function(){return function(){if(x.value){var t=e.controller.scopeList.find(function(e){return String(e.id)===String(x.value)});S.value=!1,e.controller.globalNewTopic(t?t.id:x.value)}}()},children:$c.t.value("confirm")})]})]})})]})},ab=new ra("chat-minimize"),sb=function(e){var t=e.options||{},n=t.containerId,i=t.offset,r=qa(null),o=n?document.getElementById(n):null,a=g(Wa(""),2),s=a[0],c=a[1],l=g(Wa(0),2),u=l[0],d=l[1],h=g(Wa("center"),2),f=h[0],p=h[1],v=qa(!1),m={x:(window.innerWidth-86)/window.innerWidth,y:(window.innerHeight-86)/window.innerHeight},y=Is(function(){var t=e.controller.messages.value[e.controller.messages.value.length-1];return!!t&&("ASSISTANT"===t.role&&20===t.state&&!0!==t.completed)}),k=Is(function(){var t="";if(!y.value)return c(""),d(0),t;var n=e.controller.messages.value[e.controller.messages.value.length-1];if(t=n.content,n.content&&-1!==n.content.indexOf("<think>")){var i=function(e){var t=e.indexOf("<think>"),n=e.indexOf("</think>"),i="",r="";return-1===n?(i=e.slice(t+7),r=""):(i=e.slice(t+7,n),r=e.slice(n+8)),{thoughtContent:i,answerContent:r}}(n.content);t=i.thoughtContent+i.answerContent}return t}),w=function(){var e=r.current;if(e){var t=e.getBoundingClientRect(),n=t.left+t.width/2;n-110<0?p("left"):n+110>window.innerWidth?p("right"):p("center")}},b=function(){Object.assign(r.current.style,{left:"".concat(100*m.x,"%"),top:"".concat(100*m.y,"%")}),localStorage.setItem(Tw.MINIMIZE_STYLY_CHCHE,JSON.stringify(m)),w()};return $a(function(){if(e.isMinimize&&o&&r.current){var t=function(){if(r.current){var e=o.getBoundingClientRect(),t=e.left+(e.right-e.left)/2+((null==i?void 0:i.x)||0),n=e.top-38;Object.assign(r.current.style,{left:"".concat(t,"px"),top:"".concat(n,"px")}),w()}};t();var n=new ResizeObserver(t);n.observe(o);var a=function(){return requestAnimationFrame(t)};window.addEventListener("scroll",a,!0),window.addEventListener("resize",a);var s=new MutationObserver(t);return s.observe(o,{attributes:!0,attributeFilter:["style","class"]}),o.parentElement&&s.observe(o.parentElement,{attributes:!0,attributeFilter:["style","class"]}),function(){n.disconnect(),s.disconnect(),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}}},[e.isMinimize,o]),$a(function(){var e,t=localStorage.getItem(Tw.MINIMIZE_STYLY_CHCHE);if(t)try{var n=JSON.parse(t);Sa(n)&&Object.assign(m,n)}catch(vs){console.warn("解析最小化样式缓存失败,已做容错处理",{value:t,error:vs})}b(),(e=r.current)&&(e.onmousedown=function(t){document.body.style.userSelect="none";var n=t.clientX-e.offsetLeft,i=t.clientY-e.offsetTop,r=Date.now(),o=function(e){var t=56/window.innerWidth,r=56/window.innerHeight,o=xa(e.clientX-n,e.clientY-i,t,r),a=o.x,s=o.y;Object.assign(m,{x:a,y:s}),requestAnimationFrame(function(){b()})},a=function(){var e=Date.now();v.current=e-r>300,document.body.style.userSelect="",document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)})},[]),$a(function(){if(u<k.value.length){var e=setTimeout(function(){c(function(e){return e+k.value[u]}),d(function(e){return e+1})},100);return function(){return clearTimeout(e)}}},[u,k.value]),na("div",o?{ref:r,className:"".concat(ab.b("container")," ").concat(ab.is("hidden",!e.isMinimize)),children:na("div",{className:"".concat(ab.be("container","content")),children:s&&na("div",{className:"chat-minimize-popover ".concat(ab.is("align-".concat(f),!0)),children:na("div",{className:"typewriter",children:s})})})}:{ref:r,title:e.title,className:"".concat(ab.b()," ").concat(ab.is("hidden",!e.isMinimize)," ").concat(ab.is("show-halo",y.value)),onClick:function(){v.current||e.onClick()},children:na("div",{className:"".concat(ab.e("content")," ").concat(ab.is("show-border",!y.value)),children:[s&&na("div",{className:"".concat(ab.em("content","popover")," ").concat(ab.is("align-".concat(f),!0)),children:na("div",{className:"typewriter",children:s})}),na(Ws,{})]})})},cb=ea({zIndex:10,enableBackFill:!0}),lb=function(e){function t(e){var i,r,o,a,s,c;C(this,t),T(c=n(this,t,[e]),"listenedAIChat",void 0),T(c,"onCompleteMessageHandler",function(){var e,t=(null===(e=c.props.containerOptions)||void 0===e?void 0:e.minimizeOptions)||{},n=t.enable,i=void 0!==n&&n,r=t.openMode,o=void 0===r?"default":r;if(i&&c.props.autoClose){var a=c.props.autoClose,s=a.mode,l=a.duration,u=void 0===l?3:l;switch(s){case"minimize":c.minimize();break;case"close":c.close();break;case"closetime":setTimeout(function(){c.close()},1e3*u)}}"autoexpand"===o&&c.exitMinimize()}),T(c,"onMinimizeChangeHandler",function(e){e?c.minimize():c.exitMinimize()}),T(c,"ns",new ra("chat-container")),T(c,"containerRef",{current:null}),T(c,"dragHandle",{current:null}),T(c,"footerRef",{current:null}),T(c,"data",{side:{y:0,height:1,width:750/window.innerWidth,x:(window.innerWidth-750)/window.innerWidth},window:{y:0,width:750/window.innerWidth,height:750/window.innerHeight,x:(window.innerWidth-750)/window.innerWidth},minWidth:650,minHeight:400,showMode:"side"}),T(c,"disabled",!1),T(c,"isDragging",!1),T(c,"sidebarDragStartWidth",0),T(c,"resizing",{width:!1,height:!1}),T(c,"inputDragStartHeight",0),T(c,"inputDragContainerHeight",0),T(c,"containerContext",{zIndex:(null===(i=c.props.containerOptions)||void 0===i?void 0:i.zIndex)||10,enableBackFill:void 0===(null===(r=c.props)||void 0===r?void 0:r.enableBackFill)||null===(null===(o=c.props)||void 0===o?void 0:o.enableBackFill)||(null===(a=c.props)||void 0===a?void 0:a.enableBackFill)}),T(c,"handleSidebarResizeStart",function(){c.sidebarDragStartWidth=c.props.aiTopic.topicSidebarWidth.value}),T(c,"handleSidebarResizeMove",function(e){c.props.aiTopic.topicSidebarWidth.value=c.clampSidebarWidth(c.sidebarDragStartWidth+e)}),T(c,"handleSidebarResizeEnd",function(){c.props.aiTopic.updateTopicSidebarWidth()}),T(c,"syncSidebarWidth",function(){c.props.hideTopicSidebar||c.props.aiTopic.topicSidebarCollapse.value||(c.props.aiTopic.topicSidebarWidth.value=c.clampSidebarWidth(c.props.aiTopic.topicSidebarWidth.value))}),T(c,"commitSidebarWidth",function(){c.props.hideTopicSidebar||c.props.aiTopic.topicSidebarCollapse.value||c.props.aiTopic.updateTopicSidebarWidth()}),T(c,"handleInputHeightDragStart",function(){var e=c.footerRef.current;e&&e.parentElement&&(c.inputDragStartHeight=e.offsetHeight,c.inputDragContainerHeight=e.parentElement.offsetHeight)}),T(c,"handleInputHeightDragMove",function(e){var t=c.footerRef.current;if(t){var n=Math.max(168,c.inputDragContainerHeight-200-4),i=Math.min(n,Math.max(168,c.inputDragStartHeight-e));t.style.height="".concat(i,"px")}}),T(c,"handleInputHeightDragEnd",function(){var e=c.footerRef.current;if(e){var t=e.offsetHeight;c.setState({inputHeight:t});var n=c.getInputHeightCacheKey();localStorage.setItem(n,String(t))}}),T(c,"syncInputHeight",function(){var e,t=c.footerRef.current;if(t&&t.parentElement){var n=t.parentElement.offsetHeight,i=Math.max(168,n-200-4),r=null!==(e=c.state.inputHeight)&&void 0!==e?e:168,o=Math.min(i,Math.max(168,r));t.style.height="".concat(o,"px")}}),T(c,"commitInputHeight",function(){var e=c.footerRef.current;if(e){var t=e.offsetHeight;c.setState({inputHeight:t});var n=c.getInputHeightCacheKey();localStorage.setItem(n,String(t))}});var l=(null==e||null===(s=e.containerOptions)||void 0===s?void 0:s.minimizeOptions)||{},u=l.enable,d=void 0!==u&&u,h=l.openMode,f=void 0===h?"default":h;return c.state={isFullScreen:!1,enableAIMinimize:d,isMinimize:d&&("minimize"===f||"autoexpand"===f),inputHeight:c.readInputHeight()},c}return i(t,e),x(t,[{key:"listener",value:function(){var e=this.props.aiChat;e&&this.listenedAIChat!==e&&(this.listenedAIChat&&(this.listenedAIChat.evt.off("onCompleteMessage",this.onCompleteMessageHandler),this.listenedAIChat.evt.off("onMinimizeChange",this.onMinimizeChangeHandler)),e.evt.on("onCompleteMessage",this.onCompleteMessageHandler),e.evt.on("onMinimizeChange",this.onMinimizeChangeHandler),this.listenedAIChat=e)}},{key:"componentDidUpdate",value:function(){this.listener()}},{key:"calcWindowStyle",value:function(){var e,t="window"===this.data.showMode?this.data.window:this.data.side;return{left:"".concat(100*t.x,"%"),top:"".concat(100*t.y,"%"),width:"".concat(100*t.width,"%"),height:"".concat(100*t.height,"%"),minWidth:"".concat(this.data.minWidth,"px"),minHeight:"".concat(this.data.minHeight,"px"),"z-index":(null===(e=this.props.containerOptions)||void 0===e||null===(e=e.zIndex)||void 0===e?void 0:e.toString())||"10"}}},{key:"calcSideModeStyle",value:function(e){Object.assign(this.data,{side:{y:0,x:"left"===e?0:(window.innerWidth-750)/window.innerWidth,height:1,width:750/window.innerWidth},showMode:"side"})}},{key:"setStyle",value:function(){Object.assign(this.containerRef.current.style,this.calcWindowStyle()),localStorage.setItem(Tw.STYLE_CACHE,JSON.stringify(this.data))}},{key:"snapToEdge",value:function(){var e=20/window.innerWidth,t=20/window.innerHeight,n=this.data.window,i=n.x,r=n.y,o=n.width,a=n.height;i<e||i+o>1-e?this.calcSideModeStyle(i<e?"left":"right"):(r<t&&(this.data.window.y=0),r+a>1-t&&(this.data.window.y=1-a)),this.setStyle()}},{key:"registerDragDialog",value:function(){var e=this;this.dragHandle.current.onmousedown=function(t){if(!e.state.isFullScreen){document.body.style.userSelect="none";var n=t.clientX-e.containerRef.current.offsetLeft,i=t.clientY-e.containerRef.current.offsetTop,r=function(t){if(!e.disabled){e.data.showMode="window";var r=xa(t.clientX-n,t.clientY-i,e.data.window.width,e.data.window.height),o=r.x,a=r.y;Object.assign(e.data.window,{x:o,y:a}),e.setStyle()}},o=function(){document.body.style.userSelect="",document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o),e.disabled||(e.snapToEdge(),e.syncSidebarWidth(),e.syncInputHeight(),e.commitSidebarWidth(),e.commitInputHeight())};document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)}}}},{key:"registerDragDialogBorder",value:function(){var e=this;a(this.containerRef.current).resizable({edges:{top:!0,right:!0,bottom:!0,left:!0},margin:6,modifiers:[a.modifiers.restrictEdges({outer:document.body}),a.modifiers.restrictSize({min:{width:this.data.minWidth,height:this.data.minHeight}})],inertia:!0,listeners:{move:function(t){if(!e.state.isFullScreen){var n="side"===e.data.showMode?e.data.side:e.data.window;n.x=t.rect.left/window.innerWidth,n.y=t.rect.top/window.innerHeight,n.width=t.rect.width/window.innerWidth,n.height=t.rect.height/window.innerHeight,e.setStyle();var i=t.edges,r=i.left,o=i.right,a=i.top,s=i.bottom;e.resizing.width=!(!r&&!o),e.resizing.height=!(!a&&!s),e.resizing.height&&e.syncInputHeight(),e.resizing.width&&e.syncSidebarWidth()}},start:function(){e.disabled=!0,document.body.style.userSelect="none"},end:function(){e.disabled=!1,document.body.style.userSelect="",e.resizing.height&&e.commitInputHeight(),e.resizing.width&&e.commitSidebarWidth()}}})}},{key:"handleFullScreenChange",value:function(){this.setState({isFullScreen:null!==document.fullscreenElement})}},{key:"componentDidMount",value:function(){this.handleFullScreenChange=this.handleFullScreenChange.bind(this);var e=localStorage.getItem(Tw.STYLE_CACHE);if(e)try{var t=JSON.parse(e);t.side&&Sa(t.side)&&t.window&&Sa(t.window)&&Object.assign(this.data,t)}catch(vs){console.warn("解析样式缓存失败,已做容错处理",{value:e,error:vs})}this.setStyle(),this.registerDragDialog(),this.registerDragDialogBorder(),document.addEventListener("fullscreenchange",this.handleFullScreenChange)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("fullscreenchange",this.handleFullScreenChange),this.listenedAIChat&&(this.listenedAIChat.evt.off("onCompleteMessage",this.onCompleteMessageHandler),this.listenedAIChat.evt.off("onMinimizeChange",this.onMinimizeChangeHandler),this.listenedAIChat=void 0)}},{key:"close",value:function(){this.props.close()}},{key:"fullScreen",value:function(){var e=this.containerRef.current;e&&(e.requestFullscreen(),this.props.fullscreen(!0))}},{key:"closeFullScreen",value:function(){var e;this.state.isFullScreen&&(null===(e=document)||void 0===e||e.exitFullscreen(),this.props.fullscreen(!1),this.setStyle())}},{key:"minimize",value:function(){this.closeFullScreen(),this.setState({isMinimize:!0}),this.props.minimize(!0)}},{key:"exitMinimize",value:function(){this.setState({isMinimize:!1}),this.props.minimize(!1)}},{key:"stopPropagation",value:function(e){e.stopPropagation()}},{key:"renderSidebarSplitter",value:function(){return this.props.hideTopicSidebar||this.props.aiTopic.topicSidebarCollapse.value?null:na(xw,{direction:"vertical",onDragStart:this.handleSidebarResizeStart,onMove:this.handleSidebarResizeMove,onDragEnd:this.handleSidebarResizeEnd})}},{key:"getRightWidth",value:function(){if(this.props.hideTopicSidebar)return"100%";var e=this.props.aiTopic.topicSidebarWidth.value;return this.props.aiTopic.topicSidebarCollapse.value?"calc(100% - ".concat(e,"px)"):"calc(100% - ".concat(e,"px - ").concat(4,"px)")}},{key:"clampSidebarWidth",value:function(e){var t,n,i,r,o,a=null!==(t=null===(n=this.containerRef.current)||void 0===n?void 0:n.offsetWidth)&&void 0!==t?t:0,s=230+(null!==(i=this.props.aiChat)&&void 0!==i&&i.enableKnowledgeBaseSelect.value?90:0)+(null!==(r=this.props.aiChat)&&void 0!==r&&r.enableChatProject.value?90:0)+(null!==(o=this.props.aiChat)&&void 0!==o&&o.enableRecallConfigSetting.value?16:0);return Math.min(a/2,a-s,Math.max(200,e))}},{key:"getInputHeightCacheKey",value:function(){return"".concat(this.props.compWrapperId||"DEFAULT","__").concat(Tw.INPUT_HEIGHT)}},{key:"readInputHeight",value:function(){var e=this.getInputHeightCacheKey(),t=localStorage.getItem(e);if(null===t)return null;var n=Number(t);return Number.isFinite(n)&&n>0?n:null}},{key:"getFooterStyle",value:function(){return null===this.state.inputHeight?{height:"168px"}:{height:"".concat(this.state.inputHeight,"px")}}},{key:"render",value:function(){var e;return na(cb.Provider,{value:this.containerContext,children:na("div",{className:"".concat(this.ns.b()),children:[na("div",{className:"".concat(this.ns.e("dialog")," ").concat(this.ns.is("full-screen",this.state.isFullScreen)," ").concat(this.ns.is("hidden",this.state.isMinimize)),ref:this.containerRef,children:[na("div",{ref:this.dragHandle,className:this.ns.b("header"),children:[na("div",{className:this.ns.b("header-caption"),children:this.props.caption||$c.t.value("aiAssistant")}),na("div",{className:this.ns.b("header-action-wrapper"),children:[this.state.enableAIMinimize&&na("div",{title:$c.t.value("minimize"),className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","minimize")),onMouseDown:this.stopPropagation.bind(this),onClick:this.minimize.bind(this),children:na(Vs,{})}),this.state.isFullScreen?na("div",{title:$c.t.value("exitFullscreen"),className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","close-full-screen")),onMouseDown:this.stopPropagation.bind(this),onClick:this.closeFullScreen.bind(this),children:na(js,{})}):na("div",{title:$c.t.value("fullscreen"),className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","full-screen")),onMouseDown:this.stopPropagation.bind(this),onClick:this.fullScreen.bind(this),children:na(Fs,{})}),na("div",{title:$c.t.value("close"),className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","action-close")),onMouseDown:this.stopPropagation.bind(this),onClick:this.close.bind(this),children:na(Ls,{})})]})]}),this.props.isLoading?na("div",{className:"".concat(this.ns.be("main","loading")),children:[na("div",{className:"".concat(this.ns.be("main","spinner"))}),na("div",{className:"".concat(this.ns.be("main","text")),children:$c.t.value("loading")})]}):"TOPIC"===this.props.mode?na("div",{className:"".concat(this.ns.b("main")),children:[!this.props.hideTopicSidebar&&na("div",{className:"".concat(this.ns.be("main","left")),style:{width:"".concat(this.props.aiTopic.topicSidebarWidth.value,"px")},children:"WORKSPACE"===this.props.aiTopic.workMode?na(ob,{controller:this.props.aiTopic}):na(ib,{controller:this.props.aiTopic})}),this.renderSidebarSplitter(),na("div",{className:"".concat(this.ns.be("main","right")),style:{width:this.getRightWidth()},children:[na("div",{className:this.ns.b("content"),children:na(Cw,{controller:this.props.aiChat,toolbarItems:this.props.contentToolbarItems,children:na(mw,{type:"footer",mode:this.props.mode,hideTopicSidebar:this.props.hideTopicSidebar,data:this.props.aiTopic.activedTopic.value,controller:this.props.aiChat,items:this.props.footerToolbarItems})})}),na(xw,{direction:"horizontal",onDragStart:this.handleInputHeightDragStart,onMove:this.handleInputHeightDragMove,onDragEnd:this.handleInputHeightDragEnd}),na("div",{ref:this.footerRef,className:"".concat(this.ns.b("footer")),style:this.getFooterStyle(),children:na(Qw,{controller:this.props.aiChat,questionToolbarItems:this.props.questionToolbarItems})})]},this.props.aiChat.topicId)]}):na("div",{className:"".concat(this.ns.be("main","default")),children:[na("div",{className:this.ns.b("content"),children:na(Cw,{controller:this.props.aiChat,toolbarItems:this.props.contentToolbarItems,children:na(mw,{type:"footer",mode:this.props.mode,hideTopicSidebar:this.props.hideTopicSidebar,data:this.props.aiTopic.activedTopic.value,controller:this.props.aiChat,items:this.props.footerToolbarItems})})}),na(xw,{direction:"horizontal",onDragStart:this.handleInputHeightDragStart,onMove:this.handleInputHeightDragMove,onDragEnd:this.handleInputHeightDragEnd}),na("div",{ref:this.footerRef,className:"".concat(this.ns.b("footer")),style:this.getFooterStyle(),children:na(Qw,{controller:this.props.aiChat,questionToolbarItems:this.props.questionToolbarItems})})]})]}),!this.props.isLoading&&na(sb,{options:null===(e=this.props.containerOptions)||void 0===e?void 0:e.minimizeOptions,title:this.props.caption||$c.t.value("aiAssistant"),controller:this.props.aiChat,isMinimize:this.state.isMinimize,onClick:this.exitMinimize.bind(this)},this.props.aiChat.topicId)]})})}}])}(Io);t("ChatContainer",lb);var ub=ea({enableBackFill:!0}),db=function(e){function t(){var e,i,r,o;C(this,t);for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return T(o=n(this,t,[].concat(s)),"ns",new ra("flat-chat-container")),T(o,"headerRef",{current:null}),T(o,"messagesRef",{current:null}),T(o,"toolbarsRef",{current:null}),T(o,"topicRef",{current:null}),T(o,"containerRef",{current:null}),T(o,"footerRef",{current:null}),T(o,"sidebarDragStartWidth",0),T(o,"inputDragStartHeight",0),T(o,"inputDragContainerHeight",0),T(o,"state",{mountedSlots:{},inputHeight:o.readInputHeight()}),T(o,"containerContext",{enableBackFill:void 0===(null===(e=o.props)||void 0===e?void 0:e.enableBackFill)||null===(null===(i=o.props)||void 0===i?void 0:i.enableBackFill)||(null===(r=o.props)||void 0===r?void 0:r.enableBackFill)}),T(o,"handleSidebarResizeStart",function(){o.sidebarDragStartWidth=o.props.aiTopic.topicSidebarWidth.value}),T(o,"handleSidebarResizeMove",function(e){var t,n,i,r,a,s=null!==(t=null===(n=o.containerRef.current)||void 0===n?void 0:n.offsetWidth)&&void 0!==t?t:0,c=230+(null!==(i=o.props.aiChat)&&void 0!==i&&i.enableKnowledgeBaseSelect.value?90:0)+(null!==(r=o.props.aiChat)&&void 0!==r&&r.enableChatProject.value?90:0)+(null!==(a=o.props.aiChat)&&void 0!==a&&a.enableRecallConfigSetting.value?16:0),l=Math.min(s/2,s-c,Math.max(200,o.sidebarDragStartWidth+e));o.props.aiTopic.topicSidebarWidth.value=l}),T(o,"handleSidebarResizeEnd",function(){o.props.aiTopic.updateTopicSidebarWidth()}),T(o,"handleInputHeightDragStart",function(){var e=o.footerRef.current;e&&e.parentElement&&(o.inputDragStartHeight=e.offsetHeight,o.inputDragContainerHeight=e.parentElement.offsetHeight)}),T(o,"handleInputHeightDragMove",function(e){var t=o.footerRef.current;if(t){var n=Math.max(168,o.inputDragContainerHeight-200-4),i=Math.min(n,Math.max(168,o.inputDragStartHeight-e));t.style.height="".concat(i,"px")}}),T(o,"handleInputHeightDragEnd",function(){var e=o.footerRef.current;if(e){var t=e.offsetHeight;o.setState({inputHeight:t});var n=o.getInputHeightCacheKey();localStorage.setItem(n,String(t))}}),o}return i(t,e),x(t,[{key:"appendExternalSlot",value:function(e,t,n){!this.state.mountedSlots[e]&&n&&t.current&&(t.current.appendChild(n),this.setState(function(t){return{mountedSlots:d(d({},t.mountedSlots),{},T({},e,!0))}}))}},{key:"componentDidMount",value:function(){this.syncExternalSlots()}},{key:"componentDidUpdate",value:function(e){e.aiChat!==this.props.aiChat&&this.setState({mountedSlots:{}}),this.syncExternalSlots()}},{key:"syncExternalSlots",value:function(){var e=this.props.extension;e&&(this.appendExternalSlot("header",this.headerRef,e.headerContainer),this.appendExternalSlot("messages",this.messagesRef,e.messagesContainer),this.appendExternalSlot("toolbar",this.toolbarsRef,e.toolbarContainer),this.appendExternalSlot("topic",this.topicRef,e.topicContainer))}},{key:"renderLoading",value:function(){return na("div",{className:"".concat(this.ns.be("main","loading")),children:[na("div",{className:"".concat(this.ns.be("main","spinner"))}),na("div",{className:"".concat(this.ns.be("main","text")),children:$c.t.value("loading")})]})}},{key:"renderSidebarSplitter",value:function(){return this.props.hideTopicSidebar||this.props.aiTopic.topicSidebarCollapse.value?null:na(xw,{direction:"vertical",onDragStart:this.handleSidebarResizeStart,onMove:this.handleSidebarResizeMove,onDragEnd:this.handleSidebarResizeEnd})}},{key:"getRightWidth",value:function(){if(this.props.hideTopicSidebar)return"100%";var e=this.props.aiTopic.topicSidebarWidth.value;return this.props.aiTopic.topicSidebarCollapse.value?"calc(100% - ".concat(e,"px)"):"calc(100% - ".concat(e,"px - ").concat(4,"px)")}},{key:"getInputHeightCacheKey",value:function(){return"".concat(this.props.compWrapperId||"DEFAULT","__").concat(Tw.INPUT_HEIGHT)}},{key:"readInputHeight",value:function(){var e=this.getInputHeightCacheKey(),t=localStorage.getItem(e);if(null===t)return null;var n=Number(t);return Number.isFinite(n)&&n>0?n:null}},{key:"getFooterStyle",value:function(){return null===this.state.inputHeight?{height:"168px"}:{height:"".concat(this.state.inputHeight,"px")}}},{key:"renderContent",value:function(){if(this.props.aiChat){if(!this.props.aiChat.inited.value)return this.renderLoading();var e=this.props,t=e.mode,n=e.aiChat,i=e.aiTopic,r=e.extension,o=e.hideTopicSidebar,a=e.contentToolbarItems,s=e.footerToolbarItems,c=e.questionToolbarItems;return[na("div",{className:this.ns.b("content"),ref:this.messagesRef,children:!(null!=r&&r.messagesContainer)&&na(Cw,{controller:n,toolbarItems:a,children:null!=r&&r.toolbarContainer?na("div",{className:"toolbar-slot",ref:this.toolbarsRef}):na(mw,{type:"footer",mode:t,hideTopicSidebar:o,data:i.activedTopic.value,controller:n,items:s})})},1),na(xw,{direction:"horizontal",onDragStart:this.handleInputHeightDragStart,onMove:this.handleInputHeightDragMove,onDragEnd:this.handleInputHeightDragEnd},2),na("div",{ref:this.footerRef,className:"".concat(this.ns.b("footer")),style:this.getFooterStyle(),children:na(Qw,{controller:n,questionToolbarItems:c})},3)]}}},{key:"renderHeader",value:function(){var e;return na("div",{className:this.ns.b("header"),ref:this.headerRef,children:!(null!==(e=this.props.extension)&&void 0!==e&&e.headerContainer)&&na("div",{className:this.ns.b("header-caption"),children:this.props.caption||$c.t.value("aiAssistant")})})}},{key:"render",value:function(){var e=this.props,t=e.isLoading,n=e.mode,i=e.hideTopicSidebar,r=e.aiChat,o=e.aiTopic,a=e.extension,s=!(r&&r.messages.value.length>0);return na(ub.Provider,{value:this.containerContext,children:na("div",{ref:this.containerRef,className:"".concat(this.ns.b()," ").concat(this.ns.is("empty-message",s)),children:[this.renderHeader(),t?this.renderLoading():na("div","TOPIC"===n?{className:"".concat(this.ns.b("main")),children:[!i&&na("div",{ref:this.topicRef,className:"".concat(this.ns.be("main","left")),style:{width:"".concat(o.topicSidebarWidth.value,"px")},children:!(null!=a&&a.topicContainer)&&("WORKSPACE"===o.workMode?na(ob,{controller:o}):na(ib,{controller:o}))}),this.renderSidebarSplitter(),na("div",{className:"".concat(this.ns.be("main","right")),style:{width:this.getRightWidth()},children:this.renderContent()},null==r?void 0:r.topicId)]}:{className:"".concat(this.ns.be("main","default")),children:this.renderContent()})]})})}}])}(Io);t("FlatChatContainer",db);var hb=window.SpeechRecognition||window.webkitSpeechRecognition,fb=new ra("simple-chat-input"),pb=function(e){var t,n=g(Wa(!1),2),i=n[0],r=n[1],o=e.controller.input,a=Ds(!1),s=qa(),c=qa(null);hb&&!s.current&&(s.current=new hb,s.current.onstart=function(){a.value=!0},s.current.onend=function(){a.value=!1},s.current.onresult=function(e){var t,n,i=null===(t=e.results)||void 0===t||null===(t=t[0])||void 0===t||null===(t=t[0])||void 0===t?void 0:t.transcript;i&&(null===(n=c.current)||void 0===n||n.commands.insertContent(i))});var l=Is(function(){return va(o.value).length<=0}),u=function(){try{var t,n,i,r=va(o.value);o.value="",null===(t=c.current)||void 0===t||t.chain().clearContent().run();var a=e.controller.stringlyMaterialResource(!0);null===(n=(i=e.controller.opts).action)||void 0===n||n.call(i,"send",{content:r,resources:a,agentId:e.controller.activeAIAgentID,knowledgeId:e.controller.getQueryKnowledgeBases()})}catch(s){console.error(s)}},d=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return i=Pw.getMaterialHelper("ossfile",e.controller),t.n=1,i.excuteAction(n);case 1:r(!1);case 2:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),f=function(){var t=v(h().m(function t(n,i){var o;return h().w(function(t){for(;;)switch(t.n){case 0:return o=Pw.getMaterialHelper("common",e.controller),t.n=1,o.excuteAction(n,i);case 1:r(!1);case 2:return t.a(2)}},t)}));return function(e,n){return t.apply(this,arguments)}}(),p=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.controller.knowledgeRemoteSearch(n);case 1:return i=t.v,t.a(2,i)}},t)}));return function(e){return t.apply(this,arguments)}}(),m=function(){var t=v(h().m(function t(n){var i;return h().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.controller.searchAIAgent(n);case 1:return i=t.v,t.a(2,i)}},t)}));return function(e){return t.apply(this,arguments)}}();return na("div",{className:fb.b(),children:[na("div",{className:fb.e("body"),children:[na("div",{className:fb.em("body","wrapper"),children:[na(jw,{controller:e.controller}),na(Zk,{value:o.value,c:e.controller,onCreate:function(e){c.current=e},onChange:function(e){o.value=e},onKeyDown:function(e){l.value||"Enter"!==e.code||"Enter"!==e.key||!1!==e.shiftKey||u()},placeholder:e.controller.placeholder.value,disabled:e.controller.isLoading.value})]}),na("div",{className:fb.em("body","operation"),children:[na(Bl,{position:"top",triggerMode:"click",isOpen:i,onToggleOpen:r,content:na("div",{className:fb.b("popup"),children:[na("div",{onClick:d,className:fb.be("popup","item"),children:[na("div",{className:fb.bem("popup","item","icon"),children:na(Zs,{})}),na("div",{className:fb.bem("popup","item","title"),children:$c.t.value("documentation")})]}),null===(t=e.questionToolbarItems)||void 0===t?void 0:t.map(function(e){var t,n,i;return na("div",{className:fb.be("popup","item"),onClick:function(t){return f(t,e)},children:[na("div",{className:fb.bem("popup","item","icon"),children:"function"==typeof e.icon?e.icon():(null===(t=e.icon)||void 0===t?void 0:t.showIcon)&&na(Do,{children:null!==(n=e.icon)&&void 0!==n&&n.cssClass?na("i",{className:e.icon.cssClass}):null!==(i=e.icon)&&void 0!==i&&i.imagePath?ha(e.icon.imagePath)?na("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):na("img",{src:e.icon.imagePath}):null})}),na("div",{className:fb.bem("popup","item","title"),children:e.label})]},e.id)})]}),children:na("div",{className:"".concat(fb.e("icon")," ").concat(fb.em("icon","upload")," ").concat(fb.em("body","left")),title:$c.t.value("uploadDocument"),children:na(Qs,{})})}),na("div",{className:fb.em("body","right"),children:[na("div",{className:"".concat(fb.e("icon")," ").concat(fb.em("icon","voice")," ").concat(fb.is("recording",a.value)),title:a.value?$c.t.value("voiceInputProgress"):$c.t.value("voiceInput"),onClick:function(){s.current&&(a.value?s.current.abort():s.current.start())},children:a.value?na(qs,{}):na(Us,{})}),na("div",{onClick:u,title:$c.t.value("sendMessage"),className:"".concat(fb.e("icon")," ").concat(fb.em("icon","send")," ").concat(fb.is("disabled",l.value)),children:na(Ps,{className:fb.e("send-icon")})})]})]})]}),na("div",{className:fb.e("footer"),children:[na(rl,{showBorder:!1,enableSearch:!0,placeholder:"Auto",popperStyle:{height:"220px"},className:"".concat(fb.e("action")," ").concat(fb.em("action","agent")),value:e.controller.activeAIAgentID,options:e.controller.agentList.value,icon:function(){return na("div",{title:$c.t.value("agent"),children:lc()})},disabled:!e.controller.enableAIAgentChange,onSearch:m,onChange:function(t){return n=t,void e.controller.setActiveAIAgentID(n);var n}}),e.controller.enableKnowledgeBaseSelect.value&&na(al,{className:"".concat(fb.e("action")," ").concat(fb.em("action","knowledge")," ").concat(fb.is("active",e.controller.selectionKnowledgeBases.value.length>0)),enableSearch:!0,popperStyle:{height:"220px"},options:e.controller.knowledgeBases.value,icon:function(){return na("div",{title:$c.t.value("knowledge"),children:bc})},placeholder:$c.t.value("knowledgeSearch"),value:e.controller.selectionKnowledgeBases.value,onSearch:function(e){return p(e)},onChange:function(t){e.controller.setSelectionKnowledge(t)}})]})]})},vb=function(e){function t(){var e;C(this,t);for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return T(e=n(this,t,[].concat(r)),"ns",new ra("simple-chat-container")),e}return i(t,e),x(t,[{key:"render",value:function(){return na("div",{className:this.ns.b(),children:this.props.isLoading?na("div",{className:this.ns.e("loading"),children:[na("div",{className:this.ns.em("loading","spinner")}),na("div",{className:this.ns.em("loading","text"),children:$c.t.value("loading")})]}):na(pb,{controller:this.props.aiChat,questionToolbarItems:this.props.questionToolbarItems})})}}])}(Io)}}})}();