=0;U--)j=L[U],j==="."?L.splice(U,1):j===".."?B++:B>0&&(j===""?(L.splice(U+1,B),B=0):(L.splice(U,2),B--));return w=L.join("/"),w===""&&(w=O?"/":"."),S?(S.path=w,p(S)):w}o.normalize=k;function b(c,w){c===""&&(c="."),w===""&&(w=".");var S=h(w),O=h(c);if(O&&(c=O.path||"/"),S&&!S.scheme)return O&&(S.scheme=O.scheme),p(S);if(S||w.match(u))return w;if(O&&!O.host&&!O.path)return O.host=w,p(O);var L=w.charAt(0)==="/"?w:k(c.replace(/\/+$/,"")+"/"+w);return O?(O.path=L,p(O)):L}o.join=b,o.isAbsolute=function(c){return c.charAt(0)==="/"||a.test(c)};function g(c,w){c===""&&(c="."),c=c.replace(/\/$/,"");for(var S=0;w.indexOf(c+"/")!==0;){var O=c.lastIndexOf("/");if(O<0||(c=c.slice(0,O),c.match(/^([^\/]+:\/)?\/*$/)))return w;++S}return Array(S+1).join("../")+w.substr(c.length+1)}o.relative=g;var x=function(){var c=Object.create(null);return!("__proto__"in c)}();function y(c){return c}function A(c){return _(c)?"$"+c:c}o.toSetString=x?y:A;function m(c){return _(c)?c.slice(1):c}o.fromSetString=x?y:m;function _(c){if(!c)return!1;var w=c.length;if(w<9||c.charCodeAt(w-1)!==95||c.charCodeAt(w-2)!==95||c.charCodeAt(w-3)!==111||c.charCodeAt(w-4)!==116||c.charCodeAt(w-5)!==111||c.charCodeAt(w-6)!==114||c.charCodeAt(w-7)!==112||c.charCodeAt(w-8)!==95||c.charCodeAt(w-9)!==95)return!1;for(var S=w-10;S>=0;S--)if(c.charCodeAt(S)!==36)return!1;return!0}function R(c,w,S){var O=W(c.source,w.source);return O!==0||(O=c.originalLine-w.originalLine,O!==0)||(O=c.originalColumn-w.originalColumn,O!==0||S)||(O=c.generatedColumn-w.generatedColumn,O!==0)||(O=c.generatedLine-w.generatedLine,O!==0)?O:W(c.name,w.name)}o.compareByOriginalPositions=R;function I(c,w,S){var O=c.generatedLine-w.generatedLine;return O!==0||(O=c.generatedColumn-w.generatedColumn,O!==0||S)||(O=W(c.source,w.source),O!==0)||(O=c.originalLine-w.originalLine,O!==0)||(O=c.originalColumn-w.originalColumn,O!==0)?O:W(c.name,w.name)}o.compareByGeneratedPositionsDeflated=I;function W(c,w){return c===w?0:c===null?1:w===null?-1:c>w?1:-1}function N(c,w){var S=c.generatedLine-w.generatedLine;return S!==0||(S=c.generatedColumn-w.generatedColumn,S!==0)||(S=W(c.source,w.source),S!==0)||(S=c.originalLine-w.originalLine,S!==0)||(S=c.originalColumn-w.originalColumn,S!==0)?S:W(c.name,w.name)}o.compareByGeneratedPositionsInflated=N;function T(c){return JSON.parse(c.replace(/^\)]}'[^\n]*\n/,""))}o.parseSourceMapInput=T;function E(c,w,S){if(w=w||"",c&&(c[c.length-1]!=="/"&&w[0]!=="/"&&(c+="/"),w=c+w),S){var O=h(S);if(!O)throw new Error("sourceMapURL could not be parsed");if(O.path){var L=O.path.lastIndexOf("/");L>=0&&(O.path=O.path.substring(0,L+1))}w=b(p(O),w)}return k(w)}o.computeSourceURL=E})(gn);var sa={},ua=gn,fa=Object.prototype.hasOwnProperty,$r=typeof Map!="undefined";function Mr(){this._array=[],this._set=$r?new Map:Object.create(null)}Mr.fromArray=function(l,a){for(var u=new Mr,h=0,p=l.length;h=0)return a}else{var u=ua.toSetString(l);if(fa.call(this._set,u))return this._set[u]}throw new Error('"'+l+'" is not in the set.')},Mr.prototype.at=function(l){if(l>=0&&la||u==a&&p>=h||Ss.compareByGeneratedPositionsInflated(o,l)<=0}function Xi(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Xi.prototype.unsortedForEach=function(l,a){this._array.forEach(l,a)},Xi.prototype.add=function(l){kd(this._last,l)?(this._last=l,this._array.push(l)):(this._sorted=!1,this._array.push(l))},Xi.prototype.toArray=function(){return this._sorted||(this._array.sort(Ss.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},ks.MappingList=Xi;var Xn=qi,mt=gn,Yi=sa.ArraySet,Sd=ks.MappingList;function er(o){o||(o={}),this._file=mt.getArg(o,"file",null),this._sourceRoot=mt.getArg(o,"sourceRoot",null),this._skipValidation=mt.getArg(o,"skipValidation",!1),this._sources=new Yi,this._names=new Yi,this._mappings=new Sd,this._sourcesContents=null}er.prototype._version=3,er.fromSourceMap=function(l){var a=l.sourceRoot,u=new er({file:l.file,sourceRoot:a});return l.eachMapping(function(h){var p={generated:{line:h.generatedLine,column:h.generatedColumn}};h.source!=null&&(p.source=h.source,a!=null&&(p.source=mt.relative(a,p.source)),p.original={line:h.originalLine,column:h.originalColumn},h.name!=null&&(p.name=h.name)),u.addMapping(p)}),l.sources.forEach(function(h){var p=h;a!==null&&(p=mt.relative(a,h)),u._sources.has(p)||u._sources.add(p);var k=l.sourceContentFor(h);k!=null&&u.setSourceContent(h,k)}),u},er.prototype.addMapping=function(l){var a=mt.getArg(l,"generated"),u=mt.getArg(l,"original",null),h=mt.getArg(l,"source",null),p=mt.getArg(l,"name",null);this._skipValidation||this._validateMapping(a,u,h,p),h!=null&&(h=String(h),this._sources.has(h)||this._sources.add(h)),p!=null&&(p=String(p),this._names.has(p)||this._names.add(p)),this._mappings.add({generatedLine:a.line,generatedColumn:a.column,originalLine:u!=null&&u.line,originalColumn:u!=null&&u.column,source:h,name:p})},er.prototype.setSourceContent=function(l,a){var u=l;this._sourceRoot!=null&&(u=mt.relative(this._sourceRoot,u)),a!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[mt.toSetString(u)]=a):this._sourcesContents&&(delete this._sourcesContents[mt.toSetString(u)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},er.prototype.applySourceMap=function(l,a,u){var h=a;if(a==null){if(l.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);h=l.file}var p=this._sourceRoot;p!=null&&(h=mt.relative(p,h));var k=new Yi,b=new Yi;this._mappings.unsortedForEach(function(g){if(g.source===h&&g.originalLine!=null){var x=l.originalPositionFor({line:g.originalLine,column:g.originalColumn});x.source!=null&&(g.source=x.source,u!=null&&(g.source=mt.join(u,g.source)),p!=null&&(g.source=mt.relative(p,g.source)),g.originalLine=x.line,g.originalColumn=x.column,x.name!=null&&(g.name=x.name))}var y=g.source;y!=null&&!k.has(y)&&k.add(y);var A=g.name;A!=null&&!b.has(A)&&b.add(A)},this),this._sources=k,this._names=b,l.sources.forEach(function(g){var x=l.sourceContentFor(g);x!=null&&(u!=null&&(g=mt.join(u,g)),p!=null&&(g=mt.relative(p,g)),this.setSourceContent(g,x))},this)},er.prototype._validateMapping=function(l,a,u,h){if(a&&typeof a.line!="number"&&typeof a.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(l&&"line"in l&&"column"in l&&l.line>0&&l.column>=0&&!a&&!u&&!h)){if(l&&"line"in l&&"column"in l&&a&&"line"in a&&"column"in a&&l.line>0&&l.column>=0&&a.line>0&&a.column>=0&&u)return;throw new Error("Invalid mapping: "+JSON.stringify({generated:l,source:u,original:a,name:h}))}},er.prototype._serializeMappings=function(){for(var l=0,a=1,u=0,h=0,p=0,k=0,b="",g,x,y,A,m=this._mappings.toArray(),_=0,R=m.length;_0){if(!mt.compareByGeneratedPositionsInflated(x,m[_-1]))continue;g+=","}g+=Xn.encode(x.generatedColumn-l),l=x.generatedColumn,x.source!=null&&(A=this._sources.indexOf(x.source),g+=Xn.encode(A-k),k=A,g+=Xn.encode(x.originalLine-1-h),h=x.originalLine-1,g+=Xn.encode(x.originalColumn-u),u=x.originalColumn,x.name!=null&&(y=this._names.indexOf(x.name),g+=Xn.encode(y-p),p=y)),b+=g}return b},er.prototype._generateSourcesContent=function(l,a){return l.map(function(u){if(!this._sourcesContents)return null;a!=null&&(u=mt.relative(a,u));var h=mt.toSetString(u);return Object.prototype.hasOwnProperty.call(this._sourcesContents,h)?this._sourcesContents[h]:null},this)},er.prototype.toJSON=function(){var l={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(l.file=this._file),this._sourceRoot!=null&&(l.sourceRoot=this._sourceRoot),this._sourcesContents&&(l.sourcesContent=this._generateSourcesContent(l.sources,l.sourceRoot)),l},er.prototype.toString=function(){return JSON.stringify(this.toJSON())},oa.SourceMapGenerator=er;var Qi={},Cs={};(function(o){o.GREATEST_LOWER_BOUND=1,o.LEAST_UPPER_BOUND=2;function l(a,u,h,p,k,b){var g=Math.floor((u-a)/2)+a,x=k(h,p[g],!0);return x===0?g:x>0?u-g>1?l(g,u,h,p,k,b):b==o.LEAST_UPPER_BOUND?u1?l(a,g,h,p,k,b):b==o.LEAST_UPPER_BOUND?g:a<0?-1:a}o.search=function(u,h,p,k){if(h.length===0)return-1;var b=l(-1,h.length,u,h,p,k||o.GREATEST_LOWER_BOUND);if(b<0)return-1;for(;b-1>=0&&p(h[b],h[b-1],!0)===0;)--b;return b}})(Cs);var Ls={};function ca(o,l,a){var u=o[l];o[l]=o[a],o[a]=u}function Cd(o,l){return Math.round(o+Math.random()*(l-o))}function ha(o,l,a,u){if(a=0){var k=this._originalMappings[p];if(l.column===void 0)for(var b=k.originalLine;k&&k.originalLine===b;)h.push({line:ke.getArg(k,"generatedLine",null),column:ke.getArg(k,"generatedColumn",null),lastColumn:ke.getArg(k,"lastGeneratedColumn",null)}),k=this._originalMappings[++p];else for(var g=k.originalColumn;k&&k.originalLine===a&&k.originalColumn==g;)h.push({line:ke.getArg(k,"generatedLine",null),column:ke.getArg(k,"generatedColumn",null),lastColumn:ke.getArg(k,"lastGeneratedColumn",null)}),k=this._originalMappings[++p]}return h},Qi.SourceMapConsumer=tt;function Mt(o,l){var a=o;typeof o=="string"&&(a=ke.parseSourceMapInput(o));var u=ke.getArg(a,"version"),h=ke.getArg(a,"sources"),p=ke.getArg(a,"names",[]),k=ke.getArg(a,"sourceRoot",null),b=ke.getArg(a,"sourcesContent",null),g=ke.getArg(a,"mappings"),x=ke.getArg(a,"file",null);if(u!=this._version)throw new Error("Unsupported version: "+u);k&&(k=ke.normalize(k)),h=h.map(String).map(ke.normalize).map(function(y){return k&&ke.isAbsolute(k)&&ke.isAbsolute(y)?ke.relative(k,y):y}),this._names=vn.fromArray(p.map(String),!0),this._sources=vn.fromArray(h,!0),this._absoluteSources=this._sources.toArray().map(function(y){return ke.computeSourceURL(k,y,l)}),this.sourceRoot=k,this.sourcesContent=b,this._mappings=g,this._sourceMapURL=l,this.file=x}Mt.prototype=Object.create(tt.prototype),Mt.prototype.consumer=tt,Mt.prototype._findSourceIndex=function(o){var l=o;if(this.sourceRoot!=null&&(l=ke.relative(this.sourceRoot,l)),this._sources.has(l))return this._sources.indexOf(l);var a;for(a=0;a1&&(I.source=b+N[1],b+=N[1],I.originalLine=p+N[2],p=I.originalLine,I.originalLine+=1,I.originalColumn=k+N[3],k=I.originalColumn,N.length>4&&(I.name=g+N[4],g+=N[4])),R.push(I),typeof I.originalLine=="number"&&_.push(I)}Yn(R,ke.compareByGeneratedPositionsDeflated),this.__generatedMappings=R,Yn(_,ke.compareByOriginalPositions),this.__originalMappings=_},Mt.prototype._findMapping=function(l,a,u,h,p,k){if(l[u]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+l[u]);if(l[h]<0)throw new TypeError("Column must be greater than or equal to 0, got "+l[h]);return da.search(l,a,p,k)},Mt.prototype.computeColumnSpans=function(){for(var l=0;l=0){var h=this._generatedMappings[u];if(h.generatedLine===a.generatedLine){var p=ke.getArg(h,"source",null);p!==null&&(p=this._sources.at(p),p=ke.computeSourceURL(this.sourceRoot,p,this._sourceMapURL));var k=ke.getArg(h,"name",null);return k!==null&&(k=this._names.at(k)),{source:p,line:ke.getArg(h,"originalLine",null),column:ke.getArg(h,"originalColumn",null),name:k}}}return{source:null,line:null,column:null,name:null}},Mt.prototype.hasContentsOfAllSources=function(){return this.sourcesContent?this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(l){return l==null}):!1},Mt.prototype.sourceContentFor=function(l,a){if(!this.sourcesContent)return null;var u=this._findSourceIndex(l);if(u>=0)return this.sourcesContent[u];var h=l;this.sourceRoot!=null&&(h=ke.relative(this.sourceRoot,h));var p;if(this.sourceRoot!=null&&(p=ke.urlParse(this.sourceRoot))){var k=h.replace(/^file:\/\//,"");if(p.scheme=="file"&&this._sources.has(k))return this.sourcesContent[this._sources.indexOf(k)];if((!p.path||p.path=="/")&&this._sources.has("/"+h))return this.sourcesContent[this._sources.indexOf("/"+h)]}if(a)return null;throw new Error('"'+h+'" is not in the SourceMap.')},Mt.prototype.generatedPositionFor=function(l){var a=ke.getArg(l,"source");if(a=this._findSourceIndex(a),a<0)return{line:null,column:null,lastColumn:null};var u={source:a,originalLine:ke.getArg(l,"line"),originalColumn:ke.getArg(l,"column")},h=this._findMapping(u,this._originalMappings,"originalLine","originalColumn",ke.compareByOriginalPositions,ke.getArg(l,"bias",tt.GREATEST_LOWER_BOUND));if(h>=0){var p=this._originalMappings[h];if(p.source===u.source)return{line:ke.getArg(p,"generatedLine",null),column:ke.getArg(p,"generatedColumn",null),lastColumn:ke.getArg(p,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},Qi.BasicSourceMapConsumer=Mt;function or(o,l){var a=o;typeof o=="string"&&(a=ke.parseSourceMapInput(o));var u=ke.getArg(a,"version"),h=ke.getArg(a,"sections");if(u!=this._version)throw new Error("Unsupported version: "+u);this._sources=new vn,this._names=new vn;var p={line:-1,column:0};this._sections=h.map(function(k){if(k.url)throw new Error("Support for url field in sections not implemented.");var b=ke.getArg(k,"offset"),g=ke.getArg(b,"line"),x=ke.getArg(b,"column");if(g=0;a--)this.prepend(l[a]);else if(l[mn]||typeof l=="string")this.children.unshift(l);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+l);return this},Yt.prototype.walk=function(l){for(var a,u=0,h=this.children.length;u0){for(a=[],u=0;uk.onchange(o.state),p=V=>pe=>(V(pe),h());o.selected.map(V=>o.state.selected=V.url||V.name);const k={onchange:()=>{},setMiddle:V=>o.state.middle=V,toggleConsole:p(V=>o.state.console=o.state.console===!0?"collapsed":!0),resetSize:p(()=>k.setMiddle(50)),loaded:()=>{o.loading=!1,o.console.clearOnNext&&(o.console.output=[],o.console.clearOnNext=!1),typeof k.onloaded=="function"&&k.onloaded(o.state)},fileSelectionChange:z,selectFileByIndex:L,toggleAutoReload:I,onConsoleKeyDown:T,onConsoleInput:N,consoleOutput:Q,startDragging:_,stopDragging:R,changeMiddle:te,setShareUrl:m,clearErrors:x,clearLogs:y,fileChange:X,initIframe:j,setState:A,resizing:ue,refresh:de,getLink:S,select:O,scroll:W};return b(),k;function b(){Promise.all(o.state.links.map(S)).then(()=>de({force:!0}))}function g(){o.console.output=[{content:[Le("i","Console was cleared")]}]}function x(){o.console.output=o.console.output.filter(V=>V.type!=="error")}function y(){o.console.output=o.console.output.filter(V=>V.type==="error")}function A(V){o.state=$l(V),O(Gn(o.state,o.state.selected),!0),D(),Le.redraw()}function m({dom:V}){V.addEventListener("mousedown",pe=>{V.href=Zl(o.state)},!0)}function _(){o.dragging=!0}function R(){o.dragging=!1,o.refreshCm(!0),h()}function I(){o.state.autoReload=!o.state.autoReload,h(),o.state.autoReload&&de()}function W(V){o.state.scroll=V,h()}function N(V){o.console.input=V.target.value}function T(V){if((V.key==="Enter"||V.keyCode===13)&&!V.shiftKey&&!V.altKey)return V.preventDefault(),o.console.output.push({type:"input",content:["> "+o.console.input],number:"i"+o.console.inputNumber++}),o.console.input.indexOf("console.clear()")===0&&g(),E(),!1;(V.key==="ArrowUp"||V.keyCode===38)&&(o.console.historyNavigated||V.target.selectionStart===0)?(V.preventDefault(),c()):(V.key==="ArrowDown"||V.keyCode===40)&&(o.console.historyNavigated||o.console.input==="")?(V.preventDefault(),w()):o.console.historyNavigated=!1}function E(V){!o.console.input||(o.iframe.contentWindow.postMessage({name:"eval",content:o.console.input},"*"),o.console.position=o.console.history.push(o.console.input),o.console.input="")}function c(){o.console.historyNavigated=!0,o.console.position>=0&&(o.console.position-=1),o.console.input=o.console.history[o.console.position]||""}function w(){o.console.historyNavigated=!0,o.console.position{pe=pe.replace(/\r\n/g,`
`),!(pe.length>3e5)&&(V.content=pe,V.patched=V.patches?gd(pe,V.patches)[0]:pe,o.selected()===V&&O(V))}).catch(()=>{})}function O(V,pe){typeof V=="string"&&(V=Gn(o.state,V)),o.selected(V),!pe&&h()}function L(V){const pe=o.state.files.concat(o.state.links)[V];pe&&O(pe)}function j(V){o.iframe=V,o.iframe.addEventListener("load",B)}function B(){o.iframe.contentWindow.postMessage({name:"init",content:{id:o.id,state:{scroll:o.state.scroll,files:u,links:o.state.links.map(V=>({type:V.type,name:V.name,url:V.url,content:V.patched||V.content}))}}},"*")}function U(V){const pe=V.compiler==="function"?V.compiler:Ql[V.compiler||Ii(V.name)];return pe?pe(V).then(Ne=>(Ne.error&&Q(Ne.error),Ne.map&&(V.map=Ne.map),{name:V.name,type:V.type,content:Ne.code})).catch(Ne=>(Q({content:["Error compiling "+V.compiler+":",zh(Ne)],type:"error",stack:[]}),{name:V.name,type:V.type,content:V.content})):{name:V.name,type:V.type,content:V.content}}function Q(V){o.console.clearOnNext&&(o.console.output=[],o.console.clearOnNext=!1),V.stack.forEach(pe=>{const Ne=Gn(o.state,pe.file);if(!Ne||!Ne.map)return;const je=new ji.SourceMapConsumer(Ne.map).originalPositionFor({line:pe.line,column:pe.column});pe.line=je.line,pe.column=je.column}),V.content&&!Array.isArray(V.content)&&(V.content=[V.content]),o.console.output.push(V)}function X(V,pe,Ne){V.url?V.patched=pe:V.content=pe,Ne&&(V.selections=Ne==="0:0"?void 0:Ne),typeof k.onload=="function"&&k.onload(),D(V),h()}function D(V){clearTimeout(a),a=setTimeout(()=>{if(!V)return de();V.url&&(V.patches=hd(V.content,V.patched)),o.state.autoReload&&(V.type==="style"||V.type==="css")?(o.iframe.contentWindow.postMessage({name:"css",content:{name:V.name,url:V.url,content:V.patched||V.content}},"*"),typeof k.onloaded=="function"&&k.onloaded(o.state),h()):de()},o.state.autoReloadDelay||400)}function z(V,pe){pe=pe==="0:0"?void 0:pe,pe!==V.selections&&(V.selections=pe,h())}function te(V){const{top:pe,left:Ne}=o.dom.getBoundingClientRect();o.state.middle=Math.min(Math.max(Math.round((o.vertical()?(V.clientY-pe+5)/(o.dom.offsetHeight-o.console.dom.offsetHeight):(V.clientX-Ne+5)/o.dom.offsetWidth)*1e4)/100,0),100),Le.redraw()}function ue(){o.iOS||(o.resizing=!0,clearTimeout(l),l=setTimeout(()=>{o.resizing=!1,Le.redraw()},1e3))}function de(V={}){if(!V.force&&!o.state.autoReload)return o.hasChanges=!0;o.hasChanges=!1,o.loading=!0,o.console.clearOnNext=!0,Promise.all(o.state.files.map(U)).then(Me),Le.redraw()}function Me(V){if(!o.iframe)return setTimeout(Me,10,V);Od&&(o.iframe.src+="?"),u=V,o.iframe.src=o.runtimeUrl}}var Ed={listen:(o,l)=>{const a={loaded:l.loaded,console:l.consoleOutput,resize:l.resizing,scroll:l.scroll};window.addEventListener("message",({data:u})=>{u.flems!==o.id||!(u.name in a)||(a[u.name](u.content),Le.redraw())})}};let As=!1;function Zi(o,l={},a){const u=Ch(o,l,a),h=_d(u);return As||(window.addEventListener("resize",p),As=!0),Ed.listen(u,h),Le.mount(o,null),Le.mount(o,{view:()=>wh(u,h)}),{focus:u.focus,reload:()=>h.refresh({force:!0}),onchange:k=>h.onchange=k,onload:k=>h.onload=k,onloaded:k=>h.onloaded=k,getLink:h.getLink,set:h.setState,redraw:p};function p(){Le.redraw(),u.refreshCm(!0)}}return Zi.defaults=Bi,Zi.createFlemsIoLink=Zl,Zi.version="1.5.10",Zi});
//# sourceMappingURL=flems.js.map
// -->