From 48c28d2653839541c3601e806e7bfaa0ed12d040 Mon Sep 17 00:00:00 2001 From: Bharat Chauhan Date: Sat, 6 Jul 2024 07:55:04 +0530 Subject: [PATCH] Playground: Update playground.js --- docs/static/js/playground.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/static/js/playground.js b/docs/static/js/playground.js index 9ce751e..e37575e 100644 --- a/docs/static/js/playground.js +++ b/docs/static/js/playground.js @@ -1,3 +1,3 @@ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("react"),require("react-dom"),require("react-modal")):"function"==typeof define&&define.amd?define(["react","react-dom","react-modal"],t):t((e||self).React,e.ReactDOM,e.ReactModal)}(this,function(e,t,i){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/n(e),s=/*#__PURE__*/n(t),o=/*#__PURE__*/n(i);function a(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);ithis.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),d.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let i=[];return this.decompose(e,t,i,0),d.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new m(this),r=new m(e);for(let e=t,s=t;;){if(n.next(e),r.next(e),e=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(s+=n.value.length,n.done||s>=i)return!0}}iter(e=1){return new m(this,e)}iterRange(e,t=this.length){return new g(this,e,t)}iterLines(e,t){let i;if(null==e)i=this.iter();else{null==t&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new v(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new u(e):d.from(u.split(e,[])):c.empty}}class u extends c{constructor(e,t=function(e){let t=-1;for(let i of e)t+=i.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let s=this.text[r],o=n+s.length;if((t?i:o)>=e)return new y(n,o,i,s);n=o+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new u(p(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&n){let e=i.pop(),t=f(r.text,e.text.slice(),0,r.length);if(t.length<=32)i.push(new u(t,e.length+r.length));else{let e=t.length>>1;i.push(new u(t.slice(0,e)),new u(t.slice(e)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof u))return super.replace(e,t,i);let n=f(this.text,f(i.text,p(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new u(n,r):d.from(u.split(n,[]),r)}sliceString(e,t=this.length,i="\n"){let n="";for(let r=0,s=0;r<=t&&se&&s&&(n+=i),er&&(n+=o.slice(Math.max(0,e-r),t-r)),r=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,32==i.length&&(t.push(new u(i,n)),i=[],n=-1);return n>-1&&t.push(new u(i,n)),t}}class d extends c{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,i,n){for(let r=0;;r++){let s=this.children[r],o=n+s.length,a=i+s.lines-1;if((t?a:o)>=e)return s.lineInner(e,t,i,n);n=o+1,i=a+1}}decompose(e,t,i,n){for(let r=0,s=0;s<=t&&r=s){let r=n&((s<=e?1:0)|(a>=t?2:0));s>=e&&a<=t&&!r?i.push(o):o.decompose(e-s,t-s,i,r)}s=a+1}}replace(e,t,i){if(i.lines=r&&t<=o){let a=s.replace(e-r,t-r,i),l=this.lines-s.lines+a.lines;if(a.lines>4&&a.lines>l>>6){let r=this.children.slice();return r[n]=a,new d(r,this.length-(t-e)+i.length)}return super.replace(r,o,a)}r=o+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i="\n"){let n="";for(let r=0,s=0;re&&r&&(n+=i),es&&(n+=o.sliceString(e-s,t-s,i)),s=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof d))return 0;let i=0,[n,r,s,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==s||r==o)return i;let a=this.children[n],l=e.children[r];if(a!=l)return i+a.scanIdentical(l,t);i+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let i=0;for(let t of e)i+=t.lines;if(i<32){let i=[];for(let t of e)t.flatten(i);return new u(i,t)}let n=Math.max(32,i>>5),r=n<<1,s=n>>1,o=[],a=0,l=-1,h=[];function c(e){let t;if(e.lines>r&&e instanceof d)for(let t of e.children)c(t);else e.lines>s&&(a>s||!a)?(f(),o.push(e)):e instanceof u&&a&&(t=h[h.length-1])instanceof u&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,h[h.length-1]=new u(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>n&&f(),a+=e.lines,l+=e.length+1,h.push(e))}function f(){0!=a&&(o.push(1==h.length?h[0]:d.from(h,l)),l=-1,a=h.length=0)}for(let t of e)c(t);return f(),1==o.length?o[0]:new d(o,t)}}function f(e,t,i=0,n=1e9){for(let r=0,s=0,o=!0;s=i&&(l>n&&(a=a.slice(0,n-r)),r0?1:(e instanceof u?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],s=r>>1,o=n instanceof u?n.text.length:n.children.length;if(s==(t>0?o:0)){if(0==i)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[i]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(n instanceof u){let r=n.text[s+(t<0?-1:0)];if(this.offsets[i]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=n.children[s+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof u?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class g{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new m(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class v{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(c.prototype[Symbol.iterator]=function(){return this.iter()},m.prototype[Symbol.iterator]=g.prototype[Symbol.iterator]=v.prototype[Symbol.iterator]=function(){return this});class y{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}let w=/*@__PURE__*/"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=1;ee)return w[t-1]<=e;return!1}function k(e){return e>=127462&&e<=127487}function x(e,t,i=!0,n=!0){return(i?S:O)(e,t,n)}function S(e,t,i){if(t==e.length)return t;t&&C(e.charCodeAt(t))&&A(e.charCodeAt(t-1))&&t--;let n=E(e,t);for(t+=M(n);t=0&&k(E(e,n));)i++,n-=2;if(i%2==0)break;t+=2}}}return t}function O(e,t,i){for(;t>0;){let n=S(e,t-2,i);if(n=56320&&e<57344}function A(e){return e>=55296&&e<56320}function E(e,t){let i=e.charCodeAt(t);if(!A(i)||t+1==e.length)return i;let n=e.charCodeAt(t+1);return C(n)?n-56320+(i-55296<<10)+65536:i}function M(e){return e<65536?1:2}const T=/\r\n?|\n/;var N=/*@__PURE__*/function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(N||(N={}));class D{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-n);r+=o}else{if(i!=N.Simple&&l>=e&&(i==N.TrackDel&&ne||i==N.TrackBefore&&ne))return null;if(l>e||l==e&&t<0&&!o)return e==n||t<0?r:r+a;r+=a}n=l}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i=0&&n<=t&&r>=e)return!(nt)||"cover";n=r}return!1}toString(){let e="";for(let t=0;t=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new D(e)}static create(e){return new D(e)}}class P extends D{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return B(this,(t,i,n,r,s)=>e=e.replace(n,n+(i-t),s),!1),e}mapDesc(e,t=!1){return I(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n=0){t[n]=o,t[n+1]=s;let a=n>>1;for(;i.length0&&j(i,t,r.text),r.forward(e),o+=e}let l=e[s++];for(;o>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],s=0,o=null;function a(e=!1){if(!e&&!n.length)return;so||e<0||o>t)throw new RangeError(`Invalid change range ${e} to ${o} (in doc of length ${t})`);let u=h?"string"==typeof h?c.of(h.split(i||T)):h:c.empty,d=u.length;if(e==o&&0==d)return;es&&R(n,e-s,-1),R(n,o-e,d),j(r,n,u),s=o}}(e),a(!o),o}static empty(e){return new P(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;nt&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)t.push(r[0],0);else{for(;i.length=0&&i<=0&&i==e[r+1]?e[r]+=t:0==t&&0==e[r]?e[r+1]+=i:n?(e[r]+=t,e[r+1]+=i):e.push(t,i)}function j(e,t,i){if(0==i.length)return;let n=t.length-2>>1;if(n>1])),!(i||o==e.sections.length||e.sections[o+1]<0);)a=e.sections[o++],l=e.sections[o++];t(r,h,s,u,d),r=h,s=u}}}function I(e,t,i,n=!1){let r=[],s=n?[]:null,o=new V(e),a=new V(t);for(let e=-1;;)if(-1==o.ins&&-1==a.ins){let e=Math.min(o.len,a.len);R(r,e,-1),o.forward(e),a.forward(e)}else if(a.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(a.len=0&&e=0)){if(o.done&&a.done)return s?P.createSet(r,s):D.create(r);throw new Error("Mismatched change set lengths")}{let t=0,i=o.len;for(;i;)if(-1==a.ins){let e=Math.min(i,a.len);t+=e,i-=e,a.forward(e)}else{if(!(0==a.ins&&a.lent||o.ins>=0&&o.len>t)&&(e||n.length>i),s.forward2(t),o.forward(t)}}else R(n,0,o.ins,e),r&&j(r,n,o.text),o.next()}}class V{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?c.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?c.empty:t[i].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class _{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){let e=3&this.flags;return 3==e?null:e}get goalColumn(){let e=this.flags>>5;return 33554431==e?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new _(i,n,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return H.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return H.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return H.range(e.anchor,e.head)}static create(e,t,i){return new _(e,t,i)}}class H{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:H.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;te.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new H(e.ranges.map(e=>_.fromJSON(e)),e.main)}static single(e,t=e){return new H([H.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;ne?4:0))}static normalized(e,t=0){let i=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(i);for(let i=1;in.head?H.range(o,s):H.range(s,o))}}return new H(e,t)}}function F(e,t){for(let i of e.ranges)if(i.to>t)throw new RangeError("Selection points outside of document")}let z=0;class W{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=z++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}static define(e={}){return new W(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:q),!!e.static,e.enables)}of(e){return new $([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new $(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new $(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],i=>t(i.field(e)))}}function q(e,t){return e==t||e.length==t.length&&e.every((e,i)=>e===t[i])}class ${constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=z++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,s=e[r]>>1,o=2==this.type,a=!1,l=!1,h=[];for(let i of this.dependencies)"doc"==i?a=!0:"selection"==i?l=!0:0==(1&(null!==(t=e[i.id])&&void 0!==t?t:1))&&h.push(e[i.id]);return{create:e=>(e.values[s]=i(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||J(e,h)){let t=i(e);if(o?!U(t,e.values[s],n):!n(t,e.values[s]))return e.values[s]=t,1}return 0},reconfigure:(e,t)=>{let a=i(e),l=t.config.address[r];if(null!=l){let i=re(t,l);if(this.dependencies.every(i=>i instanceof W?t.facet(i)===e.facet(i):!(i instanceof Q)||t.field(i,!1)==e.field(i,!1))||(o?U(a,i,n):n(a,i)))return e.values[s]=i,0}return e.values[s]=a,1}}}}function U(e,t,i){if(e.length!=t.length)return!1;for(let n=0;ne[t.id]),r=i.map(e=>e.type),s=n.filter(e=>!(1&e)),o=e[t.id]>>1;function a(e){let i=[];for(let t=0;te===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(G).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,i)=>{let n=e.values[t],r=this.updateF(n,i);return this.compareF(n,r)?0:(e.values[t]=r,1)},reconfigure:(e,i)=>null!=i.config.address[this.id]?(e.values[t]=i.field(this),0):(e.values[t]=this.create(e),1)}}init(e){return[this,G.of({field:this,create:e})]}get extension(){return this}}function Y(e){return t=>new Z(t,e)}const X={highest:/*@__PURE__*/Y(0),high:/*@__PURE__*/Y(1),default:/*@__PURE__*/Y(2),low:/*@__PURE__*/Y(3),lowest:/*@__PURE__*/Y(4)};class Z{constructor(e,t){this.inner=e,this.prec=t}}class ee{of(e){return new te(this,e)}reconfigure(e){return ee.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class te{constructor(e,t){this.compartment=e,this.inner=t}}class ie{constructor(e,t,i,n,r,s){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=s,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let n=[],r=Object.create(null),s=new Map;for(let i of function(e,t,i){let n=[[],[],[],[],[]],r=new Map;return function e(s,o){let a=r.get(s);if(null!=a){if(a<=o)return;let e=n[a].indexOf(s);e>-1&&n[a].splice(e,1),s instanceof te&&i.delete(s.compartment)}if(r.set(s,o),Array.isArray(s))for(let t of s)e(t,o);else if(s instanceof te){if(i.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=t.get(s.compartment)||s.inner;i.set(s.compartment,n),e(n,o)}else if(s instanceof Z)e(s.inner,s.prec);else if(s instanceof Q)n[o].push(s),s.provides&&e(s.provides,o);else if(s instanceof $)n[o].push(s),s.facet.extensions&&e(s.facet.extensions,o);else{let t=s.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);e(t,o)}}(e,2),n.reduce((e,t)=>e.concat(t))}(e,t,s))i instanceof Q?n.push(i):(r[i.facet.id]||(r[i.facet.id]=[])).push(i);let o=Object.create(null),a=[],l=[];for(let e of n)o[e.id]=l.length<<1,l.push(t=>e.slot(t));let h=null==i?void 0:i.config.facets;for(let e in r){let t=r[e],n=t[0].facet,s=h&&h[e]||[];if(t.every(e=>0==e.type))if(o[n.id]=a.length<<1|1,q(s,t))a.push(i.facet(n));else{let e=n.combine(t.map(e=>e.value));a.push(i&&n.compare(e,i.facet(n))?i.facet(n):e)}else{for(let e of t)0==e.type?(o[e.id]=a.length<<1|1,a.push(e.value)):(o[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));o[n.id]=l.length<<1,l.push(e=>K(e,n,t))}}let c=l.map(e=>e(o));return new ie(e,s,c,o,a,r)}}function ne(e,t){if(1&t)return 2;let i=t>>1,n=e.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;e.status[i]=4;let r=e.computeSlot(e,e.config.dynamicSlots[i]);return e.status[i]=2|r}function re(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const se=/*@__PURE__*/W.define(),oe=/*@__PURE__*/W.define({combine:e=>e.some(e=>e),static:!0}),ae=/*@__PURE__*/W.define({combine:e=>e.length?e[0]:void 0,static:!0}),le=/*@__PURE__*/W.define(),he=/*@__PURE__*/W.define(),ce=/*@__PURE__*/W.define(),ue=/*@__PURE__*/W.define({combine:e=>!!e.length&&e[0]});class de{constructor(e,t){this.type=e,this.value=t}static define(){return new fe}}class fe{of(e){return new de(this,e)}}class pe{constructor(e){this.map=e}of(e){return new me(this,e)}}class me{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new me(this.type,t)}is(e){return this.type==e}static define(e={}){return new pe(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let e=n.map(t);e&&i.push(e)}return i}}me.reconfigure=/*@__PURE__*/me.define(),me.appendConfig=/*@__PURE__*/me.define();class ge{constructor(e,t,i,n,r,s){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,i&&F(i,t.newLength),r.some(e=>e.type==ge.time)||(this.annotations=r.concat(ge.time.of(Date.now())))}static create(e,t,i,n,r,s){return new ge(e,t,i,n,r,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(ge.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function ve(e,t){let i=[];for(let n=0,r=0;;){let s,o;if(n=e[n]))s=e[n++],o=e[n++];else{if(!(r=0;r--){let s=i[r](e);s&&Object.keys(s).length&&(n=ye(e,we(t,s,e.changes.newLength),!0))}return n==e?e:ge.create(t,e.changes,e.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(e){let t=e.startState,i=!0;for(let n of t.facet(le)){let t=n(e);if(!1===t){i=!1;break}Array.isArray(t)&&(i=!0===i?t:ve(i,t))}if(!0!==i){let n,r;if(!1===i)r=e.changes.invertedDesc,n=P.empty(t.doc.length);else{let t=e.changes.filter(i);n=t.changes,r=t.filtered.mapDesc(t.changes).invertedDesc}e=ge.create(t,n,e.selection&&e.selection.map(r),me.mapEffects(e.effects,r),e.annotations,e.scrollIntoView)}let n=t.facet(he);for(let i=n.length-1;i>=0;i--){let r=n[i](e);e=r instanceof ge?r:Array.isArray(r)&&1==r.length&&r[0]instanceof ge?r[0]:be(t,xe(r),!1)}return e}(r):r)}ge.time=/*@__PURE__*/de.define(),ge.userEvent=/*@__PURE__*/de.define(),ge.addToHistory=/*@__PURE__*/de.define(),ge.remote=/*@__PURE__*/de.define();const ke=[];function xe(e){return null==e?ke:Array.isArray(e)?e:[e]}var Se=/*@__PURE__*/function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(Se||(Se={}));const Oe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Ce;try{Ce=/*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class Ae{constructor(e,t,i,n,r,s){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,s&&(s._state=this);for(let e=0;er.set(t,e)),i=null),r.set(t.value.compartment,t.value.extension)):t.is(me.reconfigure)?(i=null,n=t.value):t.is(me.appendConfig)&&(i=null,n=xe(n).concat(t.value));i?t=e.startState.values.slice():(i=ie.resolve(n,r,this),t=new Ae(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values),new Ae(i,e.newDoc,e.newSelection,t,(t,i)=>i.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:H.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],s=xe(i.effects);for(let i=1;ir.spec.fromJSON(s,e)))}return Ae.create({doc:e.doc,selection:H.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=ie.resolve(e.extensions||[],new Map),i=e.doc instanceof c?e.doc:c.of((e.doc||"").split(t.staticFacet(Ae.lineSeparator)||T)),n=e.selection?e.selection instanceof H?e.selection:H.single(e.selection.anchor,e.selection.head):H.single(0);return F(n,i.length),t.staticFacet(oe)||(n=n.asSingle()),new Ae(t,i,n,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(Ae.tabSize)}get lineBreak(){return this.facet(Ae.lineSeparator)||"\n"}get readOnly(){return this.facet(ue)}phrase(e,...t){for(let t of this.facet(Ae.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>t.length?e:t[n-1]})),e}languageDataAt(e,t,i=-1){let n=[];for(let r of this.facet(se))for(let s of r(this,t,i))Object.prototype.hasOwnProperty.call(s,e)&&n.push(s[e]);return n}charCategorizer(e){return t=this.languageDataAt("wordChars",e).join(""),e=>{if(!/\S/.test(e))return Se.Space;if(function(e){if(Ce)return Ce.test(e);for(let t=0;t"€"&&(i.toUpperCase()!=i.toLowerCase()||Oe.test(i)))return!0}return!1}(e))return Se.Word;for(let i=0;i-1)return Se.Word;return Se.Other};var t}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),r=this.charCategorizer(e),s=e-i,o=e-i;for(;s>0;){let e=x(t,s,!1);if(r(t.slice(e,s))!=Se.Word)break;s=e}for(;oe.length?e[0]:4}),Ae.lineSeparator=ae,Ae.readOnly=ue,Ae.phrases=/*@__PURE__*/W.define({compare(e,t){let i=Object.keys(e),n=Object.keys(t);return i.length==n.length&&i.every(i=>e[i]==t[i])}}),Ae.languageData=se,Ae.changeFilter=le,Ae.transactionFilter=he,Ae.transactionExtender=ce,ee.reconfigure=/*@__PURE__*/me.define();class Me{eq(e){return this==e}range(e,t=e){return Te.create(e,t,this)}}Me.prototype.startSide=Me.prototype.endSide=0,Me.prototype.point=!1,Me.prototype.mapMode=N.TrackDel;class Te{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Te(e,t,i)}}function Ne(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class De{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,n=0){let r=i?this.to:this.from;for(let s=n,o=r.length;;){if(s==o)return s;let n=s+o>>1,a=r[n]-e||(i?this.value[n].endSide:this.value[n].startSide)-t;if(n==s)return a>=0?s:o;a>=0?o=n:s=n+1}}between(e,t,i,n){for(let r=this.findIndex(t,-1e9,!0),s=this.findIndex(i,1e9,!1,r);rh||l==h&&c.startSide>0&&c.endSide<=0)continue;(h-l||c.endSide-c.startSide)<0||(s<0&&(s=l),c.point&&(o=Math.max(o,h-l)),i.push(c),n.push(l-s),r.push(h-s))}return{mapped:i.length?new De(n,r,i,o):null,pos:s}}}class Pe{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new Pe(e,t,i,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=e,s=e.filter;if(0==t.length&&!s)return this;if(i&&(t=t.slice().sort(Ne)),this.isEmpty)return t.length?Pe.of(t):this;let o=new Be(this,null,-1).goto(0),a=0,l=[],h=new Re;for(;o.value||a=0){let e=t[a++];h.addInner(e.from,e.to,e.value)||l.push(e)}else 1==o.rangeIndex&&o.chunkIndexthis.chunkEnd(o.chunkIndex)||ro.to||r=r&&e<=r+s.length&&!1===s.between(r,e-r,t-r,i))return}this.nextLayer.between(e,t,i)}}iter(e=0){return Ie.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ie.from(e).goto(t)}static compare(e,t,i,n,r=-1){let s=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),a=je(s,o,i),l=new Ve(s,a,r),h=new Ve(o,a,r);i.iterGaps((e,t,i)=>_e(l,e,h,t,i,n)),i.empty&&0==i.length&&_e(l,0,h,0,0,n)}static eq(e,t,i=0,n){null==n&&(n=1e9);let r=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),s=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(r.length!=s.length)return!1;if(!r.length)return!0;let o=je(r,s),a=new Ve(r,o,0).goto(i),l=new Ve(s,o,0).goto(i);for(;;){if(a.to!=l.to||!He(a.active,l.active)||a.point&&(!l.point||!a.point.eq(l.point)))return!1;if(a.to>n)return!0;a.next(),l.next()}}static spans(e,t,i,n,r=-1){let s=new Ve(e,null,r).goto(t),o=t,a=s.openStart;for(;;){let e=Math.min(s.to,i);if(s.point?(n.point(o,e,s.point,s.activeForPoint(s.to),a,s.pointRank),a=s.openEnd(e)+(s.to>e?1:0)):e>o&&(n.span(o,e,s.active,a),a=s.openEnd(e)),s.to>i)break;o=s.to,s.next()}return a}static of(e,t=!1){let i=new Re;for(let n of e instanceof Te?[e]:t?function(e){if(e.length>1)for(let t=e[0],i=1;i0)return e.slice().sort(Ne);t=n}return e}(e):e)i.add(n.from,n.to,n.value);return i.finish()}}Pe.empty=/*@__PURE__*/new Pe([],[],null,-1),Pe.empty.nextLayer=Pe.empty;class Re{constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}finishChunk(e){this.chunks.push(new De(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Re)).add(e,t,i)}addInner(e,t,i){let n=e-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0||(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),0))}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(Pe.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=Pe.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function je(e,t,i){let n=new Map;for(let t of e)for(let e=0;e=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&n.push(new Be(s,t,i,r));return 1==n.length?n[0]:new Ie(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Le(this.heap,e);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Le(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Le(this.heap,0)}}}function Le(e,t){for(let i=e[t];;){let n=1+(t<<1);if(n>=e.length)break;let r=e[n];if(n+1=0&&(r=e[n+1],n++),i.compare(r)<0)break;e[n]=i,e[t]=r,t=n}}class Ve{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ie.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Fe(this.active,e),Fe(this.activeTo,e),Fe(this.activeRank,e),this.minActive=We(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:r}=this.cursor;for(;t-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Fe(i,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let r=this.cursor.value;if(r.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function _e(e,t,i,n,r,s){e.goto(t),i.goto(n);let o=n+r,a=n,l=n-t;for(;;){let t=e.to+l-i.to||e.endSide-i.endSide,n=t<0?e.to+l:i.to,r=Math.min(n,o);if(e.point||i.point?e.point&&i.point&&(e.point==i.point||e.point.eq(i.point))&&He(e.activeForPoint(e.to+l),i.activeForPoint(i.to))||s.comparePoint(a,r,e.point,i.point):r>a&&!He(e.active,i.active)&&s.compareRange(a,r,e.active,i.active),n>o)break;a=n,t<=0&&e.next(),t>=0&&i.next()}}function He(e,t){if(e.length!=t.length)return!1;for(let i=0;i=t;i--)e[i+1]=e[i];e[t]=i}function We(e,t){let i=-1,n=1e9;for(let r=0;re.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,s);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");r(n(i),o,a,h)}else null!=o&&a.push(i.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+o+";")}(a.length||h)&&s.push((!i||l||o?e:e.map(i)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)r(n(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Je[$e]||1;return Je[$e]=e+1,"ͼ"+e.toString(36)}static mount(e,t){(e[Ue]||new Qe(e)).mount(Array.isArray(t)?t:[t])}}let Ge=null;class Qe{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(Ge)return e.adoptedStyleSheets=[Ge.sheet].concat(e.adoptedStyleSheets),e[Ue]=Ge;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),Ge=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[Ue]=this}mount(e){let t=this.sheet,i=0,n=0;for(let r=0;r-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,s),t)for(let e=0;e",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ze="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),et="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),tt="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),it="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),nt="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),rt=Ze&&(it||+Ze[1]<57)||tt&&it,st=0;st<10;st++)Ye[48+st]=Ye[96+st]=String(st);for(st=1;st<=24;st++)Ye[st+111]="F"+st;for(st=65;st<=90;st++)Ye[st]=String.fromCharCode(st+32),Xe[st]=String.fromCharCode(st);for(var ot in Ye)Xe.hasOwnProperty(ot)||(Xe[ot]=Ye[ot]);function at(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function lt(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function ht(e,t){if(!t.anchorNode)return!1;try{return lt(e,t.anchorNode)}catch(e){return!1}}function ct(e){return 3==e.nodeType?xt(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function ut(e,t,i,n){return!!i&&(ft(e,t,i,n,-1)||ft(e,t,i,n,1))}function dt(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function ft(e,t,i,n,r){for(;;){if(e==i&&t==n)return!0;if(t==(r<0?0:pt(e))){if("DIV"==e.nodeName)return!1;let i=e.parentNode;if(!i||1!=i.nodeType)return!1;t=dt(e)+(r<0?0:1),e=i}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?pt(e):0}}}function pt(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}const mt={left:0,right:0,top:0,bottom:0};function gt(e,t){let i=t?e.left:e.right;return{left:i,right:i,top:e.top,bottom:e.bottom}}function vt(e){return{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}class yt{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){this.set(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}let wt,bt=null;function kt(e){if(e.setActive)return e.setActive();if(bt)return e.focus(bt);let t=[];for(let i=e;i&&(t.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(e.focus(null==bt?{get preventScroll(){return bt={preventScroll:!0},!0}}:void 0),!bt){bt=!1;for(let e=0;et)return i.domBoundsAround(e,t,l);if(c>=e&&-1==n&&(n=a,r=l),l>t&&i.dom.parentNode==this.dom){s=a,o=h;break}h=c,l=c+i.breakAfter}return{from:r,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s=0?this.children[s].dom:null}}markDirty(e=!1){this.dirty|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.dirty|=2),1&t.dirty)return;t.dirty|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.dirty&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=At){this.markDirty();for(let i=e;ithis.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Nt(e,t,i,n,r,s,o,a,l){let{children:h}=e,c=h.length?h[t]:null,u=s.length?s[s.length-1]:null,d=u?u.breakAfter:o;if(!(t==n&&c&&!o&&!d&&s.length<2&&c.merge(i,r,s.length?u:null,0==i,a,l))){if(n0&&(!o&&s.length&&c.merge(i,c.length,s[0],!1,a,0)?c.breakAfter=s.shift().breakAfter:(i2);var Wt={mac:zt||/*@__PURE__*/ /Mac/.test(Pt.platform),windows:/*@__PURE__*/ /Win/.test(Pt.platform),linux:/*@__PURE__*/ /Linux|X11/.test(Pt.platform),ie:Lt,ie_version:Bt?Rt.documentMode||6:It?+It[1]:jt?+jt[1]:0,gecko:Vt,gecko_version:Vt?+/*@__PURE__*/(/Firefox\/(\d+)/.exec(Pt.userAgent)||[0,0])[1]:0,chrome:!!_t,chrome_version:_t?+_t[1]:0,ios:zt,android:/*@__PURE__*/ /Android\b/.test(Pt.userAgent),webkit:Ht,safari:Ft,webkit_version:Ht?+/*@__PURE__*/(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=Rt.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class qt extends Et{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,i){return(!i||i instanceof qt&&!(this.length-(t-e)+i.length>256))&&(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new qt(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Ct(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Ut(this.dom,e,t)}}class $t extends Et{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let e of t)e.setParent(this)}setAttrs(e){if(Ot(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.dirty|=6)}sync(e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e)}merge(e,t,i,n,r,s){return!(i&&(!(i instanceof $t&&i.mark.eq(this.mark))||e&&r<=0||te&&t.push(i=e&&(n=r),i=o,r++}let s=this.length-e;return this.length=e,n>-1&&(this.children.length=n,this.markDirty()),new $t(this.mark,t,s)}domAtPos(e){return Xt(this.dom,this.children,e)}coordsAt(e,t){return ei(this,e,t)}}function Ut(e,t,i){let n=e.nodeValue.length;t>n&&(t=n);let r=t,s=t,o=0;0==t&&i<0||t==n&&i>=0?Wt.chrome||Wt.gecko||(t?(r--,o=1):s=0)?0:a.length-1];return Wt.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(a,e=>e.width)||l),o?gt(l,o<0):l||null}class Jt extends Et{constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}static create(e,t,i){return new(e.customView||Jt)(e,t,i)}split(e){let t=Jt.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,n,r,s){return!(i&&(!(i instanceof Jt&&this.widget.compare(i.widget))||e>0&&r<=0||t0?i.length-1:0;n=i[t],!(e>0?0==t:t==i.length-1||n.top0?-1:1);return 0==e&&t>0||e==this.length&&t<=0?n:gt(n,0==e)}get isEditable(){return!1}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Kt extends Jt{domAtPos(e){let{topView:t,text:i}=this.widget;return t?Gt(e,0,t,i,(e,t)=>e.domAtPos(t),e=>new Ct(i,Math.min(e,i.nodeValue.length))):new Ct(i,Math.min(e,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(e,t){let{topView:i,text:n}=this.widget;return i?Qt(e,t,i,n):Math.min(t,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(e,t){let{topView:i,text:n}=this.widget;return i?Gt(e,t,i,n,(e,t,i)=>e.coordsAt(t,i),(e,t)=>Ut(n,e,t)):Ut(n,e,t)}destroy(){var e;super.destroy(),null===(e=this.widget.topView)||void 0===e||e.destroy()}get isEditable(){return!0}}function Gt(e,t,i,n,r,s){if(i instanceof $t){for(let o of i.children){let i=lt(o.dom,n),a=i?n.nodeValue.length:o.length;if(e=0;)if(t<0?n>0:n0?-1:1);return i&&i.topt.top?{left:t.left,right:t.right,top:i.top,bottom:i.bottom}:t}get overrideDOMText(){return c.empty}}function Xt(e,t,i){let n=0;for(let r=0;nr&&i0;n--){let i=t[n-1].dom;if(i.parentNode==e)return Ct.after(i)}return new Ct(e,0)}function Zt(e,t,i){let n,{children:r}=e;i>0&&t instanceof $t&&r.length&&(n=r[r.length-1])instanceof $t&&n.mark.eq(t.mark)?Zt(n,t.children[0],i-1):(r.push(t),t.setParent(e)),e.length+=t.length}function ei(e,t,i){for(let n=0,r=0;r0?a>=t:a>t)&&(t0)){let e=0;if(a==n){if(o.getSide()<=0)continue;e=i=-o.getSide()}let r=o.coordsAt(Math.max(0,t-n),i);return e&&r?gt(r,i<0):r}n=a}let n=e.dom.lastChild;if(!n)return e.dom.getBoundingClientRect();let r=ct(n);return r[r.length-1]||null}function ti(e,t){for(let i in e)"class"==i&&t.class?t.class+=" "+e.class:"style"==i&&t.style?t.style+=";"+e.style:t[i]=e[i];return t}function ii(e,t){if(e==t)return!0;if(!e||!t)return!1;let i=Object.keys(e),n=Object.keys(t);if(i.length!=n.length)return!1;for(let r of i)if(-1==n.indexOf(r)||e[r]!==t[r])return!1;return!0}function ni(e,t,i){let n=null;if(t)for(let r in t)i&&r in i||e.removeAttribute(n=r);if(i)for(let r in i)t&&t[r]==i[r]||e.setAttribute(n=r,i[r]);return!!n}qt.prototype.children=Jt.prototype.children=Yt.prototype.children=At;class ri{eq(e){return!1}updateDOM(e){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}ignoreEvent(e){return!0}get customView(){return null}destroy(e){}}var si=/*@__PURE__*/function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(si||(si={}));class oi extends Me{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new ai(e)}static widget(e){let t=e.side||0,i=!!e.block;return t+=i?t>0?3e8:-4e8:t>0?1e8:-1e8,new hi(e,t,t,i,e.widget||null,!1)}static replace(e){let t,i,n=!!e.block;if(e.isBlockGap)t=-5e8,i=4e8;else{let{start:r,end:s}=ci(e,n);t=(r?n?-3e8:-1:5e8)-1,i=1+(s?n?2e8:1:-6e8)}return new hi(e,t,i,n,e.widget||null,!0)}static line(e){return new li(e)}static set(e,t=!1){return Pe.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}oi.none=Pe.empty;class ai extends oi{constructor(e){let{start:t,end:i}=ci(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){return this==e||e instanceof ai&&this.tagName==e.tagName&&this.class==e.class&&ii(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ai.prototype.point=!1;class li extends oi{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof li&&ii(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}li.prototype.mapMode=N.TrackBefore,li.prototype.point=!0;class hi extends oi{constructor(e,t,i,n,r,s){super(t,i,r,e),this.block=n,this.isReplace=s,this.mapMode=n?t<=0?N.TrackBefore:N.TrackAfter:N.TrackDel}get type(){return this.startSide=5}eq(e){return e instanceof hi&&((t=this.widget)==(i=e.widget)||!!(t&&i&&t.compare(i)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,i}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function ci(e,t=!1){let{inclusiveStart:i,inclusiveEnd:n}=e;return null==i&&(i=e.inclusive),null==n&&(n=e.inclusive),{start:null!=i?i:t,end:null!=n?n:t}}function ui(e,t,i,n=0){let r=i.length-1;r>=0&&i[r]+n>=e?i[r]=Math.max(i[r],t):i.push(e,t)}hi.prototype.point=!0;class di extends Et{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,n,r,s){if(i){if(!(i instanceof di))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Dt(this,e,t,i?i.children:[],r,s),!0}split(e){let t=new di;if(t.breakAfter=this.breakAfter,0==this.length)return t;let{i:i,off:n}=this.childPos(e);n&&(t.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let e=i;e0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){ii(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Zt(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=ti(t,this.attrs||{})),i&&(this.attrs=ti({class:i},this.attrs||{}))}domAtPos(e){return Xt(this.dom,this.children,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.dirty|=6)}sync(e){var t;this.dom?4&this.dirty&&(Ot(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(ni(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e);let i=this.dom.lastChild;for(;i&&Et.get(i)instanceof $t;)i=i.lastChild;if(!(i&&this.length&&("BR"==i.nodeName||0!=(null===(t=Et.get(i))||void 0===t?void 0:t.isEditable)||Wt.ios&&this.children.some(e=>e instanceof qt)))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e=0;for(let t of this.children){if(!(t instanceof qt))return null;let i=ct(t.dom);if(1!=i.length)return null;e+=i[0].width}return{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length}}coordsAt(e,t){return ei(this,e,t)}become(e){return!1}get type(){return si.Text}static find(e,t){for(let i=0,n=0;i=t){if(r instanceof di)return r;if(s>t)break}n=s+r.breakAfter}return null}}class fi extends Et{constructor(e,t,i){super(),this.widget=e,this.length=t,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,n,r,s){return!(i&&(!(i instanceof fi&&this.widget.compare(i.widget))||e>0&&r<=0||t0;){if(this.textOff==this.text.length){let{value:t,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer([]),this.curLine=null,e--;continue}this.text=t,this.textOff=0}let n=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(0,i)),this.getLine().append(mi(new qt(this.text.slice(this.textOff,this.textOff+n)),t),i),this.atCursorPos=!0,this.textOff+=n,e-=n,i=0}}span(e,t,i,n){this.buildText(t-e,i,n),this.pos=t,this.openStart<0&&(this.openStart=n)}point(e,t,i,n,r,s){if(this.disallowBlockEffectsFor[s]&&i instanceof hi){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=t-e;if(i instanceof hi)if(i.block){let{type:e}=i;e!=si.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new fi(i.widget||new gi("div"),o,e))}else{let s=Jt.create(i.widget||new gi("span"),o,i.startSide),a=this.atCursorPos&&!s.isEditable&&r<=n.length&&(e0),l=!s.isEditable&&(ee.some(e=>e)});class Oi{constructor(e,t="nearest",i="nearest",n=5,r=5){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r}map(e){return e.empty?this:new Oi(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}}const Ci=/*@__PURE__*/me.define({map:(e,t)=>e.map(t)});function Ai(e,t,i){let n=e.facet(bi);n.length?n[0](t):window.onerror?window.onerror(String(t),i,void 0,void 0,t):i?console.error(i+":",t):console.error(t)}const Ei=/*@__PURE__*/W.define({combine:e=>!e.length||e[0]});let Mi=0;const Ti=/*@__PURE__*/W.define();class Ni{constructor(e,t,i,n){this.id=e,this.create=t,this.domEventHandlers=i,this.extension=n(this)}static define(e,t){const{eventHandlers:i,provide:n,decorations:r}=t||{};return new Ni(Mi++,e,i,e=>{let t=[Ti.of(e)];return r&&t.push(ji.of(t=>{let i=t.plugin(e);return i?r(i):oi.none})),n&&t.push(n(e)),t})}static fromClass(e,t){return Ni.define(t=>new e(t),t)}}class Di{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Ai(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Ai(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){Ai(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Pi=/*@__PURE__*/W.define(),Ri=/*@__PURE__*/W.define(),ji=/*@__PURE__*/W.define(),Bi=/*@__PURE__*/W.define(),Ii=/*@__PURE__*/W.define(),Li=/*@__PURE__*/W.define();class Vi{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new Vi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toAh)break;r+=2}if(!a)return i;new Vi(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),s=a.toA,o=a.toB}}}class _i{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=P.empty(this.startState.doc.length);for(let e of i)this.changes=this.changes.compose(e.changes);let n=[];this.changes.iterChangedRanges((e,t,i,r)=>n.push(new Vi(e,t,i,r))),this.changedRanges=n;let r=e.hasFocus;r!=e.inputState.notifiedFocused&&(e.inputState.notifiedFocused=r,this.flags|=1)}static create(e,t,i){return new _i(e,t,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}var Hi=/*@__PURE__*/function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Hi||(Hi={}));const Fi=Hi.LTR,zi=Hi.RTL;function Wi(e){let t=[];for(let i=0;i=t){if(o.level==i)return s;(r<0||(0!=n?n<0?o.fromt:e[r].level>o.level))&&(r=s)}}if(r<0)throw new RangeError("Index out of range");return r}}const Qi=[];function Yi(e){return[new Gi(0,e,0)]}let Xi="";function Zi(e,t,i,n,r){var s;let o=n.head-e.from,a=-1;if(0==o){if(!r||!e.length)return null;t[0].level!=i&&(o=t[0].side(!1,i),a=0)}else if(o==e.length){if(r)return null;let e=t[t.length-1];e.level!=i&&(o=e.side(!0,i),a=t.length-1)}a<0&&(a=Gi.find(t,o,null!==(s=n.bidiLevel)&&void 0!==s?s:-1,n.assoc));let l=t[a];o==l.side(r,i)&&(l=t[a+=r?1:-1],o=l.side(!r,i));let h=r==(l.dir==i),c=x(e.text,o,h);if(Xi=e.text.slice(Math.min(o,c),Math.max(o,c)),c!=l.side(r,i))return H.cursor(c+e.from,h?-1:1,l.level);let u=a==(r?t.length-1:0)?null:t[a+(r?1:-1)];return u||l.level==i?u&&u.level1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=o-1);i=s+o}}readNode(e){if(e.cmIgnore)return;let t=Et.get(e),i=t&&t.overrideDOMText;if(null!=i){this.findPointInside(e,i.length);for(let e=i.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(3==e.nodeType?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+Math.min(t,i.offset))}}function nn(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}class rn{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class sn extends Et{constructor(e){super(),this.view=e,this.compositionDeco=oi.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new di],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Vi(0,0,0,e.state.doc.length)],0)}get root(){return this.view.root}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>tthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=oi.none:(e.transactions.length||this.dirty)&&(this.compositionDeco=function(e,t){let i=an(e);if(!i)return oi.none;let{from:n,to:r,node:s,text:o}=i,a=t.mapPos(n,1),l=Math.max(a,t.mapPos(r,-1)),{state:h}=e,c=3==s.nodeType?s.nodeValue:new tn([],h).readRange(s.firstChild,null).text;if(l-a{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let e=Wt.chrome||Wt.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(e),this.dirty=0,e&&(e.written||i.selectionRange.focusNode!=e.node)&&(this.forceSelection=!0),this.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to=0?e[t]:null;if(!n)break;let{fromA:r,toA:s,fromB:o,toB:a}=n,{content:l,breakAtStart:h,openStart:c,openEnd:u}=pi.build(this.view.state.doc,o,a,this.decorations,this.dynamicDecorationMap),{i:d,off:f}=i.findPos(s,1),{i:p,off:m}=i.findPos(r,-1);Nt(this,p,m,d,f,l,h,c,u)}}updateSelection(e=!1,t=!1){if(!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange(),!t&&!this.mayControlSelection()||Wt.ios&&this.view.inputState.rapidCompositionStart)return;let i=this.forceSelection;this.forceSelection=!1;let n=this.view.state.selection.main,r=this.domAtPos(n.anchor),s=n.empty?r:this.domAtPos(n.head);if(Wt.gecko&&n.empty&&1==(o=r).node.nodeType&&o.node.firstChild&&(0==o.offset||"false"==o.node.childNodes[o.offset-1].contentEditable)&&(o.offset==o.node.childNodes.length||"false"==o.node.childNodes[o.offset].contentEditable)){let e=document.createTextNode("");this.view.observer.ignore(()=>r.node.insertBefore(e,r.node.childNodes[r.offset]||null)),r=s=new Ct(e,0),i=!0}var o;let a=this.view.observer.selectionRange;!i&&a.focusNode&&ut(r.node,r.offset,a.anchorNode,a.anchorOffset)&&ut(s.node,s.offset,a.focusNode,a.focusOffset)||(this.view.observer.ignore(()=>{Wt.android&&Wt.chrome&&this.dom.contains(a.focusNode)&&function(e,t){for(let i=e;i&&i!=t;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(a.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let e=at(this.root);if(e)if(n.empty){if(Wt.gecko){let e=(i=r.offset,1!=(t=r.node).nodeType?0:(i&&"false"==t.childNodes[i-1].contentEditable?1:0)|(in.head&&([r,s]=[s,r]),t.setEnd(s.node,s.offset),t.setStart(r.node,r.offset),e.removeAllRanges(),e.addRange(t)}var t,i}),this.view.observer.setSelectionRange(r,s)),this.impreciseAnchor=r.precise?null:new Ct(a.anchorNode,a.anchorOffset),this.impreciseHead=s.precise?null:new Ct(a.focusNode,a.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let e=this.view.state.selection.main,t=at(this.root);if(!(t&&e.empty&&e.assoc&&t.modify))return;let i=di.find(this,e.head);if(!i)return;let n=i.posAtStart;if(e.head==n||e.head==n+i.length)return;let r=this.coordsAt(e.head,-1),s=this.coordsAt(e.head,1);if(!r||!s||r.bottom>s.top)return;let o=this.domAtPos(e.head+e.assoc);t.collapse(o.node,o.offset),t.modify("move",e.assoc<0?"forward":"backward","lineboundary")}mayControlSelection(){let e=this.root.activeElement;return e==this.dom||ht(this.dom,this.view.observer.selectionRange)&&!(e&&this.dom.contains(e))}nearest(e){for(let t=e;t;){let e=Et.get(t);if(e&&e.rootView==this)return e;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;ts||e==s&&r.type!=si.WidgetBefore&&r.type!=si.WidgetAfter&&(!n||2==t||this.children[n-1].breakAfter||this.children[n-1].type==si.WidgetBefore&&t>-2))return r.coordsAt(e-s,t);i=s}}measureVisibleLineHeights(e){let t=[],{from:i,to:n}=e,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,a=this.view.textDirection==Hi.LTR;for(let e=0,l=0;ln)break;if(e>=i){let i=h.dom.getBoundingClientRect();if(t.push(i.height),s){let t=h.dom.lastChild,n=t?ct(t):[];if(n.length){let t=n[n.length-1],s=a?t.right-i.left:i.right-t.left;s>o&&(o=s,this.minWidth=r,this.minWidthFrom=e,this.minWidthTo=c)}}}e=c+h.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return"rtl"==getComputedStyle(this.children[t].dom).direction?Hi.RTL:Hi.LTR}measureTextSize(){for(let e of this.children)if(e instanceof di){let t=e.measureTextSize();if(t)return t}let e,t,i=document.createElement("div");return i.className="cm-line",i.style.width="99999px",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(i);let n=ct(i.firstChild)[0];e=i.getBoundingClientRect().height,t=n?n.width/27:7,i.remove()}),{lineHeight:e,charWidth:t}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Tt(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],s=r?r.from-1:this.length;if(s>i){let n=t.lineBlockAt(s).bottom-t.lineBlockAt(i).top;e.push(oi.replace({widget:new on(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!r)break;i=r.to+1}return oi.set(e)}updateDeco(){let e=this.view.state.facet(ji).map((e,t)=>(this.dynamicDecorationMap[t]="function"==typeof e)?e(this.view):e);for(let t=e.length;ti.anchor?-1:1);if(!n)return;!i.empty&&(t=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,t.left),top:Math.min(n.top,t.top),right:Math.max(n.right,t.right),bottom:Math.max(n.bottom,t.bottom)});let r=0,s=0,o=0,a=0;for(let e of this.view.state.facet(Ii).map(e=>e(this.view)))if(e){let{left:t,right:i,top:n,bottom:l}=e;null!=t&&(r=Math.max(r,t)),null!=i&&(s=Math.max(s,i)),null!=n&&(o=Math.max(o,n)),null!=l&&(a=Math.max(a,l))}!function(e,t,i,n,r,s,o,a){let l=e.ownerDocument,h=l.defaultView;for(let c=e;c;)if(1==c.nodeType){let e,u=c==l.body;if(u)e=vt(h);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.parentNode;continue}let t=c.getBoundingClientRect();e={left:t.left,right:t.left+c.clientWidth,top:t.top,bottom:t.top+c.clientHeight}}let d=0,f=0;if("nearest"==r)t.top0&&t.bottom>e.bottom+f&&(f=t.bottom-e.bottom+f+o)):t.bottom>e.bottom&&(f=t.bottom-e.bottom+o,i<0&&t.top-f0&&t.right>e.right+d&&(d=t.right-e.right+d+s)):t.right>e.right&&(d=t.right-e.right+s,i<0&&t.left0&&i<=0)t=pt(e=e.childNodes[t-1]);else{if(!(1==e.nodeType&&t=0))return null;e=e.childNodes[t],t=0}}}class cn{constructor(){this.changes=[]}compareRange(e,t){ui(e,t,this.changes)}comparePoint(e,t){ui(e,t,this.changes)}}function un(e,t){return t.left>e?t.left-e:Math.max(0,e-t.right)}function dn(e,t){return t.top>e?t.top-e:Math.max(0,e-t.bottom)}function fn(e,t){return e.topt.top+1}function pn(e,t){return te.bottom?{top:e.top,left:e.left,right:e.right,bottom:t}:e}function gn(e,t,i){let n,r,s,o,a,l,h,c;for(let u=e.firstChild;u;u=u.nextSibling){let e=ct(u);for(let d=0;dm||o==m&&s>p)&&(n=u,r=f,s=p,o=m),0==p?i>f.bottom&&(!h||h.bottomf.top)&&(l=u,c=f):h&&fn(h,f)?h=mn(h,f.bottom):c&&fn(c,f)&&(c=pn(c,f.top))}}if(h&&h.bottom>=i?(n=a,r=h):c&&c.top<=i&&(n=l,r=c),!n)return{node:e,offset:0};let u=Math.max(r.left,Math.min(r.right,t));return 3==n.nodeType?vn(n,u,i):s||"true"!=n.contentEditable?{node:e,offset:Array.prototype.indexOf.call(e.childNodes,n)+(t>=(r.left+r.right)/2?1:0)}:gn(n,u,i)}function vn(e,t,i){let n=e.nodeValue.length,r=-1,s=1e9,o=0;for(let a=0;ai?h.top-i:i-h.bottom)-1;if(h.left-1<=t&&h.right+1>=t&&c=(h.left+h.right)/2,n=i;if((Wt.chrome||Wt.gecko)&&xt(e,a).getBoundingClientRect().left==h.right&&(n=!i),c<=0)return{node:e,offset:a+(n?1:0)};r=a+(n?1:0),s=c}}}return{node:e,offset:r>-1?r:o>0?e.nodeValue.length:0}}function yn(e,{x:t,y:i},n,r=-1){var s;let o,a=e.contentDOM.getBoundingClientRect(),l=a.top+e.viewState.paddingTop,{docHeight:h}=e.viewState,c=i-l;if(c<0)return 0;if(c>h)return e.state.doc.length;for(let t=e.defaultLineHeight/2,i=!1;o=e.elementAtHeight(c),o.type!=si.Text;)for(;c=r>0?o.bottom+t:o.top-t,!(c>=0&&c<=h);){if(i)return n?null:0;i=!0,r=-r}i=l+c;let u=o.from;if(ue.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:n?null:wn(e,a,o,t,i);let d=e.dom.ownerDocument,f=e.root.elementFromPoint?e.root:d,p=f.elementFromPoint(t,i);p&&!e.contentDOM.contains(p)&&(p=null),p||(t=Math.max(a.left+1,Math.min(a.right-1,t)),p=f.elementFromPoint(t,i),p&&!e.contentDOM.contains(p)&&(p=null));let m,g=-1;if(p&&0!=(null===(s=e.docView.nearest(p))||void 0===s?void 0:s.isEditable))if(d.caretPositionFromPoint){let e=d.caretPositionFromPoint(t,i);e&&({offsetNode:m,offset:g}=e)}else if(d.caretRangeFromPoint){let e=d.caretRangeFromPoint(t,i);e&&(({startContainer:m,startOffset:g}=e),(Wt.safari&&function(e,t,i){let n;if(3!=e.nodeType||t!=(n=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=t.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return xt(e,n-1,n).getBoundingClientRect().left>i}(m,g,t)||Wt.chrome&&function(e,t,i){if(0!=t)return!1;for(let t=e;;){let e=t.parentNode;if(!e||1!=e.nodeType||e.firstChild!=t)return!1;if(e.classList.contains("cm-line"))break;t=e}return i-(1==e.nodeType?e.getBoundingClientRect():xt(e,0,Math.max(e.nodeValue.length,1)).getBoundingClientRect()).left>5}(m,g,t))&&(m=void 0))}if(!m||!e.docView.dom.contains(m)){let n=di.find(e.docView,u);if(!n)return c>o.top+o.height/2?o.to:o.from;({node:m,offset:g}=gn(n.dom,t,i))}return e.docView.posFromDOM(m,g)}function wn(e,t,i,n,r){let s=Math.round((n-t.left)*e.defaultCharacterWidth);e.lineWrapping&&i.height>1.5*e.defaultLineHeight&&(s+=Math.floor((r-i.top)/e.defaultLineHeight)*e.viewState.heightOracle.lineLength);let o=e.state.sliceDoc(i.from,i.to);return i.from+function(e,t,i,n){for(let n=0,r=0;;){if(r>=t)return n;if(n==e.length)break;r+=9==e.charCodeAt(n)?i-r%i:1,n=x(e,n)}return e.length}(o,s,e.state.tabSize)}function bn(e,t,i,n){let r=e.state.doc.lineAt(t.head),s=e.bidiSpans(r),o=e.textDirectionAt(r.from);for(let a=t,l=null;;){let t=Zi(r,s,o,a,i),h=Xi;if(!t){if(r.number==(i?e.state.doc.lines:1))return a;h="\n",r=e.state.doc.line(r.number+(i?1:-1)),s=e.bidiSpans(r),t=H.cursor(i?r.from:r.to)}if(l){if(!l(h))return a}else{if(!n)return t;l=n(h)}a=t}}function kn(e,t,i){let n=e.state.facet(Bi).map(t=>t(e));for(;;){let e=!1;for(let r of n)r.between(i.from-1,i.from+1,(n,r,s)=>{i.from>n&&i.fromi.from?H.cursor(n,1):H.cursor(r,-1),e=!0)});if(!e)return i}}class xn{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.rapidCompositionStart=!1,this.mouseSelection=null;for(let t in En){let i=En[t];e.contentDOM.addEventListener(t,n=>{An(e,n)&&!this.ignoreDuringComposition(n)&&("keydown"==t&&this.keydown(e,n)||(this.mustFlushObserver(n)&&e.observer.forceFlush(),this.runCustomHandlers(t,e,n)?n.preventDefault():i(e,n)))}),this.registeredEvents.push(t)}Wt.chrome&&Wt.chrome_version>=102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,Wt.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var i;let n;this.customHandlers=[];for(let r of t)if(n=null===(i=r.update(e).spec)||void 0===i?void 0:i.domEventHandlers){this.customHandlers.push({plugin:r.value,handlers:n});for(let t in n)this.registeredEvents.indexOf(t)<0&&"scroll"!=t&&(this.registeredEvents.push(t),e.contentDOM.addEventListener(t,i=>{An(e,i)&&this.runCustomHandlers(t,e,i)&&i.preventDefault()}))}}runCustomHandlers(e,t,i){for(let n of this.customHandlers){let r=n.handlers[e];if(r)try{if(r.call(n.plugin,i,t)||i.defaultPrevented)return!0}catch(e){Ai(t.state,e)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let i of this.customHandlers){let n=i.handlers.scroll;if(n)try{n.call(i.plugin,t,e)}catch(t){Ai(e.state,t)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&Date.now()e.keyCode==t.keyCode))||t.ctrlKey||t.altKey||t.metaKey||t.synthetic||(this.pendingIOSKey=i,setTimeout(()=>this.flushIOSKey(e),250),0))}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(this.pendingIOSKey=void 0,St(e.contentDOM,t.key,t.keyCode))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&(this.composing>0||!!(Wt.safari&&Date.now()-this.compositionEndedAt<100)&&(this.compositionEndedAt=0,!0))}mustFlushObserver(e){return"keydown"==e.type&&229!=e.keyCode||"compositionend"==e.type&&!Wt.ios}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const Sn=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],On=[16,17,18,20,91,92,224,225];class Cn{constructor(e,t,i,n){this.view=e,this.style=i,this.mustSelect=n,this.lastEvent=t;let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Ae.allowMultipleSelections)&&function(e,t){let i=e.state.facet(vi);return i.length?i[0](t):Wt.mac?t.metaKey:t.ctrlKey}(e,t),this.dragMove=function(e,t){let i=e.state.facet(yi);return i.length?i[0](t):Wt.mac?!t.altKey:!t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:i}=e.state.selection;if(i.empty)return!1;let n=at(e.root);if(!n||0==n.rangeCount)return!0;let r=n.getRangeAt(0).getClientRects();for(let e=0;e=t.clientX&&i.top<=t.clientY&&i.bottom>=t.clientY)return!0}return!1}(e,t)||1!=_n(t))&&null,!1===this.dragging&&(t.preventDefault(),this.select(t))}move(e){if(0==e.buttons)return this.destroy();!1===this.dragging&&this.select(this.lastEvent=e)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}select(e){let t=this.style.get(e,this.extend,this.multiple);!this.mustSelect&&t.eq(this.view.state.selection)&&t.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:t,userEvent:"select.pointer",scrollIntoView:!0}),this.mustSelect=!1}update(e){e.docChanged&&this.dragging&&(this.dragging=this.dragging.map(e.changes)),this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function An(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let i,n=t.target;n!=e.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=Et.get(n))&&i.ignoreEvent(t))return!1;return!0}const En=/*@__PURE__*/Object.create(null),Mn=Wt.ie&&Wt.ie_version<15||Wt.ios&&Wt.webkit_version<604;function Tn(e,t){let i,{state:n}=e,r=1,s=n.toText(t),o=s.lines==n.selection.ranges.length;if(null!=Fn&&n.selection.ranges.every(e=>e.empty)&&Fn==s.toString()){let e=-1;i=n.changeByRange(i=>{let a=n.doc.lineAt(i.from);if(a.from==e)return{range:i};e=a.from;let l=n.toText((o?s.line(r++).text:t)+n.lineBreak);return{changes:{from:a.from,insert:l},range:H.cursor(i.from+l.length)}})}else i=o?n.changeByRange(e=>{let t=s.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:H.cursor(e.from+t.length)}}):n.replaceSelection(s);e.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Nn(e,t,i,n){if(1==n)return H.cursor(t,i);if(2==n)return function(e,t,i=1){let n=e.charCategorizer(t),r=e.doc.lineAt(t),s=t-r.from;if(0==r.length)return H.cursor(t);0==s?i=1:s==r.length&&(i=-1);let o=s,a=s;i<0?o=x(r.text,s,!1):a=x(r.text,s);let l=n(r.text.slice(o,a));for(;o>0;){let e=x(r.text,o,!1);if(n(r.text.slice(e,o))!=l)break;o=e}for(;a{e.inputState.setSelectionOrigin("select"),27==t.keyCode?e.inputState.lastEscPress=Date.now():On.indexOf(t.keyCode)<0&&(e.inputState.lastEscPress=0)},En.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},En.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},En.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3&&1==_n(t))return;let i=null;for(let n of e.state.facet(wi))if(i=n(e,t),i)break;if(i||0!=t.button||(i=function(e,t){let i=jn(e,t),n=_n(t),r=e.state.selection,s=i,o=t;return{update(e){e.docChanged&&(i&&(i.pos=e.changes.mapPos(i.pos)),r=r.map(e.changes),o=null)},get(t,a,l){let h;if(o&&t.clientX==o.clientX&&t.clientY==o.clientY?h=s:(h=s=jn(e,t),o=t),!h||!i)return r;let c=Nn(e,h.pos,h.bias,n);if(i.pos!=h.pos&&!a){let t=Nn(e,i.pos,i.bias,n),r=Math.min(t.from,c.from),s=Math.max(t.to,c.to);c=r1&&r.ranges.some(e=>e.eq(c))?function(e,t){for(let i=0;;i++)if(e.ranges[i].eq(t))return H.create(e.ranges.slice(0,i).concat(e.ranges.slice(i+1)),e.mainIndex==i?0:e.mainIndex-(e.mainIndex>i?1:0))}(r,c):l?r.addRange(c):H.create([c])}}}(e,t)),i){let n=e.root.activeElement!=e.contentDOM;n&&e.observer.ignore(()=>kt(e.contentDOM)),e.inputState.startMouseSelection(new Cn(e,t,i,n))}};let Dn=(e,t)=>e>=t.top&&e<=t.bottom,Pn=(e,t,i)=>Dn(t,i)&&e>=i.left&&e<=i.right;function Rn(e,t,i,n){let r=di.find(e.docView,t);if(!r)return 1;let s=t-r.posAtStart;if(0==s)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&Pn(i,n,o))return-1;let a=r.coordsAt(s,1);return a&&Pn(i,n,a)?1:o&&Dn(n,o)?-1:1}function jn(e,t){let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:i,bias:Rn(e,i,t.clientX,t.clientY)}}const Bn=Wt.ie&&Wt.ie_version<=11;let In=null,Ln=0,Vn=0;function _n(e){if(!Bn)return e.detail;let t=In,i=Vn;return In=e,Vn=Date.now(),Ln=!t||i>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Ln+1)%3:1}function Hn(e,t,i,n){if(!i)return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1);t.preventDefault();let{mouseSelection:s}=e.inputState,o=n&&s&&s.dragging&&s.dragMove?{from:s.dragging.from,to:s.dragging.to}:null,a={from:r,insert:i},l=e.state.changes(o?[o,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"})}En.dragstart=(e,t)=>{let{selection:{main:i}}=e.state,{mouseSelection:n}=e.inputState;n&&(n.dragging=i),t.dataTransfer&&(t.dataTransfer.setData("Text",e.state.sliceDoc(i.from,i.to)),t.dataTransfer.effectAllowed="copyMove")},En.drop=(e,t)=>{if(!t.dataTransfer)return;if(e.state.readOnly)return t.preventDefault();let i=t.dataTransfer.files;if(i&&i.length){t.preventDefault();let n=Array(i.length),r=0,s=()=>{++r==i.length&&Hn(e,t,n.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(n[e]=t.result),s()},t.readAsText(i[e])}}else Hn(e,t,t.dataTransfer.getData("Text"),!0)},En.paste=(e,t)=>{if(e.state.readOnly)return t.preventDefault();e.observer.flush();let i=Mn?null:t.clipboardData;i?(Tn(e,i.getData("text/plain")),t.preventDefault()):function(e){let t=e.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{e.focus(),i.remove(),Tn(e,i.value)},50)}(e)};let Fn=null;function zn(e){setTimeout(()=>{e.hasFocus!=e.inputState.notifiedFocused&&e.update([])},10)}function Wn(e,t){if(e.docView.compositionDeco.size){e.inputState.rapidCompositionStart=t;try{e.update([])}finally{e.inputState.rapidCompositionStart=!1}}}En.copy=En.cut=(e,t)=>{let{text:i,ranges:n,linewise:r}=function(e){let t=[],i=[],n=!1;for(let n of e.selection.ranges)n.empty||(t.push(e.sliceDoc(n.from,n.to)),i.push(n));if(!t.length){let r=-1;for(let{from:n}of e.selection.ranges){let s=e.doc.lineAt(n);s.number>r&&(t.push(s.text),i.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),r=s.number}n=!0}return{text:t.join(e.lineBreak),ranges:i,linewise:n}}(e.state);if(!i&&!r)return;Fn=r?i:null;let s=Mn?null:t.clipboardData;s?(t.preventDefault(),s.clearData(),s.setData("text/plain",i)):function(e,t){let i=e.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=t,n.focus(),n.selectionEnd=t.length,n.selectionStart=0,setTimeout(()=>{n.remove(),e.focus()},50)}(e,i),"cut"!=t.type||e.state.readOnly||e.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})},En.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),zn(e)},En.blur=e=>{e.observer.clearSelectionRange(),zn(e)},En.compositionstart=En.compositionupdate=e=>{null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0,e.docView.compositionDeco.size&&(e.observer.flush(),Wn(e,!0)))},En.compositionend=e=>{e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionFirstChange=null,setTimeout(()=>{e.inputState.composing<0&&Wn(e,!1)},50)},En.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},En.beforeinput=(e,t)=>{var i;let n;if(Wt.chrome&&Wt.android&&(n=Sn.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let t=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}};const qn=["pre-wrap","normal","pre-line","break-spaces"];class $n{constructor(){this.doc=c.empty,this.lineWrapping=!1,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength)),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return qn.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,o=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=i,this.lineLength=n,o){this.heightSamples={};for(let e=0;e0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>Gn&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return Qn.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this;for(let s=n.length-1;s>=0;s--){let{fromA:o,toA:a,fromB:l,toB:h}=n[s],c=r.lineAt(o,Kn.ByPosNoHeight,t,0,0),u=c.to>=a?c:r.lineAt(a,Kn.ByPosNoHeight,t,0,0);for(h+=u.to-a,a=u.to;s>0&&c.from<=n[s-1].toA;)o=n[s-1].fromA,l=n[s-1].fromB,s--,o2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),i+=1+r.break,n-=r.size}else{if(!(r>2*n))break;{let t=e[i];t.break?e.splice(i,1,t.left,null,t.right):e.splice(i,1,t.left,t.right),i+=2+t.break,r-=t.size}}else if(n=r&&s(this.blockAt(0,i,n,r))}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setHeight(e,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Xn extends Yn{constructor(e,t){super(e,t,si.Text),this.collapsed=0,this.widgetHeight=0}replace(e,t,i){let n=i[0];return 1==i.length&&(n instanceof Xn||n instanceof Zn&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Zn?n=new Xn(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Qn.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setHeight(e,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Zn extends Qn{constructor(e){super(e,0)}lines(e,t){let i=e.lineAt(t).number,n=e.lineAt(t+this.length).number;return{firstLine:i,lastLine:n,lineHeight:this.height/(n-i+1)}}blockAt(e,t,i,n){let{firstLine:r,lastLine:s,lineHeight:o}=this.lines(t,n),a=Math.max(0,Math.min(s-r,Math.floor((e-i)/o))),{from:l,length:h}=t.line(r+a);return new Jn(l,h,i+o*a,o,si.Text)}lineAt(e,t,i,n,r){if(t==Kn.ByHeight)return this.blockAt(e,i,n,r);if(t==Kn.ByPosNoHeight){let{from:t,to:n}=i.lineAt(e);return new Jn(t,n-t,0,0,si.Text)}let{firstLine:s,lineHeight:o}=this.lines(i,r),{from:a,length:l,number:h}=i.lineAt(e);return new Jn(a,l,n+o*(h-s),o,si.Text)}forEachLine(e,t,i,n,r,s){let{firstLine:o,lineHeight:a}=this.lines(i,r);for(let l=Math.max(e,r),h=Math.min(r+this.length,t);l<=h;){let t=i.lineAt(l);l==e&&(n+=a*(t.number-o)),s(new Jn(t.from,t.length,n,a,si.Text)),n+=a,l=t.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let e=i[i.length-1];e instanceof Zn?i[i.length-1]=new Zn(e.length+n):i.push(null,new Zn(n-1))}if(e>0){let t=i[0];t instanceof Zn?i[0]=new Zn(e+t.length):i.unshift(new Zn(e-1),null)}return Qn.of(i)}decomposeLeft(e,t){t.push(new Zn(e-1),null)}decomposeRight(e,t){t.push(null,new Zn(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let i=[],s=Math.max(t,n.from),o=-1,a=e.heightChanged;for(n.from>t&&i.push(new Zn(n.from-t-1).updateHeight(e,t));s<=r&&n.more;){let t=e.doc.lineAt(s).length;i.length&&i.push(null);let r=n.heights[n.index++];-1==o?o=r:Math.abs(r-o)>=Gn&&(o=-2);let a=new Xn(t,r);a.outdated=!1,i.push(a),s+=t+1}s<=r&&i.push(null,new Zn(r-s).updateHeight(e,s));let l=Qn.of(i);return e.heightChanged=a||o<0||Math.abs(l.height-this.height)>=Gn||Math.abs(o-this.lines(e.doc,t).lineHeight)>=Gn,l}return(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class er extends Qn{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return 1&this.flags}blockAt(e,t,i,n){let r=i+this.left.height;return eo))return l;let h=t==Kn.ByPosNoHeight?Kn.ByPosNoHeight:Kn.ByPos;return a?l.join(this.right.lineAt(o,h,i,s,o)):this.left.lineAt(o,h,i,n,r).join(l)}forEachLine(e,t,i,n,r,s){let o=n+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,o,a,s);else{let l=this.lineAt(a,Kn.ByPos,i,n,r);e=e&&l.from<=t&&s(l),t>l.to&&this.right.forEachLine(l.to+1,t,i,o,a,s)}}replace(e,t,i){let n=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let s=r.length;for(let e of i)r.push(e);if(e>0&&tr(r,s-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e2*t.size||t.size>2*e.size?Qn.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:s}=this,o=t+r.length+this.break,a=null;return n&&n.from<=t+r.length&&n.more?a=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=o+s.length&&n.more?a=s=s.updateHeight(e,o,i,n):s.updateHeight(e,o,i),a?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function tr(e,t){let i,n;null==e[t]&&(i=e[t-1])instanceof Zn&&(n=e[t+1])instanceof Zn&&e.splice(t-1,3,new Zn(i.length+1+n.length))}class ir{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Xn?i.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new Xn(e-this.pos,-1)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=5)&&this.addLineDeco(n,r)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new Xn(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new Zn(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Xn)return e;let t=new Xn(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine(),e.type!=si.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,e.type!=si.WidgetBefore&&(this.covering=e)}addLineDeco(e,t){let i=this.ensureLine();i.length+=t,i.collapsed+=t,i.widgetHeight=Math.max(i.widgetHeight,e),this.writtenTo=this.pos=this.pos+t}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof Xn||this.isCovered?(this.writtenToe.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=i.overflow){let t=e.getBoundingClientRect();n=Math.max(n,t.left),r=Math.min(r,t.right),s=Math.max(s,t.top),o=Math.min(o,t.bottom)}t="absolute"==i.position||"fixed"==i.position?e.offsetParent:e.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:n-i.left,right:Math.max(n,r)-i.left,top:s-(i.top+t),bottom:Math.max(s,o)-(i.top+t)}}function sr(e,t){let i=e.getBoundingClientRect();return{left:0,right:i.right-i.left,top:t,bottom:i.bottom-(i.top+t)}}class or{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i"function"!=typeof e),this.heightMap=Qn.empty().applyChanges(this.stateDeco,c.empty,this.heightOracle.setDoc(e.doc),[new Vi(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=oi.set(this.lineGaps.map(e=>e.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:e,to:t})=>n>=e&&n<=t)){let{from:t,to:i}=this.lineBlockAt(n);e.push(new hr(t,i))}}this.viewports=e.sort((e,t)=>e.from-t.from),this.scaler=this.heightMap.height<=7e6?mr:new gr(this.heightOracle.doc,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,e=>{this.viewportLines.push(1==this.scaler.scale?e:vr(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(ji).filter(e=>"function"!=typeof e);let n=Vi.extendWithRanges(e.changedRanges,function(e,t,i){let n=new nr;return Pe.compare(e,t,i,n,0),n.changes}(i,this.stateDeco,e?e.changes:P.empty(this.state.doc.length))),r=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),n),this.heightMap.height!=r&&(e.flags|=2);let s=n.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heads.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let o=!e.changes.empty||2&e.flags||s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,this.updateForViewport(),o&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Hi.RTL:Hi.LTR;let s=this.heightOracle.mustRefreshForWrapping(r),o=s||this.mustMeasureContent||this.contentDOMHeight!=t.clientHeight;this.contentDOMHeight=t.clientHeight,this.mustMeasureContent=!1;let a=0,l=0,h=parseInt(i.paddingTop)||0,c=parseInt(i.paddingBottom)||0;this.paddingTop==h&&this.paddingBottom==c||(this.paddingTop=h,this.paddingBottom=c,a|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(o=!0),this.editorWidth=e.scrollDOM.clientWidth,a|=8);let u=(this.printing?sr:rr)(t,this.paddingTop),d=u.top-this.pixelViewport.top,f=u.bottom-this.pixelViewport.bottom;this.pixelViewport=u;let p=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(p!=this.inView&&(this.inView=p,p&&(o=!0)),!this.inView)return 0;let m=t.clientWidth;if(this.contentDOMWidth==m&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=m,this.editorHeight=e.scrollDOM.clientHeight,a|=8),o){let t=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(t)&&(s=!0),s||n.lineWrapping&&Math.abs(m-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:o}=e.docView.measureTextSize();s=n.refresh(r,i,o,m/o,t),s&&(e.docView.minWidth=0,a|=8)}d>0&&f>0?l=Math.max(d,f):d<0&&f<0&&(l=Math.min(d,f)),n.heightChanged=!1;for(let i of this.viewports){let r=i.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(i);this.heightMap=this.heightMap.updateHeight(n,0,s,new Un(i.from,r))}n.heightChanged&&(a|=2)}let g=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return g&&(this.viewport=this.getViewport(l,this.scrollTarget)),this.updateForViewport(),(2&a||g)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.state.doc,{visibleTop:s,visibleBottom:o}=this,a=new hr(n.lineAt(s-1e3*i,Kn.ByHeight,r,0,0).from,n.lineAt(o+1e3*(1-i),Kn.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(ea.to){let i,s=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(e,Kn.ByPos,r,0,0);i="center"==t.y?(o.top+o.bottom)/2-s/2:"start"==t.y||"nearest"==t.y&&e=o+Math.max(10,Math.min(i,250)))&&n>s-2e3&&ri.from&&o.push({from:i.from,to:n}),r=i.from&&a.from<=i.to&&fr(o,a.from-10,a.from+10),!a.empty&&a.to>=i.from&&a.to<=i.to&&fr(o,a.to-10,a.to+10);for(let{from:n,to:r}of o)r-n>1e3&&t.push(pr(e,e=>e.from>=i.from&&e.to<=i.to&&Math.abs(e.from-n)<1e3&&Math.abs(e.to-r)<1e3)||new or(n,r,this.gapSize(i,n,r,s)))}return t}gapSize(e,t,i,n){let r=dr(n,i)-dr(n,t);return this.heightOracle.lineWrapping?e.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(e){or.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=oi.set(e.map(e=>e.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];Pe.spans(e,this.viewport.from,this.viewport.to,{span(e,i){t.push({from:e,to:i})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((e,i)=>e.from!=t[i].from||e.to!=t[i].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||vr(this.heightMap.lineAt(e,Kn.ByPos,this.state.doc,0,0),this.scaler)}lineBlockAtHeight(e){return vr(this.heightMap.lineAt(this.scaler.fromDOM(e),Kn.ByHeight,this.state.doc,0,0),this.scaler)}elementAtHeight(e){return vr(this.heightMap.blockAt(this.scaler.fromDOM(e),this.state.doc,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class hr{constructor(e,t){this.from=e,this.to=t}}function cr(e,t,i){let n=[],r=e,s=0;return Pe.spans(i,e,t,{span(){},point(e,t){e>r&&(n.push({from:r,to:e}),s+=e-r),r=t}},20),r=1)return t[t.length-1].to;let n=Math.floor(e*i);for(let e=0;;e++){let{from:i,to:r}=t[e],s=r-i;if(n<=s)return i+n;n-=s}}function dr(e,t){let i=0;for(let{from:n,to:r}of e.ranges){if(t<=r){i+=t-n;break}i+=r-n}return i/e.total}function fr(e,t,i){for(let n=0;nt){let s=[];r.fromi&&s.push({from:i,to:r.to}),e.splice(n,1,...s),n+=s.length-1}}}function pr(e,t){for(let i of e)if(t(i))return i}const mr={toDOM:e=>e,fromDOM:e=>e,scale:1};class gr{constructor(e,t,i){let n=0,r=0,s=0;this.viewports=i.map(({from:i,to:r})=>{let s=t.lineAt(i,Kn.ByPos,e,0,0).top,o=t.lineAt(r,Kn.ByPos,e,0,0).bottom;return n+=o-s,{from:i,to:r,top:s,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let e of this.viewports)e.domTop=s+(e.top-r)*this.scale,s=e.domBottom=e.domTop+(e.bottom-e.top),r=e.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=tvr(e,t)):e.type)}const yr=/*@__PURE__*/W.define({combine:e=>e.join(" ")}),wr=/*@__PURE__*/W.define({combine:e=>e.indexOf(!0)>-1}),br=/*@__PURE__*/Ke.newName(),kr=/*@__PURE__*/Ke.newName(),xr=/*@__PURE__*/Ke.newName(),Sr={"&light":"."+kr,"&dark":"."+xr};function Or(e,t,i){return new Ke(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!i||!i[t])throw new RangeError(`Unsupported selector: ${t}`);return i[t]}):e+" "+t})}const Cr=/*@__PURE__*/Or("."+br,{"&.cm-editor":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Sr),Ar={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Er=Wt.ie&&Wt.ie_version<=11;class Mr{constructor(e,t,i){this.view=e,this.onChange=t,this.onScrollChanged=i,this.active=!1,this.selectionRange=new yt,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.scrollTargets=[],this.intersection=null,this.resize=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(Wt.ie&&Wt.ie_version<=11||Wt.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),Er&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),window.addEventListener("resize",this.onResize=this.onResize.bind(this)),"function"==typeof ResizeObserver&&(this.resize=new ResizeObserver(()=>{this.view.docView.lastUpdate{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange(),this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:t}=this,i=this.selectionRange;if(t.state.facet(Ei)?t.root.activeElement!=this.dom:!ht(t.dom,i))return;let n=i.anchorNode&&t.docView.nearest(i.anchorNode);n&&n.ignoreEvent(e)||((Wt.ie&&Wt.ie_version<=11||Wt.android&&Wt.chrome)&&!t.state.selection.main.empty&&i.focusNode&&ut(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1))}readSelectionRange(){let{view:e}=this,t=Wt.safari&&11==e.root.nodeType&&function(){let e=document.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}()==this.dom&&function(e){let t=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),t=e.getTargetRanges()[0]}if(e.contentDOM.addEventListener("beforeinput",i,!0),document.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),!t)return null;let n=t.startContainer,r=t.startOffset,s=t.endContainer,o=t.endOffset,a=e.docView.domAtPos(e.state.selection.main.anchor);return ut(a.node,a.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}(this.view)||at(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=ht(this.dom,t);return i&&!this.selectionChanged&&this.selectionRange.focusNode&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let e=this.delayedAndroidKey;this.delayedAndroidKey=null,this.delayedFlush=-1,this.flush()||St(this.dom,e.key,e.keyCode)}),this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t})}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=window.setTimeout(()=>{this.delayedFlush=-1,this.flush()},20))}forceFlush(){this.delayedFlush>=0&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}processRecords(){let e=this.queue;for(let t of this.observer.takeRecords())e.push(t);e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(n=!0),-1==t?({from:t,to:i}=e):(t=Math.min(e.from,t),i=Math.max(e.to,i)))}return{from:t,to:i,typeOver:n}}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return;e&&this.readSelectionRange();let{from:t,to:i,typeOver:n}=this.processRecords(),r=this.selectionChanged&&ht(this.dom,this.selectionRange);if(t<0&&!r)return;this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=this.view.state,o=this.onChange(t,i,n);return this.view.state==s&&this.view.update([]),o}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty("attributes"==e.type),"attributes"==e.type&&(t.dirty|=4),"childList"==e.type){let i=Tr(t,e.previousSibling||e.target.previousSibling,-1),n=Tr(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}destroy(){var e,t,i;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(i=this.resize)||void 0===i||i.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("beforeprint",this.onPrint),this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout)}}function Tr(e,t,i){for(;t;){let n=Et.get(t);if(n&&n.parent==e)return n;let r=t.parentNode;t=r!=e.dom?r:i>0?t.nextSibling:t.previousSibling}return null}class Nr{constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(e=>this.update([e])),this.dispatch=this.dispatch.bind(this),this.root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new lr(e.state||Ae.create(e)),this.plugins=this.state.facet(Ti).map(e=>new Di(e));for(let e of this.plugins)e.update(this);this.observer=new Mr(this,(e,t,i)=>function(e,t,i,n){let r,s,o=e.state.selection.main;if(t>-1){let n=e.docView.domBoundsAround(t,i,0);if(!n||e.state.readOnly)return!1;let{from:a,to:l}=n,h=e.docView.impreciseHead||e.docView.impreciseAnchor?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}=e.observer.selectionRange;return i&&(t.push(new rn(i,n)),r==i&&s==n||t.push(new rn(r,s))),t}(e),u=new tn(h,e.state);u.readRange(n.startDOM,n.endDOM);let d=o.from,f=null;(8===e.inputState.lastKeyCode&&e.inputState.lastKeyTime>Date.now()-100||Wt.android&&u.text.length0&&a>0&&e.charCodeAt(o-1)==t.charCodeAt(a-1);)o--,a--;return"end"==n&&(i-=o+Math.max(0,s-Math.min(o,a))-s),o=o?s-i:0,a=s+(a-o),o=s):a=a?s-i:0,o=s+(o-a),a=s),{from:s,toA:o,toB:a}}(e.state.doc.sliceString(a,l,en),u.text,d-a,f);p&&(Wt.chrome&&13==e.inputState.lastKeyCode&&p.toB==p.from+2&&"￿￿"==u.text.slice(p.from,p.toB)&&p.toB--,r={from:a+p.from,to:a+p.toA,insert:c.of(u.text.slice(p.from,p.toB).split(en))}),s=function(e,t){if(0==e.length)return null;let i=e[0].pos,n=2==e.length?e[1].pos:i;return i>-1&&n>-1?H.single(i+t,n+t):null}(h,a)}else if(e.hasFocus||!e.state.facet(Ei)){let t=e.observer.selectionRange,{impreciseHead:i,impreciseAnchor:n}=e.docView,r=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!lt(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),a=n&&n.node==t.anchorNode&&n.offset==t.anchorOffset||!lt(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset);r==o.head&&a==o.anchor||(s=H.single(a,r))}if(!r&&!s)return!1;if(!r&&n&&!o.empty&&s&&s.main.empty?r={from:o.from,to:o.to,insert:e.state.doc.slice(o.from,o.to)}:r&&r.from>=o.from&&r.to<=o.to&&(r.from!=o.from||r.to!=o.to)&&o.to-o.from-(r.to-r.from)<=4?r={from:o.from,to:o.to,insert:e.state.doc.slice(o.from,r.from).append(r.insert).append(e.state.doc.slice(r.to,o.to))}:(Wt.mac||Wt.android)&&r&&r.from==r.to&&r.from==o.head-1&&"."==r.insert.toString()&&(r={from:o.from,to:o.to,insert:c.of([" "])}),r){let t=e.state;if(Wt.ios&&e.inputState.flushIOSKey(e))return!0;if(Wt.android&&(r.from==o.from&&r.to==o.to&&1==r.insert.length&&2==r.insert.lines&&St(e.contentDOM,"Enter",13)||r.from==o.from-1&&r.to==o.to&&0==r.insert.length&&St(e.contentDOM,"Backspace",8)||r.from==o.from&&r.to==o.to+1&&0==r.insert.length&&St(e.contentDOM,"Delete",46)))return!0;let i,n=r.insert.toString();if(e.state.facet(xi).some(t=>t(e,r.from,r.to,n)))return!0;if(e.inputState.composing>=0&&e.inputState.composing++,r.from>=o.from&&r.to<=o.to&&r.to-r.from>=(o.to-o.from)/3&&(!s||s.main.empty&&s.main.from==r.from+r.insert.length)&&e.inputState.composing<0){let n=o.fromr.to?t.sliceDoc(r.to,o.to):"";i=t.replaceSelection(e.state.toText(n+r.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let n=t.changes(r),a=s&&!t.selection.main.eq(s.main)&&s.main.to<=n.newLength?s.main:void 0;if(t.selection.ranges.length>1&&e.inputState.composing>=0&&r.to<=o.to&&r.to>=o.to-10){let s=e.state.sliceDoc(r.from,r.to),l=an(e)||e.state.doc.lineAt(o.head),h=o.to-r.to,c=o.to-o.from;i=t.changeByRange(i=>{if(i.from==o.from&&i.to==o.to)return{changes:n,range:a||i.map(n)};let u=i.to-h,d=u-s.length;if(i.to-i.from!=c||e.state.sliceDoc(d,u)!=s||l&&i.to>=l.from&&i.from<=l.to)return{range:i};let f=t.changes({from:d,to:u,insert:r.insert}),p=i.to-o.to;return{changes:f,range:a?H.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):i.map(f)}})}else i={changes:n,selection:a&&t.selection.replaceRange(a)}}let a="input.type";return e.composing&&(a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1)),e.dispatch(i,{scrollIntoView:!0,userEvent:a}),!0}if(s&&!s.main.eq(o)){let t=!1,i="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),i=e.inputState.lastSelectionOrigin),e.dispatch({selection:s,scrollIntoView:t,userEvent:i}),!0}return!1}(this,e,t,i),e=>{this.inputState.runScrollHandlers(this,e),this.observer.intersecting&&this.measure()}),this.inputState=new xn(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new sn(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}dispatch(...e){this._dispatch(1==e.length&&e[0]instanceof ge?e[0]:this.state.update(...e))}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,i=!1,n=!1,r=this.state;for(let t of e){if(t.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed)return void(this.viewState.state=r);if(this.observer.clear(),r.facet(Ae.phrases)!=this.state.facet(Ae.phrases))return this.setState(r);t=_i.create(this,r,e);let s=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(s&&(s=s.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;s=new Oi(e.empty?e:H.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(Ci)&&(s=e.value)}this.viewState.update(t,s),this.bidiCache=Rr.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),i=this.docView.update(t),this.state.facet(Li)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(i,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(yr)!=t.state.facet(yr)&&(this.viewState.mustMeasureContent=!0),(i||n||s||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!t.empty)for(let e of this.state.facet(ki))e(t)}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new lr(e),this.plugins=e.facet(Ti).map(e=>new Di(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView=new sn(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ti),i=e.state.facet(Ti);if(t!=i){let n=[];for(let r of i){let i=t.indexOf(r);if(i<0)n.push(new Di(r));else{let t=this.plugins[i];t.mustUpdate=e,n.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=n,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.flush();let t=null;try{for(let e=0;;e++){this.updateState=1;let i=this.viewport,n=this.viewState.measure(this);if(!n&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let r=[];4&n||([this.measureRequests,r]=[r,this.measureRequests]);let s=r.map(e=>{try{return e.read(this)}catch(e){return Ai(this.state,e),Pr}}),o=_i.create(this,this.state,[]),a=!1,l=!1;o.flags|=n,t?t.flags|=n:t=o,this.updateState=2,o.empty||(this.updatePlugins(o),this.inputState.update(o),this.updateAttrs(),a=this.docView.update(o));for(let e=0;e{let i=ni(this.contentDOM,this.contentAttrs,t),n=ni(this.dom,this.editorAttrs,e);return i||n});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let e of i.effects)e.is(Nr.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(Li),Ke.mount(this.root,this.styleModules.concat(Cr).reverse())}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=requestAnimationFrame(()=>this.measure())),e){if(null!=e.key)for(let t=0;tt.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return kn(this,e,bn(this,e,t,i))}moveByGroup(e,t){return kn(this,e,bn(this,e,t,t=>function(e,t,i){let n=e.state.charCategorizer(t),r=n(i);return e=>{let t=n(e);return r==Se.Space&&(r=t),r==t}}(this,e.head,t)))}moveToLineBoundary(e,t,i=!0){return function(e,t,i,n){let r=e.state.doc.lineAt(t.head),s=n&&e.lineWrapping?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(s){let t=e.dom.getBoundingClientRect(),n=e.textDirectionAt(r.from),o=e.posAtCoords({x:i==(n==Hi.LTR)?t.right-1:t.left+1,y:(s.top+s.bottom)/2});if(null!=o)return H.cursor(o,i?-1:1)}let o=di.find(e.docView,t.head);return H.cursor(o?i?o.posAtEnd:o.posAtStart:i?r.to:r.from,i?-1:1)}(this,e,t,i)}moveVertically(e,t,i){return kn(this,e,function(e,t,i,n){let r=t.head,s=i?1:-1;if(r==(i?e.state.doc.length:0))return H.cursor(r,t.assoc);let o,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),h=e.coordsAtPos(r),c=e.documentTop;if(h)null==a&&(a=h.left-l.left),o=s<0?h.top:h.bottom;else{let t=e.viewState.lineBlockAt(r);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(r-t.from))),o=(s<0?t.top:t.bottom)+c}let u=l.left+a,d=null!=n?n:e.defaultLineHeight>>1;for(let i=0;;i+=10){let n=o+(d+i)*s,h=yn(e,{x:u,y:n},!1,s);if(nl.bottom||(s<0?hr))return H.cursor(h,t.assoc,void 0,a)}}(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),yn(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(e),r=this.bidiSpans(n);return gt(i,r[Gi.find(r,e-n.from,-1,t)].dir==Hi.LTR==t>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Si)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Dr)return Yi(e.length);let t=this.textDirectionAt(e.from);for(let i of this.bidiCache)if(i.from==e.from&&i.dir==t)return i.order;let i=function(e,t){let i=e.length,n=t==Fi?1:2,r=t==Fi?2:1;if(!e||1==n&&!Ki.test(e))return Yi(i);for(let t=0,r=n,o=n;t=0;e-=3)if(Ji[e+1]==-s){let t=Ji[e+2],i=2&t?n:4&t?1&t?r:n:0;i&&(Qi[a]=Qi[Ji[e]]=i),l=e;break}}else{if(189==Ji.length)break;Ji[l++]=a,Ji[l++]=t,Ji[l++]=h}else if(2==(o=Qi[a])||1==o){let e=o==n;h=e?0:1;for(let t=l-3;t>=0;t-=3){let i=Ji[t+2];if(2&i)break;if(e)Ji[t+2]|=2;else{if(4&i)break;Ji[t+2]|=4}}}for(let e=0;et;){let e=i,n=2!=Qi[--i];for(;i>t&&n==(2!=Qi[i-1]);)i--;o.push(new Gi(i,e,n?2:1))}else o.push(new Gi(t,e,0))}else for(let e=0;eDate.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{kt(this.contentDOM),this.docView.updateSelection()})}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Ci.of(new Oi("number"==typeof e?H.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return Ni.define(()=>({}),{eventHandlers:e})}static theme(e,t){let i=Ke.newName(),n=[yr.of(i),Li.of(Or(`.${i}`,e))];return t&&t.dark&&n.push(wr.of(!0)),n}static baseTheme(e){return X.lowest(Li.of(Or("."+br,e,Sr)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&Et.get(i)||Et.get(e);return(null===(t=null==n?void 0:n.rootView)||void 0===t?void 0:t.view)||null}}Nr.styleModule=Li,Nr.inputHandler=xi,Nr.perLineTextDirection=Si,Nr.exceptionSink=bi,Nr.updateListener=ki,Nr.editable=Ei,Nr.mouseSelectionStyle=wi,Nr.dragMovesSelection=yi,Nr.clickAddsSelectionRange=vi,Nr.decorations=ji,Nr.atomicRanges=Bi,Nr.scrollMargins=Ii,Nr.darkTheme=wr,Nr.contentAttributes=Ri,Nr.editorAttributes=Pi,Nr.lineWrapping=/*@__PURE__*/Nr.contentAttributes.of({class:"cm-lineWrapping"}),Nr.announce=/*@__PURE__*/me.define();const Dr=4096,Pr={};class Rr{constructor(e,t,i,n){this.from=e,this.to=t,this.dir=i,this.order=n}static update(e,t){if(t.empty)return e;let i=[],n=e.length?e[e.length-1].dir:Hi.LTR;for(let r=Math.max(0,e.length-10);r=0;r--){let t=n[r],s="function"==typeof t?t(e):t;s&&ti(s,i)}return i}const Br=Wt.mac?"mac":Wt.windows?"win":Wt.linux?"linux":"key";function Ir(e,t,i){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==i&&t.shiftKey&&(e="Shift-"+e),e}const Lr=/*@__PURE__*/X.default(/*@__PURE__*/Nr.domEventHandlers({keydown:(e,t)=>function(e,t,i,n){let r=function(e){var t=!(rt&&(e.ctrlKey||e.altKey||e.metaKey)||(et||nt)&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Xe:Ye)[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}(t),s=E(r,0),o=M(s)==r.length&&" "!=r,a="",l=!1;Hr&&Hr.view==i&&"editor"==Hr.scope&&(a=Hr.prefix+" ",(l=On.indexOf(t.keyCode)<0)&&(Hr=null));let h,c=e=>{if(e){for(let t of e.commands)if(t(i))return!0;e.preventDefault&&(l=!0)}return!1},u=e.editor;if(u){if(c(u[a+Ir(r,t,!o)]))return!0;if(o&&(t.shiftKey||t.altKey||t.metaKey||s>127)&&(h=Ye[t.keyCode])&&h!=r){if(c(u[a+Ir(h,t,!0)]))return!0;if(t.shiftKey&&Xe[t.keyCode]!=h&&c(u[a+Ir(Xe[t.keyCode],t,!1)]))return!0}else if(o&&t.shiftKey&&c(u[a+Ir(r,t,!0)]))return!0}return l}(function(e){let t=e.facet(Vr),i=_r.get(t);return i||_r.set(t,i=function(e,t=Br){let i=Object.create(null),n=Object.create(null),r=(e,t)=>{let i=n[e];if(null==i)n[e]=t;else if(i!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},s=(e,n,s,o)=>{let a=i[e]||(i[e]=Object.create(null)),l=n.split(/ (?!$)/).map(e=>function(e,t){const i=e.split(/-(?!$)/);let n,r,s,o,a=i[i.length-1];"Space"==a&&(a=" ");for(let e=0;e{let n=Hr={view:t,prefix:i,scope:e};return setTimeout(()=>{Hr==n&&(Hr=null)},4e3),!0}]})}let h=l.join(" ");r(h,!1);let c=a[h]||(a[h]={preventDefault:!1,commands:[]});c.commands.push(s),o&&(c.preventDefault=!0)};for(let i of e){let e=i[t]||i.key;if(e)for(let t of i.scope?i.scope.split(" "):["editor"])s(t,e,i.run,i.preventDefault),i.shift&&s(t,"Shift-"+e,i.shift,i.preventDefault)}return i}(t.reduce((e,t)=>e.concat(t),[]))),i}(t.state),e,t)})),Vr=/*@__PURE__*/W.define({enables:Lr}),_r=/*@__PURE__*/new WeakMap;let Hr=null;const Fr=!Wt.ios,zr=/*@__PURE__*/W.define({combine:e=>Ee(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function Wr(e={}){return[zr.of(e),$r,Jr]}class qr{constructor(e,t,i,n,r){this.left=e,this.top=t,this.width=i,this.height=n,this.className=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width>=0&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}}const $r=/*@__PURE__*/Ni.fromClass(class{constructor(e){this.view=e,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=e.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=e.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),e.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(zr).cursorBlinkRate+"ms"}update(e){let t=e.startState.facet(zr)!=e.state.facet(zr);(t||e.selectionSet||e.geometryChanged||e.viewportChanged)&&this.view.requestMeasure(this.measureReq),e.transactions.some(e=>e.scrollIntoView)&&(this.cursorLayer.style.animationName="cm-blink"==this.cursorLayer.style.animationName?"cm-blink2":"cm-blink"),t&&this.setBlinkRate()}readPos(){let{state:e}=this.view,t=e.facet(zr),i=e.selection.ranges.map(e=>e.empty?[]:function(e,t){if(t.to<=e.viewport.from||t.from>=e.viewport.to)return[];let i=Math.max(t.from,e.viewport.from),n=Math.min(t.to,e.viewport.to),r=e.textDirection==Hi.LTR,s=e.contentDOM,o=s.getBoundingClientRect(),a=Kr(e),l=window.getComputedStyle(s.firstChild),h=o.left+parseInt(l.paddingLeft)+Math.min(0,parseInt(l.textIndent)),c=o.right-parseInt(l.paddingRight),u=Qr(e,i),d=Qr(e,n),f=u.type==si.Text?u:null,p=d.type==si.Text?d:null;if(e.lineWrapping&&(f&&(f=Gr(e,i,f)),p&&(p=Gr(e,n,p))),f&&p&&f.from==p.from)return g(v(t.from,t.to,f));{let i=f?v(t.from,null,f):y(u,!1),n=p?v(null,t.to,p):y(d,!0),r=[];return(f||u).to<(p||d).from-1?r.push(m(h,i.bottom,c,n.top)):i.bottomu&&n.from=s)break;a>r&&l(Math.max(e,r),null==t&&e<=u,Math.min(a,s),null==i&&a>=d,o.dir)}if(r=n.to+1,r>=s)break}return 0==a.length&&l(u,null==t,d,null==i,e.textDirection),{top:s,bottom:o,horizontal:a}}function y(e,t){let i=o.top+(t?e.top:e.bottom);return{top:i,bottom:i,horizontal:[]}}}(this.view,e)).reduce((e,t)=>e.concat(t)),n=[];for(let i of e.selection.ranges){let r=i==e.selection.main;if(i.empty?!r||Fr:t.drawRangeCursor){let e=Yr(this.view,i,r);e&&n.push(e)}}return{rangePieces:i,cursors:n}}drawSel({rangePieces:e,cursors:t}){if(e.length!=this.rangePieces.length||e.some((e,t)=>!e.eq(this.rangePieces[t]))){this.selectionLayer.textContent="";for(let t of e)this.selectionLayer.appendChild(t.draw());this.rangePieces=e}if(t.length!=this.cursors.length||t.some((e,t)=>!e.eq(this.cursors[t]))){let e=this.cursorLayer.children;if(e.length!==t.length){this.cursorLayer.textContent="";for(const e of t)this.cursorLayer.appendChild(e.draw())}else t.forEach((t,i)=>t.adjust(e[i]));this.cursors=t}}destroy(){this.selectionLayer.remove(),this.cursorLayer.remove()}}),Ur={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Fr&&(Ur[".cm-line"].caretColor="transparent !important");const Jr=/*@__PURE__*/X.highest(/*@__PURE__*/Nr.theme(Ur));function Kr(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Hi.LTR?t.left:t.right-e.scrollDOM.clientWidth)-e.scrollDOM.scrollLeft,top:t.top-e.scrollDOM.scrollTop}}function Gr(e,t,i){let n=H.cursor(t);return{from:Math.max(i.from,e.moveToLineBoundary(n,!1,!0).from),to:Math.min(i.to,e.moveToLineBoundary(n,!0,!0).from),type:si.Text}}function Qr(e,t){let i=e.lineBlockAt(t);if(Array.isArray(i.type))for(let e of i.type)if(e.to>t||e.to==t&&(e.to==i.to||e.type==si.Text))return e;return i}function Yr(e,t,i){let n=e.coordsAtPos(t.head,t.assoc||1);if(!n)return null;let r=Kr(e);return new qr(n.left-r.left,n.top-r.top,-1,n.bottom-n.top,i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}function Xr(e,t,i,n,r){t.lastIndex=0;for(let s,o=e.iterRange(i,n),a=i;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;s=t.exec(o.value);)r(a+s.index,s)}class Zr{constructor(e){const{regexp:t,decoration:i,decorate:n,boundary:r,maxLength:s=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,n)this.addMatch=(e,t,i,r)=>n(r,i,i+e[0].length,e,t);else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");{let e="function"==typeof i?i:()=>i;this.addMatch=(t,i,n,r)=>r(n,n+t[0].length,e(t,i,n))}}this.boundary=r,this.maxLength=s}createDeco(e){let t=new Re,i=t.add.bind(t);for(let{from:t,to:n}of function(e,t){let i=e.visibleRanges;if(1==i.length&&i[0].from==e.viewport.from&&i[0].to==e.viewport.to)return i;let n=[];for(let{from:r,to:s}of i)r=Math.max(e.state.doc.lineAt(r).from,r-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}(e,this.maxLength))Xr(e.state.doc,this.regexp,t,n,(t,n)=>this.addMatch(n,e,t,i));return t.finish()}updateDeco(e,t){let i=1e9,n=-1;return e.docChanged&&e.changes.iterChanges((t,r,s,o)=>{o>e.view.viewport.from&&s1e3?this.createDeco(e.view):n>-1?this.updateRange(e.view,t.map(e.changes),i,n):t}updateRange(e,t,i,n){for(let r of e.visibleRanges){let s=Math.max(r.from,i),o=Math.min(r.to,n);if(o>s){let i=e.state.doc.lineAt(s),n=i.toi.from;s--)if(this.boundary.test(i.text[s-1-i.from])){a=s;break}for(;oc.push(i.range(e,t));if(i==n)for(this.regexp.lastIndex=a-i.from;(h=this.regexp.exec(i.text))&&h.indexthis.addMatch(i,e,t,u));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>el,add:c})}}return t}}const es=null!=/x/.unicode?"gu":"g",ts=/*@__PURE__*/new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",es),is={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let ns=null;const rs=/*@__PURE__*/W.define({combine(e){let t=Ee(e,{render:null,specialChars:ts,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==ns&&"undefined"!=typeof document&&document.body){let t=document.body.style;ns=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return ns||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,es)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,es)),t}});function ss(e={}){return[rs.of(e),os||(os=Ni.fromClass(class{constructor(e){this.view=e,this.decorations=oi.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(rs)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Zr({regexp:e.specialChars,decoration:(t,i,n)=>{let{doc:r}=i.state,s=E(t[0],0);if(9==s){let e=r.lineAt(n),t=i.state.tabSize,s=qe(e.text,t,n-e.from);return oi.replace({widget:new ls((t-s%t)*this.view.defaultCharacterWidth)})}return this.decorationCache[s]||(this.decorationCache[s]=oi.replace({widget:new as(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(rs);e.startState.facet(rs)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}let os=null;class as extends ri{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=function(e){return e>=32?"•":10==e?"␤":String.fromCharCode(9216+e)}(this.code),i=e.state.phrase("Control character")+" "+(is[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,t);if(n)return n;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class ls extends ri{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const hs=/*@__PURE__*/oi.line({class:"cm-activeLine"}),cs=/*@__PURE__*/Ni.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,i=[];for(let n of e.state.selection.ranges){if(!n.empty)return oi.none;let r=e.lineBlockAt(n.head);r.from>t&&(i.push(hs.range(r.from)),t=r.from)}return oi.set(i)}},{decorations:e=>e.decorations}),us="-10000px";class ds{constructor(e,t,i){this.facet=t,this.createTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e),this.tooltipViews=this.tooltips.map(i)}update(e){let t=e.state.facet(this.facet),i=t.filter(e=>e);if(t===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let n=[];for(let t=0;t{var t,i,n;return{position:Wt.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(i=e.find(e=>e.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=e.find(e=>e.tooltipSpace))||void 0===n?void 0:n.tooltipSpace)||fs}}}),ms=/*@__PURE__*/Ni.fromClass(class{constructor(e){var t;this.view=e,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let i=e.state.facet(ps);this.position=i.position,this.parent=i.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new ds(e,vs,e=>this.createTooltip(e)),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),null===(t=e.dom.ownerDocument.defaultView)||void 0===t||t.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e);t&&this.observeIntersection();let i=t||e.geometryChanged,n=e.state.facet(ps);if(n.position!=this.position){this.position=n.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(e){let t=e.create(this.view);if(t.dom.classList.add("cm-tooltip"),e.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",t.dom.appendChild(e)}return t.dom.style.position=this.position,t.dom.style.top=us,this.container.appendChild(t.dom),t.mount&&t.mount(this.view),t}destroy(){var e,t;null===(e=this.view.dom.ownerDocument.defaultView)||void 0===e||e.removeEventListener("resize",this.measureSoon);for(let{dom:e}of this.manager.tooltipViews)e.remove();null===(t=this.intersectionObserver)||void 0===t||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=this.view.dom.getBoundingClientRect();return{editor:e,parent:this.parent?this.container.getBoundingClientRect():e,pos:this.manager.tooltips.map((e,t)=>{let i=this.manager.tooltipViews[t];return i.getCoords?i.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(ps).tooltipSpace(this.view)}}writeMeasure(e){let{editor:t,space:i}=e,n=[];for(let r=0;r=Math.min(t.bottom,i.bottom)||l.rightMath.min(t.right,i.right)+.1){a.style.top=us;continue}let c=s.arrow?o.dom.querySelector(".cm-tooltip-arrow"):null,u=c?7:0,d=h.right-h.left,f=h.bottom-h.top,p=o.offset||gs,m=this.view.textDirection==Hi.LTR,g=h.width>i.right-i.left?m?i.left:i.right-h.width:m?Math.min(l.left-(c?14:0)+p.x,i.right-d):Math.max(i.left,l.left-d+(c?14:0)-p.x),v=!!s.above;!s.strictSide&&(v?l.top-(h.bottom-h.top)-p.yi.bottom)&&v==i.bottom-l.bottom>l.top-i.top&&(v=!v);let y=v?l.top-f-u-p.y:l.bottom+u+p.y,w=g+d;if(!0!==o.overlap)for(let e of n)e.leftg&&e.topy&&(y=v?e.top-f-2-u:e.bottom+u+2);"absolute"==this.position?(a.style.top=y-e.parent.top+"px",a.style.left=g-e.parent.left+"px"):(a.style.top=y+"px",a.style.left=g+"px"),c&&(c.style.left=l.left+(m?p.x:-p.x)-(g+14-7)+"px"),!0!==o.overlap&&n.push({left:g,top:y,right:w,bottom:y+f}),a.classList.toggle("cm-tooltip-above",v),a.classList.toggle("cm-tooltip-below",!v),o.positioned&&o.positioned()}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=us}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),gs={x:0,y:0},vs=/*@__PURE__*/W.define({enables:[ms,/*@__PURE__*/Nr.baseTheme({".cm-tooltip":{zIndex:100},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}})]}),ys=/*@__PURE__*/W.define();class ws{constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new ds(e,ys,e=>this.createHostedView(e))}static create(e){return new ws(e)}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned()}update(e){this.manager.update(e)}}const bs=/*@__PURE__*/vs.compute([ys],e=>{let t=e.facet(ys).filter(e=>e);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.filter(e=>null!=e.end).map(e=>e.end)),create:ws.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class ks{constructor(e,t,i,n,r){this.view=e,this.source=t,this.field=i,this.setHover=n,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;ei.bottom||e.xi.right+this.view.defaultCharacterWidth)return;let n=this.view.bidiSpans(this.view.state.doc.lineAt(t)).find(e=>e.from<=t&&e.to>=t),r=n&&n.dir==Hi.RTL?-1:1,s=this.source(this.view,t,e.x{this.pending==e&&(this.pending=null,t&&this.view.dispatch({effects:this.setHover.of(t)}))},e=>Ai(this.view.state,e,"hover tooltip"))}else s&&this.view.dispatch({effects:this.setHover.of(s)})}mousemove(e){var t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let i=this.active;if(i&&!function(e){for(let t=e;t;t=t.parentNode)if(1==t.nodeType&&t.classList.contains("cm-tooltip"))return!0;return!1}(this.lastMove.target)||this.pending){let{pos:n}=i||this.pending,r=null!==(t=null==i?void 0:i.end)&&void 0!==t?t:n;(n==r?this.view.posAtCoords(this.lastMove)==n:function(e,t,i,n,r,s){let o=document.createRange(),a=e.domAtPos(t),l=e.domAtPos(i);o.setEnd(l.node,l.offset),o.setStart(a.node,a.offset);let h=o.getClientRects();o.detach();for(let e=0;enull,update(e,n){if(e&&(t.hideOnChange&&(n.docChanged||n.selection)||t.hideOn&&t.hideOn(n,e)))return null;if(e&&n.docChanged){let t=n.changes.mapPos(e.pos,-1,N.TrackDel);if(null==t)return null;let i=Object.assign(Object.create(null),e);i.pos=t,null!=e.end&&(i.end=n.changes.mapPos(e.end)),e=i}for(let t of n.effects)t.is(i)&&(e=t.value),t.is(Ss)&&(e=null);return e},provide:e=>ys.from(e)});return[n,Ni.define(r=>new ks(r,e,n,i,t.hoverTime||300)),bs]}const Ss=/*@__PURE__*/me.define(),Os=/*@__PURE__*/W.define({combine(e){let t,i;for(let n of e)t=t||n.topContainer,i=i||n.bottomContainer;return{topContainer:t,bottomContainer:i}}}),Cs=/*@__PURE__*/Ni.fromClass(class{constructor(e){this.input=e.state.facet(Ms),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(Os);this.top=new As(e,!0,t.topContainer),this.bottom=new As(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(Os);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new As(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new As(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=e.state.facet(Ms);if(i!=this.input){let t=i.filter(e=>e),n=[],r=[],s=[],o=[];for(let i of t){let t,a=this.specs.indexOf(i);a<0?(t=i(e.view),o.push(t)):(t=this.panels[a],t.update&&t.update(e)),n.push(t),(t.top?r:s).push(t)}this.specs=t,this.panels=n,this.top.sync(r),this.bottom.sync(s);for(let e of o)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Nr.scrollMargins.of(t=>{let i=t.plugin(e);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class As{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Es(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Es(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Es(e){let t=e.nextSibling;return e.remove(),t}const Ms=/*@__PURE__*/W.define({enables:Cs});class Ts extends Me{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ts.prototype.elementClass="",Ts.prototype.toDOM=void 0,Ts.prototype.mapMode=N.TrackBefore,Ts.prototype.startSide=Ts.prototype.endSide=-1,Ts.prototype.point=!0;const Ns=/*@__PURE__*/W.define(),Ds={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Pe.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Ps=/*@__PURE__*/W.define();function Rs(e){return[Bs(),Ps.of(Object.assign(Object.assign({},Ds),e))]}const js=/*@__PURE__*/W.define({combine:e=>e.some(e=>e)});function Bs(e){let t=[Is];return e&&!1===e.fixed&&t.push(js.of(!0)),t}const Is=/*@__PURE__*/Ni.fromClass(class{constructor(e){this.view=e,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=e.state.facet(Ps).map(t=>new Hs(e,t));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!e.state.facet(js),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}update(e){if(this.updateGutters(e)){let t=this.prevViewport,i=e.view.viewport,n=Math.min(t.to,i.to)-Math.max(t.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}e.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(js)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&this.dom.remove();let i=Pe.iter(this.view.state.facet(Ns),this.view.viewport.from),n=[],r=this.gutters.map(e=>new _s(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks){let t;if(Array.isArray(e.type)){for(let i of e.type)if(i.type==si.Text){t=i;break}}else t=e.type==si.Text?e:void 0;if(t){n.length&&(n=[]),Vs(i,n,e.from);for(let e of r)e.line(this.view,t,n)}}for(let e of r)e.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(Ps),i=e.state.facet(Ps),n=e.docChanged||e.heightChanged||e.viewportChanged||!Pe.eq(e.startState.facet(Ns),e.state.facet(Ns),e.view.viewport.from,e.view.viewport.to);if(t==i)for(let t of this.gutters)t.update(e)&&(n=!0);else{n=!0;let r=[];for(let n of i){let i=t.indexOf(n);i<0?r.push(new Hs(this.view,n)):(this.gutters[i].update(e),r.push(this.gutters[i]))}for(let e of this.gutters)e.dom.remove(),r.indexOf(e)<0&&e.destroy();for(let e of r)this.dom.appendChild(e.dom);this.gutters=r}return n}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>Nr.scrollMargins.of(t=>{let i=t.plugin(e);return i&&0!=i.gutters.length&&i.fixed?t.textDirection==Hi.LTR?{left:i.dom.offsetWidth}:{right:i.dom.offsetWidth}:null})});function Ls(e){return Array.isArray(e)?e:[e]}function Vs(e,t,i){for(;e.value&&e.from<=i;)e.from==i&&t.push(e.value),e.next()}class _s{constructor(e,t,i){this.gutter=e,this.height=i,this.localMarkers=[],this.i=0,this.cursor=Pe.iter(e.markers,t.from)}line(e,t,i){this.localMarkers.length&&(this.localMarkers=[]),Vs(this.cursor,this.localMarkers,t.from);let n=i.length?this.localMarkers.concat(i):this.localMarkers,r=this.gutter.config.lineMarker(e,t,n);r&&n.unshift(r);let s=this.gutter;if(0==n.length&&!s.config.renderEmptyElements)return;let o=t.top-this.height;if(this.i==s.elements.length){let i=new Fs(e,t.height,o,n);s.elements.push(i),s.dom.appendChild(i.dom)}else s.elements[this.i].update(e,t.height,o,n);this.height=t.bottom,this.i++}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Hs{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,n=>{let r=e.lineBlockAtHeight(n.clientY-e.documentTop);t.domEventHandlers[i](e,r,n)&&n.preventDefault()});this.markers=Ls(t.markers(e)),t.initialSpacer&&(this.spacer=new Fs(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Ls(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let i=e.view.viewport;return!Pe.eq(this.markers,t,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class Fs{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.dom.style.height=(this.height=t)+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),function(e,t){if(e.length!=t.length)return!1;for(let i=0;iEe(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let e in t){let n=i[e],r=t[e];i[e]=n?(e,t,i)=>n(e,t,i)||r(e,t,i):r}return i}})});class qs extends Ts{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function $s(e,t){return e.state.facet(Ws).formatNumber(t,e.state)}const Us=/*@__PURE__*/Ps.compute([Ws],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(zs),lineMarker:(e,t,i)=>i.some(e=>e.toDOM)?null:new qs($s(e,e.state.doc.lineAt(t.from).number)),lineMarkerChange:e=>e.startState.facet(Ws)!=e.state.facet(Ws),initialSpacer:e=>new qs($s(e,Ks(e.state.doc.lines))),updateSpacer(e,t){let i=$s(t.view,Ks(t.view.state.doc.lines));return i==e.number?e:new qs(i)},domEventHandlers:e.facet(Ws).domEventHandlers}));function Js(e={}){return[Ws.of(e),Bs(),Us]}function Ks(e){let t=9;for(;t{let t=[],i=-1;for(let n of e.selection.ranges)if(n.empty){let r=e.doc.lineAt(n.head).from;r>i&&(i=r,t.push(Gs.range(r)))}return Pe.of(t)}),Ys=1024;let Xs=0;class Zs{constructor(e,t){this.from=e,this.to=t}}class eo{constructor(e={}){this.id=Xs++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=io.match(e)),t=>{let i=e(t);return void 0===i?null:[this,i]}}}eo.closedBy=new eo({deserialize:e=>e.split(" ")}),eo.openedBy=new eo({deserialize:e=>e.split(" ")}),eo.group=new eo({deserialize:e=>e.split(" ")}),eo.contextHash=new eo({perNode:!0}),eo.lookAhead=new eo({perNode:!0}),eo.mounted=new eo({perNode:!0});const to=Object.create(null);class io{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):to,i=new io(e.name||"",t,e.id,(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0));if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return i}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(eo.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return e=>{for(let i=e.prop(eo.group),n=-1;n<(i?i.length:0);n++){let r=t[n<0?e.name:i[n]];if(r)return r}}}}io.none=new io("",Object.create(null),0,8);class no{constructor(e){this.types=e;for(let t=0;t=n&&(s.type.isAnonymous||!1!==t(s))){if(s.firstChild())continue;e=!0}for(;e&&i&&!s.type.isAnonymous&&i(s),!s.nextSibling();){if(!s.parent())return;e=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:So(io.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,i)=>new ao(this.type,e,t,i,this.propValues),e.makeTree||((e,t,i)=>new ao(io.none,e,t,i)))}static build(e){return function(e){var t;let{buffer:i,nodeSet:n,maxBufferLength:r=Ys,reused:s=[],minRepeatType:o=n.types.length}=e,a=Array.isArray(i)?new lo(i,i.length):i,l=n.types,h=0,c=0;function u(e,t,i,m,g){let{id:v,start:y,end:w,size:b}=a,k=c;for(;b<0;){if(a.next(),-1==b)return i.push(s[v]),void m.push(y-e);if(-3==b)return void(h=v);if(-4==b)return void(c=v);throw new RangeError(`Unrecognized record size: ${b}`)}let x,S,O=l[v],C=y-e;if(w-y<=r&&(S=function(e,t){let i=a.fork(),n=0,s=0,l=0,h=i.end-r,c={size:0,start:0,skip:0};e:for(let r=i.pos-e;i.pos>r;){let e=i.size;if(i.id==t&&e>=0){c.size=n,c.start=s,c.skip=l,l+=4,n+=4,i.next();continue}let a=i.pos-e;if(e<0||a=o?4:0,d=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break e;u+=4}else i.id>=o&&(u+=4);i.next()}s=d,n+=e,l+=u}return(t<0||n==e)&&(c.size=n,c.start=s,c.skip=l),c.size>4?c:void 0}(a.pos-t,g))){let t=new Uint16Array(S.size-S.skip),i=a.pos-S.size,r=t.length;for(;a.pos>i;)r=p(S.start,t,r);x=new ho(t,w-S.start,n),C=S.start-e}else{let e=a.pos-b;a.next();let t=[],i=[],n=v>=o?v:-1,s=0,l=w;for(;a.pos>e;)n>=0&&a.id==n&&a.size>=0?(a.end<=l-r&&(d(t,i,y,s,a.end,l,n,k),s=t.length,l=a.end),a.next()):u(y,e,t,i,n);if(n>=0&&s>0&&s-1&&s>0){let e=function(e){return(t,i,n)=>{let r,s,o=0,a=t.length-1;if(a>=0&&(r=t[a])instanceof ao){if(!a&&r.type==e&&r.length==n)return r;(s=r.prop(eo.lookAhead))&&(o=i[a]+r.length+s)}return f(e,t,i,n,o)}}(O);x=So(O,t,i,0,t.length,0,w-y,e,e)}else x=f(O,t,i,w-y,k-w)}i.push(x),m.push(C)}function d(e,t,i,r,s,o,a,l){let h=[],c=[];for(;e.length>r;)h.push(e.pop()),c.push(t.pop()+i-s);e.push(f(n.types[a],h,c,o-s,l-o)),t.push(s-i)}function f(e,t,i,n,r=0,s){if(h){let e=[eo.contextHash,h];s=s?[e].concat(s):[e]}if(r>25){let e=[eo.lookAhead,r];s=s?[e].concat(s):[e]}return new ao(e,t,i,n,s)}function p(e,t,i){let{id:n,start:r,end:s,size:l}=a;if(a.next(),l>=0&&n4){let n=a.pos-(l-4);for(;a.pos>n;)i=p(e,t,i)}t[--i]=o,t[--i]=s-e,t[--i]=r-e,t[--i]=n}else-3==l?h=n:-4==l&&(c=n);return i}let m=[],g=[];for(;a.pos>0;)u(e.start||0,e.bufferStart||0,m,g,-1);let v=null!==(t=e.length)&&void 0!==t?t:m.length?g[0]+m[0].length:0;return new ao(l[e.topID],m.reverse(),g.reverse(),v)}(e)}}ao.empty=new ao(io.none,[],[],0);class lo{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new lo(this.buffer,this.index)}}class ho{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return io.none}toString(){let e=[];for(let t=0;t0));a=s[a+3]);return o}slice(e,t,i,n){let r=this.buffer,s=new Uint16Array(t-e);for(let n=e,o=0;n=t&&it;case 1:return i<=t&&n>t;case 2:return n>t;case 4:return!0}}function uo(e,t){let i=e.childBefore(t);for(;i;){let t=i.lastChild;if(!t||t.to!=i.to)break;t.type.isError&&t.from==t.to?(e=i,i=t.prevSibling):i=t}return e}function fo(e,t,i,n){for(var r;e.from==e.to||(i<1?e.from>=t:e.from>t)||(i>-1?e.to<=t:e.to0?o.length:-1;e!=l;e+=t){let l=o[e],h=a[e]+s.from;if(co(n,i,h,h+l.length))if(l instanceof ho){if(r&oo.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,t,i-h,n);if(o>-1)return new yo(new vo(s,l,e,h),null,o)}else if(r&oo.IncludeAnonymous||!l.type.isAnonymous||bo(l)){let o;if(!(r&oo.IgnoreMounts)&&l.props&&(o=l.prop(eo.mounted))&&!o.overlay)return new po(o.tree,h,e,s);let a=new po(l,h,e,s);return r&oo.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?l.children.length-1:0,t,i,n)}}if(r&oo.IncludeAnonymous||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let n;if(!(i&oo.IgnoreOverlays)&&(n=this._tree.prop(eo.mounted))&&n.overlay){let i=e-this.from;for(let{from:e,to:r}of n.overlay)if((t>0?e<=i:e=i:r>i))return new po(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new wo(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return fo(this,e,t,!1)}resolveInner(e,t=0){return fo(this,e,t,!0)}enterUnfinishedNodesBefore(e){return uo(this,e)}getChild(e,t=null,i=null){let n=mo(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return mo(this,e,t,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return go(this,e)}}function mo(e,t,i,n){let r=e.cursor(),s=[];if(!r.firstChild())return s;if(null!=i)for(;!r.type.is(i);)if(!r.nextSibling())return s;for(;;){if(null!=n&&r.type.is(n))return s;if(r.type.is(t)&&s.push(r.node),!r.nextSibling())return null==n?s:[]}}function go(e,t,i=t.length-1){for(let n=e.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[i]&&t[i]!=n.name)return!1;i--}}return!0}class vo{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class yo{constructor(e,t,i){this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new yo(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&oo.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new yo(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new yo(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new yo(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new wo(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];return r>n&&(e.push(i.slice(n,r,i.buffer[this.index+1],i.buffer[this.index+2])),t.push(0)),new ao(this.type,e,t,this.to-this.from)}resolve(e,t=0){return fo(this,e,t,!1)}resolveInner(e,t=0){return fo(this,e,t,!0)}enterUnfinishedNodesBefore(e){return uo(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,i=null){let n=mo(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return mo(this,e,t,i)}get node(){return this}matchContext(e){return go(this,e)}}class wo{constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof po)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}get name(){return this.type.name}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return!!e&&(e instanceof po?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?!(i&oo.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&oo.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&oo.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let e=i<0?0:this.stack[i]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(e)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index-1)for(let n=t+e,r=e<0?-1:i._tree.children.length;n!=r;n+=e){let e=i._tree.children[n];if(this.mode&oo.IncludeAnonymous||e instanceof ho||!e.type.isAnonymous||bo(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let s=e;s;s=s._parent)if(s.index==n){if(n==this.index)return s;t=s,i=r+1;break e}n=this.stack[--r]}for(let e=i;e=0;r--){if(r<0)return go(this.node,e,n);let s=i[t.buffer[this.stack[r]]];if(!s.isAnonymous){if(e[n]&&e[n]!=s.name)return!1;n--}}return!0}}function bo(e){return e.children.some(e=>e instanceof ho||!e.type.isAnonymous||bo(e))}const ko=new WeakMap;function xo(e,t){if(!e.isAnonymous||t instanceof ho||t.type!=e)return 1;let i=ko.get(t);if(null==i){i=1;for(let n of t.children){if(n.type!=e||!(n instanceof ao)){i=1;break}i+=xo(e,n)}ko.set(t,i)}return i}function So(e,t,i,n,r,s,o,a,l){let h=0;for(let i=n;i=c)break;p+=t}if(h==r+1){if(p>c){let e=i[r];t(e.children,e.positions,0,e.children.length,n[r]+a);continue}u.push(i[r])}else u.push(So(e,i,n,r,h,f,n[h-1]+i[h-1].length-f,null,l));d.push(f+a-s)}}(t,i,n,r,0),(a||l)(u,d,o)}class Oo{constructor(e,t,i,n,r=!1,s=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(r?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],i=!1){let n=[new Oo(0,e.length,e,0,!1,i)];for(let i of t)i.to>e.length&&n.push(i);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,s=e.length?e[0]:null;for(let o=0,a=0,l=0;;o++){let h=o=i)for(;s&&s.from=t.from||c<=t.to||l){let e=Math.max(t.from,a)-l,i=Math.min(t.to,c)-l;t=e>=i?null:new Oo(e,i,t.tree,t.offset+l,o>0,!!h)}if(t&&n.push(t),s.to>c)break;s=rnew Zs(e.from,e.to)):[new Zs(0,0)]:[new Zs(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let e=n.advance();if(e)return e}}}class Ao{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new eo({perNode:!0});let Eo=0;class Mo{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=Eo++}static define(e){if(null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new Mo([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new No;return t=>t.modified.indexOf(e)>-1?t:No.get(t.base||t,t.modified.concat(e).sort((e,t)=>e.id-t.id))}}let To=0;class No{constructor(){this.instances=[],this.id=To++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(i=>{return i.base==e&&(n=t).length==(r=i.modified).length&&n.every((e,t)=>e==r[t]);var n,r});if(i)return i;let n=[],r=new Mo(n,e,t);for(let e of t)e.instances.push(r);let s=Do(t);for(let t of e.set)for(let e of s)n.push(No.get(t,e));return r}}function Do(e){let t=[e];for(let i=0;i0&&t+3==e.length){r=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw new RangeError("Invalid path: "+e);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),t+=n[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){r=0;break}if("/"!=o)throw new RangeError("Invalid path: "+e);s=e.slice(t)}let o=i.length-1,a=i[o];if(!a)throw new RangeError("Invalid path: "+e);let l=new jo(n,r,o>0?i.slice(0,o):null);t[a]=l.sort(t[a])}}return Ro.add(t)}const Ro=new eo;class jo{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}sort(e){return!e||e.depth{let t=r;for(let n of e)for(let e of n.set){let n=i[e.id];if(n){t=t?t+" "+n:n;break}}return t},scope:n}}function Io(e,t){let i=null;for(let n of e){let e=n.style(t);e&&(i=i?i+" "+e:e)}return i}function Lo(e,t,i,n=0,r=e.length){let s=new Vo(n,Array.isArray(t)?t:[t],i);s.highlightRange(e.cursor(),n,r,"",s.highlighters),s.flush(r)}class Vo{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r){let{type:s,from:o,to:a}=e;if(o>=i||a<=t)return;s.isTop&&(r=this.highlighters.filter(e=>!e.scope||e.scope(s)));let l=n,h=s.prop(Ro),c=!1;for(;h;){if(!h.context||e.matchContext(h.context)){let e=Io(r,h.tags);e&&(l&&(l+=" "),l+=e,1==h.mode?n+=(n?" ":"")+e:0==h.mode&&(c=!0));break}h=h.next}if(this.startSpan(e.from,l),c)return;let u=e.tree&&e.tree.prop(eo.mounted);if(u&&u.overlay){let s=e.node.enter(u.overlay[0].from+o,1),h=this.highlighters.filter(e=>!e.scope||e.scope(u.tree.type)),c=e.firstChild();for(let d=0,f=o;;d++){let p=d=m)&&e.nextSibling()););if(!p||m>i)break;f=p.to+o,f>t&&(this.highlightRange(s.cursor(),Math.max(t,p.from+o),Math.min(i,f),n,h),this.startSpan(f,l))}c&&e.parent()}else if(e.firstChild()){do{if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,n,r),this.startSpan(Math.min(i,e.to),l)}}while(e.nextSibling());e.parent()}}}const _o=Mo.define,Ho=_o(),Fo=_o(),zo=_o(Fo),Wo=_o(Fo),qo=_o(),$o=_o(qo),Uo=_o(qo),Jo=_o(),Ko=_o(Jo),Go=_o(),Qo=_o(),Yo=_o(),Xo=_o(Yo),Zo=_o(),ea={comment:Ho,lineComment:_o(Ho),blockComment:_o(Ho),docComment:_o(Ho),name:Fo,variableName:_o(Fo),typeName:zo,tagName:_o(zo),propertyName:Wo,attributeName:_o(Wo),className:_o(Fo),labelName:_o(Fo),namespace:_o(Fo),macroName:_o(Fo),literal:qo,string:$o,docString:_o($o),character:_o($o),attributeValue:_o($o),number:Uo,integer:_o(Uo),float:_o(Uo),bool:_o(qo),regexp:_o(qo),escape:_o(qo),color:_o(qo),url:_o(qo),keyword:Go,self:_o(Go),null:_o(Go),atom:_o(Go),unit:_o(Go),modifier:_o(Go),operatorKeyword:_o(Go),controlKeyword:_o(Go),definitionKeyword:_o(Go),moduleKeyword:_o(Go),operator:Qo,derefOperator:_o(Qo),arithmeticOperator:_o(Qo),logicOperator:_o(Qo),bitwiseOperator:_o(Qo),compareOperator:_o(Qo),updateOperator:_o(Qo),definitionOperator:_o(Qo),typeOperator:_o(Qo),controlOperator:_o(Qo),punctuation:Yo,separator:_o(Yo),bracket:Xo,angleBracket:_o(Xo),squareBracket:_o(Xo),paren:_o(Xo),brace:_o(Xo),content:Jo,heading:Ko,heading1:_o(Ko),heading2:_o(Ko),heading3:_o(Ko),heading4:_o(Ko),heading5:_o(Ko),heading6:_o(Ko),contentSeparator:_o(Jo),list:_o(Jo),quote:_o(Jo),emphasis:_o(Jo),strong:_o(Jo),link:_o(Jo),monospace:_o(Jo),strikethrough:_o(Jo),inserted:_o(),deleted:_o(),changed:_o(),invalid:_o(),meta:Zo,documentMeta:_o(Zo),annotation:_o(Zo),processingInstruction:_o(Zo),definition:Mo.defineModifier(),constant:Mo.defineModifier(),function:Mo.defineModifier(),standard:Mo.defineModifier(),local:Mo.defineModifier(),special:Mo.defineModifier()};var ta;Bo([{tag:ea.link,class:"tok-link"},{tag:ea.heading,class:"tok-heading"},{tag:ea.emphasis,class:"tok-emphasis"},{tag:ea.strong,class:"tok-strong"},{tag:ea.keyword,class:"tok-keyword"},{tag:ea.atom,class:"tok-atom"},{tag:ea.bool,class:"tok-bool"},{tag:ea.url,class:"tok-url"},{tag:ea.labelName,class:"tok-labelName"},{tag:ea.inserted,class:"tok-inserted"},{tag:ea.deleted,class:"tok-deleted"},{tag:ea.literal,class:"tok-literal"},{tag:ea.string,class:"tok-string"},{tag:ea.number,class:"tok-number"},{tag:[ea.regexp,ea.escape,ea.special(ea.string)],class:"tok-string2"},{tag:ea.variableName,class:"tok-variableName"},{tag:ea.local(ea.variableName),class:"tok-variableName tok-local"},{tag:ea.definition(ea.variableName),class:"tok-variableName tok-definition"},{tag:ea.special(ea.variableName),class:"tok-variableName2"},{tag:ea.definition(ea.propertyName),class:"tok-propertyName tok-definition"},{tag:ea.typeName,class:"tok-typeName"},{tag:ea.namespace,class:"tok-namespace"},{tag:ea.className,class:"tok-className"},{tag:ea.macroName,class:"tok-macroName"},{tag:ea.propertyName,class:"tok-propertyName"},{tag:ea.operator,class:"tok-operator"},{tag:ea.comment,class:"tok-comment"},{tag:ea.meta,class:"tok-meta"},{tag:ea.invalid,class:"tok-invalid"},{tag:ea.punctuation,class:"tok-punctuation"}]);const ia=/*@__PURE__*/new eo;class na{constructor(e,t,i=[]){this.data=e,Ae.prototype.hasOwnProperty("tree")||Object.defineProperty(Ae.prototype,"tree",{get(){return oa(this)}}),this.parser=t,this.extension=[ma.of(this),Ae.languageData.of((e,t,i)=>e.facet(ra(e,t,i)))].concat(i)}isActiveAt(e,t,i=-1){return ra(e,t,i)==this.data}findRegions(e){let t=e.facet(ma);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(e,t)=>{if(e.prop(ia)==this.data)return void i.push({from:t,to:t+e.length});let r=e.prop(eo.mounted);if(r){if(r.tree.prop(ia)==this.data){if(r.overlay)for(let e of r.overlay)i.push({from:e.from+t,to:e.to+t});else i.push({from:t,to:t+e.length});return}if(r.overlay){let e=i.length;if(n(r.tree,r.overlay[0].from+t),i.length>e)return}}for(let i=0;ie.concat(i):void 0});var i;return new sa(t,e.parser.configure({props:[ia.add(e=>e.isTop?t:void 0)]}))}configure(e){return new sa(this.data,this.parser.configure(e))}get allowsNesting(){return this.parser.hasWrappers()}}function oa(e){let t=e.field(na.state,!1);return t?t.tree:ao.empty}class aa{constructor(e,t=e.length){this.doc=e,this.length=t,this.cursorPos=0,this.string="",this.cursor=e.iter()}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let la=null;class ha{constructor(e,t,i=[],n,r,s,o,a){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new ha(e,t,[],ao.empty,0,i,[],null)}startParse(){return this.parser.startParse(new aa(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=ao.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Oo.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=la;la=this;try{return e()}finally{la=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ca(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,i,n,r)=>t.push({fromA:e,toA:i,fromB:n,toB:r})),i=Oo.applyChanges(i,t),n=ao.empty,r=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){o=[];for(let t of this.skipped){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);ie.from&&(this.fragments=ca(this.fragments,i,n),this.skipped.splice(t--,1))}return!(this.skipped.length>=t||(this.reset(),0))}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Co{createParse(t,i,n){let r=n[0].from,s=n[n.length-1].to;return{parsedPos:r,advance(){let t=la;if(t){for(let e of n)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new ao(io.none,[],[],s-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return la}}function ca(e,t,i){return Oo.applyChanges(e,[{fromA:t,toA:i,fromB:t,toB:i}])}class ua{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new ua(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=ha.create(e.facet(ma).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ua(i)}}na.state=/*@__PURE__*/Q.define({create:ua.init,update(e,t){for(let e of t.effects)if(e.is(na.setState))return e.value;return t.startState.facet(ma)!=t.state.facet(ma)?ua.init(t.state):e.apply(t)}});let da=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(da=e=>{let t=-1,i=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(i):cancelIdleCallback(t)});const fa="undefined"!=typeof navigator&&(null===(ta=navigator.scheduling)||void 0===ta?void 0:ta.isInputPending)?()=>navigator.scheduling.isInputPending():null,pa=/*@__PURE__*/Ni.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(na.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(na.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=da(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,a=r.context.work(()=>fa&&fa()||Date.now()>s,n+(o?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:na.setState.of(new ua(r.context))})),this.chunkBudget>0&&(!a||o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>Ai(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ma=/*@__PURE__*/W.define({combine:e=>e.length?e[0]:null,enables:[na.state,pa]});class ga{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const va=/*@__PURE__*/W.define(),ya=/*@__PURE__*/W.define({combine:e=>{if(!e.length)return" ";if(!/^(?: +|\t+)$/.test(e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return e[0]}});function wa(e){let t=e.facet(ya);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function ba(e,t){let i="",n=e.tabSize;if(9==e.facet(ya).charCodeAt(0))for(;t>=n;)i+="\t",t-=n;for(let e=0;e=i.from&&n<=i.to?r&&n==e?{text:"",from:e}:(t<0?n-1&&(r+=s-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return qe(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(n);if(e>-1)return e}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Sa=/*@__PURE__*/new eo;function Oa(e){let t=e.type.prop(Sa);if(t)return t;let i,n=e.firstChild;if(n&&(i=n.type.prop(eo.closedBy))){let t=e.lastChild,n=t&&i.indexOf(t.name)>-1;return e=>function(e,t,i,n,r){let s=e.textAfter.match(/^\s*/)[0].length,o=r==e.pos+s,a=function(e){let t=e.node,i=t.childAfter(t.from),n=t.lastChild;if(!i)return null;let r=e.options.simulateBreak,s=e.state.doc.lineAt(i.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let e=i.to;;){let r=t.childAfter(e);if(!r||r==n)return null;if(!r.type.isSkipped)return r.from{let n=e&&e.test(i.textAfter);return i.baseIndent+(n?0:t*i.unit)}}const Na=/*@__PURE__*/new eo;class Da{constructor(e,t){let i;function n(e){let t=Ke.newName();return(i||(i=Object.create(null)))["."+t]=e,t}const r="string"==typeof t.all?t.all:t.all?n(t.all):void 0,s=t.scope;this.scope=s instanceof na?e=>e.prop(ia)==s.data:s?e=>e==s:void 0,this.style=Bo(e.map(e=>({tag:e.tag,class:e.class||n(Object.assign({},e,{tag:null}))})),{all:r}).style,this.module=i?new Ke(i):null,this.themeType=t.themeType}static define(e,t){return new Da(e,t||{})}}const Pa=/*@__PURE__*/W.define(),Ra=/*@__PURE__*/W.define({combine:e=>e.length?[e[0]]:null});function ja(e){let t=e.facet(Pa);return t.length?t:e.facet(Ra)}function Ba(e,t){let i,n=[La];return e instanceof Da&&(e.module&&n.push(Nr.styleModule.of(e.module)),i=e.themeType),n.push((null==t?void 0:t.fallback)?Ra.of(e):i?Pa.computeN([Nr.darkTheme],t=>t.facet(Nr.darkTheme)==("dark"==i)?[e]:[]):Pa.of(e)),n}class Ia{constructor(e){this.markCache=Object.create(null),this.tree=oa(e.state),this.decorations=this.buildDeco(e,ja(e.state))}update(e){let t=oa(e.state),i=ja(e.state),n=i!=ja(e.startState);t.length{i.add(e,t,this.markCache[n]||(this.markCache[n]=oi.mark({class:n})))},n,r);return i.finish()}}const La=/*@__PURE__*/X.high(/*@__PURE__*/Ni.fromClass(Ia,{decorations:e=>e.decorations})),Va=/*@__PURE__*/Da.define([{tag:ea.meta,color:"#7a757a"},{tag:ea.link,textDecoration:"underline"},{tag:ea.heading,textDecoration:"underline",fontWeight:"bold"},{tag:ea.emphasis,fontStyle:"italic"},{tag:ea.strong,fontWeight:"bold"},{tag:ea.strikethrough,textDecoration:"line-through"},{tag:ea.keyword,color:"#708"},{tag:[ea.atom,ea.bool,ea.url,ea.contentSeparator,ea.labelName],color:"#219"},{tag:[ea.literal,ea.inserted],color:"#164"},{tag:[ea.string,ea.deleted],color:"#a11"},{tag:[ea.regexp,ea.escape,/*@__PURE__*/ea.special(ea.string)],color:"#e40"},{tag:/*@__PURE__*/ea.definition(ea.variableName),color:"#00f"},{tag:/*@__PURE__*/ea.local(ea.variableName),color:"#30a"},{tag:[ea.typeName,ea.namespace],color:"#085"},{tag:ea.className,color:"#167"},{tag:[/*@__PURE__*/ea.special(ea.variableName),ea.macroName],color:"#256"},{tag:/*@__PURE__*/ea.definition(ea.propertyName),color:"#00c"},{tag:ea.comment,color:"#940"},{tag:ea.invalid,color:"#f00"}]),_a=/*@__PURE__*/Nr.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Ha="()[]{}",Fa=/*@__PURE__*/W.define({combine:e=>Ee(e,{afterCursor:!0,brackets:Ha,maxScanDistance:1e4,renderMatch:qa})}),za=/*@__PURE__*/oi.mark({class:"cm-matchingBracket"}),Wa=/*@__PURE__*/oi.mark({class:"cm-nonmatchingBracket"});function qa(e){let t=[],i=e.matched?za:Wa;return t.push(i.range(e.start.from,e.start.to)),e.end&&t.push(i.range(e.end.from,e.end.to)),t}const $a=/*@__PURE__*/Q.define({create:()=>oi.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let i=[],n=t.state.facet(Fa);for(let e of t.state.selection.ranges){if(!e.empty)continue;let r=Ga(t.state,e.head,-1,n)||e.head>0&&Ga(t.state,e.head-1,1,n)||n.afterCursor&&(Ga(t.state,e.head,1,n)||e.headNr.decorations.from(e)}),Ua=[$a,_a];function Ja(e={}){return[Fa.of(e),Ua]}function Ka(e,t,i){let n=e.prop(t<0?eo.openedBy:eo.closedBy);if(n)return n;if(1==e.name.length){let n=i.indexOf(e.name);if(n>-1&&n%2==(t<0?1:0))return[i[n+t]]}return null}function Ga(e,t,i,n={}){let r=n.maxScanDistance||1e4,s=n.brackets||Ha,o=oa(e),a=o.resolveInner(t,i);for(let e=a;e;e=e.parent){let t=Ka(e.type,i,s);if(t&&e.from0)return null;let h={from:i<0?t-1:t,to:i>0?t+1:t},c=e.doc.iterRange(t,i>0?e.doc.length:0),u=0;for(let e=0;!c.next().done&&e<=s;){let s=c.value;i<0&&(e+=s.length);let a=t+e*i;for(let e=i>0?0:s.length-1,t=i>0?s.length:-1;e!=t;e+=i){let t=o.indexOf(s[e]);if(!(t<0||n.resolveInner(a+e,1).type!=r))if(t%2==0==i>0)u++;else{if(1==u)return{start:h,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};u--}}i>0&&(e+=s.length)}return c.done?{start:h,matched:!1}:null}(e,t,i,o,a.type,r,s)}function Qa(e,t,i,n,r,s){let o=n.parent,a={from:n.from,to:n.to},l=0,h=null==o?void 0:o.cursor();if(h&&(i<0?h.childBefore(n.from):h.childAfter(n.to)))do{if(i<0?h.to<=n.from:h.from>=n.to){if(0==l&&r.indexOf(h.type.name)>-1&&h.from-1||(Za.push(e),console.warn(t))}function il(e,t){let i=null;for(let n of t.split(".")){let t=e[n]||ea[n];t?"function"==typeof t?i?i=t(i):tl(n,`Modifier ${n} used at start of tag`):i?tl(n,`Tag ${n} used as modifier`):i=t:tl(n,`Unknown highlighting tag ${n}`)}if(!i)return 0;let n=t.replace(/ /g,"_"),r=io.define({id:Xa.length,name:n,props:[Po({[n]:i})]});return Xa.push(r),r.id}function nl(e,t){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let r=e(t,i);return!!r&&(n(i.update(r)),!0)}}const rl=/*@__PURE__*/nl(hl,0),sl=/*@__PURE__*/nl(ll,0),ol=/*@__PURE__*/nl((e,t)=>ll(e,t,function(e){let t=[];for(let i of e.selection.ranges){let n=e.doc.lineAt(i.from),r=i.to<=n.to?n:e.doc.lineAt(i.to),s=t.length-1;s>=0&&t[s].to>n.from?t[s].to=r.to:t.push({from:n.from,to:r.to})}return t}(t)),0);function al(e,t=e.selection.main.head){let i=e.languageDataAt("commentTokens",t);return i.length?i[0]:{}}function ll(e,t,i=t.selection.ranges){let n=i.map(e=>al(t,e.from).block);if(!n.every(e=>e))return null;let r=i.map((e,i)=>function(e,{open:t,close:i},n,r){let s,o,a=e.sliceDoc(n-50,n),l=e.sliceDoc(r,r+50),h=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(l)[0].length,u=a.length-h;if(a.slice(u-t.length,u)==t&&l.slice(c,c+i.length)==i)return{open:{pos:n-h,margin:h&&1},close:{pos:r+c,margin:c&&1}};r-n<=100?s=o=e.sliceDoc(n,r):(s=e.sliceDoc(n,n+50),o=e.sliceDoc(r-50,r));let d=/^\s*/.exec(s)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-i.length;return s.slice(d,d+t.length)==t&&o.slice(p,p+i.length)==i?{open:{pos:n+d+t.length,margin:/\s/.test(s.charAt(d+t.length))?1:0},close:{pos:r-f-i.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(t,n[i],e.from,e.to));if(2!=e&&!r.every(e=>e))return{changes:t.changes(i.map((e,t)=>r[t]?[]:[{from:e.from,insert:n[t].open+" "},{from:e.to,insert:" "+n[t].close}]))};if(1!=e&&r.some(e=>e)){let e=[];for(let t,i=0;ir&&(e==s||s>a.from)){r=a.from;let e=al(t,i).line;if(!e)continue;let s=/^\s*/.exec(a.text)[0].length,l=s==a.length,h=a.text.slice(s,s+e.length)==e?s:-1;se.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:i,indent:r,empty:s,single:o}of n)!o&&s||e.push({from:t.from+r,insert:i+" "});let i=t.changes(e);return{changes:i,selection:t.selection.map(i,1)}}if(1!=e&&n.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:i,token:r}of n)if(i>=0){let n=t.from+i,s=n+r.length;" "==t.text[s-t.from]&&s++,e.push({from:n,to:s})}return{changes:e}}return null}const cl=/*@__PURE__*/de.define(),ul=/*@__PURE__*/de.define(),dl=/*@__PURE__*/W.define(),fl=/*@__PURE__*/W.define({combine:e=>Ee(e,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}),pl=/*@__PURE__*/Q.define({create:()=>Nl.empty,update(e,t){let i=t.state.facet(fl),n=t.annotation(cl);if(n){let r=t.docChanged?H.single(function(e){let t=0;return e.iterChangedRanges((e,i)=>t=i),t}(t.changes)):void 0,s=kl.fromTransaction(t,r),o=n.side,a=0==o?e.undone:e.done;return a=s?xl(a,a.length,i.minDepth,s):Cl(a,t.startState.selection),new Nl(0==o?n.rest:a,0==o?a:n.rest)}let r=t.annotation(ul);if("full"!=r&&"before"!=r||(e=e.isolate()),!1===t.annotation(ge.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=kl.fromTransaction(t),o=t.annotation(ge.time),a=t.annotation(ge.userEvent);return s?e=e.addChanges(s,o,a,i.newGroupDelay,i.minDepth):t.selection&&(e=e.addSelection(t.startState.selection,o,a,i.newGroupDelay)),"full"!=r&&"after"!=r||(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new Nl(e.done.map(kl.fromJSON),e.undone.map(kl.fromJSON))});function ml(e={}){return[pl,fl.of(e),Nr.domEventHandlers({beforeinput(e,t){let i="historyUndo"==e.inputType?vl:"historyRedo"==e.inputType?yl:null;return!!i&&(e.preventDefault(),i(t))}})]}function gl(e,t){return function({state:i,dispatch:n}){if(!t&&i.readOnly)return!1;let r=i.field(pl,!1);if(!r)return!1;let s=r.pop(e,i,t);return!!s&&(n(s),!0)}}const vl=/*@__PURE__*/gl(0,!1),yl=/*@__PURE__*/gl(1,!1),wl=/*@__PURE__*/gl(0,!0),bl=/*@__PURE__*/gl(1,!0);class kl{constructor(e,t,i,n,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(e){return new kl(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new kl(e.changes&&P.fromJSON(e.changes),[],e.mapped&&D.fromJSON(e.mapped),e.startSelection&&H.fromJSON(e.startSelection),e.selectionsAfter.map(H.fromJSON))}static fromTransaction(e,t){let i=Ol;for(let t of e.startState.facet(dl)){let n=t(e);n.length&&(i=i.concat(n))}return!i.length&&e.changes.empty?null:new kl(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ol)}static selection(e){return new kl(void 0,Ol,void 0,void 0,e)}}function xl(e,t,i,n){let r=e.slice(t+1>i+20?t-i-1:0,t);return r.push(n),r}function Sl(e,t){return e.length?t.length?e.concat(t):e:t}const Ol=[];function Cl(e,t){if(e.length){let i=e[e.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-200));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),xl(e,e.length-1,1e9,i.setSelAfter(n)))}return[kl.selection([t])]}function Al(e){let t=e[e.length-1],i=e.slice();return i[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),i}function El(e,t){if(!e.length)return e;let i=e.length,n=Ol;for(;i;){let r=Ml(e[i-1],t,n);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,i);return t[i-1]=r,t}t=r.mapped,i--,n=r.selectionsAfter}return n.length?[kl.selection(n)]:Ol}function Ml(e,t,i){let n=Sl(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):Ol,i);if(!e.changes)return kl.selection(n);let r=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new kl(r,me.mapEffects(e.effects,t),o,e.startSelection.map(s),n)}const Tl=/^(input\.type|delete)($|\.)/;class Nl{constructor(e,t,i=0,n){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Nl(this.done,this.undone):this}addChanges(e,t,i,n,r){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&!o.changes.empty&&e.changes&&(!i||Tl.test(i))&&(!o.selectionsAfter.length&&t-this.prevTimei.push(e,t)),t.iterChangedRanges((e,t,r,s)=>{for(let e=0;e=t&&r<=o&&(n=!0)}}),n}(o.changes,e.changes)||"input.type.compose"==i)?xl(s,s.length-1,r,new kl(e.changes.compose(o.changes),Sl(e.effects,o.effects),o.mapped,o.startSelection,Ol)):xl(s,s.length,r,e),new Nl(s,Ol,t,i)}addSelection(e,t,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Ol;return r.length>0&&t-this.prevTimee.empty!=o.ranges[t].empty).length?this:new Nl(Cl(this.done,e),this.undone,t,i);var s,o}addMapping(e){return new Nl(El(this.done,e),El(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let n=0==e?this.done:this.undone;if(0==n.length)return null;let r=n[n.length-1];if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:cl.of({side:e,rest:Al(n)}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let i=1==n.length?Ol:n.slice(0,n.length-1);return r.mapped&&(i=El(i,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:cl.of({side:e,rest:i}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}Nl.empty=/*@__PURE__*/new Nl(Ol,Ol);const Dl=[{key:"Mod-z",run:vl,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:yl,preventDefault:!0},{linux:"Ctrl-Shift-z",run:yl,preventDefault:!0},{key:"Mod-u",run:wl,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:bl,preventDefault:!0}];function Pl(e,t){return H.create(e.ranges.map(t),e.mainIndex)}function Rl(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function jl({state:e,dispatch:t},i){let n=Pl(e.selection,i);return!n.eq(e.selection)&&(t(Rl(e,n)),!0)}function Bl(e,t){return H.cursor(t?e.to:e.from)}function Il(e,t){return jl(e,i=>i.empty?e.moveByChar(i,t):Bl(i,t))}function Ll(e){return e.textDirectionAt(e.state.selection.main.head)==Hi.LTR}const Vl=e=>Il(e,!Ll(e)),_l=e=>Il(e,Ll(e));function Hl(e,t){return jl(e,i=>i.empty?e.moveByGroup(i,t):Bl(i,t))}function Fl(e,t,i){if(t.type.prop(i))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function zl(e,t,i){let n,r,s=oa(e).resolveInner(t.head),o=i?eo.closedBy:eo.openedBy;for(let n=t.head;;){let t=i?s.childAfter(n):s.childBefore(n);if(!t)break;Fl(e,t,o)?s=t:n=i?t.to:t.from}return r=s.type.prop(o)&&(n=i?Ga(e,s.from,1):Ga(e,s.to,-1))&&n.matched?i?n.end.to:n.end.from:i?s.to:s.from,H.cursor(r,i?-1:1)}function Wl(e,t){return jl(e,i=>{if(!i.empty)return Bl(i,t);let n=e.moveVertically(i,t);return n.head!=i.head?n:e.moveToLineBoundary(i,t)})}const ql=e=>Wl(e,!1),$l=e=>Wl(e,!0);function Ul(e){return Math.max(e.defaultLineHeight,Math.min(e.dom.clientHeight,innerHeight)-5)}function Jl(e,t){let{state:i}=e,n=Pl(i.selection,i=>i.empty?e.moveVertically(i,t,Ul(e)):Bl(i,t));if(n.eq(i.selection))return!1;let r,s=e.coordsAtPos(i.selection.main.head),o=e.scrollDOM.getBoundingClientRect();return s&&s.top>o.top&&s.bottomJl(e,!1),Gl=e=>Jl(e,!0);function Ql(e,t,i){let n=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,i);if(r.head==t.head&&r.head!=(i?n.to:n.from)&&(r=e.moveToLineBoundary(t,i,!1)),!i&&r.head==n.from&&n.length){let i=/^\s*/.exec(e.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&t.head!=n.from+i&&(r=H.cursor(n.from+i))}return r}const Yl=e=>jl(e,t=>Ql(e,t,!0)),Xl=e=>jl(e,t=>Ql(e,t,!1));function Zl(e,t){let i=Pl(e.state.selection,e=>{let i=t(e);return H.range(e.anchor,i.head,i.goalColumn)});return!i.eq(e.state.selection)&&(e.dispatch(Rl(e.state,i)),!0)}function eh(e,t){return Zl(e,i=>e.moveByChar(i,t))}const th=e=>eh(e,!Ll(e)),ih=e=>eh(e,Ll(e));function nh(e,t){return Zl(e,i=>e.moveByGroup(i,t))}function rh(e,t){return Zl(e,i=>e.moveVertically(i,t))}const sh=e=>rh(e,!1),oh=e=>rh(e,!0);function ah(e,t){return Zl(e,i=>e.moveVertically(i,t,Ul(e)))}const lh=e=>ah(e,!1),hh=e=>ah(e,!0),ch=e=>Zl(e,t=>Ql(e,t,!0)),uh=e=>Zl(e,t=>Ql(e,t,!1)),dh=({state:e,dispatch:t})=>(t(Rl(e,{anchor:0})),!0),fh=({state:e,dispatch:t})=>(t(Rl(e,{anchor:e.doc.length})),!0),ph=({state:e,dispatch:t})=>(t(Rl(e,{anchor:e.selection.main.anchor,head:0})),!0),mh=({state:e,dispatch:t})=>(t(Rl(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function gh({state:e,dispatch:t},i){if(e.readOnly)return!1;let n="delete.selection",r=e.changeByRange(e=>{let{from:t,to:r}=e;if(t==r){let e=i(t);et&&(n="delete.forward"),t=Math.min(t,e),r=Math.max(r,e)}return t==r?{range:e}:{changes:{from:t,to:r},range:H.cursor(t)}});return!r.changes.empty&&(t(e.update(r,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?Nr.announce.of(e.phrase("Selection deleted")):void 0})),!0)}function vh(e,t,i){if(e instanceof Nr)for(let n of e.state.facet(Nr.atomicRanges).map(t=>t(e)))n.between(t,t,(e,n)=>{et&&(t=i?n:e)});return t}const yh=(e,t)=>gh(e,i=>{let n,r,{state:s}=e,o=s.doc.lineAt(i);if(!t&&i>o.from&&iyh(e,!1),bh=e=>yh(e,!0),kh=(e,t)=>gh(e,i=>{let n=i,{state:r}=e,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let e=null;;){if(n==(t?s.to:s.from)){n==i&&s.number!=(t?r.doc.lines:1)&&(n+=t?1:-1);break}let a=x(s.text,n-s.from,t)+s.from,l=s.text.slice(Math.min(n,a)-s.from,Math.max(n,a)-s.from),h=o(l);if(null!=e&&h!=e)break;" "==l&&n==i||(e=h),n=a}return vh(e,n,t)}),xh=e=>kh(e,!1),Sh=e=>gh(e,t=>{let i=e.lineBlockAt(t).to;return vh(e,t=r.number){let e=t[t.length-1];e.to=s.to,e.ranges.push(n)}else t.push({from:r.from,to:s.to,ranges:[n]});i=s.number+1}return t}function Ch(e,t,i){if(e.readOnly)return!1;let n=[],r=[];for(let t of Oh(e)){if(i?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(i?t.to+1:t.from-1),o=s.length+1;if(i){n.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak});for(let i of t.ranges)r.push(H.range(Math.min(e.doc.length,i.anchor+o),Math.min(e.doc.length,i.head+o)))}else{n.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text});for(let e of t.ranges)r.push(H.range(e.anchor-o,e.head-o))}}return!!n.length&&(t(e.update({changes:n,scrollIntoView:!0,selection:H.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}function Ah(e,t,i){if(e.readOnly)return!1;let n=[];for(let t of Oh(e))n.push(i?{from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}:{from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});return t(e.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Eh=/*@__PURE__*/Mh(!1);function Mh(e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{let{from:n,to:r}=i,s=t.doc.lineAt(n),o=!e&&n==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let i,n=oa(e).resolveInner(t),r=n.childBefore(t),s=n.childAfter(t);return r&&s&&r.to<=t&&s.from>=t&&(i=r.type.prop(eo.closedBy))&&i.indexOf(s.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(s.from).from?{from:r.to,to:s.from}:null}(t,n);e&&(n=r=(r<=s.to?s:t.doc.lineAt(r)).to);let a=new xa(t,{simulateBreak:n,simulateDoubleBreak:!!o}),l=ka(a,n);for(null==l&&(l=/^\s*/.exec(t.doc.lineAt(n).text)[0].length);rs.from&&n{let r=[];for(let s=n.from;s<=n.to;){let o=e.doc.lineAt(s);o.number>i&&(n.empty||n.to>o.from)&&(t(o,r,n),i=o.number),s=o.to+1}let s=e.changes(r);return{changes:r,range:H.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}const Nh=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Th(e,(t,i)=>{i.push({from:t.from,insert:e.facet(ya)})}),{userEvent:"input.indent"})),!0),Dh=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Th(e,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let r=qe(n,e.tabSize),s=0,o=ba(e,Math.max(0,r-wa(e)));for(;sjl(e,t=>zl(e.state,t,!Ll(e))),shift:e=>Zl(e,t=>zl(e.state,t,!Ll(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>jl(e,t=>zl(e.state,t,Ll(e))),shift:e=>Zl(e,t=>zl(e.state,t,Ll(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>Ch(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>Ah(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>Ch(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>Ah(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let i=e.selection,n=null;return i.ranges.length>1?n=H.create([i.main]):i.main.empty||(n=H.create([H.cursor(i.main.head)])),!!n&&(t(Rl(e,n)),!0)}},{key:"Mod-Enter",run:/*@__PURE__*/Mh(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let i=Oh(e).map(({from:t,to:i})=>H.range(t,Math.min(i+1,e.doc.length)));return t(e.update({selection:H.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let i=Pl(e.selection,t=>{var i;let n=oa(e).resolveInner(t.head,1);for(;!(n.from=t.to||n.to>t.to&&n.from<=t.from)&&(null===(i=n.parent)||void 0===i?void 0:i.parent);)n=n.parent;return H.range(n.to,n.from)});return t(Rl(e,i)),!0},preventDefault:!0},{key:"Mod-[",run:Dh},{key:"Mod-]",run:Nh},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=Object.create(null),n=new xa(e,{overrideIndentation:e=>{let t=i[e];return null==t?-1:t}}),r=Th(e,(t,r,s)=>{let o=ka(n,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let a=/^\s*/.exec(t.text)[0],l=ba(e,o);(a!=l||s.from{if(e.state.readOnly)return!1;let{state:t}=e,i=t.changes(Oh(t).map(({from:e,to:i})=>(e>0?e--:ie.moveVertically(t,!0)).map(i);return e.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t,i){let n=!1,r=Pl(e.selection,t=>{let i=Ga(e,t.head,-1)||Ga(e,t.head,1)||t.head>0&&Ga(e,t.head-1,1)||t.head{let t=al(e.state);return t.line?rl(e):!!t.block&&ol(e)}},{key:"Alt-A",run:sl}].concat(/*@__PURE__*/[{key:"ArrowLeft",run:Vl,shift:th,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>Hl(e,!Ll(e)),shift:e=>nh(e,!Ll(e))},{mac:"Cmd-ArrowLeft",run:Xl,shift:uh},{key:"ArrowRight",run:_l,shift:ih,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>Hl(e,Ll(e)),shift:e=>nh(e,Ll(e))},{mac:"Cmd-ArrowRight",run:Yl,shift:ch},{key:"ArrowUp",run:ql,shift:sh,preventDefault:!0},{mac:"Cmd-ArrowUp",run:dh,shift:ph},{mac:"Ctrl-ArrowUp",run:Kl,shift:lh},{key:"ArrowDown",run:$l,shift:oh,preventDefault:!0},{mac:"Cmd-ArrowDown",run:fh,shift:mh},{mac:"Ctrl-ArrowDown",run:Gl,shift:hh},{key:"PageUp",run:Kl,shift:lh},{key:"PageDown",run:Gl,shift:hh},{key:"Home",run:Xl,shift:uh,preventDefault:!0},{key:"Mod-Home",run:dh,shift:ph},{key:"End",run:Yl,shift:ch,preventDefault:!0},{key:"Mod-End",run:fh,shift:mh},{key:"Enter",run:Eh},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:wh,shift:wh},{key:"Delete",run:bh},{key:"Mod-Backspace",mac:"Alt-Backspace",run:xh},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>kh(e,!0)},{mac:"Mod-Backspace",run:e=>gh(e,t=>{let i=e.lineBlockAt(t).from;return vh(e,t>i?i:Math.max(0,t-1),!1)})},{mac:"Mod-Delete",run:Sh}].concat(/*@__PURE__*/[{key:"Ctrl-b",run:Vl,shift:th,preventDefault:!0},{key:"Ctrl-f",run:_l,shift:ih},{key:"Ctrl-p",run:ql,shift:sh},{key:"Ctrl-n",run:$l,shift:oh},{key:"Ctrl-a",run:e=>jl(e,t=>H.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>Zl(e,t=>H.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>jl(e,t=>H.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>Zl(e,t=>H.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:bh},{key:"Ctrl-h",run:wh},{key:"Ctrl-k",run:Sh},{key:"Ctrl-Alt-h",run:xh},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:c.of(["",""])},range:H.cursor(e.from)}));return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let i=t.from,n=e.doc.lineAt(i),r=i==n.from?i-1:x(n.text,i-n.from,!1)+n.from,s=i==n.to?i+1:x(n.text,i-n.from,!0)+n.from;return{changes:{from:r,to:s,insert:e.doc.slice(i,s).append(e.doc.slice(r,i))},range:H.cursor(s)}});return!i.changes.empty&&(t(e.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Gl}].map(e=>({mac:e.key,run:e.run,shift:e.shift})))),Rh={key:"Tab",run:Nh,shift:Dh},jh={brackets:["(","[","{","'",'"'],before:")]}:;>"},Bh=/*@__PURE__*/me.define({map(e,t){let i=t.mapPos(e,-1,N.TrackAfter);return null==i?void 0:i}}),Ih=/*@__PURE__*/me.define({map:(e,t)=>t.mapPos(e)}),Lh=/*@__PURE__*/new class extends Me{};Lh.startSide=1,Lh.endSide=-1;const Vh=/*@__PURE__*/Q.define({create:()=>Pe.empty,update(e,t){if(t.selection){let i=t.state.doc.lineAt(t.selection.main.head).from,n=t.startState.doc.lineAt(t.startState.selection.main.head).from;i!=t.changes.mapPos(n,-1)&&(e=Pe.empty)}e=e.map(t.changes);for(let i of t.effects)i.is(Bh)?e=e.update({add:[Lh.range(i.value,i.value+1)]}):i.is(Ih)&&(e=e.update({filter:e=>e!=i.value}));return e}}),_h="()[]{}<>";function Hh(e){for(let t=0;t<_h.length;t+=2)if(_h.charCodeAt(t)==e)return _h.charAt(t+1);return function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}(e<128?e:e+1)}const Fh="object"==typeof navigator&&/*@__PURE__*/ /Android\b/.test(navigator.userAgent),zh=/*@__PURE__*/Nr.inputHandler.of((e,t,i,n)=>{if((Fh?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(n.length>2||2==n.length&&1==M(E(n,0))||t!=r.from||i!=r.to)return!1;let s=function(e,t){let i=function(e,t){return e.languageDataAt("closeBrackets",t)[0]||jh}(e,e.selection.main.head),n=i.brackets||jh.brackets;for(let r of n){let s=Hh(E(r,0));if(t==r)return s==r?Jh(e,r,n.indexOf(r+r+r)>-1):$h(e,r,s,i.before||jh.before);if(t==s&&Wh(e,e.selection.main.from))return Uh(e,0,s)}return null}(e.state,n);return!!s&&(e.dispatch(s),!0)});function Wh(e,t){let i=!1;return e.field(Vh).between(0,e.doc.length,e=>{e==t&&(i=!0)}),i}function qh(e,t){let i=e.sliceString(t,t+2);return i.slice(0,M(E(i,0)))}function $h(e,t,i,n){let r=null,s=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:i,from:s.to}],effects:Bh.of(s.to+t.length),range:H.range(s.anchor+t.length,s.head+t.length)};let o=qh(e.doc,s.head);return!o||/\s/.test(o)||n.indexOf(o)>-1?{changes:{insert:t+i,from:s.head},effects:Bh.of(s.head+t.length),range:H.cursor(s.head+t.length)}:{range:r=s}});return r?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Uh(e,t,i){let n=null,r=e.selection.ranges.map(t=>t.empty&&qh(e.doc,t.head)==i?H.cursor(t.head+i.length):n=t);return n?null:e.update({selection:H.create(r,e.selection.mainIndex),scrollIntoView:!0,effects:e.selection.ranges.map(({from:e})=>Ih.of(e))})}function Jh(e,t,i){let n=null,r=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:Bh.of(r.to+t.length),range:H.range(r.anchor+t.length,r.head+t.length)};let s=r.head,o=qh(e.doc,s);if(o==t){if(Kh(e,s))return{changes:{insert:t+t,from:s},effects:Bh.of(s+t.length),range:H.cursor(s+t.length)};if(Wh(e,s)){let n=i&&e.sliceDoc(s,s+3*t.length)==t+t+t;return{range:H.cursor(s+t.length*(n?3:1)),effects:Ih.of(s)}}}else{if(i&&e.sliceDoc(s-2*t.length,s)==t+t&&Kh(e,s-2*t.length))return{changes:{insert:t+t+t+t,from:s},effects:Bh.of(s+t.length),range:H.cursor(s+t.length)};if(e.charCategorizer(s)(o)!=Se.Word){let i=e.sliceDoc(s-1,s);if(i!=t&&e.charCategorizer(s)(i)!=Se.Word&&!function(e,t,i){let n=oa(e).resolveInner(t,-1);for(let r=0;r<5;r++){if(e.sliceDoc(n.from,n.from+i.length)==i){let t=n.firstChild;for(;t&&t.from==n.from&&t.to-t.from>i.length;){if(e.sliceDoc(t.to-i.length,t.to)==i)return!1;t=t.firstChild}return!0}let r=n.to==t&&n.parent;if(!r)break;n=r}return!1}(e,s,t))return{changes:{insert:t+t,from:s},effects:Bh.of(s+t.length),range:H.cursor(s+t.length)}}}return{range:n=r}});return n?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Kh(e,t){let i=oa(e).resolveInner(t+1);return i.parent&&i.from==t}function Gh(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var r=i[n];"string"==typeof r?e.setAttribute(n,r):null!=r&&(e[n]=r)}t++}for(;te.from==e.to||e.from==e.to-1&&i.doc.lineAt(e.from).to==e.from?oi.widget({widget:new pc(e),diagnostic:e}).range(e.from):oi.mark({attributes:{class:"cm-lintRange cm-lintRange-"+e.severity},diagnostic:e}).range(e.from,e.to)),!0);return new Xh(s,t,Zh(s))}}function Zh(e,t=null,i=0){let n=null;return e.between(i,1e9,(e,i,{spec:r})=>{if(!t||r.diagnostic==t)return n=new Yh(e,i,r.diagnostic),!1}),n}function ec(e,t){return!(!e.effects.some(e=>e.is(ic))&&!e.changes.touchesRange(t.pos))}function tc(e,t){return e.field(sc,!1)?t:t.concat(me.appendConfig.of([sc,Nr.decorations.compute([sc],e=>{let{selected:t,panel:i}=e.field(sc);return t&&i&&t.from!=t.to?oi.set([oc.range(t.from,t.to)]):oi.none}),xs(ac,{hideOn:ec}),wc]))}const ic=/*@__PURE__*/me.define(),nc=/*@__PURE__*/me.define(),rc=/*@__PURE__*/me.define(),sc=/*@__PURE__*/Q.define({create:()=>new Xh(oi.none,null,null),update(e,t){if(t.docChanged){let i=e.diagnostics.map(t.changes),n=null;if(e.selected){let r=t.changes.mapPos(e.selected.from,1);n=Zh(i,e.selected.diagnostic,r)||Zh(i,null,r)}e=new Xh(i,e.panel,n)}for(let i of t.effects)i.is(ic)?e=Xh.init(i.value,e.panel,t.state):i.is(nc)?e=new Xh(e.diagnostics,i.value?gc.open:null,e.selected):i.is(rc)&&(e=new Xh(e.diagnostics,e.panel,i.value));return e},provide:e=>[Ms.from(e,e=>e.panel),Nr.decorations.from(e,e=>e.diagnostics)]}),oc=/*@__PURE__*/oi.mark({class:"cm-lintRange cm-lintRange-active"});function ac(e,t,i){let{diagnostics:n}=e.state.field(sc),r=[],s=2e8,o=0;n.between(t-(i<0?1:0),t+(i>0?1:0),(e,n,{spec:a})=>{t>=e&&t<=n&&(e==n||(t>e||i>0)&&(t({dom:lc(e,r)})}:null}function lc(e,t){return Gh("ul",{class:"cm-tooltip-lint"},t.map(t=>fc(e,t,!1)))}const hc=e=>{let t=e.state.field(sc,!1);return!(!t||!t.panel||(e.dispatch({effects:nc.of(!1)}),0))},cc=/*@__PURE__*/W.define({combine:e=>Object.assign({sources:e.map(e=>e.source)},Ee(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null})),enables:/*@__PURE__*/Ni.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(cc);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){let e=Date.now();if(ePromise.resolve(e(this.view)))).then(t=>{let i=t.reduce((e,t)=>e.concat(t));this.view.state.doc==e.doc&&this.view.dispatch(function(e,t){return{effects:tc(e,[ic.of(t)])}}(this.view.state,i))},e=>{Ai(this.view.state,e)})}}update(e){let t=e.state.facet(cc);(e.docChanged||t!=e.startState.facet(cc))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}})});function uc(e,t={}){return cc.of({source:e,config:t})}function dc(e){let t=[];if(e)e:for(let{name:i}of e){for(let e=0;ee.toLowerCase()==n.toLowerCase())){t.push(n);continue e}}t.push("")}return t}function fc(e,t,i){var n;let r=i?dc(t.actions):[];return Gh("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Gh("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage():t.message),null===(n=t.actions)||void 0===n?void 0:n.map((i,n)=>{let s=n=>{n.preventDefault();let r=Zh(e.state.field(sc).diagnostics,t);r&&i.apply(e,r.from,r.to)},{name:o}=i,a=r[n]?o.indexOf(r[n]):-1,l=a<0?o:[o.slice(0,a),Gh("u",o.slice(a,a+1)),o.slice(a+1)];return Gh("button",{type:"button",class:"cm-diagnosticAction",onclick:s,onmousedown:s,"aria-label":` Action: ${o}${a<0?"":` (access key "${r[n]})"`}.`},l)}),t.source&&Gh("div",{class:"cm-diagnosticSource"},t.source))}class pc extends ri{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return Gh("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class mc{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=fc(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class gc{constructor(e){this.view=e,this.items=[],this.list=Gh("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)hc(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],n=dc(i.actions);for(let r=0;r{for(let t=0;thc(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(sc).selected;if(!e)return-1;for(let t=0;t{let a,l=-1;for(let e=i;ei&&(this.items.splice(i,l-i),n=!0)),t&&a.diagnostic==t.diagnostic?a.dom.hasAttribute("aria-selected")||(a.dom.setAttribute("aria-selected","true"),r=a):a.dom.hasAttribute("aria-selected")&&a.dom.removeAttribute("aria-selected"),i++});i({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{e.topt.bottom&&(this.list.scrollTop+=e.bottom-t.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Zh(this.view.state.field(sc).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:rc.of(t)})}static open(e){return new gc(e)}}function vc(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(e)}')`}function yc(e){return vc(``,'width="6" height="3"')}const wc=/*@__PURE__*/Nr.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:/*@__PURE__*/yc("#d11")},".cm-lintRange-warning":{backgroundImage:/*@__PURE__*/yc("orange")},".cm-lintRange-info":{backgroundImage:/*@__PURE__*/yc("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});class bc extends Ts{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce((e,t)=>{let i=t.severity;return"error"==i||"warning"==i&&"info"==e?i:e},"info")}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=e.state.facet(Ec).tooltipFilter;return n&&(i=n(i)),i.length&&(t.onmouseover=()=>function(e,t,i){function n(){let n=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);e.coordsAtPos(n.from)&&e.dispatch({effects:Oc.of({pos:n.from,above:!1,create:()=>({dom:lc(e,i),getCoords:()=>t.getBoundingClientRect()})})}),t.onmouseout=t.onmousemove=null,function(e,t){let i=n=>{let r=t.getBoundingClientRect();if(!(n.clientX>r.left-10&&n.clientXr.top-10&&n.clientY{clearTimeout(s),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(s),s=setTimeout(n,r)}}(e,t,i)),t}}function kc(e,t){let i=Object.create(null);for(let n of t){let t=e.lineAt(n.from);(i[t.from]||(i[t.from]=[])).push(n)}let n=[];for(let e in i)n.push(new bc(i[e]).range(+e));return Pe.of(n,!0)}const xc=/*@__PURE__*/Rs({class:"cm-gutter-lint",markers:e=>e.state.field(Sc)}),Sc=/*@__PURE__*/Q.define({create:()=>Pe.empty,update(e,t){e=e.map(t.changes);let i=t.state.facet(Ec).markerFilter;for(let n of t.effects)if(n.is(ic)){let r=n.value;i&&(r=i(r||[])),e=kc(t.state.doc,r.slice(0))}return e}}),Oc=/*@__PURE__*/me.define(),Cc=/*@__PURE__*/Q.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=ec(t,e)?null:Object.assign(Object.assign({},e),{pos:t.changes.mapPos(e.pos)})),t.effects.reduce((e,t)=>t.is(Oc)?t.value:e,e)),provide:e=>vs.from(e)}),Ac=/*@__PURE__*/Nr.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:/*@__PURE__*/vc('')},".cm-lint-marker-warning":{content:/*@__PURE__*/vc('')},".cm-lint-marker-error:before":{content:/*@__PURE__*/vc('')}}),Ec=/*@__PURE__*/W.define({combine:e=>Ee(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})});function Mc(e={}){return[Ec.of(e),Sc,xc,Ac,Cc]}class Tc{constructor(e,t,i,n,r,s,o,a,l,h=0,c){this.p=e,this.stack=t,this.state=i,this.reducePos=n,this.pos=r,this.score=s,this.buffer=o,this.bufferBase=a,this.curContext=l,this.lookAhead=h,this.parent=c}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let n=e.parser.context;return new Tc(e,[],t,i,i,0,[],0,n?new Nc(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,i=65535&e,{parser:n}=this.p,r=n.dynamicPrecedence(i);if(r&&(this.score+=r),0==t)return this.pushState(n.getGoto(this.state,i,!0),this.reducePos),is;)this.stack.pop();this.reduceContext(i,o)}storeNode(e,t,i,n=4,r=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]0&&0==e.buffer[n-4]&&e.buffer[n-1]>-1){if(t==i)return;if(e.buffer[n-2]>=t)return void(e.buffer[n-2]=i)}}if(r&&this.pos!=i){let r=this.buffer.length;if(r>0&&0!=this.buffer[r-4])for(;r>0&&this.buffer[r-2]>i;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,n>4&&(n-=4);this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=i,this.buffer[r+3]=n}else this.buffer.push(e,t,i,n)}shift(e,t,i){let n=this.pos;if(131072&e)this.pushState(65535&e,this.pos);else if(0==(262144&e)){let r=e,{parser:s}=this.p;(i>this.pos||t<=s.maxNode)&&(this.pos=i,s.stateFlag(r,1)||(this.reducePos=i)),this.pushState(r,n),this.shiftContext(t,n),t<=s.maxNode&&this.buffer.push(t,n,i,4)}else this.pos=i,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,i,4)}apply(e,t,i){65536&e?this.reduce(e):this.shift(e,t,i)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new Tc(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Pc(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==(65536&i))return!0;if(0==i)return!1;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let i=[];for(let n,r=0;r1&t&&e==n)||i.push(t[e],n)}t=i}let i=[];for(let e=0;e>19);if(n<0||t.getGoto(this.stack[n],i,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Nc{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}var Dc;!function(e){e[e.Insert=200]="Insert",e[e.Delete=190]="Delete",e[e.Reduce=100]="Reduce",e[e.MaxNext=4]="MaxNext",e[e.MaxInsertStackDepth=300]="MaxInsertStackDepth",e[e.DampenInsertStackDepth=120]="DampenInsertStackDepth"}(Dc||(Dc={}));class Pc{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,i=e>>19;0==i?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(i-1);let n=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=n}}class Rc{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Rc(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new Rc(this.stack,this.pos,this.index)}}class jc{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Bc=new jc;class Ic{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Bc,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,n=this.rangeIndex,r=this.pos+e;for(;ri.to:r>=i.to;){if(n==this.ranges.length-1)return null;let e=this.ranges[++n];r+=e.from-i.to,i=e}return r}peek(e){let t,i,n=this.chunkOff+e;if(n>=0&&n=this.chunk2Pos&&tn.to&&(this.chunk2=this.chunk2.slice(0,n.to-t)),i=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),i}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(null==i||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1:this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Bc,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(i+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return i}}class Lc{constructor(e,t){this.data=e,this.id=t}token(e,t){!function(e,t,i,n){let r=0,s=1<0){let i=e[n];if(a.allows(i)&&(-1==t.token.value||t.token.value==i||o.overrides(i,t.token.value))){t.acceptToken(i);break}}let n=t.next,l=0,h=e[r+2];if(!(t.next<0&&h>l&&65535==e[i+3*h-3])){for(;l>1,o=i+s+(s<<1),a=e[o+1];if(n=a)){r=e[o+2],t.advance();continue e}l=s+1}}break}r=e[i+3*h-1]}}(this.data,e,t,this.id)}}function Vc(e,t=Uint16Array){if("string"!=typeof e)return e;let i=null;for(let n=0,r=0;n=92&&t--,t>=34&&t--;let r=t-32;if(r>=46&&(r-=46,i=!0),s+=r,i)break;s*=46}i?i[r++]=s:i=new t(s)}return i}Lc.prototype.contextual=Lc.prototype.fallback=Lc.prototype.extend=!1;const _c="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let Hc=null;var Fc,zc;function Wc(e,t,i){let n=e.cursor(oo.IncludeAnonymous);for(n.moveTo(t);;)if(!(i<0?n.childBefore(t):n.childAfter(t)))for(;;){if((i<0?n.tot)&&!n.type.isError)return i<0?Math.max(0,Math.min(n.to-1,t-25)):Math.min(e.length,Math.max(n.from+1,t+25));if(i<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return i<0?0:e.length}}!function(e){e[e.Margin=25]="Margin"}(Fc||(Fc={}));class qc{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Wc(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Wc(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=s,null;if(r instanceof ao){if(s==e){if(s=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+r.length}}}class $c{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new jc)}getActions(e){let t=0,i=null,{parser:n}=e.p,{tokenizers:r}=n,s=n.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,a=0;for(let n=0;nh.end+25&&(a=Math.max(h.lookAhead,a)),0!=h.value)){let n=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!l.extend&&(i=h,t>n))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),i||e.pos!=this.stream.end||(i=new jc,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new jc,{pos:i,p:n}=e;return t.start=i,t.end=Math.min(i+1,n.stream.end),t.value=i==n.stream.end?n.parser.eofTerm:0,t}updateCachedToken(e,t,i){if(t.token(this.stream.reset(i.pos,e),i),e.value>-1){let{parser:t}=i.p;for(let n=0;n=0&&i.p.parser.dialect.allows(r>>1)){0==(1&r)?e.value=r>>1:e.extended=r>>1;break}}}else e.value=0,e.end=Math.min(i.p.stream.end,i.pos+1)}putAction(e,t,i,n){for(let t=0;t4*e.bufferLength?new qc(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,i=this.stacks,n=this.minStackPos,r=this.stacks=[];for(let s=0;sn)r.push(o);else{if(this.advanceStack(o,r,i))continue;{e||(e=[],t=[]),e.push(o);let i=this.tokens.getMainToken(o);t.push(i.value,i.end)}}break}}if(!r.length){let t=e&&function(e){let t=null;for(let i of e){let e=i.p.stoppedAt;(i.pos==i.p.stream.end||null!=e&&i.pos>e)&&i.p.parser.stateFlag(i.state,2)&&(!t||t.scorethis.stoppedAt?e[0]:this.runRecovery(e,t,r);if(i)return this.stackToTree(i.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(r.length>e)for(r.sort((e,t)=>t.score-e.score);r.length>e;)r.pop();r.some(e=>e.reducePos>n)&&this.recovering--}else if(r.length>1)e:for(let e=0;e500&&n.buffer.length>500){if(!((t.score-n.score||t.buffer.length-n.buffer.length)>0)){r.splice(e--,1);continue e}r.splice(i--,1)}}}this.minStackPos=r[0].pos;for(let e=1;e ":"";if(null!=this.stoppedAt&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,i=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(n);o;){let n=this.parser.nodeSet.types[o.type.id]==o.type?r.getGoto(e.state,o.type.id):-1;if(n>-1&&o.length&&(!t||(o.prop(eo.contextHash)||0)==i))return e.useNode(o,n),_c&&console.log(s+this.stackID(e)+` (via reuse of ${r.getName(o.type.id)})`),!0;if(!(o instanceof ao)||0==o.children.length||o.positions[0]>0)break;let a=o.children[0];if(!(a instanceof ao&&0==o.positions[0]))break;o=a}}let o=r.stateSlot(e.state,4);if(o>0)return e.reduce(o),_c&&console.log(s+this.stackID(e)+` (via always-reduce ${r.getName(65535&o)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let o=0;on?t.push(d):i.push(d)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Jc(e,t),!0}}runRecovery(e,t,i){let n=null,r=!1;for(let s=0;s ":"";if(o.deadEnd){if(r)continue;if(r=!0,o.restart(),_c&&console.log(h+this.stackID(o)+" (restarted)"),this.advanceFully(o,i))continue}let c=o.split(),u=h;for(let e=0;c.forceReduce()&&e<10&&(_c&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));e++)_c&&(u=this.stackID(c)+" -> ");for(let e of o.recoverByInsert(a))_c&&console.log(h+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,i);this.stream.end>o.pos?(l==o.pos&&(l++,a=0),o.recoverByDelete(a,l),_c&&console.log(h+this.stackID(o)+` (via recover-delete ${this.parser.getName(a)})`),Jc(o,i)):(!n||n.scoree.topRules[t][1]),n=[];for(let e=0;e=0)r(n,e,t[i++]);else{let s=t[i+-n];for(let o=-n;o>0;o--)r(t[i++],e,s);i++}}}this.nodeSet=new no(t.map((t,r)=>io.define({name:r>=this.minRepeatTerm?void 0:t,id:r,props:n[r],top:i.indexOf(r)>-1,error:0==r,skipped:e.skippedNodes&&e.skippedNodes.indexOf(r)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Ys;let s=Vc(e.tokenData);if(this.context=e.context,this.specialized=new Uint16Array(e.specialized?e.specialized.length:0),this.specializers=[],e.specialized)for(let t=0;t"number"==typeof e?new Lc(s,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let n=new Uc(this,e,t,i);for(let r of this.wrappers)n=r(n,e,t,i);return n}getGoto(e,t,i=!1){let n=this.goto;if(t>=n[0])return-1;for(let r=n[t+1];;){let t=n[r++],s=1&t,o=n[r++];if(s&&i)return o;for(let i=r+(t>>1);r0}validAction(e,t){if(t==this.stateSlot(e,4))return!0;for(let i=this.stateSlot(e,1);;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])return!1;i=Qc(this.data,i+2)}if(t==Qc(this.data,i+1))return!0}}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])break;i=Qc(this.data,i+2)}if(0==(1&this.data[i+2])){let e=this.data[i+1];t.some((t,i)=>1&i&&t==e)||t.push(this.data[i],e)}}return t}overrides(e,t){let i=Yc(this.data,this.tokenPrecTable,t);return i<0||Yc(this.data,this.tokenPrecTable,e){let i=e.tokenizers.find(e=>e.from==t);return i?i.to:t})),e.specializers&&(t.specializers=this.specializers.map(t=>{let i=e.specializers.find(e=>e.from==t);return i?i.to:t})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let n of e.split(" ")){let e=t.indexOf(n);e>=0&&(i[e]=!0)}let n=null;for(let e=0;e=0||(r[i]=e[i]);return r}var ru="§",su="__RJF_FILLER__",ou=/*#__PURE__*/r.default.createContext();function au(e){return e?e.charAt(0).toUpperCase()+e.substr(1).toLowerCase():""}function lu(e,t){return typeof e===t||("number"===t||"integer"===t?"string"==typeof e?""===(e=e.trim())?e=null:isNaN(Number(e))||(e=Number(e)):"boolean"==typeof e&&(e=!0===e?1:0):"boolean"===t&&(e="false"!==e&&!1!==e)),e}function hu(e){var t=typeof e;return"object"===t&&(Array.isArray(e)?t="array":null===e&&(t="null")),t}function cu(e){var t;return(t=e.hasOwnProperty("const")?hu(e.const):mu(e.type))||(t=e.hasOwnProperty("properties")||e.hasOwnProperty("keys")?"object":e.hasOwnProperty("items")?"array":e.hasOwnProperty("allOf")?"allOf":e.hasOwnProperty("oneOf")?"oneOf":e.hasOwnProperty("anyOf")?"anyOf":"string"),t}function uu(){var e=document.cookie.split(";").filter(function(e){return 0===e.trim().indexOf("csrftoken=")});if(e.length)return e[0].split("=")[1];var t=document.querySelector('input[name="csrfmiddlewaretoken"]');return t?t.value:null}function du(){return Array.from(arguments).join(ru)}function fu(e){return e.split(ru)}function pu(e){return e.slice("rjf§".length)}function mu(e){switch(Array.isArray(e)&&(e=e.find(function(e){return"null"!==e})||"null"),e){case"list":return"array";case"dict":return"object";case"keys":return"properties";case"choices":return"enum";case"datetime":return"date-time";default:return e}}function gu(e,t,i,n){return vu(e,t,vu(e,i,n))}function vu(e,t,i){var n=e[t];return void 0!==n?n:i}function yu(e,t){var i=gu(e,"choices","enum");return!i||void 0!==i.find(function(e){return"object"==typeof e&&(e=e.value),t==e})}function wu(e,t){var i={},n=gu(e,"keys","properties",{});for(var r in n){var s=n[r],o=s.hasOwnProperty("$ref"),a=s.hasOwnProperty("const");o&&delete(s=iu({},t(s.$ref),s)).$ref;var l=mu(s.type);l||(s.hasOwnProperty("oneOf")?s=s.oneOf[0]:s.hasOwnProperty("anyOf")&&(s=s.anyOf[0]),l=mu(s.type));var h=s.default;a&&(l=hu(s.const),h=s.const),i[r]="array"===l?o?[]:bu(s,t):"object"===l?wu(s,t):"boolean"===l?!1!==h&&(h||null):"integer"===l||"number"===l?0===h?0:h||null:h||""}if(e.hasOwnProperty("oneOf")&&(i=iu({},i,wu(e.oneOf[0]))),e.hasOwnProperty("anyOf")&&(i=iu({},i,wu(e.anyOf[0]))),e.hasOwnProperty("allOf"))for(var c=0;c=i)return e.default;var n=[];if(e.default&&(n=[].concat(e.default)),0===i)return n;e.items.hasOwnProperty("$ref")&&(e.items=iu({},t(e.items.$ref),e.items),delete e.items.$ref);var r=mu(e.items.type);if(r||(Array.isArray(e.items.oneOf)?r=cu(e.items.oneOf[0]):Array.isArray(e.items.anyOf)?r=cu(e.items.anyOf[0]):Array.isArray(e.items.allOf)?r=cu(e.items.allOf[0]):e.items.hasOwnProperty("const")&&(r=hu(e.items.const))),"array"===r){for(;n.length=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e);!(i=n()).done;)if(!t.has(i.value))return!1;return!0}(keyset2,keyset1))return!1}else if(n=keyset2,r=keyset1,n.size!==r.size||!Array.from(n).every(function(e){return r.has(e)}))return!1;for(var o in s)if(s.hasOwnProperty(o)){if(!e.hasOwnProperty(o))return!1;if(s[o].hasOwnProperty("const")&&s[o].const!==e[o])return!1;var a=mu(s[o].type),l=hu(e[o]);if("number"===a&&-1===["number","integer","null"].indexOf(l))return!1;if("integer"===a&&-1===["number","integer","null"].indexOf(l))return!1;if("boolean"===a&&-1===["boolean","null"].indexOf(l))return!1;if("string"===a&&"string"!==l)return!1}return!0}function Du(e,t){var i=hu(e);if(cu(t)!==i)return!1;for(var n=t.items.type,r=0;r12?1:"hh"!==e&&t>59?0:t},t.handleChange=function(e){var i,n=e.target.dataset.name,r=e.target.value;if(!isNaN(r)){var s=t.validateValue(n,parseInt(r)||0);"hh"!==n||"0"!==r&&""!==r&&"00"!==r||1!==s||(s=0),r.startsWith("0")&&s<10&&0!==s&&(s=s.toString().padStart(2,"0")),t.sendValue(((i={})[n]=""!==r?s.toString():"",i))}},t.handleKeyDown=function(e){var i;if(38===e.keyCode||40===e.keyCode){var n=e.target.dataset.name,r=parseInt(e.target.value)||0;38===e.keyCode?r++:40===e.keyCode&&r--,t.sendValue(((i={})[n]=t.validateValue(n,r).toString().padStart(2,"0"),i))}},t.handleSpin=function(e,i){var n,r=t.props[e];"ampm"===e?r="am"===r?"pm":"am":(r=parseInt(r)||0,"up"===i?r++:r--,r=t.validateValue(e,r).toString().padStart(2,"0")),t.sendValue(((n={})[e]=r,n))},t.handleBlur=function(e){var i,n=t.validateValue(e.target.dataset.name,parseInt(e.target.value)||0);n<10&&t.sendValue(((i={})[e.target.dataset.name]=n.toString().padStart(2,"0"),i))},t}a(t,e);var i=t.prototype;return i.componentWillUnmount=function(){var e={hh:this.validateValue("hh",this.props.hh).toString().padStart(2,"0"),mm:this.validateValue("mm",this.props.mm).toString().padStart(2,"0"),ss:this.validateValue("ss",this.props.ss).toString().padStart(2,"0")};this.sendValue(e)},i.render=function(){var e=this;/*#__PURE__*/return r.default.createElement("div",{className:"rjf-time-picker"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-row rjf-time-picker-labels"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},"Hrs"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},"Min"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},"Sec"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},"am/pm")),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-row"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("hh","up")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-up"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("mm","up")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-up"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("ss","up")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-up"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("ampm","up")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-up"})))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-row rjf-time-picker-values"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement("input",{type:"text","data-name":"hh",value:this.props.hh,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"},":"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement("input",{type:"text","data-name":"mm",value:this.props.mm,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"},":"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement("input",{type:"text","data-name":"ss",value:this.props.ss,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},this.props.ampm)),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-row"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("hh","down")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-down"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("mm","down")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-down"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("ss","down")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-down"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("ampm","down")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-down"})))))},t}(r.default.Component),qu=["label","help_text","error","inputRef"],$u=["label","help_text","error","value"],Uu=["label","help_text","error","value","options"],Ju=["label","help_text","error","value","options"],Ku=["label","value"],Gu=["label","help_text","error","inputRef"];function Qu(e){return e.label?/*#__PURE__*/r.default.createElement("label",{className:e.required?"rjf-required":null},e.children,e.children&&" ",e.label):null}function Yu(e){var t=e.label,i=e.help_text,n=e.error,s=e.inputRef,o=nu(e,qu);"string"===o.type&&(o.type="text"),s&&(o.ref=s),null===o.value&&(o.value="");var a={};return"hidden"==o.type&&(a.style={display:"none"}),o.readOnly&&null==o.disabled&&(o.disabled=!0),/*#__PURE__*/r.default.createElement("div",a,/*#__PURE__*/r.default.createElement(Qu,{label:t,required:o.required}),/*#__PURE__*/r.default.createElement("div",{className:n?"rjf-input-group has-error":"rjf-input-group"},o.children||/*#__PURE__*/r.default.createElement("input",o),n&&n.map(function(e,t){/*#__PURE__*/return r.default.createElement("span",{className:"rjf-error-text",key:t},e)}),i&&/*#__PURE__*/r.default.createElement("span",{className:"rjf-help-text"},i)))}function Xu(e){var t=e.label,i=e.help_text,n=e.error,s=e.value,o=nu(e,$u);return t||(t=o.name.toUpperCase()),"bool"===o.type&&(o.type="checkbox"),void 0===o.checked&&(o.checked=s),""!==o.checked&&null!=o.checked||(o.checked=!1),o.readOnly&&(o.disabled=!0),/*#__PURE__*/r.default.createElement("div",{className:n?"rjf-check-input has-error":"rjf-check-input"},/*#__PURE__*/r.default.createElement(Qu,{label:t,required:o.required},/*#__PURE__*/r.default.createElement("input",o)),n&&n.map(function(e,t){/*#__PURE__*/return r.default.createElement("span",{className:"rjf-error-text",key:t},e)}),i&&/*#__PURE__*/r.default.createElement("span",{className:"rjf-help-text"},i))}function Zu(e){var t=e.label,i=e.help_text,n=e.error,s=e.value,o=e.options,a=nu(e,Uu);return a.readOnly&&(a.disabled=!0),/*#__PURE__*/r.default.createElement("div",{className:n?"rjf-check-input has-error":"rjf-check-input"},/*#__PURE__*/r.default.createElement(Qu,{label:t,required:a.required}),o.map(function(e,t){var i,n;return"object"==typeof e?(i=e.title||e.label,n=e.value):("boolean"==typeof(i=e)&&(i=au(i.toString())),n=e),/*#__PURE__*/r.default.createElement("label",{className:"rjf-radio-option",key:i+"_"+n+"_"+t},/*#__PURE__*/r.default.createElement("input",iu({},a,{value:n,checked:n===s}))," ",i)}),n&&n.map(function(e,t){/*#__PURE__*/return r.default.createElement("span",{className:"rjf-error-text",key:t},e)}),i&&/*#__PURE__*/r.default.createElement("span",{className:"rjf-help-text"},i))}function ed(e){var t=e.label,i=e.help_text,n=e.error,s=e.value,o=e.options,a=nu(e,Ju);return a.readOnly&&(a.disabled=!0),s||!1===s||0===s||(s=""),/*#__PURE__*/r.default.createElement("div",null,/*#__PURE__*/r.default.createElement(Qu,{label:t,required:a.required}),/*#__PURE__*/r.default.createElement("div",{className:n?"rjf-input-group has-error":"rjf-input-group"},/*#__PURE__*/r.default.createElement("select",iu({value:s},a),/*#__PURE__*/r.default.createElement("option",{disabled:!0,value:"",key:"__placeholder"},"Select..."),o.map(function(e,t){var i,n;return"object"==typeof e?(i=e.title||e.label,n=e.value):("boolean"==typeof(i=e)&&(i=au(i.toString())),n=e),/*#__PURE__*/r.default.createElement("option",{value:n,key:i+"_"+n+"_"+t},i)})),n&&n.map(function(e,t){/*#__PURE__*/return r.default.createElement("span",{className:"rjf-error-text",key:t},e)}),i&&/*#__PURE__*/r.default.createElement("span",{className:"rjf-help-text"},i)))}var td=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).handleChange=function(e){var t=[].concat(i.props.value),n=e.target.value;typeof n!==i.props.valueType&&(n=lu(n,i.props.valueType)),e.target.checked?t.push(n):t=t.filter(function(e){return e!==n}),i.props.onChange({target:{type:i.props.type,value:t,name:i.props.name}})},i.showOptions=function(e){i.state.showOptions||i.setState({showOptions:!0})},i.hideOptions=function(e){i.setState({showOptions:!1})},i.toggleOptions=function(e){i.setState(function(e){return{showOptions:!e.showOptions}})},i.state={showOptions:!1},i.optionsContainer=/*#__PURE__*/r.default.createRef(),i.input=/*#__PURE__*/r.default.createRef(),i}return a(t,e),t.prototype.render=function(){/*#__PURE__*/return r.default.createElement("div",{className:this.props.readOnly?"rjf-multiselect-field readonly":"rjf-multiselect-field"},/*#__PURE__*/r.default.createElement(Yu,{label:this.props.label,help_text:this.props.help_text,error:this.props.error},/*#__PURE__*/r.default.createElement(id,{inputRef:this.input,onClick:this.toggleOptions,value:this.props.value,options:this.props.options,onChange:this.handleChange,disabled:this.props.readOnly,placeholder:this.props.placeholder})),this.state.showOptions&&/*#__PURE__*/r.default.createElement(nd,{options:this.props.options,value:this.props.value,hideOptions:this.hideOptions,onChange:this.handleChange,containerRef:this.optionsContainer,inputRef:this.input,disabled:this.props.readOnly,hasHelpText:(this.props.help_text||this.props.error)&&1}))},t}(r.default.Component),id=/*#__PURE__*/function(e){function t(){var t;return(t=e.call.apply(e,[this].concat([].slice.call(arguments)))||this).handleRemove=function(e,i){e.stopPropagation(),t.props.onChange({target:{value:t.props.value[i],checked:!1}})},t}return a(t,e),t.prototype.render=function(){var e=this,t=function(e){for(var t={},i=0;i-1,a="rjf-multiselect-field-option";return o&&(a+=" selected"),e.props.disabled&&(a+=" disabled"),/*#__PURE__*/r.default.createElement("div",{key:n+"_"+s+"_"+i,className:a},/*#__PURE__*/r.default.createElement("label",null,/*#__PURE__*/r.default.createElement("input",{type:"checkbox",onChange:e.props.onChange,value:s,checked:o,disabled:e.props.disabled})," ",n))})))},t}(r.default.Component),rd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).getFileName=function(){return i.props.value?"data-url"===i.props.type?i.extractFileInfo(i.props.value).name:"file-url"===i.props.type?i.props.value:"Unknown file":""},i.extractFileInfo=function(e){var t=function(e){var t,i=e.split(","),n=i[0].split(";"),r=n[0].replace("data:",""),s=n.filter(function(e){return"name"===e.split("=")[0]});t=1!==s.length?"unknown":s[0].split("=")[1];for(var o=atob(i[1]),a=[],l=0;l12&&(t-=12,o="pm"),n=a.getMinutes(),r=a.getSeconds(),s=a.getMilliseconds(),t=t.toString().padStart(2,"0"),n=n.toString().padStart(2,"0"),r=r.toString().padStart(2,"0")}return{date:e,hh:t,mm:n,ss:r,ms:s,ampm:o}},i.handleClickOutside=function(e){i.state.showTimePicker&&(!i.timePickerContainer.current||i.timePickerContainer.current.contains(e.target)||i.timeInput.current.contains(e.target)||i.setState({showTimePicker:!1}))},i.sendValue=function(){var e={target:{type:"text",value:"",name:i.props.name}};if(""===i.state.date||null===i.state.date)return i.props.onChange(e);var t=parseInt(i.state.hh);0===t&&(t=NaN),"am"===i.state.ampm?12===t&&(t=0):"pm"===i.state.ampm&&12!==t&&(t+=12),t=t.toString().padStart(2,"0");var n=i.state.mm.padStart(2,"0"),r=i.state.ss.padStart(2,"0");try{var s=new Date(i.state.date+"T"+t+":"+n+":"+r+"."+i.state.ms);e.target.value=s.toISOString().replace("Z","+00:00")}catch(t){return i.props.onChange(e)}i.props.onChange(e)},i.handleDateChange=function(e){i.setState({date:e.target.value},i.sendValue)},i.handleTimeChange=function(e){i.setState(iu({},e),i.sendValue)},i.showTimePicker=function(){i.setState({showTimePicker:!i.props.readOnly&&!0})},i.state=iu({},i.getStateFromProps(),{showTimePicker:!1}),i.timeInput=/*#__PURE__*/r.default.createRef(),i.timePickerContainer=/*#__PURE__*/r.default.createRef(),i}a(t,e);var i=t.prototype;return i.componentDidUpdate=function(e,t){if(e.value!==this.props.value&&""!==this.state.hh&&"0"!==this.state.hh&&"00"!==this.state.hh){var i=!1,n=this.getStateFromProps();for(var r in n)if(n[r]!==this.state[r]){i=!0;break}i&&this.setState(iu({},n))}},i.componentDidMount=function(){document.addEventListener("mousedown",this.handleClickOutside)},i.componentWillUnmount=function(){document.removeEventListener("mousedown",this.handleClickOutside)},i.render=function(){/*#__PURE__*/return r.default.createElement("div",{className:this.props.error?"rjf-datetime-field has-error":"rjf-datetime-field"},/*#__PURE__*/r.default.createElement(Qu,{label:this.props.label,required:this.props.required}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-datetime-field-inner"},/*#__PURE__*/r.default.createElement("div",{className:this.props.readOnly?"rjf-datetime-field-inputs readonly":"rjf-datetime-field-inputs"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-datetime-field-date"},/*#__PURE__*/r.default.createElement(Yu,{label:"Date",type:"date",value:this.state.date,onChange:this.handleDateChange,readOnly:this.props.readOnly})),/*#__PURE__*/r.default.createElement("div",{className:"rjf-datetime-field-time"},/*#__PURE__*/r.default.createElement(Yu,{label:"Time",type:"text",value:this.state.hh+":"+this.state.mm+":"+this.state.ss+" "+this.state.ampm,onFocus:this.showTimePicker,readOnly:!0,disabled:this.props.readOnly||!1,inputRef:this.timeInput}),/*#__PURE__*/r.default.createElement("div",{ref:this.timePickerContainer},this.state.showTimePicker&&/*#__PURE__*/r.default.createElement(Wu,{onChange:this.handleTimeChange,hh:this.state.hh,mm:this.state.mm,ss:this.state.ss,ampm:this.state.ampm})))),this.props.error&&this.props.error.map(function(e,t){/*#__PURE__*/return r.default.createElement("span",{className:"rjf-error-text",key:t},e)}),this.props.help_text&&/*#__PURE__*/r.default.createElement("span",{className:"rjf-help-text"},this.props.help_text)))},t}(r.default.Component);function ad(e){/*#__PURE__*/return r.default.createElement("div",{className:e.label?"rjf-url-field has-label":"rjf-url-field"},/*#__PURE__*/r.default.createElement(Yu,iu({},e,{type:"url",className:"rjf-url-field-input"})),e.value&&/*#__PURE__*/r.default.createElement("a",{href:e.value,target:"_blank",rel:"noopener noreferrer",className:"rjf-url-field-link",title:"Open in new tab"},/*#__PURE__*/r.default.createElement(Bu,{name:"box-arrow-up-right"})," ",/*#__PURE__*/r.default.createElement("span",null,"Open link")))}var ld=/*#__PURE__*/function(e){function t(t){var i,n,s;return(i=e.call(this,t)||this).handleSelect=function(e){i.props.multiselect&&(e=Array.isArray(i.props.value)?i.props.value.concat([e]):[e]);var t={target:{type:i.props.type,value:e,name:i.props.name}};i.props.multiselect||i.hideOptions(),i.props.onChange(t)},i.handleMultiselectRemove=function(e){var t=i.props.value.filter(function(t){return t!==e});i.props.onChange({target:{type:i.props.type,value:t,name:i.props.name}})},i.clearValue=function(e){i.handleSelect(i.defaultEmptyValue)},i.hasValue=function(){return!(Array.isArray(i.props.value)&&!i.props.value.length)&&""!==i.props.value&&null!==i.props.value},i.handleSearchInputChange=function(e){var t=e.target.value;t?i.setState({searchInputValue:t,loading:!0},i.debouncedFetchOptions):i.setState({searchInputValue:t,loading:!1,options:[]})},i.fetchOptions=function(){if(""!==i.state.searchInputValue){var e=i.props.handler;if(!e)return console.error("Error: No 'handler' endpoint provided for autocomplete input."),void i.setState({loading:!1});var t=e+"?"+new URLSearchParams({field_name:i.context.fieldName,model_name:i.context.modelName,coords:pu(i.props.name),query:i.state.searchInputValue});fetch(t,{method:"GET"}).then(function(e){return e.json()}).then(function(e){Array.isArray(e.results)||(e.results=[]),i.setState(function(t){return{loading:!1,options:[].concat(e.results)}})}).catch(function(e){alert("Something went wrong while fetching options"),console.error("Error:",e),i.setState({loading:!1})})}},i.showOptions=function(e){i.state.showOptions||i.setState({showOptions:!0})},i.hideOptions=function(e){i.setState({showOptions:!1,searchInputValue:"",options:[],loading:!1})},i.toggleOptions=function(e){i.setState(function(e){return e.showOptions?{showOptions:!1,searchInputValue:"",options:[],loading:!1}:{showOptions:!0}})},i.state={searchInputValue:"",showOptions:!1,options:[],loading:!1},i.optionsContainer=/*#__PURE__*/r.default.createRef(),i.searchInputRef=/*#__PURE__*/r.default.createRef(),i.input=/*#__PURE__*/r.default.createRef(),i.debouncedFetchOptions=(n=i.fetchOptions,function(){clearTimeout(s);var e=arguments,t=this;s=setTimeout(function(){n.apply(t,e)},500)}),i.defaultEmptyValue=t.multiselect?[]:"",i}a(t,e);var i=t.prototype;return i.componentDidUpdate=function(e,t){this.state.showOptions&&this.state.showOptions!==t.showOptions&&this.searchInputRef.current&&this.searchInputRef.current.focus()},i.render=function(){var e=this;/*#__PURE__*/return r.default.createElement("div",{className:this.props.label?"rjf-autocomplete-field has-label":"rjf-autocomplete-field"},this.props.multiselect?/*#__PURE__*/r.default.createElement(Yu,{label:this.props.label,help_text:this.props.help_text,error:this.props.error},/*#__PURE__*/r.default.createElement(id,{inputRef:this.input,onClick:this.toggleOptions,onChange:function(t){return e.handleMultiselectRemove(t.target.value)},value:this.props.value,placeholder:this.props.placeholder||" ",disabled:this.props.readOnly||!1})):/*#__PURE__*/r.default.createElement(r.default.Fragment,null,/*#__PURE__*/r.default.createElement(Yu,{label:this.props.label,type:"text",value:this.props.value,help_text:this.props.help_text,error:this.props.error,readOnly:!0,disabled:this.props.readOnly||!1,onClick:this.toggleOptions,inputRef:this.input,placeholder:this.props.placeholder,name:this.props.name,className:"rjf-autocomplete-field-input"}),this.hasValue()&&!this.props.readOnly&&/*#__PURE__*/r.default.createElement(Ru,{className:"autocomplete-field-clear",title:"Clear",onClick:this.clearValue},/*#__PURE__*/r.default.createElement(Bu,{name:"x-circle"})," ",/*#__PURE__*/r.default.createElement("span",null,"Clear"))),this.state.showOptions&&!this.props.readOnly&&/*#__PURE__*/r.default.createElement(hd,{options:this.state.options,value:this.props.value,hideOptions:this.hideOptions,onSelect:this.handleSelect,onSearchInputChange:this.handleSearchInputChange,searchInputValue:this.state.searchInputValue,containerRef:this.optionsContainer,searchInputRef:this.searchInputRef,inputRef:this.input,loading:this.state.loading,hasHelpText:(this.props.help_text||this.props.error)&&1,multiselect:this.props.multiselect}))},t}(r.default.Component);ld.contextType=ou;var hd=/*#__PURE__*/function(e){function t(){var t;return(t=e.call.apply(e,[this].concat([].slice.call(arguments)))||this).handleClickOutside=function(e){!t.props.containerRef.current||t.props.containerRef.current.contains(e.target)||t.props.inputRef.current.contains(e.target)||t.props.hideOptions()},t}a(t,e);var i=t.prototype;return i.componentDidMount=function(){document.addEventListener("mousedown",this.handleClickOutside)},i.componentWillUnmount=function(){document.removeEventListener("mousedown",this.handleClickOutside)},i.render=function(){/*#__PURE__*/return r.default.createElement("div",{ref:this.props.containerRef},/*#__PURE__*/r.default.createElement("div",{className:"rjf-autocomplete-field-popup",style:this.props.hasHelpText?{marginTop:"-15px"}:{}},/*#__PURE__*/r.default.createElement(cd,{inputRef:this.props.searchInputRef,onChange:this.props.onSearchInputChange,value:this.props.searchInputValue,loading:this.props.loading}),this.props.searchInputValue&&/*#__PURE__*/r.default.createElement(ud,{options:this.props.options,value:this.props.value,onSelect:this.props.onSelect,loading:this.props.loading,hasHelpText:this.props.hasHelpText,multiselect:this.props.multiselect})))},t}(r.default.Component);function cd(e){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-autocomplete-field-search"},/*#__PURE__*/r.default.createElement(Yu,{type:"text",placeholder:"Search...",inputRef:e.inputRef,onChange:e.onChange,value:e.value,form:""}),e.loading&&/*#__PURE__*/r.default.createElement(ju,null))}function ud(e){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-autocomplete-field-options"},!e.options.length&&!e.loading&&/*#__PURE__*/r.default.createElement("div",{className:"rjf-autocomplete-field-option disabled"},"No options"),e.options.map(function(t,i){var n,s;"object"==typeof t?(n=t.title||t.label,s=t.value):("boolean"==typeof(n=t)&&(n=capitalize(n.toString())),s=t);var o,a="rjf-autocomplete-field-option";return(o=Array.isArray(e.value)?e.value.indexOf(s)>-1:e.value===s)&&(a+=" selected"),/*#__PURE__*/r.default.createElement("div",{key:n+"_"+s+"_"+i,className:a,tabIndex:0,role:"button",onClick:function(){return e.multiselect&&o?null:e.onSelect(s)}},n)}))}function dd(e){return e.children?/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group-title"},e.children,e.editable&&/*#__PURE__*/r.default.createElement(r.default.Fragment,null," ",/*#__PURE__*/r.default.createElement(Ru,{className:"edit",onClick:e.onEdit,title:"Edit"},"Edit")),e.collapsible&&/*#__PURE__*/r.default.createElement(r.default.Fragment,null," ",/*#__PURE__*/r.default.createElement(Ru,{className:"collapse",onClick:e.onCollapse,title:e.collapsed?"Expand":"Collapse"},e.collapsed?"[+]":"[-]"))):null}function fd(e){return e.children?/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group-description"},e.children):null}function pd(e,t,i){var n=e.target.parentElement.parentElement,r=n.previousElementSibling,s=n.nextElementSibling;if(n.classList.add("rjf-animate","rjf-"+t),"move-up"===t){var o=r.getBoundingClientRect().y,a=o,l=o=n.getBoundingClientRect().y;r.classList.add("rjf-animate"),r.style.opacity=0,r.style.transform="translateY("+(l-a)+"px)",n.style.opacity=0,n.style.transform="translateY(-"+(l-a)+"px)"}else if("move-down"===t){var h=n.getBoundingClientRect().y,c=h,u=h=s.getBoundingClientRect().y;s.classList.add("rjf-animate"),s.style.opacity=0,s.style.transform="translateY(-"+(u-c)+"px)",n.style.opacity=0,n.style.transform="translateY("+(u-c)+"px)"}setTimeout(function(){i(),n.classList.remove("rjf-animate","rjf-"+t),n.style=null,"move-up"===t?(r.classList.remove("rjf-animate"),r.style=null):"move-down"===t&&(s.classList.remove("rjf-animate"),s.style=null)},200)}function md(e){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-form-row-controls"},e.onMoveUp&&/*#__PURE__*/r.default.createElement(Ru,{className:"move-up",onClick:function(t){return pd(t,"move-up",e.onMoveUp)},title:"Move up"},/*#__PURE__*/r.default.createElement("span",null,"↑")),e.onMoveDown&&/*#__PURE__*/r.default.createElement(Ru,{className:"move-down",onClick:function(t){return pd(t,"move-down",e.onMoveDown)},title:"Move down"},/*#__PURE__*/r.default.createElement("span",null,"↓")),e.onRemove&&/*#__PURE__*/r.default.createElement(Ru,{className:"remove",onClick:function(t){return pd(t,"remove",e.onRemove)},title:"Remove"},/*#__PURE__*/r.default.createElement("span",null,"×")))}function gd(e){var t="rjf-form-row";return e.hidden&&(t+=" rjf-form-row-hidden"),/*#__PURE__*/r.default.createElement("div",{className:t},/*#__PURE__*/r.default.createElement(md,e),/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-row-inner"},e.children))}function vd(e){var t=r.default.useState(!1),i=t[0],n=t[1],s=cu(e.schema);r.default.Children.count(e.children);var o,a,l=0===e.level&&"groups"===e.childrenType?"":"rjf-form-group-inner";return"object"===s?(o="Add key",a="Add new key"):(o="Add item",a="Add new item"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group"},0===e.level&&/*#__PURE__*/r.default.createElement(dd,{editable:e.editable,onEdit:e.onEdit,collapsible:e.collapsible,onCollapse:function(){return n(!i)},collapsed:i},e.schema.title),0===e.level&&/*#__PURE__*/r.default.createElement(fd,null,e.schema.description),/*#__PURE__*/r.default.createElement("div",{className:l},e.level>0&&/*#__PURE__*/r.default.createElement(dd,{editable:e.editable,onEdit:e.onEdit,collapsible:e.collapsible,onCollapse:function(){return n(!i)},collapsed:i},e.schema.title),e.level>0&&/*#__PURE__*/r.default.createElement(fd,null,e.schema.description),i&&/*#__PURE__*/r.default.createElement("div",{className:"rjf-collapsed-indicator"},/*#__PURE__*/r.default.createElement("span",null,"Collapsed")),/*#__PURE__*/r.default.createElement("div",{className:i?"rjf-form-group-children rjf-collapsed":"rjf-form-group-children"},e.children),!i&&e.addable&&/*#__PURE__*/r.default.createElement(Ru,{className:"add",onClick:function(t){return e.onAdd()},title:a},o)))}var yd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).openModal=function(e){i.setState({open:!0})},i.closeModal=function(e){i.setState({open:!1,pane:"upload"})},i.togglePane=function(e){i.setState({pane:e})},i.handleFileSelect=function(e){i.props.onChange({target:{type:"text",value:e,name:i.props.name}}),i.closeModal()},i.handleFileUpload=function(e){i.newFiles.push(e.target.value),i.addExitEventListeners(),i.props.onChange(e),i.closeModal()},i.addExitEventListeners=function(){i.exitListenersAdded||i.hiddenInputRef.current&&i.hiddenInputRef.current.form&&(window.addEventListener("beforeunload",i.promptOnExit),window.addEventListener("unload",i.sendDeleteRequestOnExit),i.hiddenInputRef.current.form.addEventListener("submit",function(e){window.removeEventListener("beforeunload",i.promptOnExit),window.removeEventListener("unload",i.sendDeleteRequestOnExit)}),i.exitListenersAdded=!0)},i.promptOnExit=function(e){i.newFiles.length&&(e.preventDefault(),e.returnValue="")},i.sendDeleteRequestOnExit=function(e){i.newFiles.length&&i.sendDeleteRequest([i.newFiles],"unsaved_form_page_exit",!0)},i.clearFile=function(){window.confirm("Do you want to remove this file?")&&i.props.onChange({target:{type:"text",value:"",name:i.props.name}})},i.sendDeleteRequest=function(e,t,n){for(var r=i.props.handler||i.context.fileHandler,s=new URLSearchParams(iu({},i.context.fileHandlerArgs,{coords:pu(i.props.name),trigger:t})),o=0;o0?t.page+1:t.page,hasMore:e.results.length>0}})}).catch(function(e){alert("Something went wrong while retrieving media files"),console.error("Error:",e),i.setState({loading:!1})})},i.onLoadMore=function(e){i.setState({loading:!0},i.fetchList)},i.onFileDelete=function(){i.setState({page:0,files:[]},i.onLoadMore)},i.state={loading:!0,files:[],page:0,hasMore:!0},i}a(t,e);var i=t.prototype;return i.componentDidMount=function(){this.fetchList()},i.render=function(){var e=this;/*#__PURE__*/return r.default.createElement("div",{className:"rjf-upload-modal__pane"},/*#__PURE__*/r.default.createElement("h3",null,"Media library"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-upload-modal__media-container"},this.state.files.map(function(t){/*#__PURE__*/return r.default.createElement(xd,iu({},t,{onClick:e.props.onFileSelect,sendDeleteRequest:e.props.sendDeleteRequest,onFileDelete:e.onFileDelete}))})),this.state.loading&&/*#__PURE__*/r.default.createElement(ju,{className:"rjf-upload-modal__media-loader"}),!this.state.loading&&this.state.hasMore&&/*#__PURE__*/r.default.createElement("div",null,/*#__PURE__*/r.default.createElement(Ru,{onClick:this.onLoadMore,className:"upload-modal__media-load"},/*#__PURE__*/r.default.createElement(Bu,{name:"arrow-down"})," View more")),!this.state.hasMore&&/*#__PURE__*/r.default.createElement("div",{className:"rjf-upload-modal__media-end-message"},this.state.files.length?"End of list":"No files found"))},t}(r.default.Component);function xd(e){var t=e.metadata||{};/*#__PURE__*/return r.default.createElement("div",{className:"rjf-upload-modal__media-tile"},/*#__PURE__*/r.default.createElement(Sd,{value:e.value,sendDeleteRequest:e.sendDeleteRequest,onFileDelete:e.onFileDelete}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-upload-modal__media-tile-inner",tabIndex:"0",onClick:function(){return e.onClick(e.value)}},/*#__PURE__*/r.default.createElement("img",{src:e.thumbnail?e.thumbnail:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23999999' viewBox='0 0 16 16'%3E%3Cpath d='M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5L14 4.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5h-2z'/%3E%3C/svg%3E"}),e.metadata&&/*#__PURE__*/r.default.createElement("div",{className:"rjf-upload-modal__media-tile-metadata"},Object.getOwnPropertyNames(t).map(function(e){/*#__PURE__*/return r.default.createElement("span",null,t[e])}))))}var Sd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).toggleMenu=function(e){i.setState(function(e){return{open:!e.open}})},i.handleDeleteClick=function(e){window.confirm("Do you want to delete this file?")&&(i.setState({loading:!0}),i.props.sendDeleteRequest([i.props.value],"delete_button").then(function(e){var t,n=e.status;200===n||(400===n?t="Bad request":401===n||403===n?t="You don't have permission to delete this file":404===n?t="This file does not exist on server":405===n?t="This operation is not permitted":n>405&&(t="Something went wrong while deleting file")),i.setState({loading:!1,open:!1}),t?alert(t):i.props.onFileDelete()}).catch(function(e){alert("Something went wrong while deleting file"),console.error("Error:",e),i.setState({loading:!1})}))},i.state={open:!1,loading:!1},i}return a(t,e),t.prototype.render=function(){/*#__PURE__*/return r.default.createElement("div",{className:this.state.open?"rjf-dropdown open":"rjf-dropdown"},/*#__PURE__*/r.default.createElement(Ru,{className:"rjf-dropdown-toggler",alterClassName:!1,title:this.state.open?"Close menu":"Open menu",onClick:this.toggleMenu},/*#__PURE__*/r.default.createElement(Bu,{name:this.state.open?"x-lg":"three-dots-vertical"})),this.state.open&&/*#__PURE__*/r.default.createElement("div",{className:"rjf-dropdown-items"},/*#__PURE__*/r.default.createElement(Ru,{className:"rjf-dropdown-item rjf-text-danger",alterClassName:!1,onClick:this.handleDeleteClick},this.state.loading&&/*#__PURE__*/r.default.createElement(ju,null),this.state.loading?" Deleting...":"Delete")))},t}(r.default.Component),Od=["data","schema","name","onChange","onRemove","removable","onEdit","onKeyEdit","editable","onMoveUp","onMoveDown","parentType","errorMap"];function Cd(e){var t,i={name:e.name,value:e.data,readOnly:gu(e.schema,"readOnly","readonly"),help_text:gu(e.schema,"help_text","helpText"),error:e.errorMap[pu(e.name)],required:e.schema.required||!1};"string"==typeof i.error&&(i.error=[i.error]),e.schema.placeholder&&(i.placeholder=e.schema.placeholder),e.schema.handler&&(i.handler=e.schema.handler),e.schema.hasOwnProperty("const")?(t=hu(e.schema.const),i.readOnly=!0):t=mu(e.schema.type);var n,s=gu(e.schema,"choices","enum");switch(s&&(i.options=s,t="select"),e.schema.widget&&("multiselect"===e.schema.widget&&"array"!==e.parentType||(t="hidden"===e.schema.widget?"string":e.schema.widget)),t){case"string":if(n=Yu,e.schema.format){var o=e.schema.format;"data-url"===o?n=rd:"file-url"===o?n=yd:"date-time"===mu(o)?n=od:"uri"!==o&&"uri-reference"!==o||(n=ad),i.type=o}else i.type="hidden"===e.schema.widget?"hidden":"text";(e.schema.minLength||0===e.schema.minLength)&&(i.minLength=e.schema.minLength),(e.schema.maxLength||0===e.schema.maxLength)&&(i.maxLength=e.schema.maxLength);break;case"fileinput":n=rd,e.schema.format&&(i.type=e.schema.format);break;case"range":case"integer":i.step="1";case"number":i.type="range"===t?"range":"number",n=Yu,(e.schema.minimum||0===e.schema.minimum)&&(i.min=e.schema.minimum),(e.schema.maximum||0===e.schema.maximum)&&(i.max=e.schema.maximum);break;case"boolean":case"checkbox":i.type="checkbox",n=Xu;break;case"radio":i.type="radio",n=Zu;break;case"select":n=ed;break;case"multiselect":i.valueType=e.schema.type,n=td;break;case"autocomplete":n=ld;break;case"multiselect-autocomplete":n=ld,i.multiselect=!0;break;case"textarea":n=sd,(e.schema.minLength||0===e.schema.minLength)&&(i.minLength=e.schema.minLength),(e.schema.maxLength||0===e.schema.maxLength)&&(i.maxLength=e.schema.maxLength);break;default:i.type="text",n=Yu}/*#__PURE__*/return r.default.createElement(n,iu({},i,{label:e.editable?/*#__PURE__*/r.default.createElement("span",null,e.schema.title," ",/*#__PURE__*/r.default.createElement(Ru,{className:"edit",onClick:e.onEdit,title:"Edit"},"Edit")):e.schema.title,onChange:function(t){return function(e,t,i){var n;n="checkbox"===e.target.type?e.target.checked:e.target.value,n=Array.isArray(n)?n.map(function(e){return lu(e,t)}):lu(n,t),i(e.target.name,n)}(t,e.schema.type,e.onChange)}}))}function Ad(e){var t=e.data,i=e.schema,n=e.name,s=e.onChange,o=e.onRemove,a=e.removable,l=e.onKeyEdit,h=e.editable,c=e.onMoveUp,u=e.onMoveDown,d=e.parentType,f=e.errorMap,p=nu(e,Od);/*#__PURE__*/return r.default.createElement(gd,{key:n,onRemove:a?function(e){return o(n)}:null,onMoveUp:c,onMoveDown:u,hidden:"hidden"===i.widget},/*#__PURE__*/r.default.createElement(Cd,iu({data:t,schema:i,name:n,onChange:s,onEdit:l,editable:h,parentType:d,errorMap:f},p)))}function Ed(e){var t=e.data,i=e.schema,n=e.name,s=e.onChange,o=e.onAdd,a=e.onRemove,l=e.onMove,h=e.onEdit,c=e.level,u=[],d=[],f=gu(i,"readonly","readOnly",!1),p=!0,m=gu(i,"min_items","minItems")||0;(t.length<=m||f)&&(p=!1);var g=!0,v=gu(i,"max_items","maxItems")||100;(t.length>=v||f)&&(g=!1),i.items.hasOwnProperty("$ref")&&(i.items=iu({},e.getRef(i.items.$ref),i.items),delete i.items.$ref);var y=mu(i.items.type),w={schema:i.items,onChange:s,onAdd:o,onRemove:a,level:c+1,removable:p,onMove:l,onEdit:h,onKeyEdit:e.onKeyEdit,parentType:"array",getRef:e.getRef,errorMap:e.errorMap};if(f&&(w.schema.readOnly=!0),"multiselect"===w.schema.widget||"multiselect-autocomplete"===w.schema.widget)w.data=t,w.name=n,w.removable=!1,w.onMoveUp=null,w.onMoveDown=null,g=!1,u.push(Ad(w));else for(var b=function(s){w.data=t[s],w.name=du(n,s),w.onMoveUp=0===s||f?null:function(e){return l(du(n,s),du(n,s-1))},w.onMoveDown=s===t.length-1||f?null:function(e){return l(du(n,s),du(n,s+1))},"array"===y?d.push(Ed(w)):"object"===y?d.push(Md(w)):i.items.hasOwnProperty("oneOf")?d.push(/*#__PURE__*/r.default.createElement(Rd,{parentArgs:e,nextArgs:iu({},w),key:"oneOf_"+n+"_"+s})):i.items.hasOwnProperty("anyOf")?d.push(/*#__PURE__*/r.default.createElement(jd,{parentArgs:e,nextArgs:iu({},w),key:"anyOf_"+n+"_"+s})):u.push(Ad(w))},k=0;k0,childrenType:"rows"},x&&x.map(function(e,t){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-error-text",key:t},e)}),u),"object"===e.parentType&&e.removable&&(u=/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group-wrapper",key:"row_group_wrapper_"+n},/*#__PURE__*/r.default.createElement(md,{onRemove:function(e){return a(n)}}),u))),d.length){var O=e.errorMap[pu(S)];"string"==typeof O&&(O=[O]),d=/*#__PURE__*/r.default.createElement("div",{key:"group_"+n,className:"rjf-form-group-wrapper"},"object"===e.parentType&&e.removable&&/*#__PURE__*/r.default.createElement(md,{onRemove:function(e){return a(n)}}),/*#__PURE__*/r.default.createElement(vd,{level:c,schema:i,addable:g,onAdd:function(){return o(xu(i.items,e.getRef),S)},editable:e.editable,onEdit:e.onKeyEdit,collapsible:t.length>0,childrenType:"groups"},O&&O.map(function(e,t){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-error-text",key:t},e)}),d.map(function(e,t){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-form-group-wrapper",key:"group_wrapper_"+n+"_"+t},/*#__PURE__*/r.default.createElement(md,{onRemove:p?function(e){return a(du(n,t))}:null,onMoveUp:t>0&&!f?function(e){return l(du(n,t),du(n,t-1))}:null,onMoveDown:t-1&&(w.required=!0);var S={data:v,schema:w,name:y,onChange:s,onAdd:o,onRemove:a,level:c+1,removable:x,onMove:l,onEdit:h,parentType:"object",getRef:e.getRef,errorMap:e.errorMap,onKeyEdit:function(){return function(e,t,i,n,r){var s=prompt("Rename key",t);if(null!==s&&(s=s.trim())!==t){if(!s)return alert("(!) Key name can't be empty.\r\n\r\n‎");if(e.hasOwnProperty(s))return alert("(!) Duplicate keys not allowed. This key already exists.\r\n\r\n‎");var o=fu(n);o.pop(),o.push(s),r(i,o=du.apply(null,o),n)}}(t,g,v,y,h)}};S.editable=x,"array"===k?u.push(Ed(S)):"object"===k?u.push(Md(S)):S.schema.hasOwnProperty("oneOf")?u.push(/*#__PURE__*/r.default.createElement(Rd,{parentArgs:e,nextArgs:iu({},S),key:"oneOf_"+n+"_"+p})):S.schema.hasOwnProperty("anyOf")?u.push(/*#__PURE__*/r.default.createElement(jd,{parentArgs:e,nextArgs:iu({},S),key:"anyOf_"+n+"_"+p})):u.push(Ad(S))},v=0;v0,childrenType:"rows"},w&&w.map(function(e,t){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-error-text",key:t},e)}),u),"object"===e.parentType&&e.removable&&(u=/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group-wrapper",key:"row_group_wrapper_"+n},/*#__PURE__*/r.default.createElement(md,{onRemove:function(e){return a(n)}}),u))}return u}function Td(e){/*#__PURE__*/return r.default.createElement(Pd,{args:e})}function Nd(e){/*#__PURE__*/return r.default.createElement(Pd,{args:e,schemaName:"anyOf"})}function Dd(e){return Md(e)}var Pd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).findSelectedOption=function(){return hu(i.props.args.data),Tu(i.props.args.data,i.props.args.schema,i.props.args.getRef,i.schemaName)},i.getOptions=function(){return i.props.args.schema[i.schemaName].map(function(e,t){return{label:e.title||"Option "+(t+1),value:t}})},i.getSchema=function(e){void 0===e&&(e=i.state.option);var t=i.props.args.schema[i.schemaName][e];return t.hasOwnProperty("$ref")&&delete(t=iu({},i.props.args.getRef(t.$ref),{schema:t})).$ref,t},i.handleOptionChange=function(e){i.updateData(i.getSchema(e.target.value))},i.schemaName=i.props.schemaName||"oneOf",i}a(t,e);var i=t.prototype;return i.updateData=function(e){this.props.args.onChange(this.props.args.name,xu(e,this.props.args.getRef))},i.render=function(){var e,t=this.findSelectedOption(),i=this.getSchema(t),n=cu(i),s=this.props.args;"object"===n?e=Md:"array"===n?e=Ed:(e=Ad,s.removable=!1,s.onMoveUp=null,s.onMoveDown=null,(Array.isArray(s.data)||"object"==typeof s.data)&&(s.data=null));var o=e(iu({},s,{schema:i})),a=this.props.args.schema.title||null;/*#__PURE__*/return r.default.createElement("div",{className:"rjf-form-group rjf-oneof-group rjf-oneof-group-top-level"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-oneof-selector"},/*#__PURE__*/r.default.createElement(ed,{value:t,options:this.getOptions(),onChange:this.handleOptionChange,className:"rjf-oneof-selector-input",label:a})),o)},t}(r.default.Component),Rd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).findSelectedOption=function(){var e=0;if(i.props.nextArgs)for(var t=hu(i.props.nextArgs.data),n=i.props.nextArgs.schema[i.schemaName],r=0;r-1){e=r;break}if("object"===t){if(Nu(i.props.nextArgs.data,s)){e=r;break}}else if("array"===t){if(Du(i.props.nextArgs.data,s)){e=r;break}}else if(t===o){e=r;break}}}else{var a=i.props.parentArgs.data,l=hu(a),h=i.props.parentArgs.schema[i.schemaName];if(void 0===h)return e;for(var c=0;c-1||(c[u]=o[u]));h.forEach(function(e,t){c[e]=xu(a[e],i.props.parentArgs.getRef)}),this.props.parentArgs.onChange(r,c)}},i.render=function(){var e,t=this,i=this.findSelectedOption(),n=this.getSchema(i),s=cu(n),o=this.props.nextArgs?this.props.nextArgs:this.props.parentArgs;"object"===s?(e=Md,"object"==typeof o.data&&null!==o.data||(o.data={})):"array"===s?(e=Ed,Array.isArray(o.data)||(o.data=[])):(e=Ad,o.removable=!1,o.onMoveUp=null,o.onMoveDown=null,(Array.isArray(o.data)||"object"==typeof o.data)&&(o.data=null));var a=e(iu({},o,{schema:n})),l=null;return this.props.nextArgs&&(l=this.props.nextArgs.schema.title||null),/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group rjf-oneof-group"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-oneof-selector"},/*#__PURE__*/r.default.createElement(ed,{value:i,options:this.getOptions(),onChange:function(e){return t.handleOptionChange(e,i)},className:"rjf-oneof-selector-input",label:l})),a)},t}(r.default.Component);function jd(e){/*#__PURE__*/return r.default.createElement(Rd,iu({},e,{schemaName:"anyOf"}))}function Bd(e){if(!(e instanceof Object))return{isValid:!1,msg:"Schema must be an object"};var t,i=cu(e);return(t="object"===i?Id(e):"array"===i?Ld(e):e.hasOwnProperty("allOf")?Fd(e):e.hasOwnProperty("oneOf")?_d(e):e.hasOwnProperty("anyOf")?Hd(e):e.hasOwnProperty("$ref")?{isValid:!0}:{isValid:!1,msg:"Outermost schema can only be of type array, list, object or dict"}).isValid&&e.hasOwnProperty("$defs")&&!e.$defs instanceof Object?{isValid:!1,msg:"'$defs' must be a valid JavaScript Object"}:t}function Id(e){if(!(e.hasOwnProperty("keys")||e.hasOwnProperty("properties")||e.hasOwnProperty("oneOf")||e.hasOwnProperty("anyOf")||e.hasOwnProperty("allOf")))return{isValid:!1,msg:"Schema of type '"+e.type+"' must have at least one of these keys: ['properties' or 'keys' or 'oneOf' or 'anyOf' or 'allOf']"};var t,i=e.properties||e.keys;if(i&&(t=function(e){if(!(e instanceof Object))return{isValid:!1,msg:"The 'keys' or 'properties' key must be a valid JavaScript Object"};for(var t in e)if(e.hasOwnProperty(t)){var i=e[t];if(!(i instanceof Object))return{isValid:!1,msg:"Key '"+t+"' must be a valid JavaScript Object"};var n={isValid:!0},r=mu(i.type);if(r?"object"===r?n=Id(i):"array"===r&&(n=Ld(i)):n=i.hasOwnProperty("$ref")?Vd(i):i.hasOwnProperty("oneOf")?_d(i):i.hasOwnProperty("anyOf")?Hd(i):i.hasOwnProperty("allOf")?Fd(i):i.hasOwnProperty("const")?{isValid:!0,msg:""}:{isValid:!1,msg:"Key '"+t+"' must have a 'type' or a '$ref"},!n.isValid)return n}return{isValid:!0,msg:""}}(i),!t.isValid))return t;if(e.hasOwnProperty("additionalProperties")){if(!(e.additionalProperties instanceof Object)&&"boolean"!=typeof e.additionalProperties)return{isValid:!1,msg:"'additionalProperties' must be either a JavaScript boolean or a JavaScript object"};if(e.additionalProperties instanceof Object)if(e.additionalProperties.hasOwnProperty("$ref")){if(!(t=Vd(e.additionalProperties)).isValid)return t}else{var n=mu(e.additionalProperties.type);if("object"===n)return Id(e.additionalProperties);if("array"===n)return Bd(e.additionalProperties)}}return e.hasOwnProperty("oneOf")&&!(t=_d(e)).isValid||e.hasOwnProperty("anyOf")&&!(t=Hd(e)).isValid||e.hasOwnProperty("allOf")&&!(t=Fd(e)).isValid?t:{isValid:!0,msg:""}}function Ld(e){if(!e.hasOwnProperty("items"))return{isValid:!1,msg:"Schema of type '"+e.type+"' must have a key called 'items'"};if(!(e.items instanceof Object))return{isValid:!1,msg:"The 'items' key must be a valid JavaScript Object'"};var t=mu(e.items.type);if(t){if("object"===t)return Id(e.items);if("array"===t)return Ld(e.items)}else{if(e.items.hasOwnProperty("$ref"))return Vd(e.items);if(!(e.items.hasOwnProperty("oneOf")||e.items.hasOwnProperty("anyOf")||e.items.hasOwnProperty("allOf")||e.items.hasOwnProperty("const")))return{isValid:!1,msg:"Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf'"}}return e.items.hasOwnProperty("oneOf")&&(validation=_d(e.items),!validation.isValid)||e.items.hasOwnProperty("anyOf")&&(validation=Hd(e.items),!validation.isValid)?validation:e.items.hasOwnProperty("allOf")?{isValid:!1,msg:"Currently, 'allOf' inside array items is not supported"}:e.items.hasOwnProperty("const")&&(validation={isValid:!0,msg:""},!validation.isValid)?validation:{isValid:!0,msg:""}}function Vd(e){return"string"!=typeof e.$ref?{isValid:!1,msg:"'$ref' keyword must be a string"}:e.$ref.startsWith("#")?e.$ref.lenght>1&&!e.$ref.startsWith("#/")?{isValid:!1,msg:"Invalid '$ref' path"}:{isValid:!0,msg:""}:{isValid:!1,msg:"'$ref' value must begin with a hash (#) character"}}function _d(e){return zd(e,"oneOf")}function Hd(e){return zd(e,"anyOf")}function Fd(e){var t=zd(e,"allOf");if(!t.isValid)return t;for(var i=e.allOf,n=0;nparseInt(o)&&this.addError(i,"Maximum "+o+" items allowed."),vu(e,"uniqueItems")&&("array"===r||"object"===r?t.length!==new Set(t.map(function(e){return JSON.stringify(e)})).size&&this.addError(i,"All items in this list must be unique."):t.length!==new Set(t).size&&this.addError(i,"All items in this list must be unique.")),a){var l=t.find(function(e){return-1===a.indexOf(e)});void 0!==l&&this.addError(i,'Invalid choice + "'+l+'"')}var h=this.getValidator(r);if(h||(n.hasOwnProperty("oneOf")?h=this.validateOneOf:n.hasOwnProperty("anyOf")?h=this.validateAnyOf:n.hasOwnProperty("anyOf")),h)for(var c=0;c-1&&!a.hasOwnProperty("required")&&(a.required=!0);var l=mu(a.type),h=this.getValidator(l);if(!h)return void this.addError(i,'Unsupported type "'+l+'" for object properties (keys).');h(a,t[o],this.joinCoords([i,o]))}e.hasOwnProperty("allOf")&&this.validateAllOf(e,t,i)}}},this.validateAllOf=function(e,t,i){for(var n={type:"object",properties:{}},r=0;rparseInt(e.maxLength)&&this.addError(i,"This value may not be longer than "+e.maxLength+" characters."),yu(e,t)){var n;switch(mu(e.format)){case"email":n=this.validateEmail;break;case"date":n=this.validateDate;break;case"time":n=this.validateTime;break;case"date-time":n=this.validateDateTime}n&&n.call(this,e,t,i)}else this.addError(i,'Invalid choice "'+t+'"')}else this.addError(i,"This value is invalid. Must be a valid string.");else this.addError(i,"This field is required.")},this.validateBoolean=function(e,t,i){e.required&&null==t?this.addError(i,"This field is required."):"boolean"!=typeof t&&null!=t&&this.addError(i,"Invalid value.")},this.validateInteger=function(e,t,i){e.required&&null==t?this.addError(i,"This field is required."):null!==t&&("number"==typeof t&&t===parseInt(t)?this.validateNumber(e,t,i):this.addError(i,"Invalid value. Only integers allowed."))},this.validateNumber=function(e,t,i){e.required&&null==t?this.addError(i,"This field is required."):null!==t&&("number"==typeof t?((e.minimum||0===e.minimum)&&te.maximum&&this.addError(i,"This value must not be greater than "+e.maximum),(e.exclusiveMinimum||0===e.exclusiveMinimum)&&t<=e.exclusiveMinimum&&this.addError(i,"This value must be greater than "+e.exclusiveMinimum),(e.exclusiveMaximum||0===e.exclusiveMaximum)&&t>=e.exclusiveMaximum&&this.addError(i,"This value must be less than "+e.exclusiveMaximum),(e.multipleOf||0===e.multipleOf)&&100*t%(100*e.multipleOf)/100&&this.addError(i,"This value must be a multiple of "+e.multipleOf),yu(e,t)||this.addError(i,'Invalid choice "'+t+'"')):this.addError(i,"Invalid value. Only numbers allowed."))},this.validateEmail=function(e,t,i){t.indexOf(" ")>-1?this.addError(i,"Enter a valid email address."):t.length>320&&this.addError(i,"Email may not be longer than 320 characters")},this.validateDate=function(e,t,i){},this.validateTime=function(e,t,i){},this.validateDateTime=function(e,t,i){}}var Qd=[{name:"Array/List",slug:"array-list",schema:{type:"array",title:"Shopping list",description:"Add items to your shopping list",items:{type:"string"},minItems:1,maxItems:5},data:["eggs","juice","milk"]},{name:"Object/Dict",slug:"object-dict",schema:{type:"object",description:"Fill in your personal details",keys:{first_name:{type:"string"},last_name:{type:"string"},age:{type:"integer"}}}},{name:"Additional properties",slug:"additional-properties",schema:{type:"object",title:"Product attributes",keys:{brand:{type:"string"},colour:{type:"string"}},additionalProperties:{type:"string"}},data:{brand:"Nokia",colour:"black",weight:"150 gm"}},{name:"Enum (Choices)",slug:"enum-choices",schema:{type:"object",keys:{country:{type:"string",choices:["Australia","India","United Kingdom","United States"]}}}},{name:"Choices with custom titles",slug:"choices-with-custom-titles",schema:{type:"object",keys:{country:{type:"string",choices:[{title:"🇦🇺 Australia",value:"au"},{title:"🇮🇳 India",value:"in"},{title:"🇬🇧 United Kingdom",value:"gb"},{title:"🇺🇸 United States",value:"us"}]}}}},{name:"Multi select choices",slug:"multi-select-choices",schema:{type:"array",title:"Cities",items:{type:"string",choices:["New york","London","Mumbai","Tokyo"],widget:"multiselect"}},description:function(){/*#__PURE__*/return React.createElement("div",null,"Multiple selections only work inside an array.",/*#__PURE__*/React.createElement("br",null),"Each selected item is added to the array in the selection order.")}},{name:"Boolean",slug:"boolean",schema:{type:"object",keys:{isActive:{type:"boolean",title:"Is active"},isActive2:{type:"boolean",title:"Are you sure?",widget:"radio",choices:[{title:"Yes",value:!0},{title:"No",value:!1}]},isActive3:{type:"boolean",title:"Really?",widget:"select",choices:[{title:"Yes",value:!0},{title:"No",value:!1}]}}},description:function(){/*#__PURE__*/return React.createElement("div",null,"Boolean fields get a radio input by default. But you can also use checkbox or a select input via the ",/*#__PURE__*/React.createElement("code",null,"widget")," keyword.")}},{name:"Referencing ($ref & $defs)",slug:"referencing",schema:{type:"object",keys:{name:{type:"string"},shipping_address:{$ref:"#/$defs/address"},billing_address:{$ref:"#/$defs/address"}},$defs:{address:{type:"object",keys:{house:{type:"string"},street:{type:"string"},city:{type:"string"},postal_code:{type:"string"}}}}}},{name:"Recursion",slug:"recursion",schema:{type:"array",items:{type:"object",title:"Person",keys:{name:{type:"string"},age:{type:"integer"},children:{$ref:"#"}}}},data:[{name:"Alice",age:90,children:[]}],description:function(){/*#__PURE__*/return React.createElement("div",null,"You can recursively nest an item within itself. However, there are certain edge cases where it might lead to infinite recursion error. So, be careful!")}},{name:"File inputs",slug:"file-inputs",schema:{type:"object",properties:{base64_upload:{type:"string",format:"data-url"},server_upload:{type:"string",format:"file-url",helpText:"Default input for file-url opens a modal"},simple_input:{type:"string",format:"file-url",widget:"fileinput",helpText:"Custom input using widget: 'fileinput'"}}},data:{},description:function(){/*#__PURE__*/return React.createElement("div",null,"File upload to server (",/*#__PURE__*/React.createElement("code",null,"file-url"),") will not work in this demo because a server is required. However, Base64 upload (",/*#__PURE__*/React.createElement("code",null,"data-url"),") will work fine.")}},{name:"Date & Time",slug:"date-time",schema:{type:"object",keys:{date:{type:"string",format:"date"},time:{type:"string",format:"time"},datetime:{type:"string",format:"date-time",helpText:"For datetime input, a custom input is used"}}}},{name:"Autocomplete",slug:"autocomplete",schema:{type:"object",keys:{country:{type:"string",widget:"autocomplete",handler:"https://run.mocky.io/v3/b4f1afe0-01a5-4218-988c-36b320a7373c"}}},description:function(){/*#__PURE__*/return React.createElement("div",null,"This demo uses a placeholder JSON API to load data. Hence, autocompletion may not work as expected.")}},{name:"Multi select + Autocomplete",slug:"multiselect-autocomplete",schema:{type:"array",title:"Countries",items:{type:"string",widget:"multiselect-autocomplete",handler:"https://run.mocky.io/v3/b4f1afe0-01a5-4218-988c-36b320a7373c"}},description:function(){/*#__PURE__*/return React.createElement("div",null,"Multiple selections only work inside an array.",/*#__PURE__*/React.createElement("br",null),"This demo uses a placeholder JSON API to load data. Hence, autocompletion may not work as expected.")}},{name:"Textarea",slug:"textarea",schema:{type:"object",keys:{title:{type:"string"},body:{type:"string",widget:"textarea"}}}},{name:"Range input",slug:"range",schema:{type:"object",title:"Range input",properties:{volume:{type:"number",widget:"range",minimum:0,maximum:10}}}},{name:"Placeholder & Help text",slug:"placehlder-help-text",schema:{type:"object",keys:{name:{type:"string",placeholder:"Placeholder text",helpText:"This is a help text"}}}},{name:"Readonly & Hidden inputs",slug:"readonly-hidden-inputs",schema:{type:"object",keys:{first_name:{type:"string",placeholder:"Readonly input",readonly:!0},last_name:{type:"string",widget:"hidden"}}},description:function(){/*#__PURE__*/return React.createElement("div",null,"The following schema has two inputs.",/*#__PURE__*/React.createElement("code",null,"first_name")," is readonly and ",/*#__PURE__*/React.createElement("code",null,"last_name")," is hidden so it's not visible.")}},{name:"Formats",slug:"formats",schema:{type:"object",title:"Available input formats",keys:{email:{type:"string",format:"email"},password:{type:"string",format:"password"},colour:{type:"string",format:"color"},url:{type:"string",format:"uri",title:"URL"}}},data:{email:"john@example.com",password:"correcthorsebatterystaple",colour:"#ffff00",url:"http://example.com"}},{name:"Validation",slug:"validation",schema:{type:"object",title:'Press "Submit" to validate data',keys:{name:{type:"string",required:!0},age:{type:"number",required:!0,minimum:50}}}},{name:"AnyOf",slug:"anyof",schema:{type:"object",title:"Person info",properties:{name:{type:"string"},age_or_birthdate:{title:"Age or Birthdate",anyOf:[{type:"integer",title:"Age"},{type:"string",format:"date-time",title:"Birthdate"}]},contacts:{type:"array",items:{anyOf:[{type:"string",title:"Email",placeholder:"you@example.com"},{type:"integer",title:"Phone",placeholder:"1234567890"}]}}}}},{name:"OneOf",slug:"oneof",schema:{type:"object",properties:{location:{oneOf:[{type:"object",title:"Coordinates",properties:{latitude:{type:"number"},longitude:{type:"number"}}},{type:"object",title:"City & Country",properties:{city:{type:"string"},country:{type:"string"}}}]},secret_code:{oneOf:[{type:"integer",title:"Numeric code"},{type:"string",title:"String code"}]}}}},{name:"AllOf",slug:"allof",schema:{type:"object",title:"Person",allOf:[{properties:{name:{type:"string"}}},{properties:{age:{type:"integer"}}}]},description:function(){/*#__PURE__*/return React.createElement("div",null,"Currently, ",/*#__PURE__*/React.createElement("code",null,"allOf")," supports very limited features. It only works inside objects and won't work inside arrays or other types.")}},{name:"Constants",slug:"const",schema:{type:"object",title:"Person",properties:{species:{const:"Homo Sapiens"},name:{type:"string"}}}}];function Yd(e){/*#__PURE__*/return r.default.createElement("div",{className:"tabs py-4"},/*#__PURE__*/r.default.createElement("div",{className:"row"},/*#__PURE__*/r.default.createElement("div",{className:"col-12"},/*#__PURE__*/r.default.createElement("nav",{className:"nav nav-pills"},Qd.map(function(t,i){/*#__PURE__*/return r.default.createElement("button",{key:i,type:"button",className:e.activeTabIndex===i?"nav-link active":"nav-link",onClick:function(n){return e.onClick(i,t.slug)}},t.name)})))))}var Xd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).getSchemaEditorNewState=function(){return Ae.create({doc:i.getEditorSchema(),extensions:[Js(),Qs,ss(),Wr(),ml(),Mc(),Ae.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let i=e.newDoc,{head:n}=e.newSelection.main,r=i.lineAt(n);if(n>r.from+200)return e;let s=i.sliceString(r.from,n);if(!t.some(e=>e.test(s)))return e;let{state:o}=e,a=-1,l=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==a)continue;a=t.from;let i=ka(o,t.from);if(null==i)continue;let n=/^\s*/.exec(t.text)[0],r=ba(o,i);n!=r&&l.push({from:t.from,to:t.from+n.length,insert:r})}return l.length?[e,{changes:l,sequential:!0}]:e}),Ba(Va,{fallback:!0}),Ja(),[zh,Vh],cs,Vr.of([].concat(Rh,Ph,Dl)),tu(),uc(e=>{try{JSON.parse(e.state.doc.toString())}catch(t){if(!(t instanceof SyntaxError))throw t;const i=function(e,t){let i;return(i=e.message.match(/at position (\d+)/))?Math.min(+i[1],t.length):(i=e.message.match(/at line (\d+) column (\d+)/))?Math.min(t.line(+i[1]).from+ +i[2]-1,t.length):0}(t,e.state.doc);return[{from:i,message:t.message,severity:"error",to:i}]}return[]}),Nr.updateListener.of(function(e){if(e.docChanged){try{JSON.parse(e.state.doc.toString())}catch(e){return void i.setState({schemaError:"Must be strictly valid JSON (no trailing commas, use double-quotes, etc.)"})}try{var t=Wd.create(e.state.doc.toString());i.setState({rjf_state:t,schemaError:!1},function(e){i.updateDataEditor(i.getEditorData())})}catch(e){return void i.setState({schemaError:e.toString()})}}})]})},i.getDataEditorNewState=function(){return Ae.create({doc:i.getEditorData(),extensions:[Js(),ss(),Wr(),Mc(),Ba(Va,{fallback:!0}),tu(),Ae.readOnly.of(!0)]})},i.handleFormChange=function(e){i.setState({rjf_state:e},function(e){i.dataEditorView&&i.updateDataEditor(i.getEditorData())})},i.validateData=function(){var e=new Gd(i.state.rjf_state.getSchema()).validate(i.state.rjf_state.getData());i.setState({errorMap:e.errorMap})},i.state={rjf_state:Wd.create(i.getActiveTabSchema(),i.getActiveTabData()),schemaError:!1,errorMap:{}},i.schemaEditorParentRef=/*#__PURE__*/r.default.createRef(),i.dataEditorParentRef=/*#__PURE__*/r.default.createRef(),i}a(t,e);var i=t.prototype;return i.componentDidMount=function(){this.schemaEditorView=new Nr({state:this.getSchemaEditorNewState(),parent:this.schemaEditorParentRef.current}),this.dataEditorView=new Nr({state:this.getDataEditorNewState(),parent:this.dataEditorParentRef.current})},i.componentDidUpdate=function(e,t){var i=this;this.props.activeTabIndex!==e.activeTabIndex&&this.setState({rjf_state:Wd.create(this.getActiveTabSchema(),this.getActiveTabData()),schemaError:!1,errorMap:{}},function(e){i.schemaEditorView.setState(i.getSchemaEditorNewState()),i.updateDataEditor(i.getEditorData())})},i.updateDataEditor=function(e){this.dataEditorView.dispatch({changes:{from:0,to:this.dataEditorView.state.doc.length,insert:e}})},i.getActiveTab=function(){return Qd[this.props.activeTabIndex]},i.getActiveTabSchema=function(){return Qd[this.props.activeTabIndex].schema},i.getActiveTabData=function(){return Qd[this.props.activeTabIndex].data},i.getEditorSchema=function(){return JSON.stringify(this.state.rjf_state.getSchema(),null,2)},i.getEditorData=function(){return JSON.stringify(this.state.rjf_state.getData(),null,2)},i.render=function(){/*#__PURE__*/return r.default.createElement("div",{className:"tab-content mt-5"},/*#__PURE__*/r.default.createElement("div",{className:"row"},/*#__PURE__*/r.default.createElement(Zd,{activeTabIndex:this.props.activeTabIndex}),/*#__PURE__*/r.default.createElement("div",{className:"col-12 col-sm-6 order-2 order-md-1"},/*#__PURE__*/r.default.createElement("div",{className:"mb-4"},/*#__PURE__*/r.default.createElement("p",null,/*#__PURE__*/r.default.createElement("strong",null,"Schema")),/*#__PURE__*/r.default.createElement("div",{ref:this.schemaEditorParentRef,className:"cm-container"}),this.state.schemaError&&/*#__PURE__*/r.default.createElement("p",{className:"text-danger"},/*#__PURE__*/r.default.createElement("small",null,"(!) Schema is not valid"),/*#__PURE__*/r.default.createElement("br",null),/*#__PURE__*/r.default.createElement("small",null,this.state.schemaError))),/*#__PURE__*/r.default.createElement("div",{className:"mb-4"},/*#__PURE__*/r.default.createElement("p",null,/*#__PURE__*/r.default.createElement("strong",null,"Output data")),/*#__PURE__*/r.default.createElement("div",{ref:this.dataEditorParentRef,className:"cm-container cm-readonly"}),/*#__PURE__*/r.default.createElement("small",{className:"text-muted"},"Read-only"))),/*#__PURE__*/r.default.createElement("div",{className:"col-12 col-sm-6 order-1 order-md-2"},/*#__PURE__*/r.default.createElement("p",null,/*#__PURE__*/r.default.createElement("strong",null,"Form")),/*#__PURE__*/r.default.createElement("div",{className:"mb-4"},/*#__PURE__*/r.default.createElement(qd,{editorState:this.state.rjf_state,onChange:this.handleFormChange,fileHandler:"/none/",fieldName:"test_field",modelName:"TestModel",errorMap:this.state.errorMap,key:this.props.activeTabIndex}),"validation"===this.getActiveTab().slug&&/*#__PURE__*/r.default.createElement("div",{className:"mt-1"},/*#__PURE__*/r.default.createElement("button",{type:"button",className:"btn btn-secondary px-3",onClick:this.validateData},"Submit"))))))},t}(r.default.Component);function Zd(e){var t=Qd[e.activeTabIndex].description;return t?/*#__PURE__*/r.default.createElement("div",{className:"col-12 mt-n4"},/*#__PURE__*/r.default.createElement("div",{className:"alert alert-info d-flex flex-row"},/*#__PURE__*/r.default.createElement("div",{className:"alert--icon flex-shrink-1 flex-grow-0 mr-3"},/*#__PURE__*/r.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",className:"bi bi-info-square",viewBox:"0 0 16 16"},/*#__PURE__*/r.default.createElement("path",{d:"M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"}),/*#__PURE__*/r.default.createElement("path",{d:"m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"}))),/*#__PURE__*/r.default.createElement("div",{className:"alert--content"},t()))):null}s.default.render(/*#__PURE__*/r.default.createElement(r.default.StrictMode,null,/*#__PURE__*/r.default.createElement(/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).onTabClick=function(e,t){window.location.hash=e+"-"+t,i.setState({activeTabIndex:e})},i.state={activeTabIndex:i.getActiveTabIndexFromHash()||0},i}a(t,e);var i=t.prototype;return i.getActiveTabIndexFromHash=function(){if(!window.location.hash)return 0;try{var e=window.location.hash.split("-")[0].split("#")[1];return isNaN(e)?0:Number(e)}catch(e){return 0}},i.render=function(){/*#__PURE__*/return r.default.createElement("div",{className:"playground"},/*#__PURE__*/r.default.createElement(Yd,{activeTabIndex:this.state.activeTabIndex,onClick:this.onTabClick}),/*#__PURE__*/r.default.createElement(Xd,{activeTabIndex:this.state.activeTabIndex}))},t}(r.default.Component),null)),document.getElementById("playgroundRoot"))}); +/*@__PURE__*/Na.add({"Object Array":function(e){let t=e.firstChild,i=e.lastChild;return t&&t.to=0||(r[i]=e[i]);return r}var ru="§",su="__RJF_FILLER__",ou=/*#__PURE__*/r.default.createContext();function au(e){return e?e.charAt(0).toUpperCase()+e.substr(1).toLowerCase():""}function lu(e,t){return typeof e===t||("number"===t||"integer"===t?"string"==typeof e?""===(e=e.trim())?e=null:isNaN(Number(e))||(e=Number(e)):"boolean"==typeof e&&(e=!0===e?1:0):"boolean"===t&&(e="false"!==e&&!1!==e)),e}function hu(e){var t=typeof e;return"object"===t&&(Array.isArray(e)?t="array":null===e&&(t="null")),t}function cu(e){var t;return(t=e.hasOwnProperty("const")?hu(e.const):mu(e.type))||(t=e.hasOwnProperty("properties")||e.hasOwnProperty("keys")?"object":e.hasOwnProperty("items")?"array":e.hasOwnProperty("allOf")?"allOf":e.hasOwnProperty("oneOf")?"oneOf":e.hasOwnProperty("anyOf")?"anyOf":"string"),t}function uu(){var e=document.cookie.split(";").filter(function(e){return 0===e.trim().indexOf("csrftoken=")});if(e.length)return e[0].split("=")[1];var t=document.querySelector('input[name="csrfmiddlewaretoken"]');return t?t.value:null}function du(){return Array.from(arguments).join(ru)}function fu(e){return e.split(ru)}function pu(e){return e.slice("rjf§".length)}function mu(e){switch(Array.isArray(e)&&(e=e.find(function(e){return"null"!==e})||"null"),e){case"list":return"array";case"dict":return"object";case"keys":return"properties";case"choices":return"enum";case"datetime":return"date-time";default:return e}}function gu(e,t,i,n){return vu(e,t,vu(e,i,n))}function vu(e,t,i){var n=e[t];return void 0!==n?n:i}function yu(e,t){var i=gu(e,"choices","enum");return!i||void 0!==i.find(function(e){return"object"==typeof e&&(e=e.value),t==e})}function wu(e,t){var i={},n=gu(e,"keys","properties",{});for(var r in n){var s=n[r],o=s.hasOwnProperty("$ref"),a=s.hasOwnProperty("const");o&&delete(s=iu({},t(s.$ref),s)).$ref;var l=mu(s.type);l||(s.hasOwnProperty("oneOf")?s=s.oneOf[0]:s.hasOwnProperty("anyOf")&&(s=s.anyOf[0]),l=mu(s.type));var h=s.default;a&&(l=hu(s.const),h=s.const),i[r]="array"===l?o?[]:bu(s,t):"object"===l?wu(s,t):"boolean"===l?!1!==h&&(h||null):"integer"===l||"number"===l?0===h?0:h||null:h||""}if(e.hasOwnProperty("oneOf")&&(i=iu({},i,wu(e.oneOf[0]))),e.hasOwnProperty("anyOf")&&(i=iu({},i,wu(e.anyOf[0]))),e.hasOwnProperty("allOf"))for(var c=0;c=i)return e.default;var n=[];if(e.default&&(n=[].concat(e.default)),0===i)return n;e.items.hasOwnProperty("$ref")&&(e.items=iu({},t(e.items.$ref),e.items),delete e.items.$ref);var r=mu(e.items.type);if(r||(Array.isArray(e.items.oneOf)?r=cu(e.items.oneOf[0]):Array.isArray(e.items.anyOf)?r=cu(e.items.anyOf[0]):Array.isArray(e.items.allOf)?r=cu(e.items.allOf[0]):e.items.hasOwnProperty("const")&&(r=hu(e.items.const))),"array"===r){for(;n.length=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e);!(i=n()).done;)if(!t.has(i.value))return!1;return!0}(keyset2,keyset1))return!1}else if(n=keyset2,r=keyset1,n.size!==r.size||!Array.from(n).every(function(e){return r.has(e)}))return!1;for(var o in s)if(s.hasOwnProperty(o)){if(!e.hasOwnProperty(o))return!1;if(s[o].hasOwnProperty("const")&&s[o].const!==e[o])return!1;var a=mu(s[o].type),l=hu(e[o]);if("number"===a&&-1===["number","integer","null"].indexOf(l))return!1;if("integer"===a&&-1===["number","integer","null"].indexOf(l))return!1;if("boolean"===a&&-1===["boolean","null"].indexOf(l))return!1;if("string"===a&&"string"!==l)return!1}return!0}function Du(e,t){var i=hu(e);if(cu(t)!==i)return!1;for(var n=t.items.type,r=0;r12?1:"hh"!==e&&t>59?0:t},t.handleChange=function(e){var i,n=e.target.dataset.name,r=e.target.value;if(!isNaN(r)){var s=t.validateValue(n,parseInt(r)||0);"hh"!==n||"0"!==r&&""!==r&&"00"!==r||1!==s||(s=0),r.startsWith("0")&&s<10&&0!==s&&(s=s.toString().padStart(2,"0")),t.sendValue(((i={})[n]=""!==r?s.toString():"",i))}},t.handleKeyDown=function(e){var i;if(38===e.keyCode||40===e.keyCode){var n=e.target.dataset.name,r=parseInt(e.target.value)||0;38===e.keyCode?r++:40===e.keyCode&&r--,t.sendValue(((i={})[n]=t.validateValue(n,r).toString().padStart(2,"0"),i))}},t.handleSpin=function(e,i){var n,r=t.props[e];"ampm"===e?r="am"===r?"pm":"am":(r=parseInt(r)||0,"up"===i?r++:r--,r=t.validateValue(e,r).toString().padStart(2,"0")),t.sendValue(((n={})[e]=r,n))},t.handleBlur=function(e){var i,n=t.validateValue(e.target.dataset.name,parseInt(e.target.value)||0);n<10&&t.sendValue(((i={})[e.target.dataset.name]=n.toString().padStart(2,"0"),i))},t}a(t,e);var i=t.prototype;return i.componentWillUnmount=function(){var e={hh:this.validateValue("hh",this.props.hh).toString().padStart(2,"0"),mm:this.validateValue("mm",this.props.mm).toString().padStart(2,"0"),ss:this.validateValue("ss",this.props.ss).toString().padStart(2,"0")};this.sendValue(e)},i.render=function(){var e=this;/*#__PURE__*/return r.default.createElement("div",{className:"rjf-time-picker"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-row rjf-time-picker-labels"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},"Hrs"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},"Min"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},"Sec"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},"am/pm")),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-row"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("hh","up")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-up"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("mm","up")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-up"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("ss","up")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-up"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("ampm","up")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-up"})))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-row rjf-time-picker-values"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement("input",{type:"text","data-name":"hh",value:this.props.hh,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"},":"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement("input",{type:"text","data-name":"mm",value:this.props.mm,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"},":"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement("input",{type:"text","data-name":"ss",value:this.props.ss,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},this.props.ampm)),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-row"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("hh","down")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-down"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("mm","down")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-down"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("ss","down")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-down"}))),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/r.default.createElement(Ru,{onClick:function(){return e.handleSpin("ampm","down")}},/*#__PURE__*/r.default.createElement(Bu,{name:"chevron-down"})))))},t}(r.default.Component),qu=["label","help_text","error","inputRef"],$u=["label","help_text","error","value"],Uu=["label","help_text","error","value","options"],Ju=["label","help_text","error","value","options"],Ku=["label","value"],Gu=["label","help_text","error","inputRef"];function Qu(e){return e.label?/*#__PURE__*/r.default.createElement("label",{className:e.required?"rjf-required":null},e.children,e.children&&" ",e.label):null}function Yu(e){var t=e.label,i=e.help_text,n=e.error,s=e.inputRef,o=nu(e,qu);"string"===o.type&&(o.type="text"),s&&(o.ref=s),null===o.value&&(o.value="");var a={};return"hidden"==o.type&&(a.style={display:"none"}),o.readOnly&&null==o.disabled&&(o.disabled=!0),/*#__PURE__*/r.default.createElement("div",a,/*#__PURE__*/r.default.createElement(Qu,{label:t,required:o.required}),/*#__PURE__*/r.default.createElement("div",{className:n?"rjf-input-group has-error":"rjf-input-group"},o.children||/*#__PURE__*/r.default.createElement("input",o),n&&n.map(function(e,t){/*#__PURE__*/return r.default.createElement("span",{className:"rjf-error-text",key:t},e)}),i&&/*#__PURE__*/r.default.createElement("span",{className:"rjf-help-text"},i)))}function Xu(e){var t=e.label,i=e.help_text,n=e.error,s=e.value,o=nu(e,$u);return t||(t=o.name.toUpperCase()),"bool"===o.type&&(o.type="checkbox"),void 0===o.checked&&(o.checked=s),""!==o.checked&&null!=o.checked||(o.checked=!1),o.readOnly&&(o.disabled=!0),/*#__PURE__*/r.default.createElement("div",{className:n?"rjf-check-input has-error":"rjf-check-input"},/*#__PURE__*/r.default.createElement(Qu,{label:t,required:o.required},/*#__PURE__*/r.default.createElement("input",o)),n&&n.map(function(e,t){/*#__PURE__*/return r.default.createElement("span",{className:"rjf-error-text",key:t},e)}),i&&/*#__PURE__*/r.default.createElement("span",{className:"rjf-help-text"},i))}function Zu(e){var t=e.label,i=e.help_text,n=e.error,s=e.value,o=e.options,a=nu(e,Uu);return a.readOnly&&(a.disabled=!0),/*#__PURE__*/r.default.createElement("div",{className:n?"rjf-check-input has-error":"rjf-check-input"},/*#__PURE__*/r.default.createElement(Qu,{label:t,required:a.required}),o.map(function(e,t){var i,n;return"object"==typeof e?(i=e.title||e.label,n=e.value):("boolean"==typeof(i=e)&&(i=au(i.toString())),n=e),/*#__PURE__*/r.default.createElement("label",{className:"rjf-radio-option",key:i+"_"+n+"_"+t},/*#__PURE__*/r.default.createElement("input",iu({},a,{value:n,checked:n===s}))," ",i)}),n&&n.map(function(e,t){/*#__PURE__*/return r.default.createElement("span",{className:"rjf-error-text",key:t},e)}),i&&/*#__PURE__*/r.default.createElement("span",{className:"rjf-help-text"},i))}function ed(e){var t=e.label,i=e.help_text,n=e.error,s=e.value,o=e.options,a=nu(e,Ju);return a.readOnly&&(a.disabled=!0),s||!1===s||0===s||(s=""),/*#__PURE__*/r.default.createElement("div",null,/*#__PURE__*/r.default.createElement(Qu,{label:t,required:a.required}),/*#__PURE__*/r.default.createElement("div",{className:n?"rjf-input-group has-error":"rjf-input-group"},/*#__PURE__*/r.default.createElement("select",iu({value:s},a),/*#__PURE__*/r.default.createElement("option",{disabled:!0,value:"",key:"__placeholder"},"Select..."),o.map(function(e,t){var i,n;return"object"==typeof e?(i=e.title||e.label,n=e.value):("boolean"==typeof(i=e)&&(i=au(i.toString())),n=e),/*#__PURE__*/r.default.createElement("option",{value:n,key:i+"_"+n+"_"+t},i)})),n&&n.map(function(e,t){/*#__PURE__*/return r.default.createElement("span",{className:"rjf-error-text",key:t},e)}),i&&/*#__PURE__*/r.default.createElement("span",{className:"rjf-help-text"},i)))}var td=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).handleChange=function(e){var t=[].concat(i.props.value),n=e.target.value;typeof n!==i.props.valueType&&(n=lu(n,i.props.valueType)),e.target.checked?t.push(n):t=t.filter(function(e){return e!==n}),i.props.onChange({target:{type:i.props.type,value:t,name:i.props.name}})},i.showOptions=function(e){i.state.showOptions||i.setState({showOptions:!0})},i.hideOptions=function(e){i.setState({showOptions:!1})},i.toggleOptions=function(e){i.setState(function(e){return{showOptions:!e.showOptions}})},i.state={showOptions:!1},i.optionsContainer=/*#__PURE__*/r.default.createRef(),i.input=/*#__PURE__*/r.default.createRef(),i}return a(t,e),t.prototype.render=function(){/*#__PURE__*/return r.default.createElement("div",{className:this.props.readOnly?"rjf-multiselect-field readonly":"rjf-multiselect-field"},/*#__PURE__*/r.default.createElement(Yu,{label:this.props.label,help_text:this.props.help_text,error:this.props.error},/*#__PURE__*/r.default.createElement(id,{inputRef:this.input,onClick:this.toggleOptions,value:this.props.value,options:this.props.options,onChange:this.handleChange,disabled:this.props.readOnly,placeholder:this.props.placeholder})),this.state.showOptions&&/*#__PURE__*/r.default.createElement(nd,{options:this.props.options,value:this.props.value,hideOptions:this.hideOptions,onChange:this.handleChange,containerRef:this.optionsContainer,inputRef:this.input,disabled:this.props.readOnly,hasHelpText:(this.props.help_text||this.props.error)&&1}))},t}(r.default.Component),id=/*#__PURE__*/function(e){function t(){var t;return(t=e.call.apply(e,[this].concat([].slice.call(arguments)))||this).handleRemove=function(e,i){e.stopPropagation(),t.props.onChange({target:{value:t.props.value[i],checked:!1}})},t}return a(t,e),t.prototype.render=function(){var e=this,t=function(e){for(var t={},i=0;i-1,a="rjf-multiselect-field-option";return o&&(a+=" selected"),e.props.disabled&&(a+=" disabled"),/*#__PURE__*/r.default.createElement("div",{key:n+"_"+s+"_"+i,className:a},/*#__PURE__*/r.default.createElement("label",null,/*#__PURE__*/r.default.createElement("input",{type:"checkbox",onChange:e.props.onChange,value:s,checked:o,disabled:e.props.disabled})," ",n))})))},t}(r.default.Component),rd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).getFileName=function(){return i.props.value?"data-url"===i.props.type?i.extractFileInfo(i.props.value).name:"file-url"===i.props.type?i.props.value:"Unknown file":""},i.extractFileInfo=function(e){var t=function(e){var t,i=e.split(","),n=i[0].split(";"),r=n[0].replace("data:",""),s=n.filter(function(e){return"name"===e.split("=")[0]});t=1!==s.length?"unknown":s[0].split("=")[1];for(var o=atob(i[1]),a=[],l=0;l12&&(t-=12,o="pm"),n=a.getMinutes(),r=a.getSeconds(),s=a.getMilliseconds(),t=t.toString().padStart(2,"0"),n=n.toString().padStart(2,"0"),r=r.toString().padStart(2,"0")}return{date:e,hh:t,mm:n,ss:r,ms:s,ampm:o}},i.handleClickOutside=function(e){i.state.showTimePicker&&(!i.timePickerContainer.current||i.timePickerContainer.current.contains(e.target)||i.timeInput.current.contains(e.target)||i.setState({showTimePicker:!1}))},i.sendValue=function(){var e={target:{type:"text",value:"",name:i.props.name}};if(""===i.state.date||null===i.state.date)return i.props.onChange(e);var t=parseInt(i.state.hh);0===t&&(t=NaN),"am"===i.state.ampm?12===t&&(t=0):"pm"===i.state.ampm&&12!==t&&(t+=12),t=t.toString().padStart(2,"0");var n=i.state.mm.padStart(2,"0"),r=i.state.ss.padStart(2,"0");try{var s=new Date(i.state.date+"T"+t+":"+n+":"+r+"."+i.state.ms);e.target.value=s.toISOString().replace("Z","+00:00")}catch(t){return i.props.onChange(e)}i.props.onChange(e)},i.handleDateChange=function(e){i.setState({date:e.target.value},i.sendValue)},i.handleTimeChange=function(e){i.setState(iu({},e),i.sendValue)},i.showTimePicker=function(){i.setState({showTimePicker:!i.props.readOnly&&!0})},i.state=iu({},i.getStateFromProps(),{showTimePicker:!1}),i.timeInput=/*#__PURE__*/r.default.createRef(),i.timePickerContainer=/*#__PURE__*/r.default.createRef(),i}a(t,e);var i=t.prototype;return i.componentDidUpdate=function(e,t){if(e.value!==this.props.value&&""!==this.state.hh&&"0"!==this.state.hh&&"00"!==this.state.hh){var i=!1,n=this.getStateFromProps();for(var r in n)if(n[r]!==this.state[r]){i=!0;break}i&&this.setState(iu({},n))}},i.componentDidMount=function(){document.addEventListener("mousedown",this.handleClickOutside)},i.componentWillUnmount=function(){document.removeEventListener("mousedown",this.handleClickOutside)},i.render=function(){/*#__PURE__*/return r.default.createElement("div",{className:this.props.error?"rjf-datetime-field has-error":"rjf-datetime-field"},/*#__PURE__*/r.default.createElement(Qu,{label:this.props.label,required:this.props.required}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-datetime-field-inner"},/*#__PURE__*/r.default.createElement("div",{className:this.props.readOnly?"rjf-datetime-field-inputs readonly":"rjf-datetime-field-inputs"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-datetime-field-date"},/*#__PURE__*/r.default.createElement(Yu,{label:"Date",type:"date",value:this.state.date,onChange:this.handleDateChange,readOnly:this.props.readOnly})),/*#__PURE__*/r.default.createElement("div",{className:"rjf-datetime-field-time"},/*#__PURE__*/r.default.createElement(Yu,{label:"Time",type:"text",value:this.state.hh+":"+this.state.mm+":"+this.state.ss+" "+this.state.ampm,onFocus:this.showTimePicker,readOnly:!0,disabled:this.props.readOnly||!1,inputRef:this.timeInput}),/*#__PURE__*/r.default.createElement("div",{ref:this.timePickerContainer},this.state.showTimePicker&&/*#__PURE__*/r.default.createElement(Wu,{onChange:this.handleTimeChange,hh:this.state.hh,mm:this.state.mm,ss:this.state.ss,ampm:this.state.ampm})))),this.props.error&&this.props.error.map(function(e,t){/*#__PURE__*/return r.default.createElement("span",{className:"rjf-error-text",key:t},e)}),this.props.help_text&&/*#__PURE__*/r.default.createElement("span",{className:"rjf-help-text"},this.props.help_text)))},t}(r.default.Component);function ad(e){/*#__PURE__*/return r.default.createElement("div",{className:e.label?"rjf-url-field has-label":"rjf-url-field"},/*#__PURE__*/r.default.createElement(Yu,iu({},e,{type:"url",className:"rjf-url-field-input"})),e.value&&/*#__PURE__*/r.default.createElement("a",{href:e.value,target:"_blank",rel:"noopener noreferrer",className:"rjf-url-field-link",title:"Open in new tab"},/*#__PURE__*/r.default.createElement(Bu,{name:"box-arrow-up-right"})," ",/*#__PURE__*/r.default.createElement("span",null,"Open link")))}var ld=/*#__PURE__*/function(e){function t(t){var i,n,s;return(i=e.call(this,t)||this).handleSelect=function(e){i.props.multiselect&&(e=Array.isArray(i.props.value)?i.props.value.concat([e]):[e]);var t={target:{type:i.props.type,value:e,name:i.props.name}};i.props.multiselect||i.hideOptions(),i.props.onChange(t)},i.handleMultiselectRemove=function(e){var t=i.props.value.filter(function(t){return t!==e});i.props.onChange({target:{type:i.props.type,value:t,name:i.props.name}})},i.clearValue=function(e){i.handleSelect(i.defaultEmptyValue)},i.hasValue=function(){return!(Array.isArray(i.props.value)&&!i.props.value.length)&&""!==i.props.value&&null!==i.props.value},i.handleSearchInputChange=function(e){var t=e.target.value;t?i.setState({searchInputValue:t,loading:!0},i.debouncedFetchOptions):i.setState({searchInputValue:t,loading:!1,options:[]})},i.fetchOptions=function(){if(""!==i.state.searchInputValue){var e=i.props.handler;if(!e)return console.error("Error: No 'handler' endpoint provided for autocomplete input."),void i.setState({loading:!1});var t=e+"?"+new URLSearchParams({field_name:i.context.fieldName,model_name:i.context.modelName,coords:pu(i.props.name),query:i.state.searchInputValue});fetch(t,{method:"GET"}).then(function(e){return e.json()}).then(function(e){Array.isArray(e.results)||(e.results=[]),i.setState(function(t){return{loading:!1,options:[].concat(e.results)}})}).catch(function(e){alert("Something went wrong while fetching options"),console.error("Error:",e),i.setState({loading:!1})})}},i.showOptions=function(e){i.state.showOptions||i.setState({showOptions:!0})},i.hideOptions=function(e){i.setState({showOptions:!1,searchInputValue:"",options:[],loading:!1})},i.toggleOptions=function(e){i.setState(function(e){return e.showOptions?{showOptions:!1,searchInputValue:"",options:[],loading:!1}:{showOptions:!0}})},i.state={searchInputValue:"",showOptions:!1,options:[],loading:!1},i.optionsContainer=/*#__PURE__*/r.default.createRef(),i.searchInputRef=/*#__PURE__*/r.default.createRef(),i.input=/*#__PURE__*/r.default.createRef(),i.debouncedFetchOptions=(n=i.fetchOptions,function(){clearTimeout(s);var e=arguments,t=this;s=setTimeout(function(){n.apply(t,e)},500)}),i.defaultEmptyValue=t.multiselect?[]:"",i}a(t,e);var i=t.prototype;return i.componentDidUpdate=function(e,t){this.state.showOptions&&this.state.showOptions!==t.showOptions&&this.searchInputRef.current&&this.searchInputRef.current.focus()},i.render=function(){var e=this;/*#__PURE__*/return r.default.createElement("div",{className:this.props.label?"rjf-autocomplete-field has-label":"rjf-autocomplete-field"},this.props.multiselect?/*#__PURE__*/r.default.createElement(Yu,{label:this.props.label,help_text:this.props.help_text,error:this.props.error},/*#__PURE__*/r.default.createElement(id,{inputRef:this.input,onClick:this.toggleOptions,onChange:function(t){return e.handleMultiselectRemove(t.target.value)},value:this.props.value,placeholder:this.props.placeholder||" ",disabled:this.props.readOnly||!1})):/*#__PURE__*/r.default.createElement(r.default.Fragment,null,/*#__PURE__*/r.default.createElement(Yu,{label:this.props.label,type:"text",value:this.props.value,help_text:this.props.help_text,error:this.props.error,readOnly:!0,disabled:this.props.readOnly||!1,onClick:this.toggleOptions,inputRef:this.input,placeholder:this.props.placeholder,name:this.props.name,className:"rjf-autocomplete-field-input"}),this.hasValue()&&!this.props.readOnly&&/*#__PURE__*/r.default.createElement(Ru,{className:"autocomplete-field-clear",title:"Clear",onClick:this.clearValue},/*#__PURE__*/r.default.createElement(Bu,{name:"x-circle"})," ",/*#__PURE__*/r.default.createElement("span",null,"Clear"))),this.state.showOptions&&!this.props.readOnly&&/*#__PURE__*/r.default.createElement(hd,{options:this.state.options,value:this.props.value,hideOptions:this.hideOptions,onSelect:this.handleSelect,onSearchInputChange:this.handleSearchInputChange,searchInputValue:this.state.searchInputValue,containerRef:this.optionsContainer,searchInputRef:this.searchInputRef,inputRef:this.input,loading:this.state.loading,hasHelpText:(this.props.help_text||this.props.error)&&1,multiselect:this.props.multiselect}))},t}(r.default.Component);ld.contextType=ou;var hd=/*#__PURE__*/function(e){function t(){var t;return(t=e.call.apply(e,[this].concat([].slice.call(arguments)))||this).handleClickOutside=function(e){!t.props.containerRef.current||t.props.containerRef.current.contains(e.target)||t.props.inputRef.current.contains(e.target)||t.props.hideOptions()},t}a(t,e);var i=t.prototype;return i.componentDidMount=function(){document.addEventListener("mousedown",this.handleClickOutside)},i.componentWillUnmount=function(){document.removeEventListener("mousedown",this.handleClickOutside)},i.render=function(){/*#__PURE__*/return r.default.createElement("div",{ref:this.props.containerRef},/*#__PURE__*/r.default.createElement("div",{className:"rjf-autocomplete-field-popup",style:this.props.hasHelpText?{marginTop:"-15px"}:{}},/*#__PURE__*/r.default.createElement(cd,{inputRef:this.props.searchInputRef,onChange:this.props.onSearchInputChange,value:this.props.searchInputValue,loading:this.props.loading}),this.props.searchInputValue&&/*#__PURE__*/r.default.createElement(ud,{options:this.props.options,value:this.props.value,onSelect:this.props.onSelect,loading:this.props.loading,hasHelpText:this.props.hasHelpText,multiselect:this.props.multiselect})))},t}(r.default.Component);function cd(e){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-autocomplete-field-search"},/*#__PURE__*/r.default.createElement(Yu,{type:"text",placeholder:"Search...",inputRef:e.inputRef,onChange:e.onChange,value:e.value,form:""}),e.loading&&/*#__PURE__*/r.default.createElement(ju,null))}function ud(e){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-autocomplete-field-options"},!e.options.length&&!e.loading&&/*#__PURE__*/r.default.createElement("div",{className:"rjf-autocomplete-field-option disabled"},"No options"),e.options.map(function(t,i){var n,s;"object"==typeof t?(n=t.title||t.label,s=t.value):("boolean"==typeof(n=t)&&(n=capitalize(n.toString())),s=t);var o,a="rjf-autocomplete-field-option";return(o=Array.isArray(e.value)?e.value.indexOf(s)>-1:e.value===s)&&(a+=" selected"),/*#__PURE__*/r.default.createElement("div",{key:n+"_"+s+"_"+i,className:a,tabIndex:0,role:"button",onClick:function(){return e.multiselect&&o?null:e.onSelect(s)}},n)}))}function dd(e){return e.children?/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group-title"},e.children,e.editable&&/*#__PURE__*/r.default.createElement(r.default.Fragment,null," ",/*#__PURE__*/r.default.createElement(Ru,{className:"edit",onClick:e.onEdit,title:"Edit"},"Edit")),e.collapsible&&/*#__PURE__*/r.default.createElement(r.default.Fragment,null," ",/*#__PURE__*/r.default.createElement(Ru,{className:"collapse",onClick:e.onCollapse,title:e.collapsed?"Expand":"Collapse"},e.collapsed?"[+]":"[-]"))):null}function fd(e){return e.children?/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group-description"},e.children):null}function pd(e,t,i){var n=e.target.parentElement.parentElement,r=n.previousElementSibling,s=n.nextElementSibling;if(n.classList.add("rjf-animate","rjf-"+t),"move-up"===t){var o=r.getBoundingClientRect().y,a=o,l=o=n.getBoundingClientRect().y;r.classList.add("rjf-animate"),r.style.opacity=0,r.style.transform="translateY("+(l-a)+"px)",n.style.opacity=0,n.style.transform="translateY(-"+(l-a)+"px)"}else if("move-down"===t){var h=n.getBoundingClientRect().y,c=h,u=h=s.getBoundingClientRect().y;s.classList.add("rjf-animate"),s.style.opacity=0,s.style.transform="translateY(-"+(u-c)+"px)",n.style.opacity=0,n.style.transform="translateY("+(u-c)+"px)"}setTimeout(function(){i(),n.classList.remove("rjf-animate","rjf-"+t),n.style=null,"move-up"===t?(r.classList.remove("rjf-animate"),r.style=null):"move-down"===t&&(s.classList.remove("rjf-animate"),s.style=null)},200)}function md(e){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-form-row-controls"},e.onMoveUp&&/*#__PURE__*/r.default.createElement(Ru,{className:"move-up",onClick:function(t){return pd(t,"move-up",e.onMoveUp)},title:"Move up"},/*#__PURE__*/r.default.createElement("span",null,"↑")),e.onMoveDown&&/*#__PURE__*/r.default.createElement(Ru,{className:"move-down",onClick:function(t){return pd(t,"move-down",e.onMoveDown)},title:"Move down"},/*#__PURE__*/r.default.createElement("span",null,"↓")),e.onRemove&&/*#__PURE__*/r.default.createElement(Ru,{className:"remove",onClick:function(t){return pd(t,"remove",e.onRemove)},title:"Remove"},/*#__PURE__*/r.default.createElement("span",null,"×")))}function gd(e){var t="rjf-form-row";return e.hidden&&(t+=" rjf-form-row-hidden"),/*#__PURE__*/r.default.createElement("div",{className:t},/*#__PURE__*/r.default.createElement(md,e),/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-row-inner"},e.children))}function vd(e){var t=r.default.useState(!1),i=t[0],n=t[1],s=cu(e.schema);r.default.Children.count(e.children);var o,a,l=0===e.level&&"groups"===e.childrenType?"":"rjf-form-group-inner";return"object"===s?(o="Add key",a="Add new key"):(o="Add item",a="Add new item"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group"},0===e.level&&/*#__PURE__*/r.default.createElement(dd,{editable:e.editable,onEdit:e.onEdit,collapsible:e.collapsible,onCollapse:function(){return n(!i)},collapsed:i},e.schema.title),0===e.level&&/*#__PURE__*/r.default.createElement(fd,null,e.schema.description),/*#__PURE__*/r.default.createElement("div",{className:l},e.level>0&&/*#__PURE__*/r.default.createElement(dd,{editable:e.editable,onEdit:e.onEdit,collapsible:e.collapsible,onCollapse:function(){return n(!i)},collapsed:i},e.schema.title),e.level>0&&/*#__PURE__*/r.default.createElement(fd,null,e.schema.description),i&&/*#__PURE__*/r.default.createElement("div",{className:"rjf-collapsed-indicator"},/*#__PURE__*/r.default.createElement("span",null,"Collapsed")),/*#__PURE__*/r.default.createElement("div",{className:i?"rjf-form-group-children rjf-collapsed":"rjf-form-group-children"},e.children),!i&&e.addable&&/*#__PURE__*/r.default.createElement(Ru,{className:"add",onClick:function(t){return e.onAdd()},title:a},o)))}var yd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).openModal=function(e){i.setState({open:!0})},i.closeModal=function(e){i.setState({open:!1,pane:"upload"})},i.togglePane=function(e){i.setState({pane:e})},i.handleFileSelect=function(e){i.props.onChange({target:{type:"text",value:e,name:i.props.name}}),i.closeModal()},i.handleFileUpload=function(e){i.newFiles.push(e.target.value),i.addExitEventListeners(),i.props.onChange(e),i.closeModal()},i.addExitEventListeners=function(){i.exitListenersAdded||i.hiddenInputRef.current&&i.hiddenInputRef.current.form&&(window.addEventListener("beforeunload",i.promptOnExit),window.addEventListener("unload",i.sendDeleteRequestOnExit),i.hiddenInputRef.current.form.addEventListener("submit",function(e){window.removeEventListener("beforeunload",i.promptOnExit),window.removeEventListener("unload",i.sendDeleteRequestOnExit)}),i.exitListenersAdded=!0)},i.promptOnExit=function(e){i.newFiles.length&&(e.preventDefault(),e.returnValue="")},i.sendDeleteRequestOnExit=function(e){i.newFiles.length&&i.sendDeleteRequest([i.newFiles],"unsaved_form_page_exit",!0)},i.clearFile=function(){window.confirm("Do you want to remove this file?")&&i.props.onChange({target:{type:"text",value:"",name:i.props.name}})},i.sendDeleteRequest=function(e,t,n){for(var r=i.props.handler||i.context.fileHandler,s=new URLSearchParams(iu({},i.context.fileHandlerArgs,{coords:pu(i.props.name),trigger:t})),o=0;o0?t.page+1:t.page,hasMore:e.results.length>0}})}).catch(function(e){alert("Something went wrong while retrieving media files"),console.error("Error:",e),i.setState({loading:!1})})},i.onLoadMore=function(e){i.setState({loading:!0},i.fetchList)},i.onFileDelete=function(){i.setState({page:0,files:[]},i.onLoadMore)},i.state={loading:!0,files:[],page:0,hasMore:!0},i}a(t,e);var i=t.prototype;return i.componentDidMount=function(){this.fetchList()},i.render=function(){var e=this;/*#__PURE__*/return r.default.createElement("div",{className:"rjf-upload-modal__pane"},/*#__PURE__*/r.default.createElement("h3",null,"Media library"),/*#__PURE__*/r.default.createElement("div",{className:"rjf-upload-modal__media-container"},this.state.files.map(function(t){/*#__PURE__*/return r.default.createElement(xd,iu({},t,{onClick:e.props.onFileSelect,sendDeleteRequest:e.props.sendDeleteRequest,onFileDelete:e.onFileDelete}))})),this.state.loading&&/*#__PURE__*/r.default.createElement(ju,{className:"rjf-upload-modal__media-loader"}),!this.state.loading&&this.state.hasMore&&/*#__PURE__*/r.default.createElement("div",null,/*#__PURE__*/r.default.createElement(Ru,{onClick:this.onLoadMore,className:"upload-modal__media-load"},/*#__PURE__*/r.default.createElement(Bu,{name:"arrow-down"})," View more")),!this.state.hasMore&&/*#__PURE__*/r.default.createElement("div",{className:"rjf-upload-modal__media-end-message"},this.state.files.length?"End of list":"No files found"))},t}(r.default.Component);function xd(e){var t=e.metadata||{};/*#__PURE__*/return r.default.createElement("div",{className:"rjf-upload-modal__media-tile"},/*#__PURE__*/r.default.createElement(Sd,{value:e.value,sendDeleteRequest:e.sendDeleteRequest,onFileDelete:e.onFileDelete}),/*#__PURE__*/r.default.createElement("div",{className:"rjf-upload-modal__media-tile-inner",tabIndex:"0",onClick:function(){return e.onClick(e.value)}},/*#__PURE__*/r.default.createElement("img",{src:e.thumbnail?e.thumbnail:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23999999' viewBox='0 0 16 16'%3E%3Cpath d='M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5L14 4.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5h-2z'/%3E%3C/svg%3E"}),e.metadata&&/*#__PURE__*/r.default.createElement("div",{className:"rjf-upload-modal__media-tile-metadata"},Object.getOwnPropertyNames(t).map(function(e){/*#__PURE__*/return r.default.createElement("span",null,t[e])}))))}var Sd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).toggleMenu=function(e){i.setState(function(e){return{open:!e.open}})},i.handleDeleteClick=function(e){window.confirm("Do you want to delete this file?")&&(i.setState({loading:!0}),i.props.sendDeleteRequest([i.props.value],"delete_button").then(function(e){var t,n=e.status;200===n||(400===n?t="Bad request":401===n||403===n?t="You don't have permission to delete this file":404===n?t="This file does not exist on server":405===n?t="This operation is not permitted":n>405&&(t="Something went wrong while deleting file")),i.setState({loading:!1,open:!1}),t?alert(t):i.props.onFileDelete()}).catch(function(e){alert("Something went wrong while deleting file"),console.error("Error:",e),i.setState({loading:!1})}))},i.state={open:!1,loading:!1},i}return a(t,e),t.prototype.render=function(){/*#__PURE__*/return r.default.createElement("div",{className:this.state.open?"rjf-dropdown open":"rjf-dropdown"},/*#__PURE__*/r.default.createElement(Ru,{className:"rjf-dropdown-toggler",alterClassName:!1,title:this.state.open?"Close menu":"Open menu",onClick:this.toggleMenu},/*#__PURE__*/r.default.createElement(Bu,{name:this.state.open?"x-lg":"three-dots-vertical"})),this.state.open&&/*#__PURE__*/r.default.createElement("div",{className:"rjf-dropdown-items"},/*#__PURE__*/r.default.createElement(Ru,{className:"rjf-dropdown-item rjf-text-danger",alterClassName:!1,onClick:this.handleDeleteClick},this.state.loading&&/*#__PURE__*/r.default.createElement(ju,null),this.state.loading?" Deleting...":"Delete")))},t}(r.default.Component),Od=["data","schema","name","onChange","onRemove","removable","onEdit","onKeyEdit","editable","onMoveUp","onMoveDown","parentType","errorMap"];function Cd(e){var t,i={name:e.name,value:e.data,readOnly:gu(e.schema,"readOnly","readonly"),help_text:gu(e.schema,"help_text","helpText"),error:e.errorMap[pu(e.name)],required:e.schema.required||!1};"string"==typeof i.error&&(i.error=[i.error]),e.schema.placeholder&&(i.placeholder=e.schema.placeholder),e.schema.handler&&(i.handler=e.schema.handler),e.schema.hasOwnProperty("const")?(t=hu(e.schema.const),i.readOnly=!0):t=mu(e.schema.type);var n,s=gu(e.schema,"choices","enum");switch(s&&(i.options=s,t="select"),e.schema.widget&&("multiselect"===e.schema.widget&&"array"!==e.parentType||(t="hidden"===e.schema.widget?"string":e.schema.widget)),t){case"string":if(n=Yu,e.schema.format){var o=e.schema.format;"data-url"===o?n=rd:"file-url"===o?n=yd:"date-time"===mu(o)?n=od:"uri"!==o&&"uri-reference"!==o||(n=ad),i.type=o}else i.type="hidden"===e.schema.widget?"hidden":"text";(e.schema.minLength||0===e.schema.minLength)&&(i.minLength=e.schema.minLength),(e.schema.maxLength||0===e.schema.maxLength)&&(i.maxLength=e.schema.maxLength);break;case"fileinput":n=rd,e.schema.format&&(i.type=e.schema.format);break;case"range":case"integer":i.step="1";case"number":i.type="range"===t?"range":"number",i.step="any",n=Yu,(e.schema.minimum||0===e.schema.minimum)&&(i.min=e.schema.minimum),(e.schema.maximum||0===e.schema.maximum)&&(i.max=e.schema.maximum);break;case"boolean":case"checkbox":i.type="checkbox",n=Xu;break;case"radio":i.type="radio",n=Zu;break;case"select":n=ed;break;case"multiselect":i.valueType=e.schema.type,n=td;break;case"autocomplete":n=ld;break;case"multiselect-autocomplete":n=ld,i.multiselect=!0;break;case"textarea":n=sd,(e.schema.minLength||0===e.schema.minLength)&&(i.minLength=e.schema.minLength),(e.schema.maxLength||0===e.schema.maxLength)&&(i.maxLength=e.schema.maxLength);break;default:i.type="text",n=Yu}/*#__PURE__*/return r.default.createElement(n,iu({},i,{label:e.editable?/*#__PURE__*/r.default.createElement("span",null,e.schema.title," ",/*#__PURE__*/r.default.createElement(Ru,{className:"edit",onClick:e.onEdit,title:"Edit"},"Edit")):e.schema.title,onChange:function(t){return function(e,t,i){var n;n="checkbox"===e.target.type?e.target.checked:e.target.value,n=Array.isArray(n)?n.map(function(e){return lu(e,t)}):lu(n,t),i(e.target.name,n)}(t,e.schema.type,e.onChange)}}))}function Ad(e){var t=e.data,i=e.schema,n=e.name,s=e.onChange,o=e.onRemove,a=e.removable,l=e.onKeyEdit,h=e.editable,c=e.onMoveUp,u=e.onMoveDown,d=e.parentType,f=e.errorMap,p=nu(e,Od);/*#__PURE__*/return r.default.createElement(gd,{key:n,onRemove:a?function(e){return o(n)}:null,onMoveUp:c,onMoveDown:u,hidden:"hidden"===i.widget},/*#__PURE__*/r.default.createElement(Cd,iu({data:t,schema:i,name:n,onChange:s,onEdit:l,editable:h,parentType:d,errorMap:f},p)))}function Ed(e){var t=e.data,i=e.schema,n=e.name,s=e.onChange,o=e.onAdd,a=e.onRemove,l=e.onMove,h=e.onEdit,c=e.level,u=[],d=[],f=gu(i,"readonly","readOnly",!1),p=!0,m=gu(i,"min_items","minItems")||0;(t.length<=m||f)&&(p=!1);var g=!0,v=gu(i,"max_items","maxItems")||100;(t.length>=v||f)&&(g=!1),i.items.hasOwnProperty("$ref")&&(i.items=iu({},e.getRef(i.items.$ref),i.items),delete i.items.$ref);var y=mu(i.items.type),w={schema:i.items,onChange:s,onAdd:o,onRemove:a,level:c+1,removable:p,onMove:l,onEdit:h,onKeyEdit:e.onKeyEdit,parentType:"array",getRef:e.getRef,errorMap:e.errorMap};if(f&&(w.schema.readOnly=!0),"multiselect"===w.schema.widget||"multiselect-autocomplete"===w.schema.widget)w.data=t,w.name=n,w.removable=!1,w.onMoveUp=null,w.onMoveDown=null,g=!1,u.push(Ad(w));else for(var b=function(s){w.data=t[s],w.name=du(n,s),w.onMoveUp=0===s||f?null:function(e){return l(du(n,s),du(n,s-1))},w.onMoveDown=s===t.length-1||f?null:function(e){return l(du(n,s),du(n,s+1))},"array"===y?d.push(Ed(w)):"object"===y?d.push(Md(w)):i.items.hasOwnProperty("oneOf")?d.push(/*#__PURE__*/r.default.createElement(Rd,{parentArgs:e,nextArgs:iu({},w),key:"oneOf_"+n+"_"+s})):i.items.hasOwnProperty("anyOf")?d.push(/*#__PURE__*/r.default.createElement(jd,{parentArgs:e,nextArgs:iu({},w),key:"anyOf_"+n+"_"+s})):u.push(Ad(w))},k=0;k0,childrenType:"rows"},x&&x.map(function(e,t){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-error-text",key:t},e)}),u),"object"===e.parentType&&e.removable&&(u=/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group-wrapper",key:"row_group_wrapper_"+n},/*#__PURE__*/r.default.createElement(md,{onRemove:function(e){return a(n)}}),u))),d.length){var O=e.errorMap[pu(S)];"string"==typeof O&&(O=[O]),d=/*#__PURE__*/r.default.createElement("div",{key:"group_"+n,className:"rjf-form-group-wrapper"},"object"===e.parentType&&e.removable&&/*#__PURE__*/r.default.createElement(md,{onRemove:function(e){return a(n)}}),/*#__PURE__*/r.default.createElement(vd,{level:c,schema:i,addable:g,onAdd:function(){return o(xu(i.items,e.getRef),S)},editable:e.editable,onEdit:e.onKeyEdit,collapsible:t.length>0,childrenType:"groups"},O&&O.map(function(e,t){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-error-text",key:t},e)}),d.map(function(e,t){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-form-group-wrapper",key:"group_wrapper_"+n+"_"+t},/*#__PURE__*/r.default.createElement(md,{onRemove:p?function(e){return a(du(n,t))}:null,onMoveUp:t>0&&!f?function(e){return l(du(n,t),du(n,t-1))}:null,onMoveDown:t-1&&(w.required=!0);var S={data:v,schema:w,name:y,onChange:s,onAdd:o,onRemove:a,level:c+1,removable:x,onMove:l,onEdit:h,parentType:"object",getRef:e.getRef,errorMap:e.errorMap,onKeyEdit:function(){return function(e,t,i,n,r){var s=prompt("Rename key",t);if(null!==s&&(s=s.trim())!==t){if(!s)return alert("(!) Key name can't be empty.\r\n\r\n‎");if(e.hasOwnProperty(s))return alert("(!) Duplicate keys not allowed. This key already exists.\r\n\r\n‎");var o=fu(n);o.pop(),o.push(s),r(i,o=du.apply(null,o),n)}}(t,g,v,y,h)}};S.editable=x,"array"===k?u.push(Ed(S)):"object"===k?u.push(Md(S)):S.schema.hasOwnProperty("oneOf")?u.push(/*#__PURE__*/r.default.createElement(Rd,{parentArgs:e,nextArgs:iu({},S),key:"oneOf_"+n+"_"+p})):S.schema.hasOwnProperty("anyOf")?u.push(/*#__PURE__*/r.default.createElement(jd,{parentArgs:e,nextArgs:iu({},S),key:"anyOf_"+n+"_"+p})):u.push(Ad(S))},v=0;v0,childrenType:"rows"},w&&w.map(function(e,t){/*#__PURE__*/return r.default.createElement("div",{className:"rjf-error-text",key:t},e)}),u),"object"===e.parentType&&e.removable&&(u=/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group-wrapper",key:"row_group_wrapper_"+n},/*#__PURE__*/r.default.createElement(md,{onRemove:function(e){return a(n)}}),u))}return u}function Td(e){/*#__PURE__*/return r.default.createElement(Pd,{args:e})}function Nd(e){/*#__PURE__*/return r.default.createElement(Pd,{args:e,schemaName:"anyOf"})}function Dd(e){return Md(e)}var Pd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).findSelectedOption=function(){return hu(i.props.args.data),Tu(i.props.args.data,i.props.args.schema,i.props.args.getRef,i.schemaName)},i.getOptions=function(){return Array.from(i.props.args.schema[i.schemaName].keys(),function(e){return{label:i.getSchema(e).title||"Option "+(e+1),value:e}})},i.getSchema=function(e){void 0===e&&(e=i.state.option);var t=i.props.args.schema[i.schemaName][e];return t.hasOwnProperty("$ref")&&delete(t=iu({},i.props.args.getRef(t.$ref),{schema:t})).$ref,t},i.handleOptionChange=function(e){i.updateData(i.getSchema(e.target.value))},i.schemaName=i.props.schemaName||"oneOf",i}a(t,e);var i=t.prototype;return i.updateData=function(e){this.props.args.onChange(this.props.args.name,xu(e,this.props.args.getRef))},i.render=function(){var e,t=this.findSelectedOption(),i=this.getSchema(t),n=cu(i),s=this.props.args;"object"===n?e=Md:"array"===n?e=Ed:(e=Ad,s.removable=!1,s.onMoveUp=null,s.onMoveDown=null,(Array.isArray(s.data)||"object"==typeof s.data)&&(s.data=null));var o=e(iu({},s,{schema:i})),a=this.props.args.schema.title||null;/*#__PURE__*/return r.default.createElement("div",{className:"rjf-form-group rjf-oneof-group rjf-oneof-group-top-level"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-oneof-selector"},/*#__PURE__*/r.default.createElement(ed,{value:t,options:this.getOptions(),onChange:this.handleOptionChange,className:"rjf-oneof-selector-input",label:a})),o)},t}(r.default.Component),Rd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).findSelectedOption=function(){var e=0;if(i.props.nextArgs)for(var t=hu(i.props.nextArgs.data),n=i.props.nextArgs.schema[i.schemaName],r=0;r-1){e=r;break}if("object"===t){if(Nu(i.props.nextArgs.data,s)){e=r;break}}else if("array"===t){if(Du(i.props.nextArgs.data,s)){e=r;break}}else if(t===o){e=r;break}}}else{var a=i.props.parentArgs.data,l=hu(a),h=i.props.parentArgs.schema[i.schemaName];if(void 0===h)return e;for(var c=0;c-1||(c[u]=o[u]));h.forEach(function(e,t){c[e]=xu(a[e],i.props.parentArgs.getRef)}),this.props.parentArgs.onChange(r,c)}},i.render=function(){var e,t=this,i=this.findSelectedOption(),n=this.getSchema(i),s=cu(n),o=this.props.nextArgs?this.props.nextArgs:this.props.parentArgs;"object"===s?(e=Md,"object"==typeof o.data&&null!==o.data||(o.data={})):"array"===s?(e=Ed,Array.isArray(o.data)||(o.data=[])):(e=Ad,o.removable=!1,o.onMoveUp=null,o.onMoveDown=null,(Array.isArray(o.data)||"object"==typeof o.data)&&(o.data=null));var a=e(iu({},o,{schema:n})),l=null;return this.props.nextArgs&&(l=this.props.nextArgs.schema.title||null),/*#__PURE__*/r.default.createElement("div",{className:"rjf-form-group rjf-oneof-group"},/*#__PURE__*/r.default.createElement("div",{className:"rjf-oneof-selector"},/*#__PURE__*/r.default.createElement(ed,{value:i,options:this.getOptions(),onChange:function(e){return t.handleOptionChange(e,i)},className:"rjf-oneof-selector-input",label:l})),a)},t}(r.default.Component);function jd(e){/*#__PURE__*/return r.default.createElement(Rd,iu({},e,{schemaName:"anyOf"}))}function Bd(e){if(!(e instanceof Object))return{isValid:!1,msg:"Schema must be an object"};var t,i=cu(e);return(t="object"===i?Id(e):"array"===i?Ld(e):e.hasOwnProperty("allOf")?Fd(e):e.hasOwnProperty("oneOf")?_d(e):e.hasOwnProperty("anyOf")?Hd(e):e.hasOwnProperty("$ref")?{isValid:!0}:{isValid:!1,msg:"Outermost schema can only be of type array, list, object or dict"}).isValid&&e.hasOwnProperty("$defs")&&!e.$defs instanceof Object?{isValid:!1,msg:"'$defs' must be a valid JavaScript Object"}:t}function Id(e){if(!(e.hasOwnProperty("keys")||e.hasOwnProperty("properties")||e.hasOwnProperty("oneOf")||e.hasOwnProperty("anyOf")||e.hasOwnProperty("allOf")))return{isValid:!1,msg:"Schema of type '"+e.type+"' must have at least one of these keys: ['properties' or 'keys' or 'oneOf' or 'anyOf' or 'allOf']"};var t,i=e.properties||e.keys;if(i&&(t=function(e){if(!(e instanceof Object))return{isValid:!1,msg:"The 'keys' or 'properties' key must be a valid JavaScript Object"};for(var t in e)if(e.hasOwnProperty(t)){var i=e[t];if(!(i instanceof Object))return{isValid:!1,msg:"Key '"+t+"' must be a valid JavaScript Object"};var n={isValid:!0},r=mu(i.type);if(r?"object"===r?n=Id(i):"array"===r&&(n=Ld(i)):n=i.hasOwnProperty("$ref")?Vd(i):i.hasOwnProperty("oneOf")?_d(i):i.hasOwnProperty("anyOf")?Hd(i):i.hasOwnProperty("allOf")?Fd(i):i.hasOwnProperty("const")?{isValid:!0,msg:""}:{isValid:!1,msg:"Key '"+t+"' must have a 'type' or a '$ref"},!n.isValid)return n}return{isValid:!0,msg:""}}(i),!t.isValid))return t;if(e.hasOwnProperty("additionalProperties")){if(!(e.additionalProperties instanceof Object)&&"boolean"!=typeof e.additionalProperties)return{isValid:!1,msg:"'additionalProperties' must be either a JavaScript boolean or a JavaScript object"};if(e.additionalProperties instanceof Object)if(e.additionalProperties.hasOwnProperty("$ref")){if(!(t=Vd(e.additionalProperties)).isValid)return t}else{var n=mu(e.additionalProperties.type);if("object"===n)return Id(e.additionalProperties);if("array"===n)return Bd(e.additionalProperties)}}return e.hasOwnProperty("oneOf")&&!(t=_d(e)).isValid||e.hasOwnProperty("anyOf")&&!(t=Hd(e)).isValid||e.hasOwnProperty("allOf")&&!(t=Fd(e)).isValid?t:{isValid:!0,msg:""}}function Ld(e){if(!e.hasOwnProperty("items"))return{isValid:!1,msg:"Schema of type '"+e.type+"' must have a key called 'items'"};if(!(e.items instanceof Object))return{isValid:!1,msg:"The 'items' key must be a valid JavaScript Object'"};var t=mu(e.items.type);if(t){if("object"===t)return Id(e.items);if("array"===t)return Ld(e.items)}else{if(e.items.hasOwnProperty("$ref"))return Vd(e.items);if(!(e.items.hasOwnProperty("oneOf")||e.items.hasOwnProperty("anyOf")||e.items.hasOwnProperty("allOf")||e.items.hasOwnProperty("const")))return{isValid:!1,msg:"Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf'"}}return e.items.hasOwnProperty("oneOf")&&(validation=_d(e.items),!validation.isValid)||e.items.hasOwnProperty("anyOf")&&(validation=Hd(e.items),!validation.isValid)?validation:e.items.hasOwnProperty("allOf")?{isValid:!1,msg:"Currently, 'allOf' inside array items is not supported"}:e.items.hasOwnProperty("const")&&(validation={isValid:!0,msg:""},!validation.isValid)?validation:{isValid:!0,msg:""}}function Vd(e){return"string"!=typeof e.$ref?{isValid:!1,msg:"'$ref' keyword must be a string"}:e.$ref.startsWith("#")?e.$ref.lenght>1&&!e.$ref.startsWith("#/")?{isValid:!1,msg:"Invalid '$ref' path"}:{isValid:!0,msg:""}:{isValid:!1,msg:"'$ref' value must begin with a hash (#) character"}}function _d(e){return zd(e,"oneOf")}function Hd(e){return zd(e,"anyOf")}function Fd(e){var t=zd(e,"allOf");if(!t.isValid)return t;for(var i=e.allOf,n=0;nparseInt(o)&&this.addError(i,"Maximum "+o+" items allowed."),vu(e,"uniqueItems")&&("array"===r||"object"===r?t.length!==new Set(t.map(function(e){return JSON.stringify(e)})).size&&this.addError(i,"All items in this list must be unique."):t.length!==new Set(t).size&&this.addError(i,"All items in this list must be unique.")),a){var l=t.find(function(e){return-1===a.indexOf(e)});void 0!==l&&this.addError(i,'Invalid choice + "'+l+'"')}var h=this.getValidator(r);if("allOf"===r&&(h=null),h)for(var c=0;c-1&&!a.hasOwnProperty("required")&&(a.required=!0);var l=cu(a),h=this.getValidator(l);if(!h)return void this.addError(i,'Unsupported type "'+l+'" for object properties (keys).');h(a,t[o],this.joinCoords([i,o]))}e.hasOwnProperty("allOf")&&this.validateAllOf(e,t,i)}}},this.validateAllOf=function(e,t,i){for(var n={type:"object",properties:{}},r=0;rparseInt(e.maxLength)&&this.addError(i,"This value may not be longer than "+e.maxLength+" characters."),yu(e,t)){var n;switch(mu(e.format)){case"email":n=this.validateEmail;break;case"date":n=this.validateDate;break;case"time":n=this.validateTime;break;case"date-time":n=this.validateDateTime}n&&n.call(this,e,t,i)}else this.addError(i,'Invalid choice "'+t+'"')}else this.addError(i,"This value is invalid. Must be a valid string.");else this.addError(i,"This field is required.")},this.validateBoolean=function(e,t,i){e.required&&null==t?this.addError(i,"This field is required."):"boolean"!=typeof t&&null!=t&&this.addError(i,"Invalid value.")},this.validateInteger=function(e,t,i){e.required&&null==t?this.addError(i,"This field is required."):null!==t&&("number"==typeof t&&t===parseInt(t)?this.validateNumber(e,t,i):this.addError(i,"Invalid value. Only integers allowed."))},this.validateNumber=function(e,t,i){e.required&&null==t?this.addError(i,"This field is required."):null!==t&&("number"==typeof t?((e.minimum||0===e.minimum)&&te.maximum&&this.addError(i,"This value must not be greater than "+e.maximum),(e.exclusiveMinimum||0===e.exclusiveMinimum)&&t<=e.exclusiveMinimum&&this.addError(i,"This value must be greater than "+e.exclusiveMinimum),(e.exclusiveMaximum||0===e.exclusiveMaximum)&&t>=e.exclusiveMaximum&&this.addError(i,"This value must be less than "+e.exclusiveMaximum),(e.multipleOf||0===e.multipleOf)&&100*t%(100*e.multipleOf)/100&&this.addError(i,"This value must be a multiple of "+e.multipleOf),yu(e,t)||this.addError(i,'Invalid choice "'+t+'"')):this.addError(i,"Invalid value. Only numbers allowed."))},this.validateEmail=function(e,t,i){t.indexOf(" ")>-1?this.addError(i,"Enter a valid email address."):t.length>320&&this.addError(i,"Email may not be longer than 320 characters")},this.validateDate=function(e,t,i){},this.validateTime=function(e,t,i){},this.validateDateTime=function(e,t,i){}}var Qd=[{name:"Array/List",slug:"array-list",schema:{type:"array",title:"Shopping list",description:"Add items to your shopping list",items:{type:"string"},minItems:1,maxItems:5},data:["eggs","juice","milk"]},{name:"Object/Dict",slug:"object-dict",schema:{type:"object",description:"Fill in your personal details",keys:{first_name:{type:"string"},last_name:{type:"string"},age:{type:"integer"}}}},{name:"Additional properties",slug:"additional-properties",schema:{type:"object",title:"Product attributes",keys:{brand:{type:"string"},colour:{type:"string"}},additionalProperties:{type:"string"}},data:{brand:"Nokia",colour:"black",weight:"150 gm"}},{name:"Enum (Choices)",slug:"enum-choices",schema:{type:"object",keys:{country:{type:"string",choices:["Australia","India","United Kingdom","United States"]}}}},{name:"Choices with custom titles",slug:"choices-with-custom-titles",schema:{type:"object",keys:{country:{type:"string",choices:[{title:"🇦🇺 Australia",value:"au"},{title:"🇮🇳 India",value:"in"},{title:"🇬🇧 United Kingdom",value:"gb"},{title:"🇺🇸 United States",value:"us"}]}}}},{name:"Multi select choices",slug:"multi-select-choices",schema:{type:"array",title:"Cities",items:{type:"string",choices:["New york","London","Mumbai","Tokyo"],widget:"multiselect"}},description:function(){/*#__PURE__*/return React.createElement("div",null,"Multiple selections only work inside an array.",/*#__PURE__*/React.createElement("br",null),"Each selected item is added to the array in the selection order.")}},{name:"Boolean",slug:"boolean",schema:{type:"object",keys:{isActive:{type:"boolean",title:"Is active"},isActive2:{type:"boolean",title:"Are you sure?",widget:"radio",choices:[{title:"Yes",value:!0},{title:"No",value:!1}]},isActive3:{type:"boolean",title:"Really?",widget:"select",choices:[{title:"Yes",value:!0},{title:"No",value:!1}]}}},description:function(){/*#__PURE__*/return React.createElement("div",null,"Boolean fields get a radio input by default. But you can also use checkbox or a select input via the ",/*#__PURE__*/React.createElement("code",null,"widget")," keyword.")}},{name:"Referencing ($ref & $defs)",slug:"referencing",schema:{type:"object",keys:{name:{type:"string"},shipping_address:{$ref:"#/$defs/address"},billing_address:{$ref:"#/$defs/address"}},$defs:{address:{type:"object",keys:{house:{type:"string"},street:{type:"string"},city:{type:"string"},postal_code:{type:"string"}}}}}},{name:"Recursion",slug:"recursion",schema:{type:"array",items:{type:"object",title:"Person",keys:{name:{type:"string"},age:{type:"integer"},children:{$ref:"#"}}}},data:[{name:"Alice",age:90,children:[]}],description:function(){/*#__PURE__*/return React.createElement("div",null,"You can recursively nest an item within itself. However, there are certain edge cases where it might lead to infinite recursion error. So, be careful!")}},{name:"File inputs",slug:"file-inputs",schema:{type:"object",properties:{base64_upload:{type:"string",format:"data-url"},server_upload:{type:"string",format:"file-url",helpText:"Default input for file-url opens a modal"},simple_input:{type:"string",format:"file-url",widget:"fileinput",helpText:"Custom input using widget: 'fileinput'"}}},data:{},description:function(){/*#__PURE__*/return React.createElement("div",null,"File upload to server (",/*#__PURE__*/React.createElement("code",null,"file-url"),") will not work in this demo because a server is required. However, Base64 upload (",/*#__PURE__*/React.createElement("code",null,"data-url"),") will work fine.")}},{name:"Date & Time",slug:"date-time",schema:{type:"object",keys:{date:{type:"string",format:"date"},time:{type:"string",format:"time"},datetime:{type:"string",format:"date-time",helpText:"For datetime input, a custom input is used"}}}},{name:"Autocomplete",slug:"autocomplete",schema:{type:"object",keys:{country:{type:"string",widget:"autocomplete",handler:"https://run.mocky.io/v3/b4f1afe0-01a5-4218-988c-36b320a7373c"}}},description:function(){/*#__PURE__*/return React.createElement("div",null,"This demo uses a placeholder JSON API to load data. Hence, autocompletion may not work as expected.")}},{name:"Multi select + Autocomplete",slug:"multiselect-autocomplete",schema:{type:"array",title:"Countries",items:{type:"string",widget:"multiselect-autocomplete",handler:"https://run.mocky.io/v3/b4f1afe0-01a5-4218-988c-36b320a7373c"}},description:function(){/*#__PURE__*/return React.createElement("div",null,"Multiple selections only work inside an array.",/*#__PURE__*/React.createElement("br",null),"This demo uses a placeholder JSON API to load data. Hence, autocompletion may not work as expected.")}},{name:"Textarea",slug:"textarea",schema:{type:"object",keys:{title:{type:"string"},body:{type:"string",widget:"textarea"}}}},{name:"Range input",slug:"range",schema:{type:"object",title:"Range input",properties:{volume:{type:"number",widget:"range",minimum:0,maximum:10}}}},{name:"Placeholder & Help text",slug:"placehlder-help-text",schema:{type:"object",keys:{name:{type:"string",placeholder:"Placeholder text",helpText:"This is a help text"}}}},{name:"Readonly & Hidden inputs",slug:"readonly-hidden-inputs",schema:{type:"object",keys:{first_name:{type:"string",placeholder:"Readonly input",readonly:!0},last_name:{type:"string",widget:"hidden"}}},description:function(){/*#__PURE__*/return React.createElement("div",null,"The following schema has two inputs.",/*#__PURE__*/React.createElement("code",null,"first_name")," is readonly and ",/*#__PURE__*/React.createElement("code",null,"last_name")," is hidden so it's not visible.")}},{name:"Formats",slug:"formats",schema:{type:"object",title:"Available input formats",keys:{email:{type:"string",format:"email"},password:{type:"string",format:"password"},colour:{type:"string",format:"color"},url:{type:"string",format:"uri",title:"URL"}}},data:{email:"john@example.com",password:"correcthorsebatterystaple",colour:"#ffff00",url:"http://example.com"}},{name:"Validation",slug:"validation",schema:{type:"object",title:'Press "Submit" to validate data',keys:{name:{type:"string",required:!0},age:{type:"number",required:!0,minimum:50}}}},{name:"AnyOf",slug:"anyof",schema:{type:"object",title:"Person info",properties:{name:{type:"string"},age_or_birthdate:{title:"Age or Birthdate",anyOf:[{type:"integer",title:"Age"},{type:"string",format:"date-time",title:"Birthdate"}]},contacts:{type:"array",items:{anyOf:[{type:"string",title:"Email",placeholder:"you@example.com"},{type:"integer",title:"Phone",placeholder:"1234567890"}]}}}}},{name:"OneOf",slug:"oneof",schema:{type:"object",properties:{location:{oneOf:[{type:"object",title:"Coordinates",properties:{latitude:{type:"number"},longitude:{type:"number"}}},{type:"object",title:"City & Country",properties:{city:{type:"string"},country:{type:"string"}}}]},secret_code:{oneOf:[{type:"integer",title:"Numeric code"},{type:"string",title:"String code"}]}}}},{name:"AllOf",slug:"allof",schema:{type:"object",title:"Person",allOf:[{properties:{name:{type:"string"}}},{properties:{age:{type:"integer"}}}]},description:function(){/*#__PURE__*/return React.createElement("div",null,"Currently, ",/*#__PURE__*/React.createElement("code",null,"allOf")," supports very limited features. It only works inside objects and won't work inside arrays or other types.")}},{name:"Constants",slug:"const",schema:{type:"object",title:"Person",properties:{species:{const:"Homo Sapiens"},name:{type:"string"}}}}];function Yd(e){/*#__PURE__*/return r.default.createElement("div",{className:"tabs py-4"},/*#__PURE__*/r.default.createElement("div",{className:"row"},/*#__PURE__*/r.default.createElement("div",{className:"col-12"},/*#__PURE__*/r.default.createElement("nav",{className:"nav nav-pills"},Qd.map(function(t,i){/*#__PURE__*/return r.default.createElement("button",{key:i,type:"button",className:e.activeTabIndex===i?"nav-link active":"nav-link",onClick:function(n){return e.onClick(i,t.slug)}},t.name)})))))}var Xd=/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).getSchemaEditorNewState=function(){return Ae.create({doc:i.getEditorSchema(),extensions:[Js(),Qs,ss(),Wr(),ml(),Mc(),Ae.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let i=e.newDoc,{head:n}=e.newSelection.main,r=i.lineAt(n);if(n>r.from+200)return e;let s=i.sliceString(r.from,n);if(!t.some(e=>e.test(s)))return e;let{state:o}=e,a=-1,l=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==a)continue;a=t.from;let i=ka(o,t.from);if(null==i)continue;let n=/^\s*/.exec(t.text)[0],r=ba(o,i);n!=r&&l.push({from:t.from,to:t.from+n.length,insert:r})}return l.length?[e,{changes:l,sequential:!0}]:e}),Ba(Va,{fallback:!0}),Ja(),[zh,Vh],cs,Vr.of([].concat(Rh,Ph,Dl)),tu(),uc(e=>{try{JSON.parse(e.state.doc.toString())}catch(t){if(!(t instanceof SyntaxError))throw t;const i=function(e,t){let i;return(i=e.message.match(/at position (\d+)/))?Math.min(+i[1],t.length):(i=e.message.match(/at line (\d+) column (\d+)/))?Math.min(t.line(+i[1]).from+ +i[2]-1,t.length):0}(t,e.state.doc);return[{from:i,message:t.message,severity:"error",to:i}]}return[]}),Nr.updateListener.of(function(e){if(e.docChanged){try{JSON.parse(e.state.doc.toString())}catch(e){return void i.setState({schemaError:"Must be strictly valid JSON (no trailing commas, use double-quotes, etc.)"})}try{var t=Wd.create(e.state.doc.toString());i.setState({rjf_state:t,schemaError:!1},function(e){i.updateDataEditor(i.getEditorData())})}catch(e){return void i.setState({schemaError:e.toString()})}}})]})},i.getDataEditorNewState=function(){return Ae.create({doc:i.getEditorData(),extensions:[Js(),ss(),Wr(),Mc(),Ba(Va,{fallback:!0}),tu(),Ae.readOnly.of(!0)]})},i.handleFormChange=function(e){i.setState({rjf_state:e},function(e){i.dataEditorView&&i.updateDataEditor(i.getEditorData())})},i.validateData=function(){var e=new Gd(i.state.rjf_state.getSchema()).validate(i.state.rjf_state.getData());i.setState({errorMap:e.errorMap})},i.state={rjf_state:Wd.create(i.getActiveTabSchema(),i.getActiveTabData()),schemaError:!1,errorMap:{}},i.schemaEditorParentRef=/*#__PURE__*/r.default.createRef(),i.dataEditorParentRef=/*#__PURE__*/r.default.createRef(),i}a(t,e);var i=t.prototype;return i.componentDidMount=function(){this.schemaEditorView=new Nr({state:this.getSchemaEditorNewState(),parent:this.schemaEditorParentRef.current}),this.dataEditorView=new Nr({state:this.getDataEditorNewState(),parent:this.dataEditorParentRef.current})},i.componentDidUpdate=function(e,t){var i=this;this.props.activeTabIndex!==e.activeTabIndex&&this.setState({rjf_state:Wd.create(this.getActiveTabSchema(),this.getActiveTabData()),schemaError:!1,errorMap:{}},function(e){i.schemaEditorView.setState(i.getSchemaEditorNewState()),i.updateDataEditor(i.getEditorData())})},i.updateDataEditor=function(e){this.dataEditorView.dispatch({changes:{from:0,to:this.dataEditorView.state.doc.length,insert:e}})},i.getActiveTab=function(){return Qd[this.props.activeTabIndex]},i.getActiveTabSchema=function(){return Qd[this.props.activeTabIndex].schema},i.getActiveTabData=function(){return Qd[this.props.activeTabIndex].data},i.getEditorSchema=function(){return JSON.stringify(this.state.rjf_state.getSchema(),null,2)},i.getEditorData=function(){return JSON.stringify(this.state.rjf_state.getData(),null,2)},i.render=function(){/*#__PURE__*/return r.default.createElement("div",{className:"tab-content mt-5"},/*#__PURE__*/r.default.createElement("div",{className:"row"},/*#__PURE__*/r.default.createElement(Zd,{activeTabIndex:this.props.activeTabIndex}),/*#__PURE__*/r.default.createElement("div",{className:"col-12 col-sm-6 order-2 order-md-1"},/*#__PURE__*/r.default.createElement("div",{className:"mb-4"},/*#__PURE__*/r.default.createElement("p",null,/*#__PURE__*/r.default.createElement("strong",null,"Schema")),/*#__PURE__*/r.default.createElement("div",{ref:this.schemaEditorParentRef,className:"cm-container"}),this.state.schemaError&&/*#__PURE__*/r.default.createElement("p",{className:"text-danger"},/*#__PURE__*/r.default.createElement("small",null,"(!) Schema is not valid"),/*#__PURE__*/r.default.createElement("br",null),/*#__PURE__*/r.default.createElement("small",null,this.state.schemaError))),/*#__PURE__*/r.default.createElement("div",{className:"mb-4"},/*#__PURE__*/r.default.createElement("p",null,/*#__PURE__*/r.default.createElement("strong",null,"Output data")),/*#__PURE__*/r.default.createElement("div",{ref:this.dataEditorParentRef,className:"cm-container cm-readonly"}),/*#__PURE__*/r.default.createElement("small",{className:"text-muted"},"Read-only"))),/*#__PURE__*/r.default.createElement("div",{className:"col-12 col-sm-6 order-1 order-md-2"},/*#__PURE__*/r.default.createElement("p",null,/*#__PURE__*/r.default.createElement("strong",null,"Form")),/*#__PURE__*/r.default.createElement("div",{className:"mb-4"},/*#__PURE__*/r.default.createElement(qd,{editorState:this.state.rjf_state,onChange:this.handleFormChange,fileHandler:"/none/",fieldName:"test_field",modelName:"TestModel",errorMap:this.state.errorMap,key:this.props.activeTabIndex}),"validation"===this.getActiveTab().slug&&/*#__PURE__*/r.default.createElement("div",{className:"mt-1"},/*#__PURE__*/r.default.createElement("button",{type:"button",className:"btn btn-secondary px-3",onClick:this.validateData},"Submit"))))))},t}(r.default.Component);function Zd(e){var t=Qd[e.activeTabIndex].description;return t?/*#__PURE__*/r.default.createElement("div",{className:"col-12 mt-n4"},/*#__PURE__*/r.default.createElement("div",{className:"alert alert-info d-flex flex-row"},/*#__PURE__*/r.default.createElement("div",{className:"alert--icon flex-shrink-1 flex-grow-0 mr-3"},/*#__PURE__*/r.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",className:"bi bi-info-square",viewBox:"0 0 16 16"},/*#__PURE__*/r.default.createElement("path",{d:"M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"}),/*#__PURE__*/r.default.createElement("path",{d:"m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"}))),/*#__PURE__*/r.default.createElement("div",{className:"alert--content"},t()))):null}s.default.render(/*#__PURE__*/r.default.createElement(r.default.StrictMode,null,/*#__PURE__*/r.default.createElement(/*#__PURE__*/function(e){function t(t){var i;return(i=e.call(this,t)||this).onTabClick=function(e,t){window.location.hash=e+"-"+t,i.setState({activeTabIndex:e})},i.state={activeTabIndex:i.getActiveTabIndexFromHash()||0},i}a(t,e);var i=t.prototype;return i.getActiveTabIndexFromHash=function(){if(!window.location.hash)return 0;try{var e=window.location.hash.split("-")[0].split("#")[1];return isNaN(e)?0:Number(e)}catch(e){return 0}},i.render=function(){/*#__PURE__*/return r.default.createElement("div",{className:"playground"},/*#__PURE__*/r.default.createElement(Yd,{activeTabIndex:this.state.activeTabIndex,onClick:this.onTabClick}),/*#__PURE__*/r.default.createElement(Xd,{activeTabIndex:this.state.activeTabIndex}))},t}(r.default.Component),null)),document.getElementById("playgroundRoot"))});